methods

Adding magic global methods to modules

I'm starting to get into the Python logging module, but unless I want all messages to say "root" I have to create a logger for each module, and it's kind of a pain to do that over and over again. I was thinking it would be handy if there were a magic __logger__() method that would return a logger for the current module, creating it if n...

Final in method parameter in eclipse

When I try to put final in method parameter eclipse doesn't help. Any idea how to get this to work? ...

Why does java/javascript/python force the use of () after a method name, even if it takes no arguments?

One of my most common bugs is that I can never remember whether something is a method or a property, so I'm constantly adding or removing parentheses. So I was wondering if there was good logic behind making the difference between calling on an object's properties and methods explicit. Obviously, it allows you to have properties and me...

Best way to pass values to a function when there are many to send ?

What is the best way to define a method signature when you have to pass many values to a function and some of these may be optional. And in future, May be I have to pass more variables or subtract some passed values given to function. For example: (phone and address are optional) function addInfo( $name, $dob, $phone='', $address='' ) ...

What is the Use of Property {get, set} method in C # 3.0

Possible Duplicate: C# Automatic Properties Hello, I have recently moved towards .net (c#) platform from Java. Here I don't face much problem yet... anyway I 'm messed up with property{get, set} method. Actually I could not get up the exact meaning of these (property) according to me the same job of initial...

How to return an arraylist from a method

Hello. I need help. For this specific method. I am trying to get it to return an arraylist that I tokenized. public ArrayList read (){ BufferedReader inputStream = null; try { inputStream = new BufferedReader(new FileReader("processes1.txt")); String l; while ((l = inputStream.readLine()) != null) { ArrayLis...

Problems with my program involving arraylists, bufferedreader, methods, and overall forgetfullness of how java works.

Hello everyone. I am having difficulties with a program that I have been working on all day. I am trying to read a text file and read each line one at a time. Take that line and make an arraylist of the words of the line. then using the index of the arraylist define terms with it. public class PCB { public static void main(Strin...

How to define extension methods for generic class?

Hi All, I am having a generic interface as: public IRepository< T > { void Add(T entity); } and a class as: public class Repository< T >:IRepository< T > { void Add(T entity) { //Some Implementation } } Now I want to make an extension method of the above interface. I made the following class: public stati...

PHP: Is it wise to call a method&nested loop in a foreach loop?

Hi I have a method that returns an array of support tickets. Each support ticket can have many notes so I have a method that returns an array of tickets notes with that ticket id. I want to display the notes alongside the ticket which would mean nesting the get notes inside the foreach loop. foreach($tickets as $ticket){ //display...

When to use class::function or class->function, is there a preferred method?

Possible Duplicate: In PHP, whats the difference between :: and -> ? I've been seeing this class::function more in some code examples and thought it was the same as this class->function, but I wanted to know if there is a use case as to when I would use one over the other? ...

How to call a method in a sub UIView?

hi, i have a uiviewcontroller named MainViewController, i add a subview in it (name:DetailView) in viewdidload event. when i press the a button in mainviewController i want to call a method in subview, writeSomething. //DetailView is a subclass of a UIView. in Mainviewcontroller: - (void)viewDidLoad { [super viewDidLoad]; ...

overriding PHP class methods referenced by non-overridden $this

So, I'm having trouble with some php OO stuff. I think the code will explain it best: class foo { $someprop; public function __construct($id){ $this->populate($id); } private function populate($id){ global $db; // obviously not the call, but to illustrate the point: $items = $db->get_fro...

How to call a method from another class in Java

So I have this class: public class Product { private String name, id, info ; private int quantity; public Product(String newName, String newID, String newInfo, Integer newQuantity){ setName(newName); setID(newID); setPrice(newInfo); setQuantity(newQuantity);} public void setName(String name) { this.name = name; } pub...

PHP, Fatal error: Call to undefined method, why?

Hi, I have a simple php structures. class Ingredient and class Ingredients, i have this code: class Ingredient { public function objectIsValid() { return $validate[0]; } } class Ingredients { public $ingObject; function __construct(){ $ingObject = new Ingredient(); } public function validateData() ...

What is use of getting button name as one of the parameter for Action control in following code ?

Hi I am a beginner in MVC 2 and I was going through the ScottGu's blog for deleting a record from database using entity framework. I don't understand the use of string confirmButton(name of button tag in View template) as one of the parameter for Delete action method in the following code. Can any one tell me why it is used ? // // HTTP...

Proper way of calling a Javascript method

Is there a reason why I should call a Javascript method as follows: onClick="Javascript:MyMethod();" or can I just call it like this: onClick="MyMethod();" Is there any difference? ...

passing a value from flipsideviewcontroller to mainviewcontroller

Hi, i am tryng to pass a value from a slider on the flipside view to a instance variable on the mainview that i use to create a maximum user input number. I know that most of the code works as i can send a value across by initializing maxValue with a number in the (void) viewdidload. However, when i try to initialize it as shown below i...

Understanding python variable scope within class

I am trying to define a variable in a class that then can be accessed/changed from functions within that class. For example: class MyFunctions(): def __init__( self): self.listOfItems = [] def displayList( self): """Prints all items in listOfItems)""" for item in self.listOfItems: print item...

Struts2 - if result type json and method defined then all methods get invoked

Idefined my struts xml as follows: "<"action name="index" method="execute" class="hr.credo.web.struts2.action.Index"> <"result name="success" >/index.jsp <"/action> <"action name="hello" class="hr.credo.web.struts2.action.Index" method="JSON"> <"result name="success" type="json" > <"/action> and in my action class i have an execute...

System.Web.Security - Specified method is not supported on Single Dev PC

I have a Win7 PC and have all of a sudden gotten the "Specified method is not supported" error when calling Membership.GetUser, etc methods. On another dev machine, the same project (WPF in SVN) executes fine. We're referencing the same System.Web.Security (2.0) dll in the GAC. How do I fix this ghost error? ...