Nowadays, performance and security are very crucial aspects of business prospects. If your product is not good in performance and not secure as well, then you are certainly going to lose your reputation. Performance and security give a positive impact towards,
- Customer trust
- High volume of business
- Reputation etc.
Because these two aspects are the keys to any software product, we can achieve these both in many ways. In this article, I am going to discuss the best practices of coding standards.
Let's say, we have a business requirement where every developer can write code in their own way to meet the business requirement. But what makes the difference between you and them? As per my understanding, in most cases, the developer thinks only from one angle which is the functional requirement to meet the business requirement, but remember, that's not enough. The real developer should think of multiple aspects before jumping into the implementation including both functional and non-functional aspects. Here, I mentioned one aspect, the non-functional requirement. This aspect plays a vital role along with the functional requirement. Non-functional requirement includes the following:
- Security
- Performance
- Scalability
- Extendability
- User friendliness etc
As a developer, we have to consider the above points along with functional requirements. Going forward, I will show you a few of the best coding practices.
Coding standards help in writing easily understandable code and maintaining consistency. I highly recommend to every software programmer or developer to follow the coding guidelines to help improve the readability of your source code and make software maintenance easier. I have listed a few best coding practices which provide:
- Great performance
- Minimized complexity
- Easier maintainability etc.
Given below are a few of the best coding standard practices:
- Assignments should not be made from within sub-expressions
- Files should not have too many lines of code (maximum 1000 lines in a namespace)
- Methods should not be too complex (Default value is 10).
- Lines should not be too long (maximum length is 200)
- Methods should not have too many parameters (Default value is 7 )
- switch statements should not have too many case clauses (Default value is 30)
- Control flow statements do, while, switch, if, foreach, for and try should not be nested too deeply (Default value is 3)
- Expressions should not be too complex
- Generic exceptions should not be ignored
- Types should be named in Pascal case
- switch case clauses should not have too many lines
- Classes should not have only private constructors
- async and await should not be used as identifiers
- Boolean checks should not be inverted
- Use break statements only with switch cases, don't use except switch cases.
- TODO tags should be handled and add summary to every method in the file and Methods should not be empty
- Enumerations Flags with zero-value members should be named None
- Fields that are only assigned in the constructor must be readonly.
- For Parameters with [DefaultParameterValue] attributes should also be marked with [Optional]
- Empty default clauses in a switch should be removed
















phakawan wongpetananPosted Feb 5, 2017, 11:32 AM
It is really good and very useful.
Tunde JohnPosted Jan 2, 2017, 2:28 AM
On declaring class constructor as private, I tend to disagree as this technique is mostly used in Singleton or Factory patterns especially when you don't want the class instantiated directly
SubashPosted Sep 16, 2016, 12:20 AM
Good share sir
Shamim UddinPosted Sep 3, 2016, 5:08 AM
Nice
Delpin Susai RajPosted Aug 30, 2016, 4:39 AM
Good one
Anu VPosted Aug 21, 2016, 11:59 PM
Nice..
Ritesh SinghPosted Aug 19, 2016, 1:38 PM
Nice post dear
Suraj PantPosted Aug 14, 2016, 2:05 PM
Nice article
Ravi KandelPosted Aug 14, 2016, 2:54 AM
Nice
RakeshPosted Aug 14, 2016, 2:41 AM
Good share
Anupam SinghPosted Aug 12, 2016, 6:46 AM
Great share specially points mentioned in coding standard practices with examples.
Kaviya BalasubramanianPosted Aug 12, 2016, 4:00 AM
Useful Post
Guest UserPosted Aug 12, 2016, 3:38 AM
Wow great post! many take aways from this article
VenkatPosted Aug 11, 2016, 12:42 AM
Nice post
SubashPosted Aug 10, 2016, 8:08 PM
Nice share
Christopher loguePosted Aug 10, 2016, 3:02 PM
Nice post, Thanks
ritik katariaPosted Aug 10, 2016, 10:31 AM
Simple and roburst post
Ramesh PalaniappanPosted Aug 10, 2016, 10:18 AM
Nice Article.
Prasanna MuraliPosted Aug 10, 2016, 9:38 AM
Nice post
Vignesh ManiPosted Aug 10, 2016, 8:33 AM
Nice one
Tk MahantaPosted Aug 10, 2016, 8:27 AM
Very Nice
Manas MohapatraPosted Aug 10, 2016, 7:07 AM
Very informative
Bhuvanesh MohankumarPosted Aug 10, 2016, 6:35 AM
Good one
Humayun Kabir MamunPosted Aug 10, 2016, 6:12 AM
Nice...