Shift Left

Note: This article was originally written for my blog in Portuguese back in 2021.

Shift Left is a practice in software development where the aim is to find defects as early in the process as possible. A study from NIST shows that the cost of finding and fixing defects increases exponentially the farther it is found in the development cycle. Therefore, the ideal scenario is to find defects as early as possible, ideally in the design phase.

As a DevOps professional, a large part of my work has been focused on code quality in our business unit, which primarily develops code for embedded systems, FPGAs, industrial automation, and industrial robot controllers. Given the nature of our products, the cost of developing high-quality code is immense, and each release cycle is exceptionally long.

To solve these problems, our team has been working to implement a Shift Left approach by following these steps:

Writing Unit Tests Concurrently with Code

Writing unit tests concurrently with the code is the most critical part of Shift Left. Developers should not wait for the next phase, testing, to see if there are any obvious bugs in the code. Instead, most testing should be done in the implementation phase through unit tests that must be run constantly. This also helps ease the test team’s workload and lets them focus on more important things than testing the basics.

Code Review

The next step is code review. Developers should create a branch, write the code (including tests), and send it for review instead of merging it directly into the trunk. Code review allows for the early detection of bugs and can prevent these issues from propagating to later stages of development, saving time and resources. Code review allows developers to learn from one another and share best practices, resulting in better code quality and more effective teamwork, again addressing them on the left. See Google’s best practices for code review.

Pre-Commit

Human beings don’t like to have their work criticized, so pre-commit hooks can reduce criticism’s human element. Using pre-commit, a bunch of tests can be pre-programmed to run in the code about to be committed. Linters, tools that check for leaking secrets, styling tools, and others can be used. Pre-commit does not allow code to be pushed if it does not pass QA on the developer’s machine. It ensures that the basics are covered before the code goes into review.

Text Editor and Plugins

The text editor/IDE that the developer uses is as far left as possible. Developers can use various plugins and tools to improve the code. For instance, Microsoft Visual Studio Code is an excellent editor with many useful plugins, including language servers, linters, and AI-based plugins like Co-pilot, Sourcery and TabNine. Sonarlint, a Sonarqube plugin, can analyze code and display issues as soon as the user saves it.

By following the steps outlined above, software development teams can significantly reduce the number of defects that make it to the testing phase. While no single solution guarantees perfect code, combining the tools and techniques discussed and a strong focus on code quality can help minimize the total project delivery cost and time. For further information on how these steps can help reduce defects and improve the overall quality of code, I strongly recommend reading Steve McConnell’s book Code Complete. Take action today to improve your software development process and achieve better outcomes for your team and business.

Troubleshooting with the OODA Loop

The OODA Loop, a decision-making technique developed by the US Air Force for combat operations, is a helpful framework for troubleshooting. By following the four phases of the OODA Loop – Observe, Orient, Decide, Act – and repeating the process if necessary, you can break down complex problems into manageable steps and make informed decisions to find a solution.

Here’s how to apply the OODA Loop to troubleshooting:

Observe: The first step is to observe the problem. Gather as much information as possible about the issue, including symptoms, errors, and messages. What else do you know about the problem? When did it start? What is the scope of the problem? What other pertinent information can you gather at this early stage? During this phase, it’s essential to focus on gathering quantity over quality. The more information you have in the beginning, the better. Leave to the decision phase on what to do with all this information.

Orient: Once you have observed the problem, the next step is to orient yourself to the expected or desired state of the system. This phase may be straightforward if you are troubleshooting something familiar. You can use your knowledge of the system to determine the normal state. However, you will need to gather information if the troubleshooting is in an unfamiliar system. The system’s end-users are often the best source of information, but documentation can also be helpful. In some cases, you may need to infer some things.

Decide: With the information gathered during the observation and orientation phases, it’s time to decide on an action plan. Keep in mind that, at this point, it is not a 100-step action plan that is sure to solve the problem. Don’t forget that we are working on a loop here. Plan something straightforward and easy to implement, just a single step to help you move further in the process. Make incremental changes, and reevaluate before moving forward.

Act: With the plan in place, it’s time to take action. Implement the plan and take the necessary steps. This could involve changing a setting, restarting a service, enabling more detailed logging in the application, or adding a breakpoint somewhere. Whatever you decided in the previous phase, do it.

Repeat: If the problem persists, enter the loop again and go through all the phases. As you observe the problem again, ask yourself if anything has changed. What is different at this moment? During the orientation phase, you need to understand the cause and effect of the problem. How did your changes during the last interaction cause the observed behaviour? Does that make sense? Have you seen similar problems? Can you infer any conclusions from what you observe? Based on your findings, decide what to do next. You may already know enough to try to implement a solution, or you may need to gather more information. Act again and return to the loop as necessary until you find a solution.

Remember, the OODA Loop is a continuous process that allows you to quickly and effectively tackle complex problems by breaking them down into manageable steps. Using this framework, you can make informed decisions based on the information you gather, act on those decisions, and continually re-evaluate until you find a solution. So, next time you’re faced with a troubleshooting challenge, try applying the OODA Loop to guide your decision-making. You can improve your problem-solving skills and become more effective at finding solutions with practice. Give it a try and see how it works for you!

Discipline

Or, more specifically, self-discipline. When you institute and follow a habit or routine as you have determined with yourself, regardless of motivation or disposition. Whether it’s hot or cold, in the mood to do it or not.

Here in my office, I have this poster right behind me, which I see every time I come to work and every time I join a video conference (for the benefit of other participants):

Discipline is freedom

At first glance, it may not seem accurate. Discipline seems almost the opposite of freedom. But let’s break it down a bit:

My alarm clock goes off at 4:15 in the morning. I don’t hit the snooze button. I don’t stay in bed enjoying another 5 minutes. When the alarm clock goes off, I immediately throw off the covers and sit on the bed—90% of the time, I don’t want to wake up. I’m not in the mood. It’s cold (I live in Canada, after all). Maybe I’m off duty and don’t have to work. But – out of sheer discipline – I get up.

That alone gives me enormous freedom. While most of the world is still sleeping, I can choose what to do with my day and get ahead of the competition.

If you have the discipline to wake up early, say 1 hour earlier than necessary, you can quickly improve your life by following the 20/20/20 principle from the book “ The 5 AM Club ”:

  1. Use the first 20 minutes for physical activities. Stretching, light jogging, or light resistance training (should not replace your primary exercise routine)
  2. Use the next 20 minutes for your education and development. Read a book, or listen to a technical podcast in your field, about self-help or another subject that will help you personally or professionally. Maybe watch a lecture or take an online course.
  3. Finally, use the last 20 minutes to meditate, reflect on the day before, write in your journal or have your daily devotional.

This isn’t particularly my routine, but it looks like a pretty decent framework.

Twenty minutes a day in a year means 121 hours. I guarantee that if you spend 121 hours a year studying, exercising and reflecting, you will be a better and more successful person, probably with more disposition and a better income.

Some perks of self-discipline I want to point out:

  1. By using discipline, you also avoid having to make decisions. And making decisions is something that generates fatigue and stress. See decision fatigue on Wikipedia.
  2. You become more productive. Less time is spent procrastinating or looking for excuses for doing or not doing something. Does your routine say that at 10 am, you answer emails? Guess what: At 10 am, you will be answering emails.
  3. Your Decisions Will Be Better: When you plan and institute a new habit or routine that you maintain via discipline, it’s usually something you’ve pondered and considered for a while. You have devised a strategy, and you have a plan. It’s not something you improvised at the last minute.

Developing discipline can seem tricky, but I think that’s because people often confuse discipline with willpower. People say I can lose weight and run marathons because I have willpower. Wrong. I have discipline.

Go back and read the first paragraph of this post again. Discipline is doing something regardless of wanting to.

I’m a fan of Jocko Willink, and on Twitter, he often answers questions as succinctly and obviously as possible.

– “How do I wake up earlier?”
– “Wake up earlier.”

– “How do I go to the gym every day?”
– “Go to the gym every day.”

One of the best ways to develop discipline is to use systems instead of setting goals.

The idea of ​​systems vs goals suggests that you should focus on developing systems and habits that lead to your desired results rather than just focusing on the results themselves. That way, you can reach your goals more sustainably and efficiently while building the discipline and skills necessary for long-term success.

If your goal is to lose 10 kg, this cannot seem easy. But adopting a system that states that you only have two meals a day and no more soda is easy to follow through discipline.

I highly recommend James Clear’s Atomic Habits book.

Finally, be persistent and have perseverance. You will succeed by creating good habits and staying disciplined even when things get tough.

In summary, self-discipline is a valuable skill that can transform a person’s life in many ways. By instituting and following established habits and routines, regardless of motivation or disposition, you can be more productive, make better decisions, and achieve goals more efficiently. When developing self-discipline, it’s essential to focus on systems rather than goals, be persistent and persevering, and look for additional resources to help with the process. Start practicing self-discipline today and experience all the benefits it can bring to your life.