I am having two classes - Project and Order.
Project
is a work project.
Order
is an order from a customer of the project.
Orders are stored as files inside each projects' directory structure in a subdirectory that indicates the status of contained order e.g. /project/orders/status/order.json
.
I have two related design pattern dilemas.
- When retrieving all orders for a given project. Should I
project.getAllOrders()
orOrder.getAll(project)
; - Same goes for similar operations like changing the status.
project.changeOrderStatus(order, status)
ororder.changeStatus(status)
In "project centric" cases, it makes sense to me, since project probably should be aware of its orders and since the directry structure belongs to the project, it should be the on who manipulates status.
In "order centric" cases the retrieval kind of resembles pattern of REST API, which also makes more sense to me, but changing the status of the order requires the order
object to know the path to the project directory, which requires either Project
instance in each order, which seems quite wasteful or additional parameter to order.changeStatus
which seems to me more like a hack.
I am aware, that the second dilema could be solved by for example using a database, but I would like to keep the directory structure.
Aucun commentaire:
Enregistrer un commentaire