Clean Code in JavaScript: Develop reliable, maintainable, and robust JavaScript

June 14, 2021
Clean Code in JavaScript: Develop reliable, maintainable, and robust JavaScript

Get the most out of JavaScript for building web applicationsthrough a series of patterns, techniques, and case studies forclean codingKey FeaturesWrite maintainable JS code using internal abstraction,well-written tests, and well-documented codeUnderstand the agents of clean coding like SOLID principles,OOP, and functional programmingExplore solutions to tackle common JavaScript challenges inbuilding UIs, managing APIs, and writing statesBook DescriptionBuilding robust apps starts with creating clean code. In thisbook, you'll explore techniques for doing this by learningeverything from the basics of JavaScript through to the practicesof clean code. You'll write functional, intuitive, and maintainablecode while also understanding how your code affects the end userand the wider community.The book starts with popular clean-coding principles such asSOLID, and the Law of Demeter (LoD), along with highlighting theenemies of writing clean code such as cargo culting andover-management. You'll then delve into JavaScript, understandingthe more complex aspects of the language. Next, you'll createmeaningful abstractions using design patterns, such as the ClassPattern and the Revealing Module Pattern. You'll explore real-worldchallenges such as DOM reconciliation, state management, dependencymanagement, and security, both within browser and serverenvironments. Later, you'll cover tooling and testing methodologiesand the importance of documenting code. Finally, the book willfocus on advocacy and good communication for improving codecleanliness within teams or workplaces, along with covering a casestudy for clean coding.By the end of this book, you'll be well-versed with JavaScriptand have learned how to create clean abstractions, test them, andcommunicate about them via documentation.What you will learnUnderstand the true purpose of code and the problems it solvesfor your end-users and colleaguesDiscover the tenets and enemies of clean code considering theeffects of cultural and syntactic conventionsUse modern JavaScript syntax and design patterns to craftintuitive abstractionsMaintain code quality within your team via wise adoption oftooling and advocating best practicesLearn the modern ecosystem of JavaScript and its challengeslike DOM reconciliation and state managementExpress the behavior of your code both within tests and viavarious forms of documentationWho this book is forThis book is for anyone who writes JavaScript, professionally orotherwise. As this book does not relate specifically to anyparticular framework or environment, no prior experience of anyJavaScript web framework is required. Some knowledge of programmingis assumed to understand the concepts covered in the book moreeffectively.Table of ContentsSetting the SceneThe Tenets of Clean CodeThe Enemies of Clean CodeSOLID and Other PrinciplesNaming Things is HardPrimitive and Built-In TypesDynamic TypingOperatorsParts of Syntax and ScopeControl FlowDesign PatternsReal-World ChallengesThe Landscape of TestingWriting Clean TestsTools for Cleaner CodeDocumenting Your CodeOther Peoples' CodeCommunication & AdvocacyCase StudyAbout the AuthorJames Padolsey is a passionate JavaScript and UI engineer withover 12 years' experience. James began his journey into JavaScriptas a teenager, teaching himself how to build websites for schooland small freelance projects. In the early years, he was a prolificblogger, sharing his unique solutions to common problems in thedomains of jQuery, JavaScript, and the DOM. He later contributed tothe jQuery library itself and authored a chapter within the jQueryCookbook published by O'Reilly Media. Over subsequent years, Jameshas been exposed to many unique software projects in his employmentat Stripe, Twitter, and Facebook, informing his philosophy on whatclean coding truly means in the ever-changing ecosystem ofJavaScript.