← Java OOP Knowledge Map← Java OOP 知识地图
Domain Modelling

Domain Modelling

Domain modelling turns real-world concepts into classes, relationships, and behaviours before you write code.Domain modelling 是把“业务里的真实东西”整理成 class、relationship 和行为。它不是先写代码,而是先弄清楚世界里有哪些概念。

Domain

A domain is the world of the problemdomain 是问题所在的世界

In a booking system, the domain contains tourists, schedules, cities, hotels, rooms, and bookings.如果你在做旅游预订系统,domain 就是游客、行程、城市、酒店、房间、预订这些概念组成的世界。

Noun / Verb Analysis

Nouns suggest classes; verbs suggest behaviour名词找 class,动词找行为

WordLikely model可能变成Reason原因
TouristclassThe system needs to remember tourists.系统里需要记录游客。
HotelRoomclassA room has grade, number, and availability.房间有等级、编号、可预订状态。
bookmethod / relationshipA tourist books a room.游客和房间之间发生预订。
Practical Check

Common modelling mistakes建模时常见错误