Names should always indicate role.
Design for Change
Coupling to accidental implementation
- Rename your variable according to the role.
This is a semantic rule. We can instruct our linters to warn us from using names related to existing classes, types o reserved words since they are too implementative.
The first name we can across is related to an accidental point of view. It takes time to build a theory on the models we are building using our MAPPERS. Once we get there, we must rename our variables-
This idea came from this tweet
Davide Bellone 🐧 - 𝗰𝗼𝗱𝗲𝟰𝗶𝘁.𝗱𝗲𝘃 📃📃@bellonedavide@mcsee1 If it's a simple regex, I totally agree.
If you need complex checks, I find that explaining how the regex works and providing examples is the best choice.
Even more if you want your validation method to be private - so you won't write tests specific for the validation.07:25 AM - 01 Apr 2021
Types are essentially assertions about a program. And I think it’s valuable to have things be as absolutely simple as possible, including not even saying what the types are.