samedi 17 octobre 2015

Object Oriented Design Issues

I'm currently trying to design a program in java using some good practices ie separation of concerns. The part I'm having trouble with is to separate everything into different classes whilst keeping low coupling. I'm not looking for entire answers but tips on how to get around it.

I have 3 different types of data and I need to be able to add and remove them. They are:

  • Workplace - contains name and a set of employees and a set of job descriptions
  • Job descriptions - Has a piece of text as the job description and is related to a work place.
  • Employees - each has a name and is related to a work place

The add,remove and view methods for job descriptions and employees are pretty much the same apart from a few words. So I thought of using the strategy pattern for that.

Now the easy way is to create a workplace class and a workplace manager where the manager would contain a list of workplaces and all the add,remove and view methods for the data however this results in a large class that does more than it should. I thought of another way to have a job description and employee manager however that would require passing a workplace list to each of their methods to ensure it stays updated and that results in high coupling. Should add that I'm using MVC and observers to connect the UI.

What would be some other options? Admittedly design is one of my weak parts in programming so I'm trying to get better at it.

Aucun commentaire:

Enregistrer un commentaire