DEV Community

miniscruff
miniscruff

Posted on

How I Split Work: Review, Cleanup, and Order

As with any design you should always get your ideas reviewed by at least one other person. They will help catch things you missed or have incorrect. For this example, I will illustrate this point by mentioning we need to check if there are any available seats before selling a ticket.

Cleanup

Now that we have our review complete, lets clean up this flow chart. This may or may not be necessary depending on how clean it was the first time.

I did not do such a great job the first time so I redid the flow chart, a quick sketch by hand is more than enough so do not think you need to spend an hour or anything on this.

Also, I just pick random shapes for things while trying to be consistent. If you know UML and like it, feel free to use that.

Cleaned up flow chart for movie theater problem

Order

Great we have a full flow chart from start to finish of what our product should do. Now what? Finding a reasonable order to work on the items in. The goal here is to do as little work, measured in time not count so big complicated stuff last, as possible in order to get our program to run with a result. The trick here is that we are ok with that result being incorrect as long as it completes.

An example is skipping out on the sales tax, sure our program won't yield the correct expected results, but it ran and completed with something. We can manually calculate what it should be for now. Or we can just have a failing test, personal preference here.

After we have our program running, we then want to fix any accuracy errors it may have.

Then to round it off, handle all the possible edge cases we know of.

Also, there will be many good answers to how you order things. So if what you came up with is different, that is probably fine. I will explain why I put things in the order I did as well.

Clean flow with numbers representing the order

  1. We start with finding the price of a ticket, however, it does not need to be accurate yet. We can simply return any number here as long as it's done in some sort of function or class. We will want to modify this later on without affecting other pieces.
  2. Once we have a price, we can calculate the total.
  3. The first step of that is summing up all our tickets. We can make an array of our thing from before to sum it all up.
  4. We can then calculate the change based on this total and our input cash amount. It will be incorrect with missing sales tax but that's fine for now.
  5. After all that, we can now complete the flow and run our program from start to finish.
  6. Now that we have it running we can fix the issue with our accuracy which comes from missing our sales tax. So let's do that next.
  7. We have this working for a single ticket, lets now run this over a list of tickets.
  8. Next, let's fix up our price math to return the real value of our tickets in all cases.
  9. Finally, we end our feature set with calculating our discounts.
  10. End our work by checking for all our edge cases making sure if anything goes wrong we abort with no tickets created.

That is it, you can now start programming. With step by step tasks like this TDD is a great candidate to follow.

Thank you for reading.

Top comments (0)