carlossierra
carlossierra

Reputation: 4717

Uncoupling Classes in Java in Very Coupled Business Logic

I am writing a simulator as a first ambitious project to start learning Java and Object Oriented Analysis and Design (OOA&D). The simulator will compare different methods to manage inventories in supply chains (if more detail is required from the business part, please let me know).

I am having a hard time getting a decoupled design for my classes. Although the full version of the simulator has more classes, the classes that I'm having trouble with are:

So my question is: is this really as good a decoupling I can get given the business logic coupling I'm facing? Can I apply any other strategies (which ones?) to help me design a more robust and flexible simulator?

Upvotes: 1

Views: 182

Answers (1)

Tim B
Tim B

Reputation: 41208

Each entry in the ProductData map should probably be a member of a ProductDataEntry class (unless the data they contain varies wildly).

It sounds like RawResults might then be able to extend ProductDataEntry since it will have the same fields.

Overall your design sounds ok - there's no way to say more without looking at the actual objects and overall architecture though and this isn't the place for that (and I don't have the time).

To be honest at this stage in your programming career (and even later) you shouldn't be afraid to try things and throw them away if they don't work. Instead of spending 3 days trying to decide what to do spend 1 day on each of 3 prototypes trying a different method and then at the end look at what you learnt and what you liked and did not like from the prototypes.

Note that while uncoupling as much as possible is a good aim to have sometimes the nature of a problem is such that things are tightly coupled. Don't bend the whole architecture out of shape to fight it when that happens - just make sure that they really do need to be coupled as tightly as they are.

Upvotes: 4

Related Questions