Objective:

Coding best practices / standards are required to write / deliver more readable, manageable, reliable and scalable code.

How It Works?

 

 

  • DRY - Don’t repeat yourself .

    • You should only need to specify intent in one place.
    • For example, in terms of application design, specific functionality should be implemented in only one component; the functionality should not be duplicated in any other component.
  • SOC - Separation of concerns.

    • Divide your application into distinct features with as little overlap in functionality as possible. The important factor is minimization of interaction points to achieve high cohesion and low coupling.
    • However, separating functionality at the wrong boundaries can result in high coupling and complexity between features even though the contained functionality within a feature does not significantly overlap.
  • SRP - Single Responsibility principle.

    • Each component or module should be responsible for only a specific feature or functionality, or aggregation of cohesive functionality.
  • POLK - Principle of Least Knowledge

    (also known as the LODLaw of Demeter). 
    • A component or object should not know about internal details of other components or objects.
  • MUD - Minimize upfront design / coding.

    • Only design what is necessary. In some cases, you may require upfront comprehensive design and testing if the cost of development or a failure in the design is very high.
    • In other cases, especially for agile development, you can avoid Big Design Upfront (BDUF).
    • If your application requirements are unclear, or if there is a possibility of the design evolving over time, avoid making a large design effort prematurely. This principle is sometimes known as YAGNI ("You ain’t gonna need it").
  • SCG - Setup Coding Guidelines

    • There are lots of coding guidelines / formatting. You must follow coding guidelines of organization or firm. if there are not guidelines setup at organization level, you must setup / start with most useful ones.

    • It is very important to setup coding guidelines to deliver optimized and high productive code.

  • Using Tools

    • Forcing coding guidelines, avoiding human error  and to expedited coding guidelines try to use productivity tools such as ReSharper, Code Maid, Code Digger

  • Peer Review

    • Peer Review is very important phase for making sure coding guidelines are followed and validated, to deliver high quality, manageable and reliable code.