Live data from Hacker News

Domain-Driven Design

verraes.net

131–140 of 198 posts

Re: Domain-Driven Design

#131
post #56

"Making illegal states unrepresentable" is one of the worst possible pieces of advice I ever encountered. It sounds very reasonable, but as soon as you face the issue of communicating to the user or other components the fact that something is wrong and what is wrong, you'll discover that it is very hard to inform about illegal states if you cannot represent them.

Is this not just as simple as recommending to use an input mask, or date picker or lookup list so it's impossible to end up with an invalid value in your system?

I always took it as such.

Re: Domain-Driven Design

#132

This principle is a key flaw in the idea: "A complex domain can not be efficiently expressed as a single universal model and language, and must therefore be separated into Bounded Contexts (ie. an internally consistent language and model) by the system designers". We humans understand how everything we experience is part of a wider world. So if you are unable to know how things relate, as all things do, you do not ye…

I don’t think it’s accurate to say that DDD advocates ignoring how things relate. It’s more like finding the higher level concepts that do relate to each other. You don’t need to know about internal combustion to write traffic rules. In fact, it’s better if you don’t know about that because your rules shouldn’t need to change when the mechanism that moves the car changes.

Re: Domain-Driven Design

#133
post #6

I attended a few DDD meetup a few years ago, and it never quite made sense why would you engage in this kind of architecture nowadays. The room was filled with experienced Java developers with deep Enterprise Software(tm) knowledge. Then, I started working as an AI Software Engineer (mix of a software engineer + devops + data scientist), and it all clicked. DDD is a wonderful design pattern for anything related to Da…

> invariant definition What's that? I haven't encountered that terminology before.

"Sales quantity are always > 0"; "Ticket number are unique"; "Returns are always linked to an existing ticket"

You know, stuff you usually put in assert statements. Except in real life you don't have strict application of these laws in the data. So you need a way to find out what percentage of your data is "misshapen" and what to do with them. You can't necessarily filter them out, because they might reflect some business process with relevant information. You goal is to easily identify these outliers without crashing your processing (that would be stupid).

Re: Domain-Driven Design

#134
post #95
post #82

Earlier quoted context omitted.

I find the original tactical DDD patterns as useful as the gang-of-four OOP patterns these days. Modern languages made the latter irrelevant. Modern DDD practice emphasizes getting the strategic aspects of DDD right: language and boundaries. Doesn't matter if your code has a type named `Aggregate` in it. Matters if you get your consistency boundaries right. > I'm not so convinced that it's something you can get just…

>Doesn't matter if your code has a type named `Aggregate` in it. Matters if you get your consistency boundaries right I tended to find a lot written about the former and very little written about the latter. In fact I found essentially zero practical or actionable advice about getting the boundaries right beyond just "it's important to get it right". DDD doesnt appear to have a coherent opinion beyond that. Not in th…

I've found that separating around "abstraction levels", to use Clean Code lingo, really helps for defining good boundaries. This is really super-emphasised in Clean Code, but I find this the most important concept in the book.

Examples:

Are you writing to disk? Printing to the screen? Saving to the database? This is a different "abstraction level" than your data processing, those things should be separated by a boundary.

Are you doing hardcore math to procedurally generate a terrain? It shouldn't be on the same layer you push the triangles to the screen.

It's also about isolation: you want to control the Framebuffers in your 3D renderer? Don't let the Framebuffer class with OpenGL calls ever leak outside the renderer, even though there's encapsulation. Just use a data class to communicate between renderer/non-renderer code.

--

However, the part that is not really discussed on these books is that we should be vigilant not to "over-abstract". Sometimes you have a certain level of abstraction distributed over two or more classes, only to mirror some kind of external structure or mental mode, but in reality you want the code for those things to be together in the same class/method.

One example I run across a lot in 3D renderers is wrapping internal 3D library concepts like "vertex buffer", "context" and "framebuffer" in separate abstract objects, even when they really don't need to be abstract.

For example: "Open GL renderer" will only ever be able to call "OpenGL vertex buffer", "OpenGL context" and "OpenGL framebuffer", while Vulkan will only call the Vulkan equivalents. This means you don't need a "framebuffer" abstraction, you can have it on the same layer as the renderer. You might need a data-only, non-abstract "framebuffer" class to control it from the outside, though.

Re: Domain-Driven Design

#135
post #60

Earlier quoted context omitted.

Good post. The technical patterns are nigh useless unless you're going all in on event sourcing and/or CQRS - and perhaps even then. KISS > DDD. To me, what matters are the strategic patterns, i.e. how you think and talk about your domain. What a lot of (microservice) software gets wrong is bounded contexts and APIs, which can be improved through event storming (discussing what kind of things happen in your domain) a…

All you need is a common vocabulary around English proper nouns and some idea of how they work together. And then the client data has all fields named in Spanish with abbreviations, lettering and numbering everywhere.

I'm an Argentine Spanish-English bilingual programmer. I try to program exclusively in English, but when developing integrations to Argentine systems I often have to fall back to spanglish code.

In general it's preferable to use only english because the code is more readable (because the language's keywords and APIs are in english), but also to maintain consistency with noun-adjective order, verb tenses, etc. Some local concepts can be easily translated (or at least it would seem so) like invoice-factura ... but then inevitably I arrive at concepts for which there is no obvious translation (so I could make one up, but it would not be clear enough for others) or for which the translation doesn't exactly line up.

Re: Domain-Driven Design

#136

Like the original post fails to mention any stakeholders when it comes to developing "Ubiquitous Language" (it enumerates "engineers, testers, analysts, …", and I don't think ellipses does any justice to them), most people forget that DDD is about modelling the real world before you start coding. My experience is that, unfortunately, majority of developers are either not experienced enough, or smart enough (these are…

> majority of developers

Jump to coding or architecting because that's their happy place. That's easy, that's what they know so they think that's what they've been hired for.

Shelling some dollars to buy an off-the-shelf solution for some ancillary application? No thanks we think we can do it ourselves and have more control over it. Let's go coding.

Re: Domain-Driven Design

#137
post #88

DDD strikes me the software version of Agile sometimes. The ideas and philosophy behind are good, but ends up being taken as a silver bullet. If you do this you will have a good architecture and your software will be well architected. Especially in the .NET world i've seen DDD being branded together with CQRS as "Clean Architecture" which in reality turns out to be a mess of layers and separations.

> DDD strikes me the software version of Agile sometimes.

DDD is more about managing your business software needs than making software. If you read "Implementing DDD" a good thing to take from it the fact you should focus your efforts on your business core value add. It's where you put your best developers, architects and money. Anything outside this core will get less resources and can often be outsourced.

And to evaluate what is this core and what is needed, you need your technical team to speak often with the domain experts. Using some common language.

The coding aspect is itself agile as usually there will be miscommunication at first between your tech team and your expert giving you a less than good result. More communication, more knowledge shared and understood will make you think differently about your product and its architecture: that's when you refactor.

Re: Domain-Driven Design

#138
post #113

Earlier quoted context omitted.

Nope, still means nothing too me. I'll just accept that how this bucket of words is supposed to form some cohesive methodology or pattern for anything is beyond my understanding. I'm sure some people get paid a lot of $ to implement it tho.

Simple Version. Before writing a function that reports how many of a certain thing has been "sold", make sure everybody involved agrees what "sold" means in this specific context and domain. And once you have agreed, make sure that every time a function, variable or database table talks about things "sold" it's using that definition. How complex your methodology around this has to be depends entirely on how complex t…

What's so novel about this that deserve its own name and writing a book about this?

Re: Domain-Driven Design

#139
post #115
post #110

Earlier quoted context omitted.

DDD provides insights to understanding how a business works for people who are not domain experts themself, and are tasked to translate business requirements to code. This insight helps make appropriate decisions about those "most critical aspects of software development", nothing more, nothing less. Whether you use factories or not is a much lower-level technical decision far removed from the essence and rationale o…

>Whether you use factories or not is a much lower-level technical decision far removed from the essence and rationale of 'doing DDD'. shrug maybe im reading all the wrong things but IME most DDD discussions, blog posts and books sound more like this: https://stackoverflow.com/questions/555241/domain-driven-des... And few delve into the real "essence" as you put it. Event storming is one of few times, but it doesn't s…

That SO article if from '09 when 'big OOP' was all the hype. Hyping things to bigger proportions than they should be are a problem in IT. We just saw it for 'Microservices', for instance. These hypes serve to overpromise what you'll get, and sow confusion for years to come. In that regard I hope that DDD will not climb the hype cycle again, and we'll stay calm and just use what works.

I think most important to realize that DDD is just another tool in your toolbox, and can be used alongside all / most of the other tools you already use. Event storming can be a nice way to quickly kick off the elaboration process, should the method appeal to you.

Re: Domain-Driven Design

#140
post #17

We use DDD at the current company I work in and to be honest, I detest it so much that sometimes it makes me wonder if I even want to continue in the programming space (been at it for 20 years). Don't get me wrong, DDD has meaning and purpose, but some companies are applying it as a badge to be obtained instead of pondering the question, do you really need to rewrite everything following DDD? In our case, simple CRUD…

I read a bit about DDD but never really went in-depth with it, like I never read the book or anything.

Instead I just try to absorb the major takeaways that I got from what I've read:

1. Bring in people with domain knowledge to help you understand the expected behavior of the system.

2. Try to establish a consistent language that is used in both verbal conversations as well as code.

I feel like those are good, easy-to-understand principles, and I've never understood why the whole DDD space is taken up by this insanely complicated terminology and theory. It's so off-putting.

Post reply on HN