Hi! I’m
José Luis
C# .NET Azure
Software Architect
Artificial Inteligence
Best Practices? Why do I need them?
Your code works, but it’s becoming increasingly difficult to modify and expand. Each new feature requires many changes, more time, and more developers. Does this sound familiar?
Good programming practices are simple guidelines that allow you to create programs that are easy to modify and expand. Your bosses and clients will be happier, reducing costs and increasing profits. Would you like to?
TDD: Test Driven Programming
First, turn your main use cases into automated tests, which will be run every time you need to change your code or release a new version to production.
The tests will tell you what code you need to write, just enough to pass the test. It will also allow you to refactor your code, knowing you are not breaking anything that already worked.
Tests will cover your most important code, greatly reducing the number of errors in your program. Spending time doing tests saves a huge amount of your time fixing bugs.
Nowadays, it is essential that all software is automatically tested every time it is compiled and deployed:
- Unit Tests ✅
- Integration Tests ✅
- Acceptance Tests ✅
- Functional Tests ✅
- Performance Tests ✅
- End-to-End Tests (GUI) ✅
- Regression Tests ✅
- Load Tests ✅
- Security Tests ✅
Clean Architecture
Use a clean architecture to organize your code. This puts your business logic at the center, so you can reuse it from anywhere, whether it is a website or a mobile app.
Components in each circle can use components in their inner circles, but never the other way around. Define interfaces to inject whatever you need into the inner circles from the outside.
This not only makes testing much easier, but it will also allow you to change databases, logging systems, or user interfaces on the fly, even at runtime.
Another way to make components independent so you can manage them separately is to have the domain launch events managed by the outer circles.
Coupling will be minimal and each team of developers will be able to develop their components independently.
DDD: Domain Driven Design
Having well-organized code will allow you to modify business rules quickly and cleanly, as well as making it easier to create and maintain tests.
Dividing your domain into differente bounded contexts is essential to be able to make developments independent. A Client entity is not the same for the Marketing department as it is for the Billing department.
Do you have to do DDD in all your developments? Of course not, only when the domain is complex, especially if it is the main part of your business. For the rest, you can use other simpler architectures.
Refactoring
and Clean Code
You will write your code once, but you will read it hundreds of times. Even if your program works, it does not mean you are done. You need to review and rewrite it to make it easy to read, easy to modify, and, above all, avoid duplication.
Do not be afraid to make changes. Remember that tests will cover all the code: if you break something, they will notify you immediately.
Establishing a style guide, using descriptive names according to the domain’s terminology, or keeping your classes and methods relatively small are some of the keys to sustainable development.
Artificial Intelligence and Machine Learning
There are problems for which there is no direct solution. In these cases, you must use algorithms based on successive approximations that gradually reduce the error committed.
We call this process machine learning, and the set of these types of algorithms is called artificial intelligence.
Since 2015, I have had the YouTube channel «Discovering Artificial Intelligence» (in Spanish), where I have published more than 200 videos with machine learning algorithms and theories on artificial intelligence in general.