|
|
|
|
|
by roflyear
1248 days ago
|
|
I never understood why this was so hard or why people complicate this so much. You have a segment of your application that "does stuff" - some mix of classes and functions. This stuff has its own API. Then you have your web views call that code through that API (which is probably just calling functions...). No, instead, it is that "does stuff" hast to be its own library, or god forbid, its own service that lives somewhere else, with its own communication layer, its own auth... Why are we making this so hard on ourselves? |
|
1. You found one case where complexity is essential.
2. That one case is not consistent with the rest of your app, and you were taught that inconsistency is bad.
3. Since you can't remove complexity from that case, for the sake of consistency you add complexity to all other cases.
Class-based views is a typical example. You found a place where CBVs are useful. Now some parts of your app use functions, some use classes, that's inconsistent. Edit your style guide to enforce CBV everywhere. Now a simple healthcheck endpoint that returns "OK" has to be a class.
As some folks used to say, you can write Java in any language.
The right approach, of course, is to say "I'd rather have inconsistency than complexity". The challenge is that perception of complexity is subjective, but inconsistency is objective. So the right approach eventually loses, and every organization turns into a bureaucratic hell.