naming-conventions

How to name a collection of an interface?

The situation is as follows. public interface IFoo { } public abstract class FooBase : IFoo { } Now I need a collection of IFoo with some additional methods. public class IFooCollection : List<IFoo> { public void UsefullMethod() { } } The problem is that IFooCollection looks like an interface while it is a class. The options ar...

Naming Conventions and Namespaces

If I have objects on one layer with the same name as objects on another layer, is it best to change the object names with some prefix or have new namespace and refer to them with fully qualified names? For example: namespace Project1.Data Object Person; namespace Project1.Model Object Person; Data.Person.Name=Person.Name; OR dbPe...

Naming conventions - One rule for Controllers, no rules for Models and Views

In ASP.NET MVC controllers exist in a folder called Controllers. Their names must end Controller otherwise things just don't work (you get an HTTP 404 error). However, Model names don't have to end Model and View names don't have to end with View. This seems inconsistent...why (from an MVC or design standpoint) do controller names have...

How verbose should names be for Model-View-ViewModel (MVVM) classes and instances?

In general, I prefer to be verbose with .NET class and instance names, but some times (to quote Mike Woodhouse): Over-verbosity tends to conceal syntax, and syntax is important. The first place I felt like I really strayed into the over-verbosity regime is upon implementing the Model-View-ViewModel (MVVM) pattern in Silverlight and...

Hungarian notation in C#

Before using C#, C++ was my primary programming language. And the Hungarian notation is deep in my heart. I did some small projects in C# without reading a C# book or other guidelines on the language. In those small c# projects I used something like private string m_strExePath; Until I read something from SO that said: Do not u...

C# check or force naming conventions

I have inherited a few programs from a previous developer who was a little sloppy with naming variables, methods and classes with different capitalization and sometimes underscores. Is there a program or a way in visual studio to validate the naming of each variable, method, property, constant, class.... I would be fine with the standar...

What are the type parameter naming guidelines?

I noticed, as well as saw in the Essential C# 3.0 book, that paramters are usually defined as T or TEntity For example: public class Stack<T> { } or public class EntityCollection<TEntity> { } How do you decide which name to use? Thanks ...

C++ Style Convention: Parameter Names within Class Declaration

Hello. I'm a fairly new C++ programmer and I would like to hear the arguments for and against naming parameters within the class declaration. Here's an example: Student.h #ifndef STUDENT_H_ #define STUDENT_H_ #include <string> using namespace std; class Student { private: string name; unsigned int age; float h...

Naming convention for Embed Resource DLL?

I have never used an embedded resource DLL before. I would like to start right so that I'd not have to rename DLL later on. Suppose that, I have a Main Exe file named "Demo.exe", how would you name embedded resource associated with it? Demo.Resource.dll? Resource.Demo.dll? etc? ...

What is a good naming convention for a routine that sets a global variable in the same class

Code Complete (Chapter 7, Section 3) says that a good function should be named for the value it returns and a good procedure name in a class should be named for what it does. When I write synchronized methods in Delphi (pre 2009) I sometimes need to use them to set global variables, a seemingly bad programming practice, but a necessar...

Do Scala libraries follow the same inverted domain convention for naming packages as Java?

I'm looking to write a small Scala library to get a feel for its Actor programming model. In the example code I've come across, some libraries use inverted domain (e.g. org.foo.bar) for packages and some do not (maybe just for brevity). Is it advisable for Scala libraries to use the same package naming conventions as Java? More ge...

Are there any naming convention guidelines for REST APIs?

When creating REST APIs, are there any guidelines or defacto standards for naming conventions within the API (eg: URL endpoint path components, querystring parameters)? Are camel caps the norm, or underscores? others? For example: api.service.com/helloWorld/userId/x or api.service.com/hello_world/user_id/x Note: This is not a que...

Good Naming Convention for Anonymous Types

An anonymous type can be thought of as a "Set Once" Object type, whereas an plain old Object or Variant can be set many times. An object or variant tends to be short lived, while an anonymous type is expected to live longer, making it important to communicate intent. What naming convention do you use to communicate intent when using ano...

ID, id, or Id?

I use camelCase in my code and database field names, etc, but with fields that have Id at the end, it always ends up being hard to read. For example, itemId, teacherId, unitId, etc. In these cases I consider breaking convention and writing itemID, teacherID, or unitID just for improved readability. What do you do and what's a general, b...

How to name pure virtual protected property

foreword: I have a component, lets call it IView. This component is implemented by BaseView class which holds most of it's functionality. We are using the template pattern to delegate logic to inheretting classes. The problem: We have a property named IView.Visible, that indicates if the component should or should not be visible. This...

_Underscores in Function Names

In a lot of languages with simple OO capability (PHP 4), or misunderstood OO capabilities (Javascript, C using function pointers, etc.), you'll end up with a function naming convention that uses leading underscores to to indicate privilege level. //ex. function _myPrivateFunction(){ } While individual teams are always going to come...

Naming Conventions: amountPaid vs. paidAmount

Howdy all, here is two samples with two different approaches to naming variables: decimal amountDue = 1000; decimal amountPaid = 800; vs. decimal dueAmount = 1000; decimal paidAmount = 800; Which one would you usually prefer and why? ...

Best practice for renaming property/method names that are reserved words?

I'm creating a car class. Make and model are properties but both make and model appear to be reserved words in C#. What's the best practice for naming properties/methods when your preferred name is a reserved word? My first instinct is to call the properties CarMake, CarModel (so a convention of ClassNamePropertyName). Is there some bet...

Global variables as aliases for singletons?

Hi! I'm developing a Cocoa (Touch) app and there's certain data (like own device information and a list of locations) that I have to persist between different views and controllers. I thought of storing it as instance variables in my App Delegate, but addressing the delegate is quite cumbersome (no joy typing [[[UIApplication sharedAp...

C# Code Analysis dislikes protected static s_Foo (CA1709, CA1707)

I usually add an m_ in front of private fields and an s_ before static members. With a code like protected static readonly Random s_Random = new Random (); I get the following warnings by VS2008's Code Analysis: CA1709: Microsoft.Naming : Correct the casing of 's' in member name 'Bar.s_Random' by changing it to 'S'. CA1707: Microso...