Skip to main content

Five tips to become a better coder

(Image credit: Image Credit: Christina Morillo / Pexels)

Today, every company is a software company. Enterprises across industries are under pressure to deliver flawless digital experiences to customers faster than their competitors, and they rely on DevOps to make this happen. But the skills DevOps engineers provide are hard to find and easy to lose: according to LinkedIn, there are only 25,000 DevOps engineers employed in the United States and nearly 33,000 open positions.

In an industry that’s growing and changing rapidly, the opportunities within technology are fantastic; we get to solve difficult problems, build great teams and communities, share knowledge, and experience personal growth. DevOps culture and practices encourage this growth across organisations and teams. I highly recommend becoming the type of engineer that accelerates software delivery excellence and software code quality. No matter what you learn, coding is at the heart of the software services and products we ship. So don’t sweat it  - just keep on coding and read on to get my five tips for becoming a better coder.

1. Understanding the source code.

If you’re looking to extend and enhance your applications effectively, take care to understand the codebase. Think of the entry points of the application. What parts of the app are always called? What are the control flows for service requests? How did the application come to be, and what decisions were made to get to its current state? If you are a newer developer on the team, this is a great way to quickly become effective, as you’re able to navigate the application and resolve fixes.

Here are a few more tips to understanding codebases:

  • Read existing documentation and commit messages to gain context to a source code’s history. What tools and approaches were considered in the decision-making process? What were the outcomes of the research? Encourage and seek out discussions with other members of your team.
  • Pair programming is a great way to build comrade across the team while sharing peer-feedback. Two pairs of eyes are better than one when it comes to reviewing code. And this is also a great way to build domain expertise across the team. There are dozens of resources that document the benefits of pair programming.

Having an in-depth understanding of the app helps you scale your team. Quickly create new modules to interface with the application. And feel comfortable working with existing modules of your application.

2. Creating readability of source code.

If your team does not already have one, I recommend defining a programming style guide. A guide helps maintain consistency through the codebase. Define rules around anything, such as indent styles, comments, and naming conventions. If you’d like some inspiration on style guides see Google’s Style Guides. It’s also possible to enforce these styles into your build or approval processes.

Aside from the readability of the code itself, pay attention to the code’s control flow. Nested bubbles of logic are hard to comprehend. The best way to avoid this is to reiterate that conditionals serve as gates (known as guard clauses). Instead of taking the happy path through the code, use conditions to check for failure and ensure that the code fails on said conditions.

As an individual contributor, if it’s code you’re working on, leave it better than how you found it. Practice the Don’t Repeat Yourself –DRY– methodology by avoiding duplicate code when you can create helper functions/files. These basics make a huge difference in the readability of source code!

3. Consider symptoms of code complexity.

Code complexity is “the degree to which a system or component has a design or implementation that is difficult to understand and verify.” Tools like SonarQube offer complexity grading and metrics. Poor performance in these areas can cause a variety of symptoms. One symptom of complexity is the time it takes to implement feature fixes or additions. Consider that code that is hard to evolve may be complex in nature.

To minimise code complexity:

  • Break apart your code. Separate code that is likely to change or contains domain logic. It’ll be easier to spot needs for performance optimisations, in consideration of memory space and execution time.
  • Note error handling and recovery. Consider best practices when handling exceptions (here is one on Java). Errors should also bubble up to the outer layers of your codebase.

Code complexity keeps in mind three indicators: readability, understandability, and modifiability of code. Learn to recognise and reconcile code complexity based on symptoms of complexity.

4. Navigate the dependencies.

Tightly coupled code is hard to fix. One change could result in a ripple effect of more changes. Testing also becomes harder because your unit tests will grow in complexity and size.

If you have trouble with this, consider using dependency injection and mocking out stable application components to enable the right amount of flexibility in your codebase. Dependency injection is the practice of creating a component that is dependent on another component. There are levels to the dependency injection that can occur at the function or constructor level. Code dependencies can also be managed with dependencies frameworks that will auto-generate code.

Poor code designs lead to changes that cause ripple effects that span different components. Manage your dependencies to avoid this and enable your testing suite. Remember that you can go too far with dependency injection, you shouldn’t end maintaining and writing unit tests that require the mocking of more than 2 or 3 services just to test a component.

5. Love your Craft. 

Don’t forget to love what you do! This sentiment is too underrated. Your work will naturally improve and set you apart with time and dedication. I enjoy this quote from Dave Xiang: “Code is meant to be shared and loved. It’s not just your code-it’s everyone’s code.” Code on.

Software delivery is a top priority for organisations that own software, yet it remains one of the most challenging problems enterprises face today. Enterprises are keen on tighter execution models for delivery and using DevOps practices to get there. DevOps begins with people, process, and technology. And these were five tips on maintaining and delivering better code with your team. I hope these tips help you gain the insight and experience you need to keep delivering better!

Tiffany Jachja, Evangelist, Harness

Tiffany Jachja is an Evangelist at Harness. Before joining Harness, Tiffany was a consultant with Red Hat's App Dev consulting practice, where she helped customers build their software applications living in the cloud. In her spare time, she likes to go on walks with her cat Rico and blog about self-development.