coding-standards

QT warning level suggestion

What is the warning level you use while compiling QT projects? When I compiled with W4, I'm getting a lot of warnings such as: C4127: conditional expression is constant Should I compile at W3, or find other ways to handle warnings at W4, such as: adding a new header file and using pragma's(mentioned here C++ Coding Standards: 101 Rul...

Coding guidelines + Best Practices?

I couldn't find any question that directly applies to my query so I am posting this as a new question. If there is any existing discussion that may help me, please point it out and close the question. Question: I am going to do a presentation on C# coding guidelines but it is not supposed to limit to coding standards. So I have a roug...

A regular expression that moves opening { braces to a new line, for C/C++/PHP/etc code

This kind of code structure makes, IMHO, code less readable: int func() { [...] } It's just a matter of taste, but I prefer this one: int func() { [...] } So I've trying to make a regular expression to apply in my text editor in order to make code in the first example look like the second one. I've come up with something lik...

Style and coding practice for a very weakly typed language

I am using a proprietary language called VGL which really does not type variables at all. For Example I could Declare variables as such: DECLARE thisvariable, thatvariable, anothervariable all three of the above variables can be used in any different way I choose, string, integer, character, float, Boolean etc... The product in it's n...

what does "+" means in Objective-C files

Hey all, I've been reading some Obj-C projects, and I'm always finding this standard for naming files: ClassName+OtherClassName.h What does this mean? Normally is used with a base class used on the left side, and another class used on the right side, like: NSString+URLEncoding.h Thanks in advance. ...

Java Code Formating

I'm using FreeMarker to generate java code, but as most of it is dynamically generated it's difficult to control the code formation. I want to get code well formatted. Does anyone knows a lib or something like a pretty printer for java code? ...

What are the naming conventions and other standards used while developing a class in php?

I am pretty new to PHP classes and I want to follow the standard pattern? ...

Is it proper to get and especially set Perl module's global variables directly?

I was wondering what the best practice in Perl is regarding getting - or, more importantly, setting - a global variable of some module by directly accessing $Module::varName in case the module didn't provide getter/setter method for it. The reason it smells bad to me is the fact that it sort of circumvents encapsulation. Just because I ...

Forced naming of parameters in python

In python you may have a function definition: def info(object, spacing=10, collapse=1) which could be called in any of the following ways: info(odbchelper) info(odbchelper, 12) info(odbchelper, collapse=0) info(spacing=15, object=odbchelper) thanks to python's allowing of any-order argume...

Are variables named the same as the class bad practice?

Possible Duplicate: Giving a property the same name as its class I will frequently do/see this for local variables: MyObject myObject = new MyObject(); I occasionally get stuck with my naming convention that has public properties capitalized. Something like this: public MyObject MyObject { get; set;} Is this bad? The c...

What would be the best way to implement a constant object?

First of all I should probably say that the term 'constant object' is probably not quite right and might already mean something completely different from what I am thinking of, but it is the best term I can think of to describe what I am talking about. So basically I am designing an application and I have come across something that seem...

Incremental variable naming convention like i, but for an inside For statement?

Hi experts. This is the example: for(int i = 0; i < 10;i++) { for(int ? = 0;? < 10 ; ?++) { } } I usually use an "o" for the second loop, but is there any standard out there? ideas? Thanks. ...

Return enum instead of bool from function for clarity ?

This is similar to : http://stackoverflow.com/questions/2908876/net-bool-vs-enum-as-a-method-parameter but concerns returning a bool from a function in some situations. e.g. Function which returns bool : public bool Poll() { bool isFinished = false; // do something, then determine if finished or not. ...

Number of characters recommended for a statement

Hi, I have been using Qt 4.5 and so do C++. I have been told that it's a standard practice to maintain the length of each statement in the application to 80 characters. Even in Qt creator we can make a right border visible so that we can know whether we are crossing the 80 characters limit. But my question is, Is it really a standard ...

Coding Conventions - Naming Enums

Hi all, Is there a document describing how to name enumerations? My preference is that an enum is a type. So, for instance, you have an enum Fruit{Apple,Orange,Banana,Pear, ... } NetworkConnectionType{LAN,Data_3g,Data_4g, ... } I am opposed to naming it: FruitEnum NetworkConnectionTypeEnum I understand it is easy to pick off w...

Is there a standard for "???", "!!!", "TODO" etc. tags in comments?

I'm talking about special words/tokens used in the beginning of comments, to facilitate grepping or otherwise to attach some special meaning to the comment, like // TODO: Find out what to do about this error. The meaning of some tags are obvious, like TODO and FIXME, but what about ??? and !!!? Are there others? I'm asking because I've ...

Qt's QList: which is the canonical form of getting the number of items in a list?

Qt's QList class provides several methods for getting the number of items in the list - count, length, and size. As we all know, consistency is important, so which should be the canonical/preferred method to use of those 3? ...

Not specifying control names in WPF... performance effect

If you need to access a WPF control from the code behind, you need to supply a Name attribute to it in XAML. In many cases, you don't need to access controls from the code behind, since a lot of coding logic such as binding is better applied directly inside XAML. My question is: Is there a performance gain from not supplying the name a...

Where should I put @Transactional annotation: at an interface definition or at an implementing class?

The question from the title in code: @Transactional (readonly = true) public interface FooService { void doSmth (); } public class FooServiceImpl implements FooService { ... } vs public interface FooService { void doSmth (); } @Transactional (readonly = true) public class FooServiceImpl implements FooService { ... } ...

F# coding style and standard

While there is no One True Correct Style, some points of general agreement exist in the C# community regarding coding standard / style; usually, they are variations of the .NET Framework Design Guidelines. When you look into F#, though, the standard is visibly different from what is considered normal in C#. As an example, the function...