Domain Driven Design Flashcards

1
Q

What is domain driven design?

A

Domain-driven design (DDD) is a software development approach that focuses on the complex and intricate relationships between a business and the data that it processes. In short, it focuses more on the businesses the technology should support.

Advantages:

Improved communication: DDD emphasizes the use of a ubiquitous language, which is a shared vocabulary that is used by all members of the development team and is based on the language used by domain experts. This can improve communication within the development team and between the team and domain experts.

Increased focus on the business domain: By focusing on the business domain, DDD helps ensure that the software being developed is aligned with the needs and goals of the business.

Enhanced flexibility: The domain model in DDD is designed to be flexible and adaptable, which can make it easier to make changes to the software as the needs of the business evolve.

Better understanding of the problem domain: By actively engaging with domain experts and working to understand the complexities of the business domain, the development team can gain a deeper understanding of the problem they are trying to solve, which can lead to better software design.

Improved design: The focus on the domain model in DDD can lead to the creation of a more cohesive and well-structured design, which can make the software easier to maintain and expand over time.

One disadvantage is that it can be time-consuming and resource-intensive, as it requires close collaboration between developers and domain experts and may involve multiple iterations of the design process. Additionally, DDD requires a deep understanding of the business domain, which may not always be feasible for developers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is strategic design?

A

Explorer the problem space and involves identifying the key business objectives and the desired outcomes for the software solution, and then defining the high-level requirements and architecture for the solution.

Understand and model how software handle different domain needs and how they relate to each other.

And involves the following elements:
- Core domain
- Sub-domains
- Bounded context
- Relationships
- Up-stream and Down-stream of data sharing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a sub-domain? And the 3 types of sub-domains.

A
  • Core subdomain:

A core subdomain is a part of a larger domain that is particularly central or important to the business. A core subdomain is typically defined in terms of the business’s core business processes or activities. Examples are patient care in healthcare and designing products in manufacturing .

Creates competitive advantage and is implemented in-house.

  • Supporting subdomain:

A supporting subdomain is a part of a larger domain that supports or enables the core subdomain, but is not itself central to the business’s core processes or activities. Examples are make sure laws and regulations are followed in finance or maintaining and repairing equipment in production.

Doesn’t create competitive advantage and is usually in-house/outsourced service.

  • Generic subdomain:

A generic subdomain is a part of a larger domain that is common to many different types of businesses, and is not specific to a particular industry or sector. Examples are HR, marketing and financial management.

Doesn’t create competitive advantage and is usually adopted/bought service.

They are usually mapped to a single bounded context.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a Context map?

A

A context map describes the relationship between the various sub-domains.

What is the relationship context?

Is data downstream or up-stream?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a bounded context, and ubiquitous language?

A

Bounded context is a conceptual boundary within which a specific domain model applies. The idea of a bounded context is to define a clear separation between different parts of the domain model, so that the meaning of concepts and terms is clearly understood within that context.

For example, in a large organization, there may be multiple bounded contexts, each with its own domain model that applies only within that context. For example, there might be one bounded context for the sales team, with a domain model that includes concepts such as “customer,” “order,” and “invoice,” and another bounded context for the finance team, with a domain model that includes concepts such as “account,” “transaction,” and “balance.”

This is referred to as ubiquitous language. This makes sure everyone speaks the same “language” and the terms used in the code are the same as the business experts.

Jesper mener det er et IT system

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is tactical design?

A

Understand and model the detail of the domain

Consist of:

  • Entities
  • Value object
  • Domain services
  • Aggregates
  • Repositories
  • Factories (ikke gennemgået i undervisnignen)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a monolithic IT system and what are the problems of a this type of IT system?

A

A monolithic IT system is a single, large software application that is built as a single, unified entity. It is typically composed of a large number of components that are tightly integrated and that work together to provide a range of functions. They also often have one common relational database:

The problems with this is:
- It’s difficult to change database
- It’s almost impossible to remove or change aspects of the same
- Performance issues from synchronous transactions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does a layered architecture consist of?

A
  • User interface layer

The user interface (UI) layer is the presentation layer in a layered architecture. It is responsible for handling the interactions between the user and the application, and for displaying information to the user in a way that is easy to understand and use.

  • Application layer

The application layer is the layer of a software application that contains the business logic of the application and is responsible for performing tasks and operations that are specific to the application. Meaning the code is not reusable outside of the context of the application.

In a web application, the application layer might include code that handles user requests, performs validation and authentication, and invokes the appropriate actions in the domain layer. The application layer is often implemented as a set of classes or modules that perform specific tasks or functions.

  • Domain layer

The domain layer is the layer of a software application that contains the core domain model of the application and is responsible for representing the key concepts and relationships of the domain.

The domain layer is typically implemented as a set of classes or objects that represent the key entities, relationships, and behaviors of the domain. It is designed to be independent of the UI and application layers, so that it can be used and reused in different contexts.

A class that represents a customer in an e-commerce application. This class might include properties like customer name, address, and email, and it might include methods to retrieve orders placed by the customer, to update the customer’s account information, and to calculate the total amount spent by the customer.

  • Infrastructure layer

This layer will be the layer that accesses external services such as database, messaging systems and email services. The IUserRepository interface designed in the domain layer and used in the application layer will be implemented in this layer and gain an identity. Similarly, the object that is used through the IIntegrationMessageBroker interface will have an implementation on this layer. Access to RabbitMq platform using AMQP protocol can be considered as an option.

Pieces of code that will be executed to communicate with the outside world such as network and file system are located in this layer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is an entity in tactical design?

A

An entity is a class that represents a unique and identifiable object in the domain. It has a unique identity that distinguishes it from other objects, and it is typically used to represent things like customers, products, and orders.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a value object in tactical design?

A

In Domain-Driven Design (DDD), a value object is a class that represents a value or concept that is not unique and does not have a separate identity. Value objects are typically used to represent things like money, dates, and addresses.

For example, a money value object might have properties like amount and currency, and it might have methods like add() and subtract(). The money value object would not have a separate identity of its own, but rather would be used to represent a specific monetary value.

These objects are immutable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is an aggregat in tactical design?

A

an aggregate is a group of related objects that are treated as a unit for the purpose of data changes. An aggregate has a root entity, which is the main object in the aggregate. The root entity is responsible for enforcing the invariants of the aggregate, and all changes to the objects within the aggregate should go through the root entity.

A customer entity might be related to several order entities (like order and items), and these entities might be combined into a customer aggregate.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a domain service in tactical design?

A

A domain service is a class that performs a specific operation in the domain. It does not have any state of its own and is not associated with any particular entity or value object. Domain services are typically used to implement business logic that does not naturally fit into any of the entities or value objects in the domain model.

For example, a tax calculation service might be a domain service that has a method like calculateTax(order: Order) that takes an order as input and returns the amount of tax that should be charged for the order. The tax calculation service would not have any state of its own and would not be associated with any particular entity or value object. It would simply provide a service that can be used by other parts of the application to perform tax calculations.

They operate on more than one object and is usually implemented as a function, but can also be implemented as a class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a repository in tactical design?

A

A repository is a design pattern that provides a consistent interface for accessing and manipulating data stored in a database.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is an event?

A

An event is an occurrence in the domain that represents something that has happened or that is about to happen. Events are used to communicate changes in the state of the domain model and to trigger actions or side effects.

Events are produced by entities, aggregates and domain services.

They are stored as log files.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the different context relationship types?

A
  • Published language

The interacting BC (bounded context) agree on a common language by which they can interact with each other

  • Open host service

BC specifies a protocol by which any other BC can use its services

  • Shared kernel

Two BC’s use a common kernel of code as a common

  • Customer/Supplier
    One BC uses the services of another and is a stakeholder of that other BC. As such it can influence the services provided by that BC
  • Conformist
    One BC uses the services of another but is not a stakeholder to that other BC
  • Anti-corruption layer
    One BC uses the services of another and is not a stakeholder, but aims to minimize impact from changes in the BC it depends on by introducing a set of adapter.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is event storming?

A

Event storming is a collaborative workshop method for discovering, discussing, and analyzing complex business processes and systems.

Event storming consists of creating a visual representation of a system’s events, using sticky notes and a whiteboard or large sheets of paper. Participants are invited to contribute ideas and insights about the system, and the facilitator helps guide the conversation and capture key points. The goal is to identify bottlenecks, pain points, and areas for improvement in the system.

It’s also in this process you start creating the different bounded contexts.

Advantages:

Collaborative: Event storming brings together a diverse group of people, including developers, business analysts, and subject matter experts, to work together and share their knowledge and perspectives. This helps to ensure that all relevant viewpoints are taken into account when designing a system or process.

Visual: The use of sticky notes and a whiteboard or large sheets of paper allows participants to create a visual representation of the system, which can be easier to understand and more engaging than a text-based document.

Fast: Event storming is a rapid, iterative process that allows teams to quickly identify problems and come up with solutions. This makes it well-suited to agile software development methodologies.

Fun: Event storming is a highly interactive and engaging activity that can be enjoyable for participants. This can help to foster a positive team culture and improve morale.

Flexible: Event storming can be applied to a wide range of industries and domains, and it can be customized to fit the needs of different organizations and projects.

Effective: Event storming has been shown to be an effective method for discovering and analyzing complex systems, and it can help teams to identify bottlenecks and pain points, as well as potential solutions, more quickly and accurately.

17
Q

What are the different notations and components in event storming?

A
  • Events (Orange)

An event is something that has happened. Like and invoice is sent.

  • Aggregates (Yellow)

Aggregates receive commands and accept or reject them. As a result they create one (or more) events.

  • Commands (Blue)

A decision taken by a user (or software). Example could be ‘create invoice’.

  • Policy (Purple)

How is the system supposed to react to an event? It’s used to describe the conditions under which certain actions are taken or certain outcomes are achieved. Policies are in between an event and command. Example ‘create invoice only if an order has been approved’

  • Read model (Green)

a read model is a representation of a system’s data or state that is optimized for reading or querying. It is typically used to support the display of data to users or to enable the system to respond to queries or requests for information. These are decision making tools. Example would be if you work in marketing an want to see how many leads you generated, how close you are to target and where the leads are located the combination of those three things makes up a read model. They are good when you need some information, but not all.

  • External systems (pink)

This refers to any any system or component that is external to the main system. This could be a payment system that’s connected through an API.

  • Hotspot (Red)

Open issues in the flow that (for the most part) happens due to a high volume of events in the system. Hotspots can arise for a variety of reasons, such as a high rate of user activity, a large number of updates to a particular data set, or the need to perform complex calculations or aggregations on a large volume of data.

18
Q

What is the primary things you are looking to learn from an event storming? Why host it?

A
  • To understand the business

Only use events until you have a clear business understanding and know how the business work

  • Understand what data their is

Look for data mentioned in the events and define the aggregates and their content.

Then add the commands and policies when you know which events fit with which aggregates.

  • Look for user interactions that requires a user interface.

Add read models and additional commands.

19
Q

How does layered architecture and domain driven design ensure loose coupling?

A

Coupling refers to the degree to which one module or component relies on or is dependent on another module or component. High coupling between two components means that there is a strong dependency between them, and a change in one component is likely to affect the other. Low coupling between two components means that there is a weak dependency between them, and a change in one component is less likely to affect the other.

  • DDD splits most of functionality up in domains and further into aggregates.
  • Don’t make function calls between aggregates.
  • Use function calls outside of the aggregate on the aggregate root (domain services)
  • Function calls that affect one object is made inside the aggregat.
  • Events are used to move data from one aggregate to the other.