What’s In a Name?
What we call things in software matters. Naming conventions make communication easier for other developers, and can help bring clarity to the software for yourself.
Overloading a term is a common occurrence. I find this more common in summary data where you might have a term such as Sale Amount. What is a Sale Amount? Well, it can have different meanings depending on the level of aggregation implied.
Consider a purchase order. You could have a line item that has a unit amount, the number of units, and the sale amount equal to the number of units times the unit amount.
The same term could then be used for all of the purchase orders from a customer. The sum of all Sale Amounts for that customer, could then be named as a term “Sale Amount”.
As you can see the term Sale Amount has different meanings in this kind of a system. Does it make sense instead to have some identifier as to the level of aggregation for that sale amount?
- Purchase order line item – ExtendedSaleAmount
- Purchase Order Sale Amount – POSaleAmount
- Customer Orders Sale Amount – SalesAmount
- Quarterly Sale Amount – SalesAmount
You get the picture. It might be more meaningful to add a suffix to the name identifying the aggregation level of the value. You see this more often in a Data Warehouse.
- Sum Sales Month to Date – SalesAmountMTD
- Sum Sales Year To Date – SalesAmountYTD
- Sum Sales First Quarter – SalesAmountQ1
If you were using data marts, or views, this the periodicity of the Sum could be derived by the table/view name. However, once the data is removed from that view in a result set, the periodicity is not readily known, hence the suffix. Without it, you could have a monthly, quarterly, yearly view on the data all having the same term SalesAmount. The term itself is not fully descriptive.
These are simply observations I have made over time. I’m sure many of you have similar observations. Why not share your thoughts and practices by leaving a comment below, or even dropping me an Email at btaylor@sswug.org. Get into the conversation.
Cheers,
Ben
$$SWYNK$$
Featured Article(s)
What To Do to Prepare for an Interview
Steve Wynkoop and I talk about designing and managing our professional careers on a weekly interview on SSWUG.org. This episode was about how to prepare for that important interview. This article goes into more detail.
Featured White Paper(s)
Achieve an astounding return on investment with Toad® for Oracle
read more)