A DDD example of container truck management system
This is a consulting DDD case for a shanghai transportation company(shanghai Yangshan harbor which is maximum harbour in the world) ,this paper shows some processes and ideas of analysis and design.
Requirement
I. Background
II. functional requirements Dispatch center manages all tasks, monitor task execution status and improve the rationality of distributed tasks , reduce human error rates and unreasonable truck cost. Can be embedded GPS monitoring, according to the vehicle transport tasks, you can display information corresponding vehicle GPS monitoring system, SMS can achieve vehicle tasks distributed before each task execution task messages can be sent to the driver's cell phone . The driver can reply different information indicates that the task execution , the system promptly modify the current state of the driver and the vehicle based on the replies received
Understand requirement
According to the requirements document , the first project from the beginning to understand the flow chart positioning throughout a large system , Route planning is so important for transportation company, it has set up a two-stage designer:
Modeling
The use case diagram can be used to find out the basic requirements, the company's managers have their own understanding for the requirements, they will mislead our analysis. in this system , "Task" may be our focus, because task is managers's focus, but it is not domain melody, not a aggregate root entity. At first we regarded a task as a root entity, a entity should have a unique identifier, what is unique identifier of task? task's time or task's no.? what is important for a task? after discussion we found the task main core is planning a vehicle running route. Next step, we according below method to check if "Task " is fit for requirement functions:
Task is the Entity, it should has a state that can be changed by user's command, in a dreiver arrived container inventory, he send loading a container event to system, the loading event will modify the state of the task, but Task's state should be planning or running or finished, the loading event change which state of them? At last, we realize business cohesion is the "truck" entity, it should be aggregate root, truck's route specification is main core of a task. task only a explicit output for tracing truck's route planning and transport process.
ImplementionAfter we get the domain model, we can use jdonframework to implements it. programmer's codes include: repository implemention (such as mysql), and UI implemention(Angular.js and mobile app.)
|