# What components of your coding typical add to top quality code?

In feedback to This Question, I ask : What are the most effective components of your coding criterion?

What are the most effective techniques that aid with code top quality, integrity, maintainability, readability, etc

Please include the language, the thing from the criterion, and also the factor it boosts your code.

0
2019-05-09 11:01:31
Source Share

Any Language :

Adequate and also regular use whitespace, both upright and also straight, significantly boosts the capacity of the code to be swiftly skimmed along with read at a regular rate. I'm not mosting likely to say concerning tabs versus rooms, as long as their use corresponds, yet correct impression and also wise use empty lines and also rooms around drivers are all definitely essential.

Relevant : maintaining line sizes to a practical restriction such as 80 columns has verifiable advantages : no unusual covering on gaming consoles, no demand to scroll, and also the capacity to watch numerous documents alongside on a vast display, as well as that it often tends to aid urge refactoring of deeply - nested code and also run - on expressions.

0
2019-12-05 02:36:26
Source

C# and also Java :

• Making certain logging of essential areas is effectively specified (log4 *).
• Maintain approaches and also courses tiny (Single Responsibility).
• TDD or creating device examinations for vital areas of organisation reasoning (jUnit or nUnit).
0
2019-12-04 05:36:42
Source

All Languages : Write legible code as opposed to remarks

• A comment adhered to by a block of code can be changed by a method which mentions the intent equally as well as the comment, and also makes the code extra modular and also multiple-use too.
• It makes refactoring take place regularly.
• It aids us write straightforward, readable clean code. Legible code is a pleasure to collaborate with.
• It often tends to make approaches succinct.
• It stays clear of remarks leaving sync with the code
• It tests you to revise commented code that is difficult to comprehend.

Contrast this :

public void update() {
// Fetch the data from somewhere
lots of lines of;
code;
for;
fetching;
data;
from somewhere;
// Sort the data
more lines of;
code;
which sorts;
stuff;
around;
a bit and then;
// Update the database
lines of code;
which uses;
some lib;
to update;
using iteration;
and logic;
the database;
done;
}


With this variation where remarks are changed with function calls :

public void update() {
data = fetchData();
sorted = sortResults(data);
updateDatabase(sorted);
}

0
2019-12-04 05:33:39
Source

For C+npls inheritance. Mentioning that,

• Multiple Inheritance : Only really hardly ever is numerous execution inheritance in fact valuable.

For various other points.

• Preprocessor Macros : Be really mindful with macros. Prefer inline functions, enums, and also const variables to macros.
• Smart Pointers : If you in fact require reminder semiotics, scoped_ptr is wonderful. You need to just make use of sexually transmitted disease:: tr1:: shared_ptr under really details problems, such as when things require to be held by STL containers. You need to never ever make use of auto_ptr.
0
2019-05-31 11:16:04
Source

Formatting - specifically Indentation! I'm making use of Delphi and also the first point to do when I get code not formatted to my use I reformat it. The constructed - in formatter in Delphi acts as among one of the most previously owned fetaures in these instances.

0
2019-05-31 11:06:33
Source

Unique identifying method, does not matter on the language. As an example. G = Global, L = Local, P = Parameter. Currently when you have a variable like G_strFoo I recognize that it is definition can be situated in my international documents. Aids with staying on par with all the variables in my programs.

0
2019-05-31 10:56:03
Source

Just one public class have to be placed in each documents, say goodbye to.

0
2019-05-12 04:05:05
Source

C : Preprocessor macro 'features' need to remain in all caps

Example : #define CUBE(x) ((x)*(x)*(x))

Reason : When scanning code, Macros attract attention from normal features, and also sharp you that there might negative effects a regular function call would certainly never ever have, like transforming the value of the "input" argument, or having it reviewed 3 times.

0
2019-05-10 06:29:34
Source

C# : Use Extract Method as opposed to comments

If we seemed like we required to add a comment to a block of code to clarify what it's doing, rather we would certainly extract that code right into a new method with a detailed name.

This makes the code extra legible and also modular, and also lowers the variety of (out - of - day) comments drifting about.

0
2019-05-10 06:21:15
Source

### C# : Differing calling designs for various sorts of names.

As an example :

public class ClassNamesArePascalCase{
public int FieldsArePascalCase;
private int _privateFieldsAreUnderscoredCamelCase
public const int CONSTANTS_ARE_CAPITAL = 3;

public void MethodNamesArePascalCase( string parametersAreCamel ){
int localVariablesAreCamel;
}
}


It does not matter a lot which criteria you make use of for which name kinds, as long as it's regular amongst that type (eg, all constants are resources), regular within the task, and also various from eachother. The advantage below is that I can inform at a look that _ someVar is an exclusive area without needing to look it up.

0
2019-05-10 06:15:30
Source