Go Base

Efficiently Develop and Manage your Golang Codebase

I see Software Engineering as an art. It's all about developing applications using principles and methods that ensure we have a high-quality software solution that meets a particular requirement. Now Client's requirements can be different and principles can also be different it all depends on the situation and the organization.

When writing code, I tend to follow a few steps which I'll list below.

  1. Make sure the code works(correctness). Here all I am concerned about is that this particular API works, I give it data and it spits out the correct result for me

  2. Make sure my data is secure (data integrity). Golang can be an object-oriented or data-oriented language. I use it as a data-oriented language in this context because it offers simplicity and efficiency in dealing with data. Also, the semantics around data sharing (value and pointer semantics) make it easy to process data, maintain integrity and ensure correctness, especially in a world where data is the foundation of many modern-day and important technologies.

  3. Refactor for better readability. Now that my data is secure the next thing is to ensure readability, software engineering is all about trade-offs and you can always trade in a little bit of efficiency for readability. Readability makes it easier to work as a team and makes it easier to debug and even predict what the code would do. It also makes onboarding easier for new engineers, Readability is something we don't think we need, but we need it. When we are writing code we shouldn't consider ourselves alone; pity the next engineer coming in please :). It's perfectly okay to repeat a few lines than to simplify into a new function that makes the whole thing more complicated now

  4. Optimization: Now we can look at optimization and how to make our codebase faster

"Make it correct, make it clear, make it concise, make it fast. In that order." Wes Dyer

A good codebase is governed by rules, rules make it easier to maintain consistency, this kind of rules can vary from how to contribute to the project to code styling, declaring variables, and defining errors. some even would require you to leave a new line under every file. These are all personal preferences based on your superiors or organization.

Apart from these preferences, I think what makes a codebase well-maintained is

  1. Readability

  2. Maintainability

  3. Testability

  4. Reliability

  5. Security

This takes me back to my first sentence, Software engineering is art, there are different ways to draw a car, the same way there are different ways to design applications. A good car will have four tires, a steering wheel and all of that, same way a good codebase would have all of the features above.

It is also important to note that we can't have the perfect code base, so we need to keep on going through these phases that Wes Dyer has said

Remember "Code is like humor. When you have to explain it, it’s bad." - Cory House