naming-conventions

Lambda variable names - to short name, or not to short name?

Typically, when I use lambdas, I just use "a, b, c, d..." as variable names as the types are easily inferred, and I find short names to be easier to read. Here is an example: var someEnumerable = GetSomeEnumerable(); var somethingElseList = someEnumerable.Select(a => a.SomeProperty) .OrderBy(a => a...

Should we put units of measurements in attribute names?

I think most of us agree that it's a good idea to use a descriptive name for variables, object attributes, and database columns. If you want to store something's name, you may as well call the attribute Name so people know what to put in it. Where the unit of measurement isn't immediately apparent, I think you should go a step further ...

Naming convention for params of ctors and setters

For those of you who name you member variables with no special notation like m_foo or foo_, how do you name parameters to your ctors and setters? Some options I've tried so far... Obj(int foo) : foo(foo) { } void set_foo(int foo) { this->foo = foo; } Obj(int _foo) : foo(_foo) { } void set_foo(int _foo) { foo = _foo; } Obj(int a_foo) ...

What is readable code? What are the best practices to follow while naming variables?

Do you think x, y, z are good variable names? How will you explain a new programmer to write readable code? ...

In an OO language, what do you name your class that contains the Main method?

For instance in C# or Java, you always have a main() method used to get your program running. What do you name the class that it is in? Some ideas I would use would just be "Program" or the name of the program itself. What would be considered conventional in this case? ...

How do you recommend denoting static class members?

I have a naming strategy for denoting the nature of code entity (variable, method, etc.) which accounts for the most common permutations of scope, entity type, and mutability, but I have not been able to choose a way of denoting private static member fields (not properties). What are some recommended ways of denoting this? Update: F...

In C#, what is the generally accepted way to refer to member properties within the class?

Have read through the MSDN naming guidelines and could not find a clear answer, other than that you should try to avoid underscores in general. Let's say I have the following: public class Employee { private string m_name; //to store property value called Name public string Name { get { return m_name; } set...

Naming conventions for replacement APIs / classes

Do you have a naming convention for APIs or Classes that are being phased in to replace an older version that performed the same function / filled the same role? E.g. Windows does this by adding "Ex" to the end of the function: ShellExecute // old ShellExecuteEx // new What do you prefer, and what are you reasonings? Appendin...

What is your preferred boolean pair: 1/0 Yes/No True/False ?

When dealing with MySQL, I typically use the BOOLEAN type, which is equivalent to TINYINT(1), or 1/0 In most languages I work with, true/false is preferred When displaying forms, sometimes "Yes / No" makes more sense ...

Naming conventions in C# compared to Java

The standard naming convention in the Java world is to name packages, classes and methods according to: com.domainname.productname (package) com.domainname.productname.ClassName (class) com.domainname.productname.ClassName.isUpperCase(String str) (method) What is the C#/.NET standard naming convention for the above cases? ...

Is the "_" prefix reserved for MovieClip names?

Is it possible to use the "_" underscore prefix for your own MovieClip names? (AS2) i.e. Can you name a created/attached MovieClip "_feature" or "_bug" ? Typically this is reserved for internal properties like _x or _visible. ...

Stored procedure name tagging

Ever wonder what wikipedia's database schema looks like? I recently read this thread from reddit. I like how their tables are tagged with a prefix so you can sort of tell its functionality, purpose, and relationship with other tables right off the bat. One thing I do not notice is how they name their stored procedures. Do they even u...

Camel case names: How strict?

What is the feeling on how strictly one should apply camel casing to variables. I'm thinking specifically of variables like identifiers whose names will contain ID. Do you use thingID, or the more correct thingId? The second one always looks wrong to me. ...

C# naming convention for enum and matching property

Hi All, I often find myself implementing a class maintaining some kind of own status property as an enum: I have a Status enum and ONE Status property of Status type. How should I solve this name conflict? public class Car { public enum Status { Off, Starting, Moving }; Status status = Status.Off; public Status ...

What name do you use for the parameter in a static variable setter method?

When I write setters for instance methods, I use this to disambiguate between the instance variable and the parameter: public void setValue(int value) { this.value = value; } So, what do I do when value is a class variable (static) instead of a member of an instance? private static int value = 7; public static void setValue(int val...

Shorter naming convention for types.

I am developing a framework, and some of the objects have reaaally long names. I don't really like this, but I don't like acronyms either. I am trying to come up with a shorter name for "EventModelSocket", basically a wrapper around the .Net socket class that implements various events, and methods to send files, objects, etc. Some of the...

Naming types in a namespace by the .NET Framework Design Guidelines

I'm having some problems to come up with a sane type naming scheme for our new line of applications. I want to follow the .NET Framework Developer's Guide - Design Guidelines for Developing Class Libraries, but I'm starting to wonder if that's such a good idea. I'd like to use the Company.Product.Feature namespace scheme as a basis. Pr...

Best Practice for Storing JSON Data That Will Be Passed to jQuery Plugin

I'm looking for the "best practice" as to where the JSON should be stored if it's just a string array. Should it be stored in a variable in a script block in the HTML page? Should it be stored in a JavaScript file outside of the HTML for separation? Or should it be stored in the plugin itself? If it should be an external js file, what's...

What's the best name for a non-mutating "add" method on an immutable collection?

Sorry for the waffly title - if I could come up with a concise title, I wouldn't have to ask the question. Suppose I have an immutable list type. It has an operation Foo(x) which returns a new immutable list with the specified argument as an extra element at the end. So to build up a list of strings with values "Hello", "immutable", "wo...

Is there a best way to handle naming fads?

In the last year and a bit of working on my team's code base I have noticed a steady progression of naming conventions. For example, there are a lot of classes that are named to express that they are a class that helps you do something. Here's the ones I've spotted: MyClassUtil MyClassFactory MyClassHelper MyClassManager MyClassServic...