naming-conventions

Unit test naming best practices?

What are the best practices for naming unit test classes and test methods? Previously I don't know if this is a very good approach but currently in my testing projects I have a one to one mapping between a class and a test class, e.g. Product and ProductTest In my test classes I then have methods with the name of the me...

What is the naming convention in Python for variable and function names?

Coming from a C# background the naming convention for variables and method names are usually either CamelCase or Pascal Case: // C# example string thisIsMyVariable = "a" public void ThisIsMyMethod() In Python, I have seen the above but I have also seen underscores being used: # python example this_is_my_variable = 'a' def this_is_my_...

Naming conventions in a Python library

Hello, I'm implementing a search algorithm (let's call it MyAlg) in a python package. Since the algorithm is super-duper complicated, the package has to contain an auxiliary class for algorithm options. Currently I'm developing the entire package by myself (and I'm not a programmer), however I expect 1-2 programmers to join the project l...

What are the naming guidelines for ASP.NET controls?

We are in the process of nutting out the design guidelines we would like to use in our development team and got into a discussion today around how ASP.NET controls should be named. I am talking about our good friends Label, TextBox, Button etc. We came up with the following three possibilities that we voted on: (Example is a TextBox to ...

Foreign Key naming scheme

I'm just getting started working with foreign keys for the first time and I'm wondering if there's a standard naming scheme to use for them? Given these tables: task (id, userid, title) note (id, taskid, userid, note); user (id, name) Where Tasks have Notes, Tasks are owned by Users, and Users author Notes. How would the three forei...

Good examples of Hungarian Notation?

Please answer with good examples of Hungarian Notation, so we can bring together a collection of these. Edit: I agree that Hungarian for types isn't that necessary, I'm hoping for more specific examples where it increases readability and maintainability, like Joel gives in his article. ...

Best name for array indexed by id with boolean value

I get obsessed with the best names for arrays and variables that I use, I'll look up words in the thesaurus, dictionary, etc.. So I'm trying to name this array / structure: $nameMe = array( '392' => TRUE, '234' => TRUE, '754' => TRUE, '464' => TRUE, ); and it's used to check if that id has a certain property, like so ...

Why would a javascript variable start with a dollar sign?

I quite often see javascript with variables that start with a dollar sign. When/why would you choose to prefix a variable in this way? (I'm not asking about $('p.foo') syntax that you see in jQuery and others, but normal variables like $name and $order) ...

Naming of ID columns in database tables

I was wondering peoples opinions on the naming of ID columns in database tables. If I have a table called Invoices with a primary key of an identity column I would call that column InvoiceID so that I would not conflict with other tables and it's obvious what it is. Where I am workind current they have called all ID columns ID. So the...

Really long class/variable/property/method names

Some friends and colleagues of mine have a little running contest to find or write the longest class/variable/property/method names possible. Keep in mind, we try to be good boys and girls and keep the naming intelligible and concise, while still explaining what the thing does via its name. Sometimes it just doesn't happen though. Hav...

Why specify primary/foreign key attributes in column names

A couple of recent questions discuss strategies for naming columns, and I was rather surprised to discover the concept of embedding the notion of foreign and primary keys in column names. That is select t1.col_a, t1.col_b, t2.col_z from t1 inner join t2 on t1.id_foo_pk = t2.id_foo_fk I have to confess I have never worked on any databa...

Do you use particular conventions for naming complementary variables?

I often find myself trying to come up with good names for complementary pairs of variables; where two variables denote opposing concepts, two participants in some sort of duologue, and so on. This might be better explained by a counter-example - I maintain an app that prints two graphics as part of a print advertisement. They're stored ...

What's a good naming convention for a lookup map/hash?

In data processing, I frequently need to create a lookup data structure to map one identifier to another. As a concrete example, let's take a structure which holds a 1-to-1 mapping between a country's 2 character code and its full name. In it we would have AD -> Andorra AE -> United Arab Emirates AF -> Afghanistan What's a good n...

Standard File Naming Conventions in Ruby

For a file containing the given class, SomeCoolClass, what would be the proper or standard filename? 1. somecoolclass.rb 2. some_cool_class.rb 3. some-cool-class.rb 4. SomeCoolClass.rb or some other variation? I noticed in the Ruby stdlib, versions 1, 2 and 3 are used. ...

What naming convention do you use for the Decorator Pattern?

I just recently really truly groked dependency injection and the wonder of the Decorator design pattern and am using it all over the place. As wonderful as it is however, one thing that I've been having difficulty with is naming my decorator classes so I would just like to know what others do. Do you always append the word Decorator? ...

Are there established alternatives to ISomething/ ISomethingable for interfaces?

The .NET standard of prefixing an interface name with an I seems to be becoming widespread and isn't just limited to .NET any more. I have come across a lot of Java code that uses this convention (so it wouldn't surprise me if Java used it before C# did). Also Flex uses it, and so on. The placing of an I at the start of the name smacks o...

What does a type followed by _t (underscore-t) represent?

This seems like a simple question, but I can't find it with the Stack Overflow search or Google. What does a type followed by a _t mean? Such as int_t anInt; I see it a lot in C code meant to deal closely with hardware—I can't help but think that they're related. ...

To foo bar, or not to foo bar: that is the question.

This was something originally discussed during a presentation given by Charles Brian Quinn of the Big Nerd Ranch at acts_as_conference. He was discussing what he had learned from instructing a Ruby on Rails Bootcamp to many people both new to programming and new to Rails. One particular slide that stood out was along the lines of never...

Variable Naming Conventions in C++

Hi All, I come from a .NET world and I'm new to writting C++. I'm just wondering what are the preferred naming conventions when it comes to naming local variables and struct members. For example, the legacy code that I've inheritted has alot of these: struct MyStruct { TCHAR szMyChar[STRING_SIZE]; bool bMyBo...

Which method name fits in best with Objective-C/Cocoa conventions?

Here's a quicky question. Which method name makes the most sense for an Objective-C Cocoa application? -(void) doSomethingWithAnimation:(BOOL)animated or: -(void) doSomething:(BOOL)animated or even: -(void) doSomethingAnimated:(BOOL)animated ...