SlideShare uma empresa Scribd logo
1 de 34
Realizzare applicazioni
estendibili e configurabili
          Ambizioso?



                                                Mauro Servienti
                                      Microsoft MVP - Visual C#

                       Software Mason @ Managed Designs S.r.l.
                             mauro.servienti@manageddesigns.it
Agenda
• Perchè?
• Il “problema”;
• Dogmi:
    – Open Closed Principle;
    – Single Point of Responsability;
•   Best Practice(s);
•   Inversion Of Control;
•   Chain Of Responsability;
•   Una voce fuori dal coro: System.AddIn;
IMHO



• La bacchetta magica non esiste:
  – Ogni volta è una nuova avventura;
  – Non c’è una ricetta che vada bene per tutte le
    salse ;-)
  – Esistono i Design Pattern....ma...
• Partire dai Pattern è rischioso:
  – Rischia di farci perdere la visione concreta del
    progetto;
  – Refactoring to Pattern: “software mason”;
Perchè abbiamo bisogno di realizzare applicazioni estensibili.

ESTENSIBILITÀ... WHO
CARES?
Perchè?



• Supporto per l’integrazione e
  l’interoperabilità;
• Consente di modificare a caldo il
  comportamento;
• Elevatissima manutenibilità;
• Verticalizzazione;
• Testing;
• Può essere un’ottimo “strumento”
  commerciale;
Un primo approccio al problema

LE DIPENDENZE STATICHE
il problema: le dipendenze statiche

           Componente   Componente

           ComA         ComB
Il cammino verso la soluzione...


Componente   Interfaccia

ComA         IComB



             Componente

             ComB




                             ...to be continued
Fobia da “dipendenza statica”?, un faro nella nebbia...

I PRINCIPI GUIDA
Open Closed Principle

 “software entities should be open for
        extension, but closed for
             modification”
• Open for Extension:
  – Il componente deve essere estendibile;
• Closed for Modification:
  – L’estensione non deve portare ad una
    rottura del rapporto;
Ma in soldoni?

• Quello che vogliamo evitare è che
  una semplice modifica in un punto si
  propaghi a macchi d’olio in tutta
  l’applicazione;
  – Eg: sostituibilità a “caldo” del DAL
    • Se abbiamo un riferimento al DAL concreto
      non siamo “Closed”;
    • Se facciamo assunzioni particolari non siamo
      “Closed”;
Non “Closed”
Single Point of Responsability

• Ad ognuno il suo ruolo;
• Lo scope del ruolo assegnato deve
  essere il più preciso possibile
  (focuse);
• Se ad un componente assegno più
  responsabilità violo l’Open Closed
  Principle;
Troppe responsabilità
Il panico da “Empty Solution”

BEST PRACTICE(S)
Scrivere in ottica estensibilità

• Interfaces vs. Abstract classes;
• Pensare agli entry point;
• Prevedere quali dati potranno essere
  necessari;
• Le “pipeline”, un esempio da seguire:
  – HttpModule, HttpHanlder;
• Refactoring, refactoring, refactoring,
  refactoring e ancora refactoring;
Interfaces vs. Abstract classes
 Interface                      Abstract Class
 • Posso simulare               • Mi permette di fornire
    ereditarietà multipla;        un’implementazione di
 • Non “brucio” l’unico punto     base alle classi derivate;
    di inheritance
                          Quindi?
• Colgo il meglio dei due mondi:
   • Interface verso il chiamante;
   • Abstract Class(es) nel modello;
Il meglio dei due mondi (1)
Il meglio dei due mondi (2)




                       ...to be continued
Entry Point

• Dove avrò bisogno di estendere:
  – Ovunque ;-), mai chiudersi le porte...
• Un esempio: la “Conversazione”
  – è la Session? Si;
  – Perchè non usare la Session? E se
    domani mattina la Session non mi
    andasse più bene?
  – Mettiamo le mani avanti: “Facade”
Mascheriamo
...ma dietro le quinte?




• Slega il nostro modello da Asp.Net;
  – Siamo “Open”!;
• Quanto abbiamo investito?
Prevedere...

• Non abbiamo la sfera di cristallo
• Incapsulare i dati in classi adatte al
  loro trasporto:
  – EventArgs;
  – CancelEventArgs;
  – CustomEventArgs : estendiamo
    CancelEventArgs/EventArgs
“Trasportare” i dati


• le informazioni non sono sufficienti



• ...non compila più: non siamo “Closed”
Le “pipeline”

• “pipeline”, un esempio da seguire:
  – HttpModule + HttpHanlder;



 Request   IProcessor   IProcessor   IProcessor   IProcessor

              A            B            C            n

 Data
Le “pipeline” (code)
Inversion of Control
                                    Interfaccia
  Componente
               ServiceProvider
  ComA           (IoC Container)    IComB




                       Componente    IoC
                       ComB         Config
Vediamolo in azione....

DEMO
IoC Containers e non solo

• StructureMap;
• Castle Windsor;
• Spring.NET
• Unity (Enterprise Library 4.0)
I’ve got the power <cit.>




• Se volessimo cambiare l’ordine...?
• Se volessimo aggiungere/rimuovere
  step...?
• Se volessimo fare il tutto “a caldo”...?
Vediamolo in azione....

DEMO
IoC Containers: cosa offrono

• Contenitore di Servizi;
• Lifecycle management;
• Policy Injection (interceptors);

• Difetti? Si la gestione della
  configurazione...
Non sparate sul pianista....

DOMANDE?
Grazie a tutti, mi raccomando...

IL MODULO DI FEEDBACK

Mais conteúdo relacionado

Semelhante a Inversion of Control @ CD2008

Delphi & Dintorni Webinar - Padroneggiare i principi SOLID con Delphi
Delphi & Dintorni Webinar - Padroneggiare i principi SOLID con DelphiDelphi & Dintorni Webinar - Padroneggiare i principi SOLID con Delphi
Delphi & Dintorni Webinar - Padroneggiare i principi SOLID con DelphiMarco Breveglieri
 
Brokering over WCF @ dotNetMarche
Brokering over WCF @ dotNetMarcheBrokering over WCF @ dotNetMarche
Brokering over WCF @ dotNetMarcheMauro Servienti
 
Test Driven Development @ Xe.Net
Test Driven Development @ Xe.NetTest Driven Development @ Xe.Net
Test Driven Development @ Xe.NetMauro Servienti
 
MySQL Tech Tour 2015 - Soluzioni di alta disponibilità con MySQL
MySQL Tech Tour 2015 - Soluzioni di alta disponibilità con MySQLMySQL Tech Tour 2015 - Soluzioni di alta disponibilità con MySQL
MySQL Tech Tour 2015 - Soluzioni di alta disponibilità con MySQLPar-Tec S.p.A.
 
Il tuo team "agile" scrive codice "flaccido"? Forse scrum non basta
Il tuo team "agile" scrive codice "flaccido"? Forse scrum non bastaIl tuo team "agile" scrive codice "flaccido"? Forse scrum non basta
Il tuo team "agile" scrive codice "flaccido"? Forse scrum non bastaStefano Muro
 
Software Engineering Introduction in Italian
Software Engineering Introduction in ItalianSoftware Engineering Introduction in Italian
Software Engineering Introduction in ItalianPierpaoloCaricato
 
festival ICT 2013: Gestire criticità in maniera efficiente per liberare slot ...
festival ICT 2013: Gestire criticità in maniera efficiente per liberare slot ...festival ICT 2013: Gestire criticità in maniera efficiente per liberare slot ...
festival ICT 2013: Gestire criticità in maniera efficiente per liberare slot ...festival ICT 2016
 
Industrial Iot - IotSaturday
Industrial Iot - IotSaturday Industrial Iot - IotSaturday
Industrial Iot - IotSaturday Riccardo Zamana
 
Maze Enterprise: front-end e back-end. Trova la miglior soluzione!
Maze Enterprise: front-end e back-end. Trova la miglior soluzione!Maze Enterprise: front-end e back-end. Trova la miglior soluzione!
Maze Enterprise: front-end e back-end. Trova la miglior soluzione!Codemotion
 
Industrial iot: dalle parole ai fatti
Industrial iot: dalle parole ai fatti Industrial iot: dalle parole ai fatti
Industrial iot: dalle parole ai fatti Riccardo Zamana
 
Sviluppo Agile secondo l'approccio SCRUM
Sviluppo Agile secondo l'approccio SCRUMSviluppo Agile secondo l'approccio SCRUM
Sviluppo Agile secondo l'approccio SCRUMMatteo Papadopoulos
 
Agile Experience Design & Development - IAD 2012
Agile Experience Design & Development - IAD 2012Agile Experience Design & Development - IAD 2012
Agile Experience Design & Development - IAD 2012Timothy Carniato
 
GAE python GDG Milano - L02
GAE python GDG Milano - L02GAE python GDG Milano - L02
GAE python GDG Milano - L02Paolo Dadda
 
Hybrid DevOps Stack
Hybrid DevOps StackHybrid DevOps Stack
Hybrid DevOps StackMatteo Emili
 
Wpc2019 - Distruggere DevOps, la storia di un vero team
Wpc2019 - Distruggere DevOps, la storia di un vero teamWpc2019 - Distruggere DevOps, la storia di un vero team
Wpc2019 - Distruggere DevOps, la storia di un vero teamAlessandro Alpi
 
Loosely Coupled Complexity - Unleash the power of your domain model
Loosely Coupled Complexity - Unleash the power of your domain modelLoosely Coupled Complexity - Unleash the power of your domain model
Loosely Coupled Complexity - Unleash the power of your domain modelFrancesca1980
 

Semelhante a Inversion of Control @ CD2008 (20)

m-v-vm @ UgiAlt.Net
m-v-vm @ UgiAlt.Netm-v-vm @ UgiAlt.Net
m-v-vm @ UgiAlt.Net
 
Delphi & Dintorni Webinar - Padroneggiare i principi SOLID con Delphi
Delphi & Dintorni Webinar - Padroneggiare i principi SOLID con DelphiDelphi & Dintorni Webinar - Padroneggiare i principi SOLID con Delphi
Delphi & Dintorni Webinar - Padroneggiare i principi SOLID con Delphi
 
Brokering over WCF @ dotNetMarche
Brokering over WCF @ dotNetMarcheBrokering over WCF @ dotNetMarche
Brokering over WCF @ dotNetMarche
 
Test Driven Development @ Xe.Net
Test Driven Development @ Xe.NetTest Driven Development @ Xe.Net
Test Driven Development @ Xe.Net
 
MySQL Tech Tour 2015 - Soluzioni di alta disponibilità con MySQL
MySQL Tech Tour 2015 - Soluzioni di alta disponibilità con MySQLMySQL Tech Tour 2015 - Soluzioni di alta disponibilità con MySQL
MySQL Tech Tour 2015 - Soluzioni di alta disponibilità con MySQL
 
Il tuo team "agile" scrive codice "flaccido"? Forse scrum non basta
Il tuo team "agile" scrive codice "flaccido"? Forse scrum non bastaIl tuo team "agile" scrive codice "flaccido"? Forse scrum non basta
Il tuo team "agile" scrive codice "flaccido"? Forse scrum non basta
 
Software Engineering Introduction in Italian
Software Engineering Introduction in ItalianSoftware Engineering Introduction in Italian
Software Engineering Introduction in Italian
 
festival ICT 2013: Gestire criticità in maniera efficiente per liberare slot ...
festival ICT 2013: Gestire criticità in maniera efficiente per liberare slot ...festival ICT 2013: Gestire criticità in maniera efficiente per liberare slot ...
festival ICT 2013: Gestire criticità in maniera efficiente per liberare slot ...
 
Industrial Iot - IotSaturday
Industrial Iot - IotSaturday Industrial Iot - IotSaturday
Industrial Iot - IotSaturday
 
UI Composition
UI CompositionUI Composition
UI Composition
 
OOP... Object Whaaat?
OOP... Object Whaaat?OOP... Object Whaaat?
OOP... Object Whaaat?
 
Maze Enterprise: front-end e back-end. Trova la miglior soluzione!
Maze Enterprise: front-end e back-end. Trova la miglior soluzione!Maze Enterprise: front-end e back-end. Trova la miglior soluzione!
Maze Enterprise: front-end e back-end. Trova la miglior soluzione!
 
Industrial iot: dalle parole ai fatti
Industrial iot: dalle parole ai fatti Industrial iot: dalle parole ai fatti
Industrial iot: dalle parole ai fatti
 
Sviluppo Agile secondo l'approccio SCRUM
Sviluppo Agile secondo l'approccio SCRUMSviluppo Agile secondo l'approccio SCRUM
Sviluppo Agile secondo l'approccio SCRUM
 
Agile Experience Design & Development - IAD 2012
Agile Experience Design & Development - IAD 2012Agile Experience Design & Development - IAD 2012
Agile Experience Design & Development - IAD 2012
 
Kotlin hexagonal-architecture
Kotlin hexagonal-architectureKotlin hexagonal-architecture
Kotlin hexagonal-architecture
 
GAE python GDG Milano - L02
GAE python GDG Milano - L02GAE python GDG Milano - L02
GAE python GDG Milano - L02
 
Hybrid DevOps Stack
Hybrid DevOps StackHybrid DevOps Stack
Hybrid DevOps Stack
 
Wpc2019 - Distruggere DevOps, la storia di un vero team
Wpc2019 - Distruggere DevOps, la storia di un vero teamWpc2019 - Distruggere DevOps, la storia di un vero team
Wpc2019 - Distruggere DevOps, la storia di un vero team
 
Loosely Coupled Complexity - Unleash the power of your domain model
Loosely Coupled Complexity - Unleash the power of your domain modelLoosely Coupled Complexity - Unleash the power of your domain model
Loosely Coupled Complexity - Unleash the power of your domain model
 

Mais de Mauro Servienti

Welcome to the (state) machine @ ExploreDDD 2019
Welcome to the (state) machine @ ExploreDDD 2019Welcome to the (state) machine @ ExploreDDD 2019
Welcome to the (state) machine @ ExploreDDD 2019Mauro Servienti
 
Designing a ui for microservices @ .NET Day Switzerland 2019
Designing a ui for microservices @ .NET Day Switzerland 2019Designing a ui for microservices @ .NET Day Switzerland 2019
Designing a ui for microservices @ .NET Day Switzerland 2019Mauro Servienti
 
Welcome to the (state) machine @ Xe One Day Enterprise Applications
Welcome to the (state) machine @ Xe One Day Enterprise ApplicationsWelcome to the (state) machine @ Xe One Day Enterprise Applications
Welcome to the (state) machine @ Xe One Day Enterprise ApplicationsMauro Servienti
 
All our aggregates are wrong @ NDC Copenhagen 2019
All our aggregates are wrong @ NDC Copenhagen 2019All our aggregates are wrong @ NDC Copenhagen 2019
All our aggregates are wrong @ NDC Copenhagen 2019Mauro Servienti
 
Be like water, my friend @ Agile for Innovation 2019
Be like water, my friend @ Agile for Innovation 2019Be like water, my friend @ Agile for Innovation 2019
Be like water, my friend @ Agile for Innovation 2019Mauro Servienti
 
Microservices architecture is it the right choice to design long-living syste...
Microservices architecture is it the right choice to design long-living syste...Microservices architecture is it the right choice to design long-living syste...
Microservices architecture is it the right choice to design long-living syste...Mauro Servienti
 
Titles, abstracts, and bio matter... oh my! @ Global Diversity CFP Day 2019
Titles, abstracts, and bio matter... oh my! @ Global Diversity CFP Day 2019Titles, abstracts, and bio matter... oh my! @ Global Diversity CFP Day 2019
Titles, abstracts, and bio matter... oh my! @ Global Diversity CFP Day 2019Mauro Servienti
 
Living organizations, particular software @ do IT Better Parma
Living organizations, particular software @ do IT Better ParmaLiving organizations, particular software @ do IT Better Parma
Living organizations, particular software @ do IT Better ParmaMauro Servienti
 
Welcome to the (state) machine @ Crafted Software
Welcome to the (state) machine @ Crafted SoftwareWelcome to the (state) machine @ Crafted Software
Welcome to the (state) machine @ Crafted SoftwareMauro Servienti
 
PO is dead, long live the PO - Italian Agile Day 2018
PO is dead, long live the PO - Italian Agile Day 2018PO is dead, long live the PO - Italian Agile Day 2018
PO is dead, long live the PO - Italian Agile Day 2018Mauro Servienti
 
Design a UI for your Microservices @ Do IT Better
Design a UI for your Microservices @ Do IT BetterDesign a UI for your Microservices @ Do IT Better
Design a UI for your Microservices @ Do IT BetterMauro Servienti
 
Microservices and pineapple on pizza what do they have in common - dos and ...
Microservices and pineapple on pizza   what do they have in common - dos and ...Microservices and pineapple on pizza   what do they have in common - dos and ...
Microservices and pineapple on pizza what do they have in common - dos and ...Mauro Servienti
 
All our aggregates are wrong (ExploreDDD 2018)
All our aggregates are wrong (ExploreDDD 2018)All our aggregates are wrong (ExploreDDD 2018)
All our aggregates are wrong (ExploreDDD 2018)Mauro Servienti
 
Designing a ui for microservices
Designing a ui for microservicesDesigning a ui for microservices
Designing a ui for microservicesMauro Servienti
 
Po is dead, long live the po
Po is dead, long live the poPo is dead, long live the po
Po is dead, long live the poMauro Servienti
 
Shipping code is not the problem, deciding what to ship it is!
Shipping code is not the problem, deciding what to ship it is!Shipping code is not the problem, deciding what to ship it is!
Shipping code is not the problem, deciding what to ship it is!Mauro Servienti
 
GraphQL - Where are you from? Where are you going?
GraphQL - Where are you from? Where are you going?GraphQL - Where are you from? Where are you going?
GraphQL - Where are you from? Where are you going?Mauro Servienti
 
Dall'idea al deploy un lungo viaggio che passa per git flow e semver
Dall'idea al deploy   un lungo viaggio che passa per git flow e semverDall'idea al deploy   un lungo viaggio che passa per git flow e semver
Dall'idea al deploy un lungo viaggio che passa per git flow e semverMauro Servienti
 
Progettare una UI per i Microservices
Progettare una UI per i MicroservicesProgettare una UI per i Microservices
Progettare una UI per i MicroservicesMauro Servienti
 
The road to a Service Oriented Architecture is paved with messages
The road to a Service Oriented Architecture is paved with messagesThe road to a Service Oriented Architecture is paved with messages
The road to a Service Oriented Architecture is paved with messagesMauro Servienti
 

Mais de Mauro Servienti (20)

Welcome to the (state) machine @ ExploreDDD 2019
Welcome to the (state) machine @ ExploreDDD 2019Welcome to the (state) machine @ ExploreDDD 2019
Welcome to the (state) machine @ ExploreDDD 2019
 
Designing a ui for microservices @ .NET Day Switzerland 2019
Designing a ui for microservices @ .NET Day Switzerland 2019Designing a ui for microservices @ .NET Day Switzerland 2019
Designing a ui for microservices @ .NET Day Switzerland 2019
 
Welcome to the (state) machine @ Xe One Day Enterprise Applications
Welcome to the (state) machine @ Xe One Day Enterprise ApplicationsWelcome to the (state) machine @ Xe One Day Enterprise Applications
Welcome to the (state) machine @ Xe One Day Enterprise Applications
 
All our aggregates are wrong @ NDC Copenhagen 2019
All our aggregates are wrong @ NDC Copenhagen 2019All our aggregates are wrong @ NDC Copenhagen 2019
All our aggregates are wrong @ NDC Copenhagen 2019
 
Be like water, my friend @ Agile for Innovation 2019
Be like water, my friend @ Agile for Innovation 2019Be like water, my friend @ Agile for Innovation 2019
Be like water, my friend @ Agile for Innovation 2019
 
Microservices architecture is it the right choice to design long-living syste...
Microservices architecture is it the right choice to design long-living syste...Microservices architecture is it the right choice to design long-living syste...
Microservices architecture is it the right choice to design long-living syste...
 
Titles, abstracts, and bio matter... oh my! @ Global Diversity CFP Day 2019
Titles, abstracts, and bio matter... oh my! @ Global Diversity CFP Day 2019Titles, abstracts, and bio matter... oh my! @ Global Diversity CFP Day 2019
Titles, abstracts, and bio matter... oh my! @ Global Diversity CFP Day 2019
 
Living organizations, particular software @ do IT Better Parma
Living organizations, particular software @ do IT Better ParmaLiving organizations, particular software @ do IT Better Parma
Living organizations, particular software @ do IT Better Parma
 
Welcome to the (state) machine @ Crafted Software
Welcome to the (state) machine @ Crafted SoftwareWelcome to the (state) machine @ Crafted Software
Welcome to the (state) machine @ Crafted Software
 
PO is dead, long live the PO - Italian Agile Day 2018
PO is dead, long live the PO - Italian Agile Day 2018PO is dead, long live the PO - Italian Agile Day 2018
PO is dead, long live the PO - Italian Agile Day 2018
 
Design a UI for your Microservices @ Do IT Better
Design a UI for your Microservices @ Do IT BetterDesign a UI for your Microservices @ Do IT Better
Design a UI for your Microservices @ Do IT Better
 
Microservices and pineapple on pizza what do they have in common - dos and ...
Microservices and pineapple on pizza   what do they have in common - dos and ...Microservices and pineapple on pizza   what do they have in common - dos and ...
Microservices and pineapple on pizza what do they have in common - dos and ...
 
All our aggregates are wrong (ExploreDDD 2018)
All our aggregates are wrong (ExploreDDD 2018)All our aggregates are wrong (ExploreDDD 2018)
All our aggregates are wrong (ExploreDDD 2018)
 
Designing a ui for microservices
Designing a ui for microservicesDesigning a ui for microservices
Designing a ui for microservices
 
Po is dead, long live the po
Po is dead, long live the poPo is dead, long live the po
Po is dead, long live the po
 
Shipping code is not the problem, deciding what to ship it is!
Shipping code is not the problem, deciding what to ship it is!Shipping code is not the problem, deciding what to ship it is!
Shipping code is not the problem, deciding what to ship it is!
 
GraphQL - Where are you from? Where are you going?
GraphQL - Where are you from? Where are you going?GraphQL - Where are you from? Where are you going?
GraphQL - Where are you from? Where are you going?
 
Dall'idea al deploy un lungo viaggio che passa per git flow e semver
Dall'idea al deploy   un lungo viaggio che passa per git flow e semverDall'idea al deploy   un lungo viaggio che passa per git flow e semver
Dall'idea al deploy un lungo viaggio che passa per git flow e semver
 
Progettare una UI per i Microservices
Progettare una UI per i MicroservicesProgettare una UI per i Microservices
Progettare una UI per i Microservices
 
The road to a Service Oriented Architecture is paved with messages
The road to a Service Oriented Architecture is paved with messagesThe road to a Service Oriented Architecture is paved with messages
The road to a Service Oriented Architecture is paved with messages
 

Inversion of Control @ CD2008

  • 1. Realizzare applicazioni estendibili e configurabili Ambizioso? Mauro Servienti Microsoft MVP - Visual C# Software Mason @ Managed Designs S.r.l. mauro.servienti@manageddesigns.it
  • 2. Agenda • Perchè? • Il “problema”; • Dogmi: – Open Closed Principle; – Single Point of Responsability; • Best Practice(s); • Inversion Of Control; • Chain Of Responsability; • Una voce fuori dal coro: System.AddIn;
  • 3. IMHO • La bacchetta magica non esiste: – Ogni volta è una nuova avventura; – Non c’è una ricetta che vada bene per tutte le salse ;-) – Esistono i Design Pattern....ma... • Partire dai Pattern è rischioso: – Rischia di farci perdere la visione concreta del progetto; – Refactoring to Pattern: “software mason”;
  • 4. Perchè abbiamo bisogno di realizzare applicazioni estensibili. ESTENSIBILITÀ... WHO CARES?
  • 5. Perchè? • Supporto per l’integrazione e l’interoperabilità; • Consente di modificare a caldo il comportamento; • Elevatissima manutenibilità; • Verticalizzazione; • Testing; • Può essere un’ottimo “strumento” commerciale;
  • 6. Un primo approccio al problema LE DIPENDENZE STATICHE
  • 7. il problema: le dipendenze statiche Componente Componente ComA ComB
  • 8. Il cammino verso la soluzione... Componente Interfaccia ComA IComB Componente ComB ...to be continued
  • 9. Fobia da “dipendenza statica”?, un faro nella nebbia... I PRINCIPI GUIDA
  • 10. Open Closed Principle “software entities should be open for extension, but closed for modification” • Open for Extension: – Il componente deve essere estendibile; • Closed for Modification: – L’estensione non deve portare ad una rottura del rapporto;
  • 11. Ma in soldoni? • Quello che vogliamo evitare è che una semplice modifica in un punto si propaghi a macchi d’olio in tutta l’applicazione; – Eg: sostituibilità a “caldo” del DAL • Se abbiamo un riferimento al DAL concreto non siamo “Closed”; • Se facciamo assunzioni particolari non siamo “Closed”;
  • 13. Single Point of Responsability • Ad ognuno il suo ruolo; • Lo scope del ruolo assegnato deve essere il più preciso possibile (focuse); • Se ad un componente assegno più responsabilità violo l’Open Closed Principle;
  • 15. Il panico da “Empty Solution” BEST PRACTICE(S)
  • 16. Scrivere in ottica estensibilità • Interfaces vs. Abstract classes; • Pensare agli entry point; • Prevedere quali dati potranno essere necessari; • Le “pipeline”, un esempio da seguire: – HttpModule, HttpHanlder; • Refactoring, refactoring, refactoring, refactoring e ancora refactoring;
  • 17. Interfaces vs. Abstract classes Interface Abstract Class • Posso simulare • Mi permette di fornire ereditarietà multipla; un’implementazione di • Non “brucio” l’unico punto base alle classi derivate; di inheritance Quindi? • Colgo il meglio dei due mondi: • Interface verso il chiamante; • Abstract Class(es) nel modello;
  • 18. Il meglio dei due mondi (1)
  • 19. Il meglio dei due mondi (2) ...to be continued
  • 20. Entry Point • Dove avrò bisogno di estendere: – Ovunque ;-), mai chiudersi le porte... • Un esempio: la “Conversazione” – è la Session? Si; – Perchè non usare la Session? E se domani mattina la Session non mi andasse più bene? – Mettiamo le mani avanti: “Facade”
  • 22. ...ma dietro le quinte? • Slega il nostro modello da Asp.Net; – Siamo “Open”!; • Quanto abbiamo investito?
  • 23. Prevedere... • Non abbiamo la sfera di cristallo • Incapsulare i dati in classi adatte al loro trasporto: – EventArgs; – CancelEventArgs; – CustomEventArgs : estendiamo CancelEventArgs/EventArgs
  • 24. “Trasportare” i dati • le informazioni non sono sufficienti • ...non compila più: non siamo “Closed”
  • 25. Le “pipeline” • “pipeline”, un esempio da seguire: – HttpModule + HttpHanlder; Request IProcessor IProcessor IProcessor IProcessor A B C n Data
  • 27. Inversion of Control Interfaccia Componente ServiceProvider ComA (IoC Container) IComB Componente IoC ComB Config
  • 29. IoC Containers e non solo • StructureMap; • Castle Windsor; • Spring.NET • Unity (Enterprise Library 4.0)
  • 30. I’ve got the power <cit.> • Se volessimo cambiare l’ordine...? • Se volessimo aggiungere/rimuovere step...? • Se volessimo fare il tutto “a caldo”...?
  • 32. IoC Containers: cosa offrono • Contenitore di Servizi; • Lifecycle management; • Policy Injection (interceptors); • Difetti? Si la gestione della configurazione...
  • 33. Non sparate sul pianista.... DOMANDE?
  • 34. Grazie a tutti, mi raccomando... IL MODULO DI FEEDBACK