• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Afstudeer presentatie: Solid design
 

Afstudeer presentatie: Solid design

on

  • 2,201 views

Presentatie gegeven tijdens verdediging van afstudeertraject. Afstuderen was in het kader van HBO opleiding Informatica aan de Haagse Hogeschool.

Presentatie gegeven tijdens verdediging van afstudeertraject. Afstuderen was in het kader van HBO opleiding Informatica aan de Haagse Hogeschool.

Statistics

Views

Total Views
2,201
Views on SlideShare
1,205
Embed Views
996

Actions

Likes
0
Downloads
19
Comments
0

4 Embeds 996

http://www.paulderaaij.nl 990
http://www.slashdocs.com 3
http://translate.googleusercontent.com 2
http://www.docseek.net 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Afstudeer presentatie: Solid design Afstudeer presentatie: Solid design Presentation Transcript

    • Building your application SOLID Paul de Raaij | @pderaaij 2-2-2012
    • Student HHS
    • Afstudeerder
    • Korte introductie• Afstuderen bij Eleven
    • Toolbox
    • Formulierenmodule
    • DESIGN
    • SOLID software design
    • SOLID Design• Vijf essentiële principes• Geïntroduceerd door Robert C. MartinPr i n c i p l e s o f O b j e c t -O r i e n t e d d
    • Waarom SOLIDdesign?
    • Loosely coupled
    • High cohesion
    • Reusable
    • Maintainable
    • Testable
    • Waar staat het voor• Single Responsibility Principle• Open/Closed Principle• Liskov Substitution Principle• Interface Segregation Principle• Dependency Inversion Principle
    • Single Responsibility PrincipleEen klasse heeft maar één reden om te wijzigen
    • Single Responsibility Principle1. public class Employee {2. public BigDecimal pay();3. public String getFullName();4. public float getWorkedHours();5. }
    • Single Responsibility Principle1. public class Employee {2. public String getFullName();3. }4.5. public class Cashier {6. public void pay(Employee e);7. }8.9. public class EmployeeReporter {10. public float getWorkedHours(Employee e);11.}
    • Open/Closed principle Entiteiten moeten gesloten zijn voorwijzigingen, maar open voor uitbreidingen
    • Open/Closed principle1. public class Musician {2. public void playGuitar();3. }
    • Open/Closed principle1. public class Musician {2. public void playGuitar();3. public void playPiano();4. }
    • Open/Closed principle1. public class Musician {2. public void playInstrument(Instrument i);3. }4.5. interface Instrument {6. public void play();7. }8.9. public class Guitar implements Instrument {10. public void play();11.}12.13.public class Piano implements Instrument {14. public void play();15.}
    • Liskov Substitution PrincipleFuncties die gebruik maken van een basis klassemoeten feilloos werken als een afgeleide klasse wordt gebruikt
    • Liskov Substitution Principle1. class Rectangle {2. public int width;3. public int height;4.5. public void setWidth(int w) {}6. public void setHeight(int h) {}7. public int getArea() { return h*w; }8. }9.10. class Square extends Rectangle {11. public void setWidth( int w ) { super.setWidth(w); super.setHeight(w); }12. public void setHeight( int h ) { super.setWidth(h); super.setHeight(h); }13. }14.15. class TestProgram {16. Rectangle r = new Rectangle();17. r.setWidth(5); r.setHeight(4);18. r.getArea(); // returns 2019.20. Square s = new Square();21. s.setWidth(5); s.setHeight(4);22. s.getArea(); // returns 16;23. }
    • Interface Segregation Principle Functie-specifieke interfaces zijn beter dan één generieke interface
    • Interface Segregation Principle1. interface Animal {2. public void bark();3. public void fly();4. public void run();5. public void eatPlant();6. public void eatMeat();7. }8.9. public Dog implements Animal {10. public void bark();11. public void run();12. public void eatPlant();13. public void eatMeat();14. }15.16. public Duck implements Animal {17. public void fly();18. public void eatPlant();19. }
    • 1. interface Barkable {2. public void bark();3. }4.5. interface Flyable {6. public void fly();7. }8.9. interface Runnable {10. public void run();11. }12.13. interface Herbivore() {14. public void eatPlant();15. }16.17. interface Carnivore() {18. public void eatMeat();19. }20.21. public Dog implements Barkable, Runnable, Herbivore, Carnivore {22. public void bark();23. public void run();24. public void eatPlant();25. public void eatMeat();26. }27.28. public Duck implements Flyable, Herbivore {29. public void fly();30. public void eatPlant();31. }
    • Dependency Inversion Principle A) High level modules mogen niet afhankelijk zijn van low level modules, beide moeten afhangen van abstracties B) Abstracties mogen niet afhangen van details, details moeten afhangen van abstracties
    • Dependency Inversion Principle1. class Band {2. private Singer = new Singer();3. private Musician = new Musician();4.5. public void playSong();6. }
    • Dependency Inversion Principle1. interface MusicalTalent {2. public void useTalent();3. }4.5. class Musician implements MusicalTalent() {}6. class Singer implements MusicalTalent() {}7. class SingingGuitarist implements MusicalTalent() {}8.9. class Band {10. public void playSong( MusicalTalent mt ) {11. mt.useTalent();12. }13. }
    • Dependency Inversion Principle1. interface MusicalTalent {2. public void useTalent();3. }4.5. class Musician implements MusicalTalent() {}6. class Singer implements MusicalTalent() {}7. class SingingGuitarist implements MusicalTalent() {}8.9. class Band {10. private List<MusicalTalent> members = new ArrayList<MusicalTalent>();11. public Band() {}12. public void addMember( MusicalTalent mt ) {13. members.add( mt );14. }15.16. public void playSong() {}17. }
    • SOLID
    • Nooit alleen…
    • … Sterk aan elkaargekoppeld
    • Perfect ontwerp bestaat niet SOLID helpt de balans te vinden