Can somebody help me with this problem, I dont know why there is an addCustomer() function in the Customer class.
How can a new Customer object be created in a Customer object? The example is as follows:
-------------------
Class Customer
-------------------
+forename
+lastname
-------------------
+createCustomer()
-------------------
I mean where is the new Customer obejct stored when there are only those 2 attributes ?
EDIT: updated following comment from Alexander Pavlov below (thanks).
Most likely it’s a factory method. So it’s a class-based operation rather than instance-based. Just like in java/c#/etc where class-based ops (e.g. constructor/factory) and instance-based operations are both declared in the class signature.
As with java etc. the
createCustomer()operation would not be called on an instance. e.g. (pseudocode)There used to be a convention in UML that class-based ops start with the ‘$’ symbol to differentiate them from instance-based ops. However, iirc, it was just a convention, not mandated in the UML spec. (don’t have easy access to the spec just now to check).
hth.