-
Continue reading →: Rest parameter under the hood…
You know the rest parameter (usually prefixed with …) allows functions or methods to accept indefinite numbers of parameters. This parameter is actually gathering the values from arguments and creates an array of values from it. How? Let’s see with code using ES6 rest parameter and it’s corresponding transpiled version. Simple…
-
Continue reading →: const does not mean value it holds is immutable
I see many JavaScript developers have started replacing var with const just because some linter forces them to do so. const in JavaScript is not only blocked scope but also const variable cannot be reassigned with new content. It creates readonly reference. It means you cannot reassign value to the…
-
Continue reading →: Fizz-Buzz generator using test driven development
This is a Fizz Buzz generator using test driven development. Problem statement: The Fizz buzz generator is a simple program, it’s method say generate accepts the numeric input and produces the output string based on the rules and input number. Rules The generate method returns the string FizzBuzz when input parameter is divisible…
-
Naming query variables
Published by
on
Continue reading →: Naming query variablesAfter working with the different framework and libraries like Laravel, PHP, ASP.NET MVC, ExpressJS and other technologies, I realized that I should write about naming query variables. Perhaps, variable that holds the query and executes it later (Deferred execution). Sometimes, when developers of any language or framework choose to write…
-
Continue reading →: Be declarative wherever possible
Imperative programming focuses on describing how a program operates. Take an example of the below function “ isPresent “. Of course, it searches a number (search term) in the numbers array and replies with true or false. If you observe carefully, it focuses on how the number is searched. It iterates each number one by…
-
Naming functions or methods
Published by
on
Continue reading →: Naming functions or methodsI will show you bad and good naming of methods with the help of some code examples. Let’s see some of the typical functions related code smells on a case by case basis. Smells — Abbreviations appointCR(…) : What does CR mean? Appoint code reviewer or class responsible? It was about…
-
Continue reading →: Naming Modules or Classes
The thinking in this post is applicable to the class as well as modules. However, in this post, I’ll use the word class. Let me walk you through some of the bad and good examples first and show you the useful notes at the end of the post. Uglier ways of…
-
Return as early as possible
Published by
on
Continue reading →: Return as early as possibleDo you know how to check if the given year is a leap year or not? Let us go through a simple leap year code snippet. Tells you whether the given year is a leap year or not. The above code snippets read like: If a given year is divisible…
-
Continue reading →: Naming Matters
Choosing a name has a huge impact on the readability of the code. In this post, I will walk you through some of the bad and good examples which might convince you why naming matters. Project directories: Can you guess which project serves as an admin website, mobile app, and…
-
Continue reading →: The Journey BeginsThanks for joining me! Good company in a journey makes the way seem shorter. — Izaak Walton
