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?
Related:
Cross-cutting concerns in package-by-feature structure
Folder-by-type or Folder-by-feature
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.
quoted-promotion
, even a consideration? It could depend equally on both quotation and promotion.traffic
, and also have quotation based on bothtraffic
andpromotion
. And obviously any combination oftraffic
,location
andpromotion
. Second concern is the integration of said API. i.e. how to decide which API to invoke based on different condition. Another one is maintainability of the codebase<thing>
that can depend on one or several factors, like{traffic, location}
or{quotation, promotion}
, etc. Can you extract and name this thing? Maybe it already exists under some name, but is not generalized enough?