A
A
Alksar2015-04-23 19:11:53
OOP
Alksar, 2015-04-23 19:11:53

Class design, inheritance, aggregation, what to choose?

c# language. It is necessary to implement the architecture of classes for orders, in short, then:
There are several types of orders, for all of them there is common data and behavior, which means we make an abstract class Order (Order) that implements this.
Further there are two classifications for the development of orders:
1) Orders are divided into:
a) Orders with one executor . (Contain an Employee object that completes the order in full);
b) Orders with several performers . (They contain the Employee-->Task list, where Task is the part of the order that the executor performs).
2) Orders are divided by type:
a) Translation order.
b) Order for interpretation.
c) Order for reading the course.
At the same time, Orders for translation and interpretation have a common logic, and therefore it is logical to assume that they should have a common ancestor, for example, the abstract "Order for translation".
But here's the thing:
A translation order has many executors.
Order for interpretation and course reading - one performer.
This means that if you enter the parents "Order with one executor" and "Order with several executors", then you will not be able to have a common ancestor for translations.
How to act in such a situation?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Makarov, 2015-04-24
@Alksar

I support asdz. In theory, the behavior of classes for N executors should not differ, given N (even if N = 1).
If the relationship "I am an order with one/many performer(s)" is very important, you can specify that the order for reading the course and for interpreting implements the IHaveOnePerformer interface, and the order for translation implements the IHaveSeveralPerformer interface.

A
asdz, 2015-04-23
@asdz

An order with one executor is a special case of an order with several executors. Maybe just add a property to the order class that returns the order type depending on the number of performers?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question