I am recently having a discussion with colleagues about where should a piece of code reside within our django project.
For the sake of the question, let's say we are creating APIs for uber-like quotation feature
We have the following modules(an app in django's lingo), each concerns with persistence, business logic and API
- location, for GPS storage and distance calculation
- traffic, for travel time estimation
- promotion, for discount using promo codes
- quotation, for price calculation, currently depends on location only
Now we want to have an API for quotation to also take promotion into account.
It comes natural to me to put the API under
quotation module, extending existing API behaviour, and adding
promotion as a dependency.
However my colleague advocates otherwise - to create a new API under
promotion and adding
quotation as a dependency.
While the above example is for illustration only, I would like to hear what, in general, considerations should be made when placing cross cutting code?
Edit: A comment I find useful
Two services can be pretty well designed at one point in time, with isolated use cases, and next year someone comes up with a new requirement which requires cross-domain access - that is how reality works. Throwing the old system away and build a new one with just one service instead of two is not even impractical, it seldom results in a better system.