What it means
Code should be Understandable to others as well as for us after sometime, Intiuitve,Adaptable, Extendable, Debuggable
Maintainability is writing or making code easy to understand and easy to debug
Why it is needed
Mostly we are maintaining the code rather writing a new piece.
It takes more time to figure out where we have to look out to solve a problem comparitively to create a solution for the problem
It will be helpful for Co-worker present and in future.
It will be helpful for Development community if we work for opensource projects
How it can be achieved
Indenting Code which is easy as well as very important
Commenting the code atleast at the top of each function and classes , while we use large code chunks , if we write any new algorithm or if we write any hack for display purpose on various browser
Variable name should be nouns and function name should start with verbs with their usage.
In client side we have three components they are JavaScript (behaviour),CSS(Presentation) and HTML (Structure )
Maintain these separate dont mingle these things in one file which will leads to confusion.
Keep Bussiness logic out of event handler.
Dont extend objects which are native (Array,String,RegExp)
Dont override methods which are from native objects
Functions and variables should be attached to an object
Dont use global variables instead use var Constants={name:value}
Throw your own errors
Avoid null comparisons (variable =='null' instead use variable instanceof Array or typeof variable =='string')
Use constants when it is UI string ,repeated value ,URL and values which may change the future
No comments:
Post a Comment