Four Stages Of Naming
by {"name"=>"Vuyisile Weni"}
In this blog post i will be explaining my understanding of the Four stages of naming, this is based on assigning names to functions, which i find quiet challenging because a function is a form of action that intents on one thing only.
We all know that it is a rule that a Function name should show intention of the action formed, the four stages on naming are basically a guideline or steps on how to better function names that we assign. Lets create a function that returns a sum of two numbers.
-
First step, declear the function with a name that makes No-sense, well it could be something that is way out of the picture like: firstNumAndSecondNum(num1,num2), this is just a starting point where theres room for improvement.
-
Second step, considering that the function does what it’s supposed to do, now we change the to something Accurate like: combineFirstNumAndSecondNum(num1,num2), this is still a bit out of the picture but there is a bit of light (an idea of what the function does, but combine has a lot of meanings, one could be merge or join).
-
Third step, this is the part where we focus on upgrading the name to something error-free or Precise, that shows honesty and intent of the function based on expression, something like: calculateTheSumOfFirstNumAndSecondNum().
-
Last step, which focuses on the intent and Meaning of the function. This is the part where we refactor and define the function with a verb that is short and understandable, and expresses 100% meaning and intention of the function. so our function name will end up being: addTwoNums(num1,num2).