Trying to build a basic 3-layer architecture in my new application suite. For first time i want to start applying best design practices (like IoC/DI e.t.c).
My UI layer will have to create a BLL object in order to do its work.
Lets say that my UI needs to call BLL 10 times . Will i have to create my BLL object 10 times or i will have to create it once on form load?
Preferred practice is when interfaces of business layer objects are injected to your GUI form, on creation or later thru properties. In this case your form knows nothing about business layer objects, doesn’t bother with instantiating them, and does only what it should – GUI interactions.
Personally I prefer constructor injection:
Where
IDocumentStorageandIJobsRegistratorare your business layer interfaces. You can use properties setters instead, if there are some limitations (say, you can have only parameterless constructor).