Coding Principles in C#

In this section we are going to learn about some of the basic coding Principles that help in writing good quality code that improves the overall performance and scalability of the application.

1. Naming convention
  Always use the proper naming convention.

*Solution name should provide meaningful information about the project.
*Project name should specify the layer or component part of the application.
*Solution name should always be different from the project name. Because one solution may contain multiple projects.
*Classes should be noun or noun pharses.
*Methods should represent the actions.
*Pascal casing for Class and method .
*Camel casing for parameters and other variables.
*In Pascal casing, first letter of every word is capital letter.
*  In Camel casing , first letter of every word is small letter .

2.Code Comments
 Proper comments assist developers in many ways . It reduces the time to understand the code. So proper Comments should be given.
When talking about APIs , Swagger is widely used and popular in the developer community. It will provide the complete API documentation.

3.One class per file
  We can create one single .cs file and create number of classes inside it. But it's bad practice when working with large applications. So create one single class inside one .cs file.

4. One logic per method
    Always write methods to do one thing at a time. It may seem big process but it has benefits.

I hope this section would be more beneficial to you.

Comments

Popular posts from this blog

Types of Architects

Basic measurements

Search html table contents based on its td using Jquery