Project Templates - Need to be re-written I think - Discussion/Saga

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.

Hope these give ideas on industry standard project template defaults and custom settings:

This approach sounds ok.

You could try to have a notion of “dependence”, so that you had a list of “all the fields I need to calculate after I calculate this one”. But that might turn out more complex than your suggested iterative approach. I guess that for the amounts of data we’re talking about here, there’s no need to over-engineer things.

Thanks @pgr trying to make sure I start off on the right foot with the strategy to process the tasks.

This waterfall scheduling.
Would be a great bonus to add the 3 other project task scheduling types:

And to support scheduling all 4 task dependency relationships:

  1. finish to start,
  2. start to start,
  3. finish to finish,
  4. start to finish.

Thanks @chris001 I hadn’t considered other methods. I think for the scope of what my skillset is, I was going to keep it just to the creation of tasks from the task template and have it take into account proper start and end dates depending on predecessors. I will read over the other methods in detail and see if I can incorporate some of that logic in how tasks are processed from the template.