I'm try to think how I can understand this UML diagram and check how I can represent it to code:
What is make me confuse, we have an association relation between Company and Employee interface, and Designer classe is implement the Employee interface, but how we can connect Company with Employee interface?
What I understand (PHP for Example):
class Company {
...
}
class GameDevCompany extends Company {
...
}
class Designer extends GameDevCompany implements Employee {
...
}
If I think about this diagram like this code, its a truth way or I missing something or make something wrong?
Thanks
We have three concepts in this diagram:
Company
has two specializations which are GameDev Company
and Outsourcing Company
Designer
(or Programmer
, Artist
, Tester
, ...)Company
is associated with Employee
. The diagram does not say anything about multiplicity. But since this is a very simple model, and based on our knowledge, we could guess that a Company may be associated with no, one, or several Employee
.In PHP terminology, specialization is inheritance, which is expressed with the extend
keyword:
class Company {
...
}
class GameDevCompany extends Company {
...
}
In PHP terminology interfaces are implemented rather than realized and this is expressed with keyword implements
interface Employee {
...
}
class Designer implements Employee {
...
}
The association from one Company
with potentially several Employee
requires that Company
has some kind of iterable container such as an array that holds references to the Employee
objects. My PHP is very rusty, but I understand that objects in an array are always references which is exactly what is needed for ordinary associations.