Keep it simple
Although DiVine helps you a lot in keeping your code clean, DiVine cannot guarantee that your code will always be simple.
The key of writing code with DiVine, is to keep your stuff simple.
A service itself should not be responsible of doing too much functions, as it would make testing and readability a lot harder.
Avoid circular dependencies as much as possible. Circular dependencies make it harder for one to understand the structure of your code, as services keep referring to each other. This also complicates your code.
Use interfaces for your services when reasonable. Interface services are the easiest to mock for testing, and they also improve the maintainability and portability of your code. However just because it is a service, you don't need to enforce it to be an interface. For example a UserController that is a rest mapping for and endpoint, will probably never be inherited from.
Use DiVine's advanced features instead of workarounds for your dependencies. DiVine covers a lot of fields in your services' management. Therefore it is the best to use them universally in your application, instead of coming up with custom solutions for each case.
Use a layered architecture. This will make your code structure more understandable, as it will describe the relationship between your classes. This will also help you avoid circular dependencies for the most parts.
Find the happy middleground. Most people either completely avoid the principles of clean code, or fully enforce them. It is the best if your main focus is about shipping your features in a productive way, whilst ensuring that your code can be maintained easily. DiVine's standard approaches can help you with that.
Last updated