Questions tagged [method-names]

55 questions
41
votes
4 answers

How to disambiguate links to methods in scaladoc?

I'm documenting a Scala class with overloaded methods. How can I distinguish them when referring to them in scaladoc comments? For example, if I have /** * The most important method is [[Doc.foo]]. */ object Doc { def foo[A]: A = throw new…
Petr
  • 62,528
  • 13
  • 153
  • 317
28
votes
4 answers

Use of special characters in function names

In Ruby, a standard convention is to use a question mark at the end of a method name to indicate the method returns a boolean result: [].empty? #=> true Another standard convention is to end a method name with an exclamation point if the method…
11
votes
11 answers

Is there a particular naming convention for Java methods that throw exceptions?

I'm tempted to add a suffix like "Ex" to differentiate methods (with similar signatures) that throw Exceptions from those that don't. Is there such a convention?
lyates
  • 167
  • 1
  • 3
  • 9
10
votes
2 answers

Is the method naming for property getters/setters standardized in IL?

I have the following two methods that I am wondering if they are appropriate: public bool IsGetter(MethodInfo method) { return method.IsSpecialName && method.Name.StartsWith("get_", StringComparison.Ordinal); } public bool…
myermian
  • 31,823
  • 24
  • 123
  • 215
9
votes
6 answers

Is there a technical difference between the terms "length" and "size" (in programming, of course)?

Possible Duplicate: count vs length vs size in a collection In Java in particular, on Strings, you call string.length(), whereas in Lists you call list.size(). Is there a technical difference between the two terms, seeing as a String is really…
Tom R
  • 5,991
  • 9
  • 35
  • 41
6
votes
4 answers

How to get the methodname from a known method?

Is it possible to get the name of another method in the same class but without using a manually written string? class MyClass { private void doThis() { // Wanted something like this print(otherMethod.name.ToString()); } …
Malvin
  • 859
  • 2
  • 11
  • 19
5
votes
1 answer

java - DAO methods convention - overloading or change the method name?

Related to Standard Naming Convention for DAO Methods and DAO class methods naming questions. Why the methods in DAO classes are like: getUserById(int id) getUserByUsernameAndPassword(String username, String password) instead of: getUser(int…
Ismail Yavuz
  • 6,727
  • 6
  • 29
  • 50
4
votes
4 answers

Bad method names and what it says about code structure

(Apologies in advance if this is a re-post but I didn't find similar posts) What bad method name patterns have you seen in code and what did it tell you about the code. For instance, I keep seeing: public void preform___X___IfNecessary(...); I…
maxfridbe
  • 5,872
  • 10
  • 58
  • 80
4
votes
1 answer

Bizzare method signature, with unnamed arguments (obj-c)

I wasn't aware this syntax was valid. + (void) methodName:(TypeObject *)typeObject1:(TypeObject *)typeObject2; Which is then called like so: [object methodName:obj1:obj2]; I find it ugly and disturbing, but it builds. Can someone point me at a…
ocodo
  • 29,401
  • 18
  • 105
  • 117
3
votes
1 answer

How to get real method name istead of .ctor?

Hi i have method getting the name of calling method: public static string GetMethodName() { System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(); return trace.GetFrame(1).GetMethod().Name; } And…
TrN
  • 1,230
  • 2
  • 17
  • 32
3
votes
1 answer

Get the name of the current method/function in Python

For now, I got two ways to fetch the name of the current function/method in python Function based >>> import inspect >>> import sys >>> def hello(): ... print(inspect.stack()[0][3]) ... print(sys._getframe( ).f_code.co_name) ... >>>…
Shiva Krishna Bavandla
  • 25,548
  • 75
  • 193
  • 313
3
votes
1 answer

RemoteViews method names

I am creating an App which uses some widgets and I use setInt() method on a remoteView for changing the background source. That´s not a problem, but I wonder where the documentation about the method names is. In the RemoteViews API it is not…
Opiatefuchs
  • 9,800
  • 2
  • 36
  • 49
3
votes
3 answers

Get a function name like printed in Chrome console

Considering this code : var o = {}; o.f = function(){}; new o.f; Chrome prints o.f {} into the console. Do you know how this o.f part is called? More importantly, is there any way to get this result without using the console? I'd like to extract…
user1636522
3
votes
3 answers

Is there a way to get a method name dynamically in c#?

I have a case where I pass a method name to a function as a string, but I don't want it hard-coded. for example void MyMethodName() { // some code } void SomeOtherMethod() { …
Esam Bustaty
  • 346
  • 1
  • 4
  • 13
3
votes
4 answers

Which of these approaches to method naming is better and why?

In my app, we have Users who can perform actions on one another - like poking on Facebook. I'm writing the methods just now and am not really sure which approach to take. I mean, I know they're both acceptable but is there a more idiomatic…
bodacious
  • 6,608
  • 9
  • 45
  • 74
1
2 3 4