It appears as an artform to write good code and if you want to be perfect in it then so much time will be needed. However, when core guidelines are not known to you then some more time may be required. If you want that reading, writing, and maintaining software should be easy then you need to write a clean code for it. If as per your expectation the application operates then a thinking can come to your mind that you have completed the work. Here you need to understand one thing that the purpose of coding is not only for the computer’s use. You have to recognize that humans are living people but not computers and for these living people, you have to write clean code. Now I am going to tell you why you need to write clean code and along with this, I will also show you some coding standards that matter.
Standards Of Documentation And Commenting
If at the time of coding you add random documentation or a group of comments then we can not call it commenting. In order to help colleagues understand the coding, you can mention certain things which come under commenting.
- Commenting determines those things that you want to accomplish via coding as well as it gives the component’s description.
- The component needs to attach a file known as Changelog.md for logging any modifications. If you take interest in having consistency then a particular format needs to be maintained for that purpose.
For different languages, you can use different types of formatting. Basically, new lines, brace positions, whitespace, and indenting come under formatting. As an example, PHP (Drupal) is a language for which formatting exists. For beautifying the code, the editors contain a large number of plugins.
Conventions For Naming
- For instance, if there are constants then for these we use UPPER_CASE, if there are classes and CSS IDs, we use lower-case-hyphenated, if there are functions and variables of JS then we use camelCase and if there are functions and variables of PHP then we use lower_case.
- As per the data contained in the variables their naming should be done. In the same manner, functionality needs to be provided by the functions. We call this code self-documenting. It is not necessary to tell how functions are performing. The important thing here is to tell what functions are doing. There is no need to change the name of the function but you need to change the only implementation that is underlying and it is known as abstraction.
If between different platforms you want to move the code then it is necessary for the code to be portable. So, at the time of coding you need to consider a number of things:
- URLs, as well as those file paths that are absolute, come under the values which are hardcoded and you have to avoid these.
- The code should not have magic numbers. It is very difficult to update a value that is hard-coded. It is because, after a certain period of time, changes can occur in a value which is hard-coded.
- For SCSS code we can use those standards of CSS code that are meant for Drupal. However, Drupal.org does not contain any documentation that is related to SCSS.
- Here a few SCSSLint related documentation are available and finding these is possible for you.
- Priority is given to JSHint when it conflicts with those conventions of JS formatting that are related to Drupal.
If you take interest in customizing, implementing, and integrating Salesforce for the growth of your online trade then contact an offshore salesforce development company.
You Must Know About