Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Software Frameworks

2,371 views

Published on

Software Frameworks

Published in: Software
  • Login to see the comments

Software Frameworks

  1. 1. Software Frameworks Gerson Sunyé University of Nantes gerson.sunye@univ-nantes.fr http://sunye.free.fr 1
  2. 2. Gerson Sunyé — Université de Nantes Agenda • Introduction. • Properties • Template method pattern • A toy example • Correlated concepts • Real-world examples • Conclusion 2
  3. 3. Introduction
  4. 4. Gerson Sunyé — Université de Nantes Software Framework • A framework is a reusable,“semi-complete’’ application that can be specialized to produce custom applications [Johnson and Foote, 1988]. 4
  5. 5. Gerson Sunyé — Université de Nantes In Short, a Framework is • A set of classes, abstract classes and interfaces. • A set of behaviors, spread over these classes. • An incomplete application for a family of products. • A set of hooks, where subclasses can insert their specialized behavior. • The expectations placed upon the subclasses. • A logic decomposition of a problem. • Represented by its code. 5
  6. 6. Gerson Sunyé — Université de Nantes Creating Real-World 
 Applications by • Modifying working examples. • Creating subclasses. • Configuring objects. • Writing configuration files. • Writing programs/scripts for a domain-specific language. • Modifying a model@run.time. 6
  7. 7. Gerson Sunyé — Université de Nantes Framework Goals • Reuse: code, design, domain analysis, and documentation. • Simplify software development. • Reduce code writing. • Allow inexperienced designers and programmers to develop good software. • Extract the knowledge of experimented designers and programmers. 7
  8. 8. Properties
  9. 9. Gerson Sunyé — Université de Nantes Basic Properties 1. Modularity 2. Reusability 3. Extensibility 4. Inversion of control 5. Non-modifiable code 9
  10. 10. Gerson Sunyé — Université de Nantes Modularity • Abstract classes have a stable interface that encapsulates volatile implementation details. • They provide hotspots or “points of planned variability”, where the behavior can be extended. • Design and implementation changes are limited to these points, reducing the effort to understand and maintain the software. 10
  11. 11. Gerson Sunyé — Université de Nantes Reusability • The stable interfaces define generic components that can be extended to create new applications. • Reuse of framework components improves developer productivity, as well as software performance, reliability, and interoperability. 11
  12. 12. Gerson Sunyé — Université de Nantes Extensibility • A framework enhances extensibility by providing explicit hook methods for planned variability. • Extensibility is essential to ensure rapid customization of new application features. 12
  13. 13. Gerson Sunyé — Université de Nantes Inversion of Control • In a framework, the flow of control is not dictated by the callers, but by the framework itself (the abstract classes). • The inversion of control enables canonical application processing steps to be customized by hotspots. • Also called the Hollywood principle:“Don’t call us, we’ll call you” [Richard E. Sweet 1985]. 13
  14. 14. Gerson Sunyé — Université de Nantes Non-Modifiable Code • The framework source code is supposed to be extended, not modified. 14
  15. 15. Template Method Pattern
  16. 16. Gerson Sunyé — Université de Nantes Hook andTemplate Methods • Hook and template methods are the building blocks of software frameworks. • They allow the implementation of commonality and variability. 16
  17. 17. Gerson Sunyé — Université de Nantes Template Method • A template method defines the skeleton of an algorithm, deferring some steps to subclasses. • Subclasses can redefine some steps without changing the algorithm’s structure. 17
  18. 18. Template Method Example public void openDocument(String name) { if (!canOpenDocument(name)) { // cannot handle this document return; } Document doc = doCreateDocument(); if (doc != null) { docs.add(doc); aboutToOpenDocument(doc); doc.open(); doc.doRead(); } } save() open() close() doRead() Document addDocument() openDocument() doCreateDocument() canOpenDocument() aboutToOpenDocument() Application doRead() MyDocument doCreateDocument() canOpenDocument() aboutToOpenDocument() MyApplication
  19. 19. Gerson Sunyé — Université de Nantes Template Method Behavior • A template method usually calls the following kinds of operations: • concrete Client operations. • concrete AbstractClass operations (i.e., operations that are generally useful to subclasses). • concrete operations.. • abstract operations. • factory methods (see Factory Method Pattern). • hook operations, which provide default behavior that subclasses can extend if necessary. A hook operation often does nothing by default. 19
  20. 20. Gerson Sunyé — Université de Nantes Hook Methods • A hook method represents a point of variability by providing the calling interface to a variable behavior. • Each implementation of a hook method provides a variant of that behavior. 20
  21. 21. AToy Example [Greg Butler]
  22. 22. Domain Bouncing-Bumping Games Texte
  23. 23. Class Diagram
  24. 24. Template Methods Game::makeWorld() { makeBouncer(); makeControllers(); makeObstacles(); makeEventHandlerTable(); } Game::run(){ loop over event e in eventQueue { ehTable[e]-> handleEvent(e); refreshDisplay(); } }
  25. 25. Correlated Concepts
  26. 26. Gerson Sunyé — Université de Nantes Frameworks and Libraries • Library use case: • The developer designs the application, decomposes the problem and specifies the flow of control. • The application calls the library. 26
  27. 27. Gerson Sunyé — Université de Nantes Frameworks and Libraries • Framework use case: • The developer extends the framework.The framework defines the flow of control and design decomposition. • The framework call the extension code. 27
  28. 28. Gerson Sunyé — Université de Nantes Frameworks and Patterns • Design Patterns: • describe micro-architectures • are abstract • Software Frameworks: • have concrete architecture and code. • incorporate design patterns, often to provide extension points (variability). • are a rich field for design pattern mining. 28
  29. 29. Gerson Sunyé — Université de Nantes Frameworks and 
 Software Architectures • Software architectures: • describe abstract macro-architectures. • target whole systems, but can be used for a product line and single applications. • are design artifacts. • are designed to ensure software quality. • describe the guiding principles behind a given application. 29
  30. 30. Gerson Sunyé — Université de Nantes Frameworks and 
 Software Architectures • Software Frameworks: • are concrete implementation of abstract architectures. • are designed to be specialized/customized. • focus on reusability. 30
  31. 31. Real-World Examples
  32. 32. Gerson Sunyé — Université de Nantes Technology Frameworks • Provide a standard and generic software foundation. • Examples: COM, CORBA, Java J2EE,ACE (Adaptive Communication Environment, Doug Schmidt et al). 32
  33. 33. Gerson Sunyé — Université de Nantes Application Frameworks • Implement the standard structure of an application. • MVC (ModelView Controller) — Smalltalk [1980]. • MFC, Microsoft Foundation Classes. • MacApp/ACS — Objective Pascal, C++ [1986] • NeXTStep/OpenStep/Cocoa/GNUStep — Objective C, Java. 33
  34. 34. Gerson Sunyé — Université de Nantes Business Frameworks • Domain-specific, business solution that can be extended into an organization. • Baan: Enterprise Resource Planning (ERP) software written in Java. • San Francisco Business Objects (Taligent/IBM). • The Oracle Enterprise Architecture Framework. 34
  35. 35. Gerson Sunyé — Université de Nantes Web Application Frameworks • Designed to support the development of dynamic websites, web applications, web services and web resources. • Zope (Zope Corporation) — Python. • Apache Struts — Java. • Django, Ruby on Rails, Symfony, Yii, Spring MVC, Stripes, Play, CodeIgniter, etc. 35
  36. 36. Conclusion
  37. 37. Gerson Sunyé — Université de Nantes Framework Main Characteristics • Hotspots: planned extension points. • Inversion of control: the framework controls the application and not the opposite. 37
  38. 38. Gerson Sunyé — Université de Nantes Main Issues • Learning curve. • Important initial investment. • Framework developers must be domain experts. • Framework evolution is complex. 38
  39. 39. Gerson Sunyé — Université de Nantes Framework Benefits • Code and design reuse. • Perspective shift: programmers are forced to write reusable software. • Improvement of software quality and developer productivity. 39
  40. 40. Gerson Sunyé — Université de Nantes References • M.E. Fayad, D.C. Schmidt, R.E. Johnson,“Building Application Frameworks”,Addison-Wesley, 1999. • Object Oriented Frameworks. Greg Butler. Ecoop 2001 Workshops. 40
  41. 41. Software Frameworks

×