Esempi di IoC e DI (Alessandro Giorgetti)
-
Upload
dotnetmarche -
Category
Technology
-
view
312 -
download
2
description
Transcript of Esempi di IoC e DI (Alessandro Giorgetti)
IoC/DI in ActionModularization – Service Locator – Abstract Factories … and SL 4
Eng. Giorgetti AlessandroSoftware ArtisanSID s.r.l.
Two words about me
Graduated EngineerOwner/co-founder of SID s.r.l.Blog: http://www.primordialcode.comEmail: [email protected]: @A_Giorgetti
Giorgetti Alessandro
Engineering an Application
To be able to use an IoC/DI framework effectively you need to structure your application the right way!Your first problem is an Architectural problem:
How to partition an application?How to structure each module?What are the interactions?Dependencies?…
Engineering an Application
Only When you’ve answered those questions, you can think of how to implement the solution!
Only at this stage you can start thinking of which ‘tool’ to use and which ‘best practice’ you can follow to solve your problems!
Application Architecture
When you think of an application architecture, usually this is the first thing it come into your mind:
DAL
Business Logic
User Interface
Secu
rty
Logg
ing
InfrastructureRIGHT!….but also WRONG!
Application Architecture
When using a IoC/DI container your application sounds more like this:
Security ServiceIService1Module1
Logging ServiceIService2Module2
Infrastructure
Shell
Application Framework
IService3 Messaging Service
Application Architecture
When implementing a module/service
Module1
Module2
Infrastructure
Shell
Application Framework
DAL
Business Logic
User Interface
Secu
rty
Logg
ing
Infrastructure
Hints when building an Architecture based on IoC
Keep things simple!Use a top-down approach while defining and designing the applicationBreak the application in modules / features and decouple the more you can: reusability, easy implementationThink using ‘interfaces’ (do not try to implement anything at this stage)…but avoid over-engineering
Problems – Architectural level
Design Interfaces
Component configuration, creation, lifecycle IoC/DI/ServiceLocator, etc…
Managing interactions data storage, shared data, message brokering, etc…
Problems – Module/Feature level
You have plenty of ‘tools’ and ‘patterns’ that helps you implementing your solution:
• Layered applications
• Implementation patterns (MVC, MVVM, …)
• Reuse services
ServiceLocator – Abstract Factoriesmetacode
Eng. Giorgetti Alessandro
demo
MusicStore (SL 4 version)an example of those techniques in action
Eng. Giorgetti Alessandro
demo
MusicStore (SL 4 version)some indepths
Inspired by this workshop I’ve started a series of articles on my blog you can check to dig into some of the arguments I proposed here:
Silverlight, MVVM … and IoChttp://www.primordialcode.com/blog/post/silverlight-mvvm-ioc-part-1http://www.primordialcode.com/blog/post/silverlight-mvvm-ioc-part-2
Silverlight Navigation Framework … and IoChttp://www.primordialcode.com/blog/post/silverlight-navigation-framework-resolve-pages-ioc-container
More to come…
Eng. Giorgetti Alessandro
Questions ? (and maybe … answers)