naming-conventions

Functions or methods?

纵饮孤独 提交于 2019-12-01 19:00:50
If I'm writing abstract data types in C, are the functions written to perform actions on these data types and exposed in the interface (.h files) called functions , methods , or something yet completely different? I can't seem to find a constructive answer anywhere. Is method a C++ specific term? Is method a C++ specific term? A "method" is an object-oriented programming term, and refers to a function that is part of the namespace of an object. So you can create methods for objects in languages like C++, Java, Objective-C, etc. In C on the otherhand, you still have stand-alone functions, not

Objective-C class names with a +

有些话、适合烂在心里 提交于 2019-12-01 18:51:24
Does a class name, say UIImage+Something or UIImageView+Somethingelse , mean that it acts like a custom UIImage or UIImageView ? I think you are looking at the file names of Categories, not Classes. The plus character + is not allowed in class names or any other identifier in Objective-C. An Objective-C category is a way of adding methods (but not instance variables) to a class you don't necessarily have the source to. For example, if you frequently want to make upside-down copies of UIImages, you can use a category to add a upsideDownImage method onto the UIImage class. It's common to save

Java convention on reference to methods and variables

Deadly 提交于 2019-12-01 18:12:05
Section 10.2 of Java conventions recommends using class names instead of objects to use static variables or methods, i.e. MyClass.variable1 or MyClass.methodName1() instead of MyClass Obj1 = new MyClass(); Obj1.variable1; Obj1.methodName1(); There is no explanation of the rationale behind this, although I suspect this has something to do with memory use. It would be great if someone could explain this. I guess you mean "for static methods and variables". There is no difference regarding memory, except of course if you create the instance just for calling the method. Conventions aren't for

Should a class have the same name as the namespace?

匆匆过客 提交于 2019-12-01 17:53:34
I'm designing a namespace to hold a set of classes that will handle user related tasks for a several different applications. (Log-in, authenticate etc) The problem is the namespace will be called Fusion.User but then it requires a class in that namespace that makes sense to call User . Should you have a class with the same name as the namespace? Or am I taking the wrong approach here? Having class named in the same way as the name space (package) may lead to a thought that class is central to the package. But if I get it correctly User is just a data object in your case. As far as I see you

Non-ASCII characters in C

↘锁芯ラ 提交于 2019-12-01 17:47:06
I was looking at google go's runtime source code (at https://go.googlecode.com/hg/src/pkg/runtime/ ), and it seems they use a special character for their function names, · . (Look for example at https://go.googlecode.com/hg/src/pkg/runtime/cgocall.c ). Is this accepted across major compilers? It's not ANSI C, is it? Or is it just some macro magic? Thank you! C90 doesn't allow additional character in identifier (over those in the basic characters set), C99 do (both with the universal character syntax -- \uXXXX and \UXXXXXXXX -- and an implementation defined set of other characters). 6.4.2.1/1

Where does the C# generics naming convention come from?

妖精的绣舞 提交于 2019-12-01 17:26:52
I understand T comes from Type , but why is it that the next variable often used is K ? I've seen K used for Key but not frequently as the "next" type parameter. For example, you'll see Dictionary<K, V> where K is for Key and V is for Value . Sometimes you'll see T1 , T2 , etc. or T , U , V (the former is preferred here). But I prefer more descriptive names like Map<TSource, TDestination> or Create<TUnitOfWork> My guess would be that it's from Key . One more variation is the GenericFunction<T1,T2,TResult> , where TResult is the type of value returned by the functon. (as in, Func<T1,T2,...

Where does the C# generics naming convention come from?

冷暖自知 提交于 2019-12-01 15:44:25
问题 I understand T comes from Type , but why is it that the next variable often used is K ? 回答1: I've seen K used for Key but not frequently as the "next" type parameter. For example, you'll see Dictionary<K, V> where K is for Key and V is for Value . Sometimes you'll see T1 , T2 , etc. or T , U , V (the former is preferred here). But I prefer more descriptive names like Map<TSource, TDestination> or Create<TUnitOfWork> 回答2: My guess would be that it's from Key . 回答3: One more variation is the

What are the requirements for naming python modules?

旧时模样 提交于 2019-12-01 07:13:38
问题 I've been going through Learn Python The Hard Way as a sort of refresher. Instead of naming each example ex#.py (where # is the number of the exercise), however, I've just been calling them #.py. This worked fine until I got to Exercise 25, which requires you to import a module you just created through the interpreter. When I try this the following happens: >>> import 25 File "<stdin>", line 1 import 25 ^ SyntaxError: invalid syntax I tried renaming the file to ex25.py and it then worked as

Matlab- How does you name a new variable based on other variables' values? [duplicate]

ぐ巨炮叔叔 提交于 2019-12-01 06:52:08
问题 This question already has answers here : Closed 8 years ago . Possible Duplicates: How to concatenate a number to a variable name in MATLAB? MATLAB: How can I use a variables value in another variables name? I want to name a variable using values of other variables given in a function. So, if I have values for an x1,x2 I can make the new variable's name as: x_(x1's value)_(x2's value) as a name. I've checked out the eval, num2str, strcat functions, but as of yet I can't make it so that I have

Naming local constants: UpperCamelCase or lowerCamelCase?

早过忘川 提交于 2019-12-01 06:51:31
Which naming convention do you use for local constants in C# and why? const int Pi = 3; const int pi = 3; It seems the trade-off is between lower camel-case indicating restricted scope, and upper camel-case being more readable and easier to move to a class level. I've noticed StyleCop prefers upper camel-case. I'm used to upper case (pascal case) for everything except variables and fields. Global constants are an exception to the fields, I don't know why, probably because they are public in some cases. Local constants are also lowercase so. It's just a matter of taste imo. Of course, within a