We are currently witnessing an exponential advance in technology. Many people reckon that we are not only tech fans, but rather, we are fully immersed in this tech world that “never sleeps”. As a result, our lives have been transformed by constant tech advancements, especially in the area of software development.
For example, grab your cell phone now and see how many apps you have: how many apps could you live without? This is one of the "superpowers" of Software Engineering; and the trend is that the use of software in our daily lives will only continue to increase. Therefore, those who develop software have a great responsibility to build software that is not only functional, but also high quality.
The idea of quality control – however relative, and based on individual perspective – influences the development of strong, long-lasting apps (especially given the constant evolution in technology), with better cost-benefit ROI, and added value to consumers.
Thus, the need to apply best practices in your software development is self-evident, since this is what will drive the most benefits to your app, such as: durability, agility, and even spare resources. These practices help maintain the quality of your software. Above all, I think that Software Engineering, despite its peculiarities, is similar in many aspects to other areas.
For example, in gastronomy, "chefs" do not start their careers knowing best practices - for example, knowing that food should never be defrosted out in the open; instead, frozen foods should be defrosted inside the fridge.
My intention with this example is not for you to learn best practices in the kitchen (but you did, didn’t you?) – but to show you that best practices in any area isn’t something you can obtain overnight. Mastering concepts and applying them in everyday life takes a lot of effort, patience, and above all, learning.
All this to shed light on the simple fact that as human beings, we are mostly used to "bad practices" (vs. their “good” counterpart), since we tend to lean more heavily on actions that could bring us a faster, and easier result. These so-called "best practices,” on the other hand, sometimes do not bring us immediate results - often, the extra dedication is worth the effort.
Best practices aren’t a "silver bullet" for software development; because if it were, we wouldn't have new problems and new practices coming up all the time on a daily basis, right? But let’s pause for a second. We do have existing "mandatory" practices in software development, so to speak.
In this article, I will introduce you to 4 best practices in software development that will help you - just as they’ve helped me and the software development community - to maintain a high caliber for your app quality, and solve common challenges.
#1. Clean Code
Clean Code is a set of best practices in writing software, where you apply a series of techniques that help in writing and reading code, thus making your code more readable and easier to maintain. The first version of Clean Code techniques appeared in August 2008 in the book Clean Code: A Handbook of Agile Software Craftsmanship, written by Robert Cecil Martin, better known as Uncle Bob.
In 2008, Uncle Bob already had a little over 38 years of experience in development, when he observed that the main obstacle in software development was related to software maintenance; he based this on the premise that software is never completely finished, since over time changes will occur – such as updates and new features – which require the code to become (or be) increasingly "clean".
Applying the principles of clean code in your day-to-day will help your web app development become simpler and easier to maintain, saving you time, effort, and money. Cost especially would be expensive, if your software did not have any of these characteristics.
Techniques that are part of clean code include:
- Scout Rule: One of the main rules of “Scout Law” is to always leave the place you've been cleaner than you found it – and this is a philosophy you should carry into your code. Create better code than what you were given. If you and the members of your team incorporate this rule as a "lifestyle," your app will only get better and better as time goes by.
- KISS: Keep It Stupid Simple: Keeping things simple is essential. As we gain more experience in life, we tend to overcomplicate things - it’s the old adage of killing an ant with a sledgehammer - when we could find a much simpler solution.
- Dealing with errors: It is important that you know how to handle the exceptions - the obstacles that can appear, such as the infamous "errors" - that can (and will) occur within your app, thereby ensuring that the software does what it needs to do.
- Nomenclature: the nomenclature that you use within your code is essential for a good understanding of coding, whether it’s classes, attributes, functions, files, etc. Always remember: nomenclature in software development must always be clear and objective.
Software testing is fundamental to ensure the quality control of your software. Testing is a process that aims to validate the software in different scenarios, and verify that it’s “behaving” according to plan. Testing needs to ensure that all the intended requirements are being met, not only focusing on the most successful path, but also on paths that include possible exceptions to the rule.
With testing, it is possible to maintain logs containing known bugs, bug reports, possible improvements and metrics, thus ensuring that the requirements are being met.
Some advantages of testing:
- Ensures that all necessary requirements are being met
- Builds trust within the teams involved, and with the user
- Guarantees project delivery
- Supports system maintenance
- Uncovers bugs and errors before customers do
There are an endless number of tests and ways to run them. Their execution will vary based on the type of validation that you intend to use for your project.
Black Box Test
White Box Test
#3. Refactoring the code
The process of code refactoring consists of making (often small) changes to the software, while maintaining the same external behavior, but improving the design and internal structure – i.e. changing the "how" and not the "what". An important characteristic of refactoring is that it should not add, nor remove, functionality.
Refactoring allows the software to become resilient (and adapt to new changes that arise over time), thus enabling the project code to move side-by-side with the evolution of the product.
Refactoring a project brings benefits such as: more readable software, code resilient to new changes over time, easy to execute testing, easy to find and fix bugs, avoid duplicate code, and avoid even excessive comments in the project.
The benefits that refactoring provides are great; however, there is a lot of questioning within businesses. Things like: "we have new features to develop, when will we refactor?"; the fact is that refactoring requires time (and money). But it is worth pointing out here that it’s never a waste of time, since refactoring will help you save time once your code has good maintainability.
Not completing necessary refactoring today, may lead to a problem in the future, and its correction may be more costly. So don't put it off until tomorrow – start thinking about it right now.
#4. Code Review
Code review is the practice of performing constant revisions to a given software code. Usually this process occurs when there is a new commit (change in the software).
With each alteration made to the app’s code, it is important to review the new changes, with the goal of understanding what has changed and identifying possible problems. In addition, code review is an excellent tool for finding errors that were not caught in the testing phase.
This process is performed by another developer, different from the one who originally wrote the new code. The average time for a code review is usually between 15 and 30 minutes, but it can vary according to the size and complexity of the change.
After receiving feedback, it is important to focus on the positive points, address the negative points presented, and offer suggestions for resolving the points raised. An important aspect is to understand that the code review does not have a personal criticism purpose, but rather the goal of performing a collective quality work.
Tips for making a great code review:
- Use checklists
- Watch out for new threats
- Combine automation with manual work
- Set aside some "quiet" time to review
- Be collaborative
- Provide clear feedback
Through code review, flaws and bugs are corrected in advance. This way, the software will reach the production phase and the end user without inconsistencies. Code review also offers benefits like: identifying possible improvements, knowledge sharing between teams, different solutions for a given problem, and better team collaboration.
In this article I have presented 4 programming best practices that improve software quality. It is worth mentioning that there are many other guidelines used within the industry, such as Clean Architecture, the SOLID principles (commonly used in the OO paradigm), code reuse, pattern documentation, Design Patterns and others.
Using programming best practices in your day to day will benefit everyone, from the company where you work, to the development team, and to the final user. Good software is not simply one that works, but one that does not generate excessive costs to maintain itself after it’s released.
Hiring Senior Software Developers