Introduction
As a software engineer, I often need to work on an existing solution that was developed previously. And I always notice the difference between a well done Job where all details are considered and the botched work where the focus were only on that specific instant without taking into consideration the evolutions in the future.
So I'm writing this article to talk about the elements that make a solution clean and that make the ramp up of a new ressource easy.
In fact, having a clean solution is not only the responsibility of the developer. Yes the developer is a key role in that goal, but all the team should have that in mind: The validator, the integrator, the devops; the team leader ... all of them are responsible for the stability of the system. Here in this article, every section will focus on a concept that can be made by one or several roles in the team
Please feel free to suggest other points in the comments if you consider that they are important in the quality of the deliverable.
Developers should respect patterns
One mistake that several developers make, is that when they have a requirement, they directly jump into the IDE and start coding. The most part of the job of the developer is thinking, then comes coding to translate your idea into a code. Certainly, you need to think about how your deliverable will be compliant with the requirement. But also you need to ensure that you will deliver a clean and maintainable source code.
It should not only work, but it should also work and repsect the best practices. Always tell to yourself that someone else may work on your code, and you need to help him by providing a self documented and clean code.
You may also work on it again after several months or even years later, and here you will help yourself in the future and avoid blaming your memory for forgetting things. Even if you implement workarounds for any reason, comment them clearly and mention the reason for their existence.
Having a well structured and organized solution relies on several points, some of which are the following (if you have other points in mind, feel free to put them in comment).
Modularity and Reusability
Separation of concerns is one of the most important concept in programming. In fact, it means that you need to organize the components of your solution in a way that one module is responsible on one activity. For example, you need to put your logger in a separate module, your access to the database in a separate layer, etc. And it's also valid for classes, one class should have only one and single responsibility.
This separation will give your solution a certain level of modularity and it will allow you to have good visibility of your solution. You will be able also to reuse your module when needed and you won't have a duplication of code.
Extensibility
Your solution should be extensible, it means that later on time if another person wants to add features, he needs to do it without impacting the existing ones. At the level of the class, you should ensure that your class is open for extension (inheritance or implementation) and closed for updates.
For more details about the previous concepts, please refer to SOLID which is an acronym that refers to five development principles. I just tried to explain some of them in my words without going deeper as this article gives the main lines.
Logging and exception management
Generally, when I work on an existing solution, I try to run it from a functional point of view. This generally helps a better understanding of the requirement.
In an application when an exception occurs or if I don't find log files to find the traces, I will know that I will have some tasks other than building new features: which is the stabilization of the application. So while developing ensure that you have handled all the possible exceptions (even the native one when possible) and also ensure that you have a logger in a separate module.
As the logs contains a huge amount of data, they should be configurable to ensure that the information is accessible and easy to read.
Some of the elements to configure are the following: The level of logging (debug, info, error ...), the log rotation, the file's sizes, the log retention ...
Unit Tests are important
Let's be honest, most of the developers think that the unit tests are annoying and a waste of time because they need to recall the methods that they already called and used in the application. Unit tests might not be the funniest part of the development but they are very important.
The unit tests allow you to have a very good visibility on the stability of your code, they don't only help you to find the issues in your code before providing the solution to the QA team, but they also help you to see if you have some anti-patterns in your code. The more your coverage percentage increases, the more your code is stable. For C#, there are several tools that help you to have nice reports like Open Cover with ReportGenerator. To be able to test the methods or the constructors where you use abstract classes or interfaces you can Mock them using Moq or any other mocking library.

Join the conversation! Your thoughts help the community grow.