Operations: Add/delete student, get roster, check if full.
Generalization (概括化):
Establishes a taxonomic relationship where a general class (superclass) abstracts common features, and specific classes (subclasses) add unique characteristics.
Example: A “Person” class generalizes “Employee,” “Customer,” and “Supplier”; an “Employee” generalizes “Hourly Employee” (e.g., driver, cleaner).
Inheritance (繼承):
Allows a subclass to inherit attributes, operations, and relationships from a superclass, supporting code reuse.
Types:
Single Inheritance: One superclass (e.g., “Account” to “Savings Account”).
Multiple Inheritance: Multiple superclasses (use cautiously due to complexity).
Subclasses can add or redefine inherited features.
Example: “Person” (superclass) with “Patient” and “Doctor” (subclasses); “Doctor” inherits “Person” attributes (e.g., name) and adds specific ones (e.g., specialty).
Message Passing (訊息傳遞):
Enables objects to communicate by sending messages to invoke methods.
Example: In a sales system, a “Sales Transaction” object sends a message to a “Customer” object to update details.
Interface (Polymorphism, 多型):
Allows objects of different classes to respond to the same message in unique ways, hiding implementation details behind a single interface.
Supports “plug-and-play” architectures for flexible system design.
Example: A “calculatePay” method behaves differently for “Full-Time Employee,” “Part-Time Employee,” and “Contract Employee.”
Package (套件):
Organizes model elements (e.g., classes) into groups for better management and configuration.