4 ms·
I feel like a lot of the pain in codebase organization boils down to having a technical project structure (i.e. layout on disk) that does not align well with th
by bob1029 7y ago
I feel like a lot of the pain in codebase organization boils down to having a technical project structure (i.e. layout on disk) that does not align well with the business. Obviously, it's impossible to force something to directly align with such disparate and abstract requirements, so you have to create abstractions (layers) to enable a hypothetically-pure realm.
In our architecture, we've created roughly 2 different kinds of abstraction: Platform and Business.
The Platform abstractions are only intended to support themselves and the Business abstractions. These are not supposed to be easily-accessible by non-technical folks. Their entire purpose is to make the Business abstractions as elegant as possible. The idea is these should be slowly-changing and stable across all use cases. Developers are only expected to visit this realm maybe once every other week. We effectively treat ourselves as our own customer with this layer.
The Business abstractions are built using only first-party primitives and our Platform layer. Most of this is very clean because we explicitly force all non-business concerns out into the Platform layer. Things like validation logic are written using purely functional code in this realm, which makes it very easy to reason with. Developers are expected to live in this area most of the time. Organization of business abstractions typically falls along lines of usage or logical business activity. We explicitly duplicate some code in order to maintain very clean separation of differing business activities. I've watched first hand as the subtle variances of a single combined Customer model across hundreds of contexts eventually turned it into a boat anchor.
As a consequence of all this, our project managers and other non-code-experts are actually able to review large parts of the codebase and derive meaningful insights without a developer babysitting them. We are at a point where project managers can open PRs for adjusting basic validation and parameter items in our customers' biz code. Developers also enjoy not having to do massive altitude shifts on abstractions while reading through 1 source file. You either spend a day working platform concerns, or you are in the business layer. Context switching sucks and we built to avoid it as much as possible. IMO, having a bad project structure is one direct side-effect of being forced to context switch all the time.
- ajsharma 7y agoWow, I love this idea. I'm curious how you have that structured within the code base. Is it literally a platform folder and a business folder?
- bob1029 7y agoPretty much. We have an issue in our backlog right now that will pull the platform concern into a completely different project/DLL from the rest of the biz code. We still have a little bit of coupling, but we are 99% of the way there. Our long-term goal is to produce a company-common platform layer that can be used to build a wide range of final products. Most business applications that we would build share a lot of common concerns - namely how to manage business state, client views and transactions with external business systems. This is all implemented in various services within our platform layer so we rarely think about it. When we integrate with a 3rd party vendor's API, it goes into platform so anything can now use that integration. The crazy thing I've come to realize is that the journey doesn't have to end there either... You can build yet-higher-order abstractions on top of your platform layer (i.e. a platform for platform). I don't know where this all ends up, but 1 or 2 iterations of it has been extremely healthy for our architecture and business use cases so far. We are now able to chain together extremely complex business processes in ways that can be reasoned with in a single POCO mapper. Without a separation of the "noise" of platform-related and other lower-order code from the business code, it would become impossible to see these opportunities.
- thomk 7y agoBob can you give more details about this or is there a way to contact you? I am genuinely curious about this type of architecture and would love to learn more. If you would rather respond here could you give two simple, concrete examples of each case?
- bob1029 7y agoBased on the responses here, it is apparent that I should spend some time documenting this concept in more detail for the greater good. I do not have the bandwidth for this right now, but perhaps in a few weeks I'll have time to put together some realistic examples for a proper Show HN submission.
- bogidon 7y agoI would definitely read and share a blog post about this that has an example!
- gitgud 7y agoThat's a brilliant way to separate concerns! I've found it's easier to understand a code-base when grouping src files by feature, rather than by file type (html, js, css). But I end up with a strange mix of platform features and business-case features. I can't believe I never thought to simply separate these too distinct types into different parent folders...
- jariel 7y agoHaving a core+utils area and then separate feature (i.e. business) areas I think is another way of saying this, it's not entirely uncommon.
- PudgePacket 7y agoreminds me a little of "ducks" https://www.freecodecamp.org/news/scaling-your-redux-app-with-ducks-6115955638be/ https://www.freecodecamp.org/news/scaling-your-redux-app-wit...
- victorbojica 7y agoDo you have some boilerplate or some demo published anywhere ? Seems like a very neat concept.