Wednesday, April 22, 2015

Address1 and Address2 are fairly typical variable names for the two lines of a street address.

I remember from reading Bob Martin's Clean Code that variables and class instances which are named in a series with a numbers bolted onto the end like this are named poorly (per the book) as this goofy abbreviated encoding like most such shortcuts of "speech" is counter to the goals of ubiquitous language as suggested in Eric Evans' Domain Driven Design. It seems Address1 and Address2 are a silly convention that is here to stay however and we might as well embrace it instead of fight with it. There are numerous examples of this in the works of others. It's nearly a standard. If I were to name a variable SecondOptionalAddressLineForSuiteNumber to be explicit it would confuse everyone but myself.

No comments:

Post a Comment