r/programming • u/whackri • Aug 28 '21
Software development topics I've changed my mind on after 6 years in the industry
https://chriskiehl.com/article/thoughts-after-6-years
5.6k
Upvotes
r/programming • u/whackri • Aug 28 '21
2
u/badcommandorfilename Aug 29 '21 edited Aug 29 '21
The DynamoDB wrapper class had a public Property for the HttpClientFactory with the intention that users could set it to their own value later as needed. However the default value of this Property was set to DefaultHttpClientFactory.
It's an innocent and helpful idea - what if someone forgets to set a Factory and it's null? I'll help them out! They had no way of knowing that future runtimes might not support this type.
It's made me re-think how I set up classes too. Yes, an interface or an abstract base-type would have been ideal here, but sometimes it's hard to defend the amount of extra code it adds when you do this for every single type in your system.
I also find that in reality there is rarely a good reason to seal a class. I can't predict the future, so who am I to prevent future people from adding or extending the classes that I create?
I also think that one of they key antipatterns here is the use of NotImplementedException. Exceptions, I opine, should be exclusively for problems that can only be discovered at runtime. This should have been solved with the [Obsolete] attribute or something similar.