methods

Method not found error after updating Rails

Hi, it's about Ruby On Rails and it's Restful Authentication plugin. The title says it all: I updated Rails. I restarted my WebApp. The method "store_location" of Restful Authentication cannot be found. in the file lib/restful_authentication.rb can the method be found, by me, but no longer by Rails. Why? Please help! Yo...

Can an object know from which object its method is called?

In Moritz Haarmann's Blog I found an example of usage of Bonjour by Java. Here is the code taken from there: public class ServiceAnnouncer implements IServiceAnnouncer, RegisterListener { private DNSSDRegistration serviceRecord; private boolean registered; public boolean isRegistered(){ return registered; } ...

Can I use methods of a class without instantiating this class?

I have a class with several methods and there is no constructor among these methods. So, I am wondering if it is possible to call a method of a class without a creation of an instance of the class. For example, I can do something like that: NameOfClass.doMethod(x1,x2,...,xn) In general I do not see why it should be impossible. I jus...

Reuse method within a class

I have a method that basically returns the results of a mysql query. public function getStuff() { $this->sort = "myColumn ASC"; $query = ... ORDER BY $this->sort; return $data; } I'd like to reuse that result, only with a different sort order, and it seems like I should be able to grab that data in another method, just by calling th...

How do I reference a static method of a variable class in PHP?

Hi folks! I'm writing a factory class that should be able to return singleton instances of a number of different types, depending on the given parameter. The method would look something like this, but the way I'm referencing the singleton's static method is obviously wrong: public function getService($singletonClassName) { return $...

What is "logger" in Java?

I have a class in which I see the following things: this.logger.severe(""); this.logger.warning(""); this.logger.info(""); I do not understand several things: How can we use a method that was not defined earlier? I mean, there are no "logger" methods defined in the class. I thought that these methods could be defined because the con...

Refactoring large method in .NET

Hi, If I have a large .NET method, I want to know if it is good practice to split it up into multiple methods or not. My concerns are: 1 - Is there any point creating a method if it will only be called once? 2 - If I'm calling a private method from within my class, I try not to use instance variables. Is this good or bad practice? Fo...

How call c# method in javascript

Hi, I need call codeBehind method named RebinData() in a javaScript function How I do it ?? Regards ...

Whats wrong with my syntax and am i doing this efficiently?

I'm trying to make a method that will tell me weather or not it is true or false that a number is prime. here's the code: class prime { public static boolean prime (int a, int b) { if (a == 0) { return false; } else if (a%(b-1) == 0) { return false; ...

refactoring this function in Java

Hi folks, I'm learning Java, and I know one of the big complaints about newbie programmers is that we make really long and involved methods that should be broken into several. Well here is one I wrote and is a perfect example. :-D. public void buildBall(){ /* sets the x and y value for the center of the canvas */ doubl...

Recommend a better way to turn synchronous methods to asynchronous in Java

In a classes are some methods that are run synchronously. I would like them to run asynchronously, the first idea was to wrap it, and use switch enum to decide which function should be called. But for every method called, I needed a new method in the wrapper class and a new enum. It looks like this: public class QueuedShow implements In...

fetch php method comments

I want to fetch a method's comments,take below method for example: /** * Returns the regex to extract all inputs from a file. * @param string The class name to search for. * @return string The regex. */ public function method($param) { //... } the result should be Returns the regex to extract all inputs from a file. @param string ...

Use properties or methods to expose business rules in C#?

I'm writing a class to encapsulate some business rules, each of which is represented by a boolean value. The class will be used in processing an InfoPath form, so the rules get the current program state by looking up values in a global XML data structure using XPath operations. What's the best (most idiomatic) way to expose these rules t...

array_unique for objects?

Hi! Is there any method like the array_unique for objects? I have a bunch of arrays with 'Role' objects that I merge, and then I want to take out the duplicates :) Thanks ...

in java is the name of a method a string?

in java is the name of a method a string? why or why not? so if i have something like: public static int METHODNAME (some parameters or not) { something to do ; } is METHODNAME a string? ...

Where To Call Custom Method? viewDidLoad, viewWillLoad...

I am loading some info from a server. I have created a separate method to do this. I am then calling [self myCustomMethod] to run the method. No matter where I call [self myCustomMethod] (initWithNibName, viewDidLoad, viewWillLoad, viewWillAppear, viewDidAppear), the custom method is getting called twice - what's the deal? ...

Frustrated with Objective-c code...

Well, I've started with iPod/iPhone programming using Head First iPhone Development (O'reilly) and I'm typing code out of the book. There are two problems, one is programming related and the other is not. I don't understand the format of objective-c methods. I'm getting an few errors now, based on source code from the book. Which lead...

How do you replace a method of a Moose object at runtime?

Is it possible to replace a method of a Moose object at runtime ? By looking at the source code of Class::MOP::Method (which Moose::Meta::Method inherits from) I concluded that by doing $method->{body} = sub{ my stuff } I would be able to replace at runtime a method of an object. I can get the method using $object->meta->find_meth...

Where should the line between property and method be?

Possible Duplicate: Properties vs Methods For many situations it is obvious whether something should be a property or a method however there are items that might be considered ambiguous. Obvious Properties: "name" "length" Obvious Methods: "SendMessage" "Print" Ambiguous: "Valid" / "IsValid" / "Validate" "InBounds...

Capitalize Words in PHP with custom delimitor

Hey guys, i need a method to capitalize every first letter of a word. This is what i got so far and it is working for almost every string...but it fails on this one "WELLNESS & RENOMME". // method in stringModify Class function capitalizeWords($words, $charList) { $capitalizeNext = true; for ($i = 0, $max = strlen($wo...