- 最終更新
- 2026/08/17
3秒でわかる
クラスの持つデータと操作、そしてクラス同士のつながりを四角と線で表すUMLの図。実装前に責務の分け方を検討するために描きます。
30秒図解
もう少し詳しく
どういうものか
クラス構成図(クラス図)は、
クラス同士は
なぜ必要か
コードを
レビューの場でも
具体例
図は
+---------------------+ +------------------+
| Order | | OrderItem |
+---------------------+ 1 * +------------------+
| - id: Long |<>--------| - productId |
| - createdAt: Date | | - quantity: int |
+---------------------+ | - unitPrice |
| + total(): int | +------------------+
| + addItem(item) | | + subtotal(): int|
+---------------------+ +------------------+
^
| (継承)
+---------------------+
| SubscriptionOrder |
+---------------------+
| - intervalDays: int |
+---------------------+この
public class Order {
private Long id;
private final List<OrderItem> items = new ArrayList<>();
public int total() {
return items.stream().mapToInt(OrderItem::subtotal).sum();
}
public void addItem(OrderItem item) { items.add(item); }
}
public class SubscriptionOrder extends Order {
private int intervalDays;
}- は+ は
つまずきやすいところ
1 と * の似た用語との違い
| 図 | 表すもの |
|---|---|
| クラス図 | クラスの |
| シーケンス図 | 処理の |
| ER 図 | テーブルと |
覚え方
クラス図は


