Best practices?… again?
Yes, guys, I know, there are a lot of articles and discussions around the best practices, more over
there are different practices for different languages as far as common practices (common sense
in programming
I would say).
So why I decided to write this article:
- to have one place where you and I can store our ideas
- it is never enough to have best practices - if we all share the same idea we will improve our code quality and will have robust arguments
- the best practices are scattered all around the internet and sometimes it is hard to find the proper one, but there is no sense to copy paste the whole articles. The idea is to have here only the essence of the best practice with short description of the arguments and link to detailed article
- the last one, but not the least one and the most selfish - contributing to this article will help me (and I hope you as well) to get acquainted with big variety of practices and start using them in daily work
Spring
Dependency injection using constructor
Be sure that you always use constructor injection
Arguments:
- it makes testing much easier, because you can easily set up all the dependencies through constructor like you normally do without using sophisticated mocking techniques.
- you can make your fields final
Resources to check: