4 ms·
One of our clients is a company that franchises out their operations for different countries. I wish I could have a simple PhoneNumber class. Or simple anythi
by bcrosby95 5y ago
One of our clients is a company that franchises out their operations for different countries. I wish I could have a simple PhoneNumber class. Or simple anything class.
But realistically what happens is, e.g., each franchisee wants us to treat phone number differently than eachother. USA wants no country code. Europe does. Japan wants strict number validation. Taiwan doesn't care. And so on.
At the end of the day it all gets stored as a simple string in the database, and there's software other companies have written that can set it to whatever the hell they want so we have to handle that anyways.
Really all I need is a simple string and a validation function.
- spawarotti 5y agoWhat you are saying might be a manifestation of the "bounded context" pattern/problem: https://martinfowler.com/bliki/BoundedContext.html https://martinfowler.com/bliki/BoundedContext.html It is a huge topic. Hard for me to discuss this further without knowing the specifics. But intuitively, if it was as simple as "Really all I need is a simple string and a validation function." then you wouldn't need a class with several hundred lines of code. Or you could have UsaPhoneNumber, JapanesePhoneNumber, etc. And instead of doing: IsValidUsaPhoneNumber(str); you could do: var usaPhoneNumber = new UsaPhoneNumber(str); and now you have the validness captured as a type: https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/ https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-va...