I laugh now, especially considering where my career and the world has gone.
We have seen an explosion in technical advancements with the number of unique mobile internet users standing at 4.32 billion (Source: 2021), indicating that over 90 percent of the global internet population use a mobile device to go online.
We have also seen a revolution in the way we design, build and deliver these web and mobile applications that impact our daily lives. Practitioners like me have learnt from our mistakes and learnt from others who continue to build and share best practices.
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?
In this article, I will introduce you to four best practices in software development that will help you - just as they’ve helped me - to maintain a high calibre 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.
- Unit Test
- Integration Test
- Operational Test
- Positive-Negative Test
- Regression Test
- Black Box Test
- White Box Test
- Functional Test
- Interface Test
- Performance Test
- Load Test
- Volume Test
- Stress Test
- Configuration Test
- Compatibility Test
- Installation/Uninstallation Test
- Security Test
3/ Refactoring the code
The process of code refactoring consists of making (often small) changes to the software, while maintaining the same external behaviour, 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.
Hugh Simpson is the CEO of Liquid Technology and has over 20 years experience in delivering outcomes for clients and over 10 years in designing, building and delivering technology solutions.
Image: Fotis Fotopoulos on Unsplash