So I’m really delving into the code on Project Task creation from Project Templates. The logic is really simple. (I think based on what I’ve found so far)
Basically, it starts with the first task, makes the start date equal to the project start date if it is the first task, for subsequent tasks it keeps track of the end date of the previous task processed and makes that date + 1 day (or 1 business day) the start date of the next task, then loops through until all tasks are processed.
While this works, and is simple, it doesn’t address “start to start” tasks, where a task can start where it’s direct predecessor starts.
You might think this is simple, just modify the the loop and check for the “relationship type” (which is start to start or finish to start) and then use either the start date of the previous task as the start date or the finish date of the previous task depending on the type of the current task. Sounds straightforward right?
Well not so fast, you don’t know in the loop if the predecessor to the current task has been processed yet and has been assigned a start and end date, you only know start and end dates of tasks already processed.
This is a real software engineering problem! (and I’m just learning).
I’m thinking there are a couple of approaches to handle this, I guess you could assume the project tasks in the template are in order, but that’s a whole other can of worms, when you sort the tasks in the project template it doesn’t re-reorder them by ID, which I assume is how they would get called in order in the loop.
The other approach I think would be to process all the tasks in an array first, and sort them for an initial sort based on tasks that don’ t have predecessors, then you can calculate the start and finish of those, then move on to calculate the start and finish of tasks that are now able to start based on the tasks that have been processed so far. Then you just keep looping through until there are no more tasks.
Does that logic make sense? This looks like a fun project to dive into for the next few months, I’m going to be doing the grunt work of trying to figure it out, but if any more senior devs want to jump in and coach me in the right direction, it would be greatly appreciated.
If anyone has previously delved into this area would be great to hear from you.
Still trying to get my head around it and figure out the best plan to tackle the problem.
End result = much better project management module for everyone.