coding-standards

Where to Declare Structures, etc?

Should all structs and classes be declared in the header file? If I declare a struct/class in a source file, what do I need to put in the header file so that it can be used in other files? Also, are there any resources that show some standard practices of C++ out there? ...

Does this function have too many parameters?

In the end, I got this function. I don't know whether it's normal or not. function user_registration($user_name, $user_email , $user_pass , $address , $city , $postalcode , $country , $phone , $mobilephone) How and why can I improve this? ...

Arguments, local variables, and global variables coding convention in Python

In python, there is no way to differentiate between arguments, local variables, and global variables. The easy way to do so might be have some coding convention such as Global variables start with _ and capital letter arguments end with with _ _Gvariable = 10 def hello(x_, y_): z = x_ + y_ Is this a Pythonian way to go? I mean...

How do people handle working with Code Names for their projects?

Hi All, Recently we started using some code names for several different types of prototype applications all following a theme. This made things a little more fun and was a great idea. The problem is that Im not too sure how people deal with migrating a codebase from "codename" state into version 1.0 state which may have a proper name.....

Why is it assumed that send may return with less than requested data transmitted on a blocking socket?

The standard method to send data on a stream socket has always been to call send with a chunk of data to write, check the return value to see if all data was sent and then keep calling send again until the whole message has been accepted. For example this is a simple example of a common scheme: int send_all(int sock, unsigned char *bu...

How to force myself to follow naming and other conventions

I believe, I program good, at least my code produces results... But I feel I have drawback... I hardly follow any naming conventions... neither for variables.. nor for methods... nor for classes... nor for tables, columns, SPs... Further to this, I hardly comment anything while programming... I always think that, Let me first see t...

Microsoft C++ Language Reference

Whenever any question is asked, and a reference text is needed, I never see MSDN C++ Language Reference being referred. I was browsing through it and I personally feel that it is extremely well written. Is there some specific reason it is not used as often as a standard? Is it because it contains some VC++ specific features? ...

Is VERIFY(...) a good practice in C++ coding?

Also, how does it compare to throwing an exception when something goes wrong ? ...

What is the difference between a private and public function?

I am a new programmer, and I started in C and am now starting to enjoy JavaScript and a tiny bit of PHP more. Lately I've heard the terms 'private' and 'public' functions a lot. Could anybody give an explanation of the both and how they are of use to a programmer? And I'm probably totally wrong here... but is a (function(){}) in j...

Where should JavaScript be put?

I've been doing a little JavaScript (well, more like jQuery) for a while now and one thing I've always been confused about is where I should put my scripts, in the <head> tag or in the <body> tag. If anyone could clarify this issue, that'd be great. An example of what should go where would be perfect. ...

Automatic .NET code, nhibernate session, and LINQ datacontext clean-up?

Hi all, in my goal to adopt better coding practices I have a few questions in general about automatic handling of code. I have heard different answers both from online and talking with other developers/programmers at my work. I am not sure if I should have split them into 3 questions, but they all seem sort of related: 1) How does .NET ...

Is there any plug-in or add-on available in eclipse to Check/(set own rules if any) C/C++ source code against a set of coding standards?

Please suggest............ .. ...

Is there a way to make eclipse report a general "catch (Exception e)" as an error/warning (in java)?

I'm trying to encourage a best practice of not catching general exceptions in Java code. eg: try { ... } catch (Exception e) { // bad! ... } Is there a way to flag this as an error/warning in Eclipse? I know PMD picks this up, but I'd rather avoid integrating it into everyone's build environment at the moment. ...

VS coding conventions tools

Please can you help me to find some tools which will help developers to follow coding conventions for .NET( .NET Naming Guidelines,...) I found this ones: StyleCop FxCop ...

Unnecessary 'else' statement

As you know, in Eclipse you can turn on "Unnecessary 'else' statement" check that will trigger on if-then-else with premature return. And, from my experience, there are two most possible situations when use such statement: 1) Pre-check: if (!validate(arg1)) { return false; } doLotOfStuff(); 2) Post-check: doLotOfStuff(); if (con...

Is or Are to prefix boolean values

When naming a boolean, or a function returning a boolean it's usual to prefix with 'is' e.g. isPointerNull isShapeSquare What about when refering to multiple items, should it be: arePointersNull or isPointersNull areShapesNull or isShapesNull I can see arguments for both; is offers consistency and perhaps slightly better readabil...

How to make a webpage display differently in different browsers?

I want to display the contents of a web page in a different format in different browsers. How to go about implementing it? EDIT:More Information The motivation behind this is to display the content in different mobile devices. For example: iPhone uses Safari So if a safari browser is used I will adjust the content so that it fits the ...

Has anybody published any C# 4 coding standards / guidelines / style guides?

I'm aware of a number of coding standards and guidelines for C# 2 and C# 3 but am looking for some which have been written with C# 4 in mind. ...

Any good python open source projects exemplifying coding standards and best practices?

In the question ...

What is a good rule for when to prepend members with 'this' (C#)?

If I am accessing a member field, property, or method, I'm never sure when I should prepend it with 'this'. I am not asking about cases where it is required, like in the case where a local variable has the same name. I am talking about cases where the meaning is exactly the same. Which is more readable? Are there any standards, best ...