Often during development you may find you don’t fully understand something or don’t know why something is working a particular way and start getting side-tracked from what you are actually meant to be doing.

You could stop and delve in and find the answer, which could take a short time or a long time. However, nine times out of ten in this situation I find that I will naturally stumble upon the answer later on, when working on something completely unrelated.

Therefore in these situations it can be a good idea to add a #todo comment in your code and carry on. Something along the lines of:

/*
 * #todo look into why {description of thing you don't understand}
 */ 

The advantage of this approach is the comment would be picked up on a code-review by a peer should you not have figured this out yet, which would give an opportunity to go through it.

If you’d rather not add comments like this to code that may end up on Production, you can keep a notepad of similar Questions to your future self. You might even find that when you come to add a new entry you know the answer to some of the older ones.

When you have the time available, periodically review either your #todo entries or your notepad and remind yourself of the areas you need to look further into.

The trick is, don’t spend hours looking into a tangent right now, as there’s a good chance you’ll stumble across the answer naturally later.

Photo by Glenn Carstens-Peters on Unsplash.

Published by Joseph McDermott

A certified Magento solution specialist with eleven years experience leading ecommerce development projects, converting complex problems into elegant technical solutions.

Leave a comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.