In terms of good OOP design, what is the best way to structure the code described below.
I have a set of commands. Each command has an identifier, deadline, and a set of jobs to be done. Each job has an identifier, a processing_time, a set of successors and we must precise the command to which it belongs. A successor of a job is necessarily a job that belongs to the same command. Visually, each command has its graph of jobs.
What needs to be done?
I need to construct big graph out of all the graphs by adding two dummy nodes. One node is directed to all the jobs from all the commands that has no predecessors. On the other hand, all the jobs of all the commands that has no successors will be directed to the other dummy node. Here is a figure to make things clear (a project is a command). The start and end are the two dummy nodes I am talking about. Note that those dummy nodes don't belong to any command.
From now on, I will only manipulate the big graph (doing graph traversal algorithms etc).
My attempt 1
- A class Command that has the attributes id, deadline, jobs (dictionary whose keys are jobs ids and whose values are objects of type Job)
- A class Job that has the attributes id, processing-time, successors, command(object of type Command)
- A class Problem where I put parsed data. It has an attribute commands (a dictionary whose keys are the ids of commands and whose values are objects of type Command )
Doing this, I will need later to merge all the tasks of all the jobs in a a new variable. I don't want to do it this way, I want the architecture to take into account the fact that i will only be manipulating jobs and not jobs grouped by commands (as in my commands attribute in the class Problem). How to do it in that way?
I am thinking about removing the jobs attribute from the class Command. Indeed, from a command point of view I don't need to know which jobs belongs to me.
PS: I am using Python.