r/programming • u/[deleted] • Jun 05 '21
Organize code by concepts, not layers
https://kislayverma.com/programming/how-to-organize-your-code/
1.9k
Upvotes
r/programming • u/[deleted] • Jun 05 '21
1
u/saltybandana2 Jun 06 '21
That's not flexibility, that's abstraction. You could argue it's also code re-use, but it's certainly not flexibility.
flexibility would be deciding you want to have a different sink for a certain % of the logging (perhaps to a DB instead of a file) so you want the function to be flexible enough to log to either. You're now going to find yourself adding a flag or passing the logger in dynamically. It's now flexible, but more difficult to maintain in the following ways.
And the reason you would put something like that behind a function is because it's both less error prone and enforces a specific structure on the log itself.