Đó là một sai lầm phổ biến cho người mới bắt đầu nghĩ đến những khái quát như đặc biệt
hiệp hội. Quan niệm sai lầm này sinh ra vì cả hai khái quát và
các hiệp hội kết nối lớp học với nhau trong một sơ đồ lớp.
Tuy nhiên, sự khác biệt giữa hai khái niệm này rất sâu rộng.
■ Một hiệp hội mô tả một mối quan hệ đó sẽ tồn tại giữa các trường tại thời gian chạy.
■ Một khái quát mô tả mối quan hệ giữa các lớp trong một sơ đồ lớp.
Một sơ đồ đối tượng không bao giờ có thể chứa một sự tổng quát, và chỉ có thể chứa
các liên kết được tạo ra bởi các hiệp hội, không phải là hiệp hội mình.
Khi bạn thấy một sơ đồ đối tượng được tạo ra bởi một hiệp hội, bạn thấy
trường hợp của cả hai lớp tham gia của hiệp hội đó. Mặt khác, khi bạn
thấy một sơ đồ đối tượng được tạo ra bởi một hệ thống phân cấp thừa kế, bạn thấy một đơn
thể hiện của một lớp học cụ thể của mình. Đó là trường hợp duy nhất sẽ chứa các giá trị của
các thuộc tính được định nghĩa trong lớp học của mình, cũng như những đặc tính di truyền từ
superclasses. Nói cách khác, một thể hiện của lớp nào cũng cần được xem xét
để có một thể hiện của mỗi superclasses của lớp đó.
đang được dịch, vui lòng đợi..