samedi 24 juillet 2021

Abstract Factory or Builder Class for similar objects with minor differences?

I have an app, where I have 10 different order types, these are huge objects of like 400 properties, with minor differences between them, at this point adding a new order type, or changing something in one of them requires huge amounts of effort.

Since I am doing a refactor coupled with a redesign shortly, I have been looking for a way to make things easier for me.

The Factory method looks very appealing, but I cannot imagine it working for me, since I have some methods that are implemented only on some or a single order type. But ideally a factory would have been the best, just calling the same functions, and not having the client worry about the order type, but i think this is not possible, since for example, for some order types I have subscriptions, for others I have simple payments, or some have different kinds of artworks attached to them, or different kinds of target audience. But they do not differ in a huge way, just some functions are not doing exactly the same thing, should I have a general way of naming functions, that generally describes the action and implement it for the particular order in that way?

I have been thinking if something like a builder class would make more sense in this context, I am not a very experienced person in this kind of design and planning.

Should I provide more context on this, or provide some examples, come up with some mock data? Or can we make and educated guess? Or an opinion, on what could make my life easier.

Aucun commentaire:

Enregistrer un commentaire