Skip to main content
Share Your Experience: Take the 2024 Developer Survey
119 votes
Accepted

Why is inheritance bad in a Person-Student model?

The problem I have with this model is that teacher & student are roles while person is a real entity.  While this model will work in the short term, it will have problems if: a student becomes a ...
Erik Eidt's user avatar
  • 34.1k
115 votes

What is a domain?

The domain is the real-world context in which you're attempting to solve a problem using software. Each domain comes with expertise, vocabulary and tools that are part of that domain. A specific ...
Robert Harvey's user avatar
99 votes
Accepted

Should entities contain information about their amount?

This is not a question of "good practice", but a question of the requirements of the system. For example: Let's say your system is for a library. If the library has several instances of the ...
Doc Brown's user avatar
  • 209k
70 votes

Is there an industry standard for gender model other than male and female?

First consider why you need to collect this data. Do not collect it if it is unnecessary. For example: You would like to address the individuals properly. Then, simply ask for their preferred form of ...
amon's user avatar
  • 134k
55 votes

Modeling first and lastname separately

First name and last name are not useful concepts. Names work differently in different countries. In most Asian countries, the family name is written first, but it is still used for sorting—so you may ...
Jan Hudec's user avatar
  • 18.3k
53 votes
Accepted

Clean architecture validation in domain vs data persistence layer?

Validation of data entry is one of those things where everyone starts out trying to make it pure and clean and (if they're smart about it) eventually gives up, because there are so many competing ...
John Wu's user avatar
  • 26.6k
44 votes
Accepted

Is extracting an interface just for testing purposes a code smell?

In the described context, there is some unstructured legacy code. Now to improve this situation, you add more structure to it by using classes and interfaces for creating sensible abstractions - just ...
Doc Brown's user avatar
  • 209k
41 votes

What is a domain?

It simply means the problem space you are working in. For example, if you were building an e-commerce website your domain would be "e-commerce" and would involve the processes associated with your ...
Becuzz's user avatar
  • 4,835
32 votes

Modeling first and lastname separately

The only argument that matters is what are the requirements of your system? Do you need to deal with just one culture? If so, conform to that culture. Otherwise plan for internationalization (as ...
Becuzz's user avatar
  • 4,835
26 votes
Accepted

Is there an industry standard for gender model other than male and female?

Sometimes the term gender may be used when sex is meant. Sex is defined by a person's biological traits whereas gender is determined by identity. The standard for sex is codified by the ISO/IEC 5218 ...
Wes Toleman's user avatar
26 votes

Is extracting an interface just for testing purposes a code smell?

The central misconception causing you to doubt this design is right on your question: My doubts are that the only HasHorsePower implementation will be...well.. only the Car If you introduce test ...
Greg Burghardt's user avatar
25 votes
Accepted

How do you push Design changes in TDD in late development stage

How do you do design change in TDD when you have such huge amounts of test that may be dependent on the existing implementation? First, the best approach may be to avoid running into this situation ...
Doc Brown's user avatar
  • 209k
22 votes

What is a domain?

A Domain is an area of knowledge. It can be though about as an activity in which problems solved by your software exist. (Wiki, DDD Community) Eric Evans in his book, uses cargo shipping to explain ...
potfur's user avatar
  • 479
22 votes

When is primitive obsession not a code smell?

Primitive Obsession is using primitive data types to represent domain ideas. The opposite would be "domain modeling", or perhaps "over engineering". Would you create a DateOfBirth object and a ...
VoiceOfUnreason's user avatar
22 votes

Pros and cons of representing routes as legs or stops?

but I'm wondering if using legs would be better When one has two alternative data structures representing the same thing, I would recommend against the assumption that one representation could be ...
Doc Brown's user avatar
  • 209k
21 votes

Should entities contain information about their amount?

It depends on the identity of your items: In a book store, books having the same title and same author all look identical and interchangeable. You would have one instance, holding the total ...
Christophe's user avatar
20 votes

Find the DDD Aggregate Root

Short Version The rationale for DDD is that Domain Objects are abstractions which should fulfil your functional domain requirements - if Domain Objects are unable to easily fulfil those requirements, ...
Ben Cottrell's user avatar
  • 11.8k
20 votes

Find the DDD Aggregate Root

What's the criteria for defining an aggregate ? Let's go back to the basics of the big blue book: Aggregate: A cluster of associated objects that are treated as a unit for the purpose of data changes....
Christophe's user avatar
20 votes
Accepted

What is a domain?

The word “domain” in the Domain Driven Design book by Eric Evans has specific meaning. It’s the thing the software is about. Evans goes further though. In his view there are sub domains even with the ...
RibaldEddie's user avatar
  • 3,283
14 votes

Who are the domain experts?

What is a domain expert ? When you develop software using Domain Driven Design, the primary focus should be on the domain model, that is a representation of the domain in which the software will be ...
Christophe's user avatar
14 votes
Accepted

DDD Injecting Services on Entity Methods Calls

It's totally fine to pass a Domain service in an entity call. Say, we need to calculate an invoice sum with some complicated algorithm that can depend on, say, a customer type. Here is what it might ...
Vadim Samokhin's user avatar
14 votes

Is there an industry standard for gender model other than male and female?

As you mentioned Healthcare, it's worth looking at the NHS Data Dictionary for an example, used in the UK as one of the national coding systems for health data (alongside SNOMED). Depending on ...
Callie J's user avatar
  • 259
14 votes

Is extracting an interface just for testing purposes a code smell?

Is extracting an interface just for testing purposes a code smell? No. In fact, what you describe is one of the kinds of pressure that tests place on design -- the feeling that "testing this ...
VoiceOfUnreason's user avatar
13 votes

How to design an unpredictable model?

I've no idea why Hospitals, Prisons, Nursing Homes, etc need their own classes. Nothing here makes me think they do. Why aren't these simply different instances of InternshipProvider? Not ...
candied_orange's user avatar
12 votes

DDD Injecting Services on Entity Methods Calls

I am shocked to read some of the answers here. It's perfectly valid to pass domain services into entity methods in DDD to delegate some business calculations. As an example, imagine your aggregate ...
diegosasw's user avatar
  • 387
12 votes

When is primitive obsession not a code smell?

A possible rule of thumb may depend on the program's layer. For the Domain (DDD) aka Entities Layer (Martin, 2018), this might as well be "to avoid primitives for anything representing a domain/...
schrödingcöder's user avatar
12 votes

What kind of logic can Domain Objects realistically contain?

Arguably, the smallest method of encapsulation is a function. float harmonic(int n) { float h = 1.0; for (int i = 2; i <= n; i++) { h += 1.0 / i; } return h; } ...
Robert Harvey's user avatar
11 votes
Accepted

Entity Framework and avoiding the Anemic Domain Model

The issue is, you are using EF objects as domain objects in the first place. EF objects are data models NOT business models. You need to declare business objects which give you the freedom to do as ...
TheCatWhisperer's user avatar
11 votes

Pros and cons of representing routes as legs or stops?

A route is just a path in a graph that is annotated with time information: A leg describes an edge in this path (from, to, duration), with a time annotation for either start or end of the edge. A ...
Christophe's user avatar
10 votes
Accepted

Does reference by ID between Aggregates lead to an Anemic Domain Model?

Vaughn Vernon's recommendation is one of the best tactical rules that one should follow. If you really need to hold a reference to another aggregate root then you need to review your aggregate's ...
Constantin Galbenu's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible