3
The scenario is simple, it has a Personal Physical class that has linked to it a list of Contacts (instances of physical persons), Telephones (instances of an entity Telephone) and a list of Addresses (instances of an entity Address).
I have in the current project the standard layers: DAO, Businesslayer and Gui, only that Gui accesses the layers below by a Facade. Use Singleton to instantiate Facade, as it maintains instances of business layers and repositories.
I am planning a refactoring because currently the repository of the class Personal Physique loads all information when I have a person uploaded/located in the database, even if I am not going to use the data of contacts, addresses, etc.
So, I plan to use Lazy load to improve performance, but, I’m having doubts on how to do dependency injection in the best way.
Since I already have an interface for the repository, I’m thinking of using a Factory that delivers the proper implementations of the repositories and Singleton to avoid having more than one instance, whatever the part of the application.
The repositories for the addresses would be passed via constructor to the Personal Physical class, but I would like to not force the user of the Personal Physical class to instill the Repositions and abstract this responsibility without compromising the project standards, some idea?
I already have the unit tests for the methods of the Positorios, which makes refactoring much easier.
The project is web, with Asp.net and c# and ADO.NET usage.
Do you think this is the best way? Suggestions?
What exactly are you using in the data layer? Any framework? Have you implemented the layer using your code? There are frameworks that already perform this work for you.
– Leonel Sanches da Silva
@Ciganomorrisonmendez I am implementing everything in hand, I use no framework (Entity, etc). It was a matter of conceptual integrity, the project already had legacy code (.net 2.0) and I chose to continue maintaining the standard so as not to have to refactor everything and to avoid staying with the same layer components implemented with different tools.
– Intruso