![]() This is a no-brainer but it is scary how often you will come across variables like x1, fe2 or xbqne in JavaScript, or - on the other end of the spectrum - variable names like incrementorForMainLoopWhichSpansFromTenToTwenty or createNewMemberIfAgeOverTwentyOneAndMoonIsFull. However, I have found that following these principles has made me a more effective developer and allowed other developers to build upon my work more easily.Ĭall things by their name - easy, short and readable variable and function names I am sure you will find things to disagree with, and that is a good thing - you should question what you read, and strive to find better solutions. Take the advice below to heart and keep it in a part of your brain that has a quick access route so you can apply it without thinking about it. So I’ve decided to make it easier for you by creating this article, which is a compilation of best practices and good advice I’ve amassed over the years, much of it learnt the hard way (experimentation and suchlike). However, looking around the web and getting code handed over to me from other developers for years has taught me that common sense is actually quite a rarity in live code on the web, and the “sensible and logical thing to do” gets pushed far down the priority list once you are in the middle of a project, and the deadline is looming. To a number of you, what you are about to read will appear to be very obvious and just the sensible thing to do. Writing a best practice article is quite a tricky business. ![]() 16 Add functionality with JavaScript, don’t create too much content.10 Allow for configuration and translation.7 Use shortcut notation when it makes sense.5 Comment as much as needed but not more.2 Call things by their name - easy, short and readable variable and function names.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |