Trying to avoid a ‘God Class’, how do I break this up?

I'm trying to avoid building a 'God Class' and could really use some helping designing my class architecture.

I've got an API to our manufacturing database that I'll be using–so no direct ODBC stuff.

I need to be able to track these assembly lines, the employees logged into them, and the jobs that are in them. I'm trying to avoid doing something like:

class SpiderLine { List<string> Jobs; List<string> Employees; public bool AddJob(string Job); public bool RemoveJob(string Job); public List<string> GetJobs(); public bool AddEmployee(string Employee); public bool RemoveEmployee(string Employee); public List<string> GetEmployees(); } 

Each SpiderLine will have it's own subset of unique jobs and employees. I thought about nesting a Job and Employee class to break it up a little, but then it gets a little complex because when you add an Employee, the spiderline needs access to the list of Jobs to add that employee to each Job. When you add a Job, the spiderline needs to access each employee.

If I just keep things the way they appear above, that SpiderLine class becomes huge, since with each function it's a lot more than just adding a string to a list–I need to validate with the DB, process labor transactions, etc etc. SpiderLine would absolutely become an unwieldy God Class.

It would be great if in the end I could just create a SpiderLine and go

MySpiderLine.Jobs.Add(1234); MySpiderLine.Employees.Remove("Joe"); 



by fievelm via /r/csharp

Leave a Reply