Difference between revisions of "UML"
Jump to navigation
Jump to search
Line 22: | Line 22: | ||
Inheritance is about special and general cases. First you might want to ask what is the difference between the cases - (called a discriminator). In your case it is the type of reservation and you could avoid the inheritance by modelling this type of reservation and implementing the different behavior based on the reservation type. That would lead to a design like: | Inheritance is about special and general cases. First you might want to ask what is the difference between the cases - (called a discriminator). In your case it is the type of reservation and you could avoid the inheritance by modelling this type of reservation and implementing the different behavior based on the reservation type. That would lead to a design like: | ||
+ | |||
+ | ==== Avoiding inheritance ==== | ||
<uml> | <uml> | ||
hide circle | hide circle | ||
Line 29: | Line 31: | ||
price: int | price: int | ||
delete(): boolean | delete(): boolean | ||
+ | start:date | ||
+ | end:date | ||
+ | frequency:int | ||
+ | new(date,optional date,optional int) | ||
} | } | ||
class Client { | class Client { | ||
name | name | ||
} | } | ||
+ | Reservation -> Client | ||
+ | Reservation "n" <- "1" Reservation | ||
</uml> | </uml> | ||
− | ==== | + | ==== Applying inheritance ==== |
<uml> | <uml> | ||
hide circle | hide circle | ||
Line 42: | Line 50: | ||
price: int | price: int | ||
delete(): boolean | delete(): boolean | ||
+ | new(date,Client,int,int,RegularReservation) | ||
+ | } | ||
+ | class Regular_Reservation { | ||
start:date | start:date | ||
end:date | end:date | ||
frequency:int | frequency:int | ||
− | new(date, | + | new(date,date,int) |
+ | } | ||
+ | Reservation -> Client | ||
+ | Reservation <|-- Regular_Reservation | ||
+ | Reservation "n" <- "1" Regular_Reservation | ||
+ | </uml> | ||
+ | class Reservation { | ||
+ | date: Date | ||
+ | duration: int | ||
+ | price: int | ||
+ | delete(): boolean | ||
} | } | ||
class Client { | class Client { | ||
name | name | ||
} | } | ||
− | |||
− | |||
</uml> | </uml> | ||
= Learning UML = | = Learning UML = | ||
{{Link|target=UML-Day}} | {{Link|target=UML-Day}} |
Revision as of 10:52, 15 December 2018
Tools
Stackoverflow Tags
Tool-Evaluations
- https://www.herzbube.ch/article/evaluation-free-uml-tools
- https://www.predictiveanalyticstoday.com/open-source-free-unified-modeling-language-uml-tools/
Stackoverflow Questions
Inheritance
When implementing inheritance there is usually some cost involved in terms of extra classes, tables, documentation and other results that need to be created after the decision to use inheritance.
Inheritance is about special and general cases. First you might want to ask what is the difference between the cases - (called a discriminator). In your case it is the type of reservation and you could avoid the inheritance by modelling this type of reservation and implementing the different behavior based on the reservation type. That would lead to a design like:
Avoiding inheritance
Applying inheritance
class Reservation { date: Date duration: int price: int delete(): boolean } class Client { name } </uml>