Skip to main content

Notifications

Dynamics 365 CRM Development Standards - Coding Rules

Overview

Coding Standards, also known as coding conventions, are guidelines and best practices that define a set of rules for writing source code. The purpose of coding standards is to ensure consistency, readability, maintainability, and portability of the codebase by establishing a common set of practices and formats for coding.

Coding standards cover various aspects of coding, such as naming conventions, code structure, indentation, comments, error handling, security, and performance optimization.

The following are some coding rules related to D365 CRM development.

1. Naming convention, using meaningful and descriptive names for variables, classes, functions, etc.

For example:

Pascal Case for Namespace, File name, Class, Public Method.

Camel case for Internal variables, private method.

2. One Statement per Line

Writing one statement per line helps to improve the readability and organization of the written text, making it easier for readers to understand and process the information being presented.

It also allows for better version control in collaborative writing environments, as changes can be tracked and identified more easily.

pastedimage1681462526412v1.png

3. Curly braces must always be used to encapsulate compound statement code blocks, even if there is only one statement in the code block.

pastedimage1681462555506v2.png

4. When using While, must keep the Loop conditions can be met. Infinite Loops must be avoided.

5. User-Friendly error messages should be used, and invalid error messages should be avoided.

pastedimage1681462585033v3.png

6. Checking the Input Parameter in functions before being used.

pastedimage1681462616101v4.png

7. Remove commented-out or unused Using.

  • Right-click in the .cs file
  • Remove and Sort Usings

pastedimage1681462655849v5.png

8. Maintain consistent code formatting. Use the standard shortcut key CTR+K+D in VS.

9. Use Early-bound and Late-bound to avoid any hard-coding.

10. When building a query expression, it's important to avoid using meaningless sorting or unnecessary columns. This can improve query efficiency and reduce resource consumption.

pastedimage1681462695598v6.png

11. Comment block describing the functionality provided by a file should be included in all source files.

12. Comments are required for complex logic, algorithms, or difficult-to-understand scenarios.

13. Version Control is essential even if there is only one developer, as it helps to track changes and maintain a history of the code.

For example Azure DevOps/ GitLab/GitHub or any others.

14. Check-in comments are required, it’s used to help track the change history. Below is a check-in comments template.

Title/Description: (short one-line description)

Issue/Ticket Number: (reference to relevant issue or ticket number)

Description: (detailed explanation of what changes were made and their purpose)

Testing Done: (summary of tests performed to ensure changes did not introduce issues)

Reviewer: (name of colleague who reviewed the changes, if applicable)

Notes: (any additional notes or comments)

 

Please refer to this page for all the content. 

This is a series of blogs introducing the Development Standards and Best Practices to help configure and customize CRM to do so consistently, clearly, and meaningfully.

Dynamics 365 CRM Development Standards and Best Practices.

Comments

*This post is locked for comments