0
More on Software Architecture and Design Verification (© T. Horton 2007) <ul><li>Design Patterns </li></ul><ul><li>Overvie...
Design Patterns <ul><li>Usually design “in the small” </li></ul><ul><li>Sometimes a pattern is central to larger framework...
Maybe you know these terms? <ul><li>What’s a code idiom? </li></ul><ul><ul><li>Example from Java, C++, ? </li></ul></ul><u...
Verification (© T. Horton 2007)
Idioms, Patterns, Frameworks <ul><li>Idiom: a small language-specific pattern or technique </li></ul><ul><ul><li>A more pr...
Design Pattern <ul><li>Design pattern: a description of a problem that reoccurs and an outline of an approach to solving t...
Design Patterns Are (and Aren’t) <ul><li>Name and description of a  proven  solution to a design problem </li></ul><ul><li...
Describing Design Patterns <ul><li>The GoF defined a standard format </li></ul><ul><ul><li>Generally followed </li></ul></...
Pattern Format (cont’d) <ul><ul><li>Participants </li></ul></ul><ul><ul><ul><li>Classes and objects, their responsibilitie...
Example 1: Singleton Pattern <ul><li>Global variables are bad! </li></ul><ul><ul><li>Why? </li></ul></ul><ul><li>We are te...
Example 1: Singleton Pattern <ul><li>Context: Only one instance of a class is created. Everything in the system that needs...
Singleton Pattern <ul><li>The singleton pattern’s solution </li></ul><ul><ul><li>The class has a static variable called  t...
Singleton: Java implementation Verification (© T. Horton 2007) public class MySingleton {   private static MySingleton the...
Example 2: <ul><li>A nested data structure </li></ul><ul><ul><li>We have item objects and item-group objects </li></ul></u...
Example 2: Composite pattern <ul><li>Use an interface or abstract class to represent a more generic for of item </li></ul>...
Class Diagram for Composite Verification (© T. Horton 2007)
Operations on Group Objects <ul><li>PlayList contains a list of PlayableItems </li></ul><ul><li>PlayList.play() calls play...
Example 3: Stateful Behavior <ul><li>Problem statement: </li></ul><ul><ul><li>A “stateful object”: behavior varies dependi...
The State Design Pattern <ul><li>Each Connection object has a “helper” object </li></ul><ul><ul><li>state  attribute refer...
Pros and Cons? <ul><li>What are the design advantages of the State design pattern? </li></ul><ul><ul><li>Disadvantages? </...
Categories of Design Patterns <ul><li>Three common categories </li></ul><ul><ul><li>Creational </li></ul></ul><ul><ul><ul>...
Example 4: Watching for State Changes <ul><li>Problem </li></ul><ul><ul><li>An object is responsible for storing and manag...
This Problem in GUIs <ul><li>GUIs have this exact situation </li></ul><ul><ul><li>Button object </li></ul></ul><ul><ul><ul...
Solutions: Observer, MVC <ul><li>Model-View-Controller (MVC) </li></ul><ul><ul><li>An old design pattern </li></ul></ul><u...
Observer Object Interactions Verification (© T. Horton 2007)
Analysis of Observer <ul><li>Explain the advantages of the Observer DP </li></ul><ul><ul><li>Can you explain this in terms...
Some Newer Architecture Frameworks <ul><li>Design patterns represent “best practices” </li></ul><ul><ul><li>Usually for wh...
Some General Issues <ul><li>Client/Server architectures </li></ul><ul><li>Web interface through the browser </li></ul><ul>...
AJAX and Web 2.0 <ul><li>Have a look at: </li></ul><ul><ul><li>Ajax: A New Approach to Web Applications,  by Jesse James G...
Usual Model for Web Apps <ul><li>Interact with a page </li></ul><ul><ul><li>Maybe enter info in forms, then hit Submit </l...
New Model: Web 2.0, Ajax <ul><li>Web 2.0: just a buzzword? </li></ul><ul><ul><li>See Wikipedia for the history </li></ul><...
Ajax Component Technologies <ul><li>Presentation with XHTML and CSS </li></ul><ul><li>Dynamic page display and interaction...
What’s Different than the Old Model? <ul><li>Small events </li></ul><ul><ul><li>Small request to the server that makes sma...
Old vs. New <ul><li>from Garrett’s web article </li></ul>Verification (© T. Horton 2007)
Page Modification in Ajax <ul><li>From  Pragmatic Ajax </li></ul><ul><li>See explanation given in class </li></ul>Verifica...
Ajax Support <ul><li>Server-side “remoting” </li></ul><ul><ul><li>Frameworks and toolkits to support communcations more ea...
Ruby on Rails <ul><li>A framework for developing web apps </li></ul><ul><ul><li>Remember what a framework is? </li></ul></...
Concepts behind Rails <ul><li>More slogans! </li></ul><ul><ul><li>DRY: Don’t repeat yourself </li></ul></ul><ul><ul><ul><l...
ORM in Rails <ul><li>Challenges putting together an OO program with class design and a set of database tables </li></ul><u...
Rails and MVC Architecture <ul><li>MVC is a design pattern for interactive applications </li></ul><ul><li>Model: just like...
MVC in Rails Diagram <ul><li>(from book  Agile Web Development with Rails) </li></ul>Verification (© T. Horton 2007)
Views, Controllers in Rails <ul><li>First step: Rails code generation… </li></ul><ul><li>Views: </li></ul><ul><ul><li>You ...
Summary <ul><li>The high-level big picture here is: </li></ul><ul><ul><li>Certain kinds of applications… </li></ul></ul><u...
Summary (2) <ul><li>Standard best-practices and techniques at the design/architecture level </li></ul><ul><ul><li>Design p...
Upcoming SlideShare
Loading in...5
×

(PPT)

822

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
822
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "(PPT)"

  1. 1. More on Software Architecture and Design Verification (© T. Horton 2007) <ul><li>Design Patterns </li></ul><ul><li>Overview of some newer architecture frameworks </li></ul><ul><ul><li>Ruby on Rails </li></ul></ul><ul><ul><li>Ajax and Web 2.0 </li></ul></ul><ul><ul><li>Web services with .NET </li></ul></ul>
  2. 2. Design Patterns <ul><li>Usually design “in the small” </li></ul><ul><li>Sometimes a pattern is central to larger frameworks </li></ul><ul><ul><li>MVC and Ruby on Rails </li></ul></ul><ul><ul><li>Observer and Java Swing </li></ul></ul>Verification (© T. Horton 2007)
  3. 3. Maybe you know these terms? <ul><li>What’s a code idiom? </li></ul><ul><ul><li>Example from Java, C++, ? </li></ul></ul><ul><li>What’s a framework? </li></ul><ul><ul><li>Examples? Why? </li></ul></ul><ul><li>What’s a design pattern? </li></ul>Verification (© T. Horton 2007)
  4. 4. Verification (© T. Horton 2007)
  5. 5. Idioms, Patterns, Frameworks <ul><li>Idiom: a small language-specific pattern or technique </li></ul><ul><ul><li>A more primitive building block </li></ul></ul><ul><li>Framework: </li></ul><ul><ul><li>A partially completed design that can be extended to solve a problem in a domain </li></ul></ul><ul><ul><ul><li>Horizontal vs. vertical </li></ul></ul></ul><ul><ul><li>Examples: </li></ul></ul><ul><ul><ul><li>Java Swing. Java Collections Framework </li></ul></ul></ul><ul><ul><ul><li>Microsoft’s MFC for Windows apps using C++ </li></ul></ul></ul>Verification (© T. Horton 2007)
  6. 6. Design Pattern <ul><li>Design pattern: a description of a problem that reoccurs and an outline of an approach to solving that problem </li></ul><ul><ul><li>Generally domain, language independent </li></ul></ul><ul><ul><ul><li>But often based in OO </li></ul></ul></ul><ul><ul><li>(Also, analysis patterns, process patterns,…) </li></ul></ul><ul><li>Seminal book from 1995: Design Patterns: Elements of Reusable Object-Oriented Software </li></ul><ul><ul><li>By Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides </li></ul></ul><ul><ul><li>The “Gang of Four” </li></ul></ul>Verification (© T. Horton 2007)
  7. 7. Design Patterns Are (and Aren’t) <ul><li>Name and description of a proven solution to a design problem </li></ul><ul><li>Documentation of a design decision </li></ul><ul><li>They’re not: </li></ul><ul><ul><li>Reusable code, class libraries, etc. (At a higher level) </li></ul></ul><ul><ul><li>Do not require complex implementations </li></ul></ul><ul><ul><li>Always the best solution to a given situation </li></ul></ul><ul><ul><li>Simply “a good thing to do” </li></ul></ul>Verification (© T. Horton 2007)
  8. 8. Describing Design Patterns <ul><li>The GoF defined a standard format </li></ul><ul><ul><li>Generally followed </li></ul></ul><ul><ul><li>Not just a UML diagram! </li></ul></ul><ul><li>Pattern Format (13 sections): </li></ul><ul><ul><li>Pattern name and classification </li></ul></ul><ul><ul><li>Intent: what’s it do? Rationale? </li></ul></ul><ul><ul><li>Also known as </li></ul></ul><ul><ul><li>Motivation </li></ul></ul><ul><ul><ul><li>A scenario that illustrates a sample problem and how this patterns helps solve it. </li></ul></ul></ul><ul><ul><li>Applicability </li></ul></ul><ul><ul><ul><li>For which situations can this be applied? </li></ul></ul></ul><ul><ul><li>Structure </li></ul></ul><ul><ul><ul><li>Graphical representation (e.g. UML) </li></ul></ul></ul>Verification (© T. Horton 2007)
  9. 9. Pattern Format (cont’d) <ul><ul><li>Participants </li></ul></ul><ul><ul><ul><li>Classes and objects, their responsibilities </li></ul></ul></ul><ul><ul><li>Collaborations </li></ul></ul><ul><ul><ul><li>How participants interact </li></ul></ul></ul><ul><ul><li>Consequences </li></ul></ul><ul><ul><li>Implementation </li></ul></ul><ul><ul><ul><li>Pitfalls, hints, techniques, language issues </li></ul></ul></ul><ul><ul><li>Sample code </li></ul></ul><ul><ul><ul><li>Code fragments that illustrate the pattern </li></ul></ul></ul><ul><ul><li>Known uses </li></ul></ul><ul><ul><ul><li>From real systems </li></ul></ul></ul><ul><ul><li>Related patterns </li></ul></ul><ul><ul><ul><li>Similar patterns, collaborating patterns </li></ul></ul></ul>Verification (© T. Horton 2007)
  10. 10. Example 1: Singleton Pattern <ul><li>Global variables are bad! </li></ul><ul><ul><li>Why? </li></ul></ul><ul><li>We are tempted to use global variables (no?) </li></ul><ul><ul><li>Why? </li></ul></ul>Verification (© T. Horton 2007)
  11. 11. Example 1: Singleton Pattern <ul><li>Context: Only one instance of a class is created. Everything in the system that needs this class interacts with that one object. </li></ul><ul><li>Controlling access: Make this instance accessible to all clients </li></ul><ul><li>Solution: </li></ul><ul><ul><li>How would you do this? Discuss and present! </li></ul></ul>Verification (© T. Horton 2007)
  12. 12. Singleton Pattern <ul><li>The singleton pattern’s solution </li></ul><ul><ul><li>The class has a static variable called theInstance (etc) </li></ul></ul><ul><ul><li>The constructor is made private (or protected) </li></ul></ul><ul><ul><li>Clients call a public operation getInstance() that returns the one instance </li></ul></ul><ul><ul><ul><li>This may construct the instance the very first time or be given an initializer </li></ul></ul></ul>Verification (© T. Horton 2007)
  13. 13. Singleton: Java implementation Verification (© T. Horton 2007) public class MySingleton { private static MySingleton theInstance = new MySingleton(); private MySingleton() { // constructor … } public static MySingleton getInstance() { return theInstance; } }
  14. 14. Example 2: <ul><li>A nested data structure </li></ul><ul><ul><li>We have item objects and item-group objects </li></ul></ul><ul><ul><ul><li>E.g. files and directories </li></ul></ul></ul><ul><ul><li>Group objects can contain items and other groups </li></ul></ul><ul><ul><li>nested to any level </li></ul></ul><ul><li>Common operations on groups or items </li></ul><ul><ul><li>E.g. getSize() returns either file-size or sum of all files stored beneath a directory </li></ul></ul><ul><li>Question: how do you do this class design? </li></ul>Verification (© T. Horton 2007)
  15. 15. Example 2: Composite pattern <ul><li>Use an interface or abstract class to represent a more generic for of item </li></ul><ul><ul><li>Something “nestable” – could be either a group-object or a single-item </li></ul></ul><ul><li>The operation is located here as an abstract method </li></ul><ul><li>“ Group objects” store a list of “nestable” objects </li></ul><ul><li>All subclasses of the generic class implement the operation </li></ul><ul><ul><li>Directly or on each thing a group contains </li></ul></ul>Verification (© T. Horton 2007)
  16. 16. Class Diagram for Composite Verification (© T. Horton 2007)
  17. 17. Operations on Group Objects <ul><li>PlayList contains a list of PlayableItems </li></ul><ul><li>PlayList.play() calls play() on each item for (int i=0; i<list.size(); ++i) { ( (PlayableItem) list.get(i) ).play(); } </li></ul><ul><li>Will call the Song.play() or PlayList.play() depending on what item i really is </li></ul>Verification (© T. Horton 2007)
  18. 18. Example 3: Stateful Behavior <ul><li>Problem statement: </li></ul><ul><ul><li>A “stateful object”: behavior varies depending on what state the object is currently in </li></ul></ul><ul><ul><li>Example: </li></ul></ul><ul><ul><ul><li>a Connection object has state { Closed, Open, Listening, …} </li></ul></ul></ul><ul><ul><ul><li>Connection.acknowledge() does different behavior depending on state of object </li></ul></ul></ul><ul><ul><ul><li>Other methods too! </li></ul></ul></ul><ul><li>Obvious solutions? Discuss and tell us </li></ul><ul><ul><li>What does acknowledge() look like inside? </li></ul></ul><ul><ul><li>Good inheritance-based solutions? </li></ul></ul>Verification (© T. Horton 2007)
  19. 19. The State Design Pattern <ul><li>Each Connection object has a “helper” object </li></ul><ul><ul><li>state attribute references abstract class / interface TCPstate </li></ul></ul><ul><li>Connection delegates requests to its state object </li></ul><ul><li>On each state-change, make state reference a new object of the proper subclass of TCPState </li></ul>Verification (© T. Horton 2007)
  20. 20. Pros and Cons? <ul><li>What are the design advantages of the State design pattern? </li></ul><ul><ul><li>Disadvantages? </li></ul></ul><ul><ul><li>Compared to “obvious” solution or your solution? </li></ul></ul><ul><ul><li>Can you describe these in terms of coupling and/or cohesion? </li></ul></ul><ul><li>Delegation </li></ul><ul><li>Popular Mottos (Are these relevant here? Why?) </li></ul><ul><ul><li>Prefer aggregation over inheritance </li></ul></ul><ul><ul><li>Code to interfaces not concrete classes </li></ul></ul>Verification (© T. Horton 2007)
  21. 21. Categories of Design Patterns <ul><li>Three common categories </li></ul><ul><ul><li>Creational </li></ul></ul><ul><ul><ul><li>We saw: Singleton </li></ul></ul></ul><ul><ul><ul><li>Others: Factory; Abstract Factory; Object Pool; etc. </li></ul></ul></ul><ul><ul><li>Structural </li></ul></ul><ul><ul><ul><li>We saw: Composite </li></ul></ul></ul><ul><ul><ul><li>Others: Façade; Adapter; Flyweight; Decorator; etc. </li></ul></ul></ul><ul><ul><li>Behavioral </li></ul></ul><ul><ul><ul><li>We saw: State </li></ul></ul></ul><ul><ul><ul><li>Others: Observer; Visitor; Command; Strategy; etc. </li></ul></ul></ul>Verification (© T. Horton 2007)
  22. 22. Example 4: Watching for State Changes <ul><li>Problem </li></ul><ul><ul><li>An object is responsible for storing and managing information </li></ul></ul><ul><ul><li>Other objects “watch” it for changes, and may display changes etc. </li></ul></ul><ul><ul><ul><li>Such objects come and go. May be many of these. </li></ul></ul></ul><ul><ul><li>Other objects may get updates and need to be connected to the first object and call its update operations </li></ul></ul><ul><li>Goals: </li></ul><ul><ul><ul><li>Loose coupling. Keep first object from being tightly coupled with some large set of “watcher” classes. Support dynamic changes. </li></ul></ul></ul>Verification (© T. Horton 2007)
  23. 23. This Problem in GUIs <ul><li>GUIs have this exact situation </li></ul><ul><ul><li>Button object </li></ul></ul><ul><ul><ul><li>State/Events: pressed, not pressed </li></ul></ul></ul><ul><ul><ul><li>Watchers: any event handlers </li></ul></ul></ul><ul><ul><li>List of text-choices (e.g. Swing’s JList) </li></ul></ul><ul><ul><ul><li>State: list of items, what’s selected </li></ul></ul></ul><ul><li>How’s this done in Java Swing? Or Windows Forms and C#? </li></ul>Verification (© T. Horton 2007)
  24. 24. Solutions: Observer, MVC <ul><li>Model-View-Controller (MVC) </li></ul><ul><ul><li>An old design pattern </li></ul></ul><ul><ul><li>Basis for simpler design pattern </li></ul></ul><ul><li>Observer Design Pattern </li></ul><ul><ul><li>an Observable object </li></ul></ul><ul><ul><ul><li>It (or a “helper” object) maintains a list of Observers </li></ul></ul></ul><ul><ul><ul><li>Has attach operation that’s called by an Observer (etc.) </li></ul></ul></ul><ul><ul><ul><li>Will call update on each Observer when needed </li></ul></ul></ul><ul><ul><li>an Observer object (probably an interface) </li></ul></ul><ul><ul><ul><li>registers / attaches to an Observable </li></ul></ul></ul><ul><ul><ul><li>Has update operation that will respond to changes in Observable </li></ul></ul></ul>Verification (© T. Horton 2007)
  25. 25. Observer Object Interactions Verification (© T. Horton 2007)
  26. 26. Analysis of Observer <ul><li>Explain the advantages of the Observer DP </li></ul><ul><ul><li>Can you explain this in terms of coupling and cohesion? </li></ul></ul><ul><ul><li>Can you say something about extensibility? (E.g. more observers added to the system later) </li></ul></ul><ul><ul><li>Can you talk about this in terms of the general design goal of separation of concerns ? </li></ul></ul>Verification (© T. Horton 2007)
  27. 27. Some Newer Architecture Frameworks <ul><li>Design patterns represent “best practices” </li></ul><ul><ul><li>Usually for what I call “design in the small” </li></ul></ul><ul><li>Software Architectures </li></ul><ul><ul><li>Larger organization of components </li></ul></ul><ul><ul><li>Frameworks include: </li></ul></ul><ul><ul><ul><li>Components we’re given as building blocks </li></ul></ul></ul><ul><ul><ul><li>Standard forms of behavior between components </li></ul></ul></ul><ul><ul><li>Some frameworks for web-based applications </li></ul></ul><ul><ul><ul><li>AJAX and Web. 2.0 </li></ul></ul></ul><ul><ul><ul><li>Ruby on Rails </li></ul></ul></ul><ul><ul><ul><li>Webservices (.NET and JSEE) </li></ul></ul></ul>Verification (© T. Horton 2007)
  28. 28. Some General Issues <ul><li>Client/Server architectures </li></ul><ul><li>Web interface through the browser </li></ul><ul><ul><li>Client-side processing (Javascript) </li></ul></ul><ul><li>Server needs </li></ul><ul><ul><li>Underlying database management </li></ul></ul><ul><ul><li>Server side processing </li></ul></ul><ul><ul><ul><li>Security, authorization, etc. </li></ul></ul></ul><ul><ul><ul><li>Transaction processing </li></ul></ul></ul><ul><ul><ul><li>Business logic </li></ul></ul></ul><ul><ul><ul><li>Etc. </li></ul></ul></ul>Verification (© T. Horton 2007)
  29. 29. AJAX and Web 2.0 <ul><li>Have a look at: </li></ul><ul><ul><li>Ajax: A New Approach to Web Applications, by Jesse James Garrett http://www.adaptivepath.com/publications/essays/archives/000385.php </li></ul></ul><ul><ul><li>Building Rich Web Applications with Ajax, by Linda Dailey Paulson. (From IEEE Software .) http://www.computer.org/portal/cms_docs_ieeecs/ieeecs/images/ajax.pdf </li></ul></ul><ul><ul><li>Book: Pragmatic Ajax: A Web 2.0 Primer (Overview) </li></ul></ul>Verification (© T. Horton 2007)
  30. 30. Usual Model for Web Apps <ul><li>Interact with a page </li></ul><ul><ul><li>Maybe enter info in forms, then hit Submit </li></ul></ul><ul><li>Server receives the URL (and forms data etc.) </li></ul><ul><ul><li>Processes information, and then… </li></ul></ul><ul><li>New page is returned to the browser and loaded </li></ul><ul><ul><li>Even small changes require entire page to be re-loaded </li></ul></ul><ul><li>(The web as a hypertext system, not a SW app platform) </li></ul>Verification (© T. Horton 2007)
  31. 31. New Model: Web 2.0, Ajax <ul><li>Web 2.0: just a buzzword? </li></ul><ul><ul><li>See Wikipedia for the history </li></ul></ul><ul><li>In part, Web 2.0 is about </li></ul><ul><ul><li>The web as a computing platform </li></ul></ul><ul><li>Ajax </li></ul><ul><ul><li>Named from “Asynchronous JavaScript and XML” </li></ul></ul><ul><ul><li>Used to refer to two things </li></ul></ul><ul><ul><ul><li>Collection of “old” Web-related technologies </li></ul></ul></ul><ul><ul><ul><li>A web-based SW architecture </li></ul></ul></ul><ul><li>Example apps: Google maps; new Yahoo mail </li></ul>Verification (© T. Horton 2007)
  32. 32. Ajax Component Technologies <ul><li>Presentation with XHTML and CSS </li></ul><ul><li>Dynamic page display and interaction using the DOM (Document Object Model) in the browser </li></ul><ul><li>Data interchange and processing with XML and XSLT </li></ul><ul><li>Asynchronous data retrieval with XMLHttpRequest (or equivalent) </li></ul><ul><li>JavaScript </li></ul><ul><ul><li>Ties it all together on the server-side </li></ul></ul>Verification (© T. Horton 2007)
  33. 33. What’s Different than the Old Model? <ul><li>Small events </li></ul><ul><ul><li>Small request to the server that makes small change to the page </li></ul></ul><ul><ul><li>No refresh of complete page! </li></ul></ul><ul><li>Asynchronous processing </li></ul><ul><ul><li>Browser doesn’t block while waiting </li></ul></ul><ul><ul><li>Key is a XMLHttpRequest (Javascript to server) </li></ul></ul><ul><li>Richer events on the client-side </li></ul><ul><ul><li>Browser recognizes and shares events much like a GUI-application does </li></ul></ul>Verification (© T. Horton 2007)
  34. 34. Old vs. New <ul><li>from Garrett’s web article </li></ul>Verification (© T. Horton 2007)
  35. 35. Page Modification in Ajax <ul><li>From Pragmatic Ajax </li></ul><ul><li>See explanation given in class </li></ul>Verification (© T. Horton 2007)
  36. 36. Ajax Support <ul><li>Server-side “remoting” </li></ul><ul><ul><li>Frameworks and toolkits to support communcations more easily </li></ul></ul><ul><li>Client-side </li></ul><ul><ul><li>GUI toolkits for Ajax apps (Java Script) </li></ul></ul><ul><li>More complete toolkits for building larger apps </li></ul><ul><ul><li>Rails, Tapestry, Dojo, Django, … </li></ul></ul><ul><ul><li>SEAS Final 4 Bracket Challenge </li></ul></ul><ul><ul><ul><li>Aptana, includes supprot for Ajax/Javascript libraries </li></ul></ul></ul><ul><ul><ul><li>Used Dojo and Yahoo UI </li></ul></ul></ul>Verification (© T. Horton 2007)
  37. 37. Ruby on Rails <ul><li>A framework for developing web apps </li></ul><ul><ul><li>Remember what a framework is? </li></ul></ul><ul><ul><li>Rails derived from a real commercial application </li></ul></ul><ul><li>Features </li></ul><ul><ul><li>client-side dynamic pages (DHTML) </li></ul></ul><ul><ul><li>good integration with database on the server </li></ul></ul><ul><ul><li>coding written in Ruby </li></ul></ul><ul><ul><li>based on the MVC architecture </li></ul></ul><ul><ul><li>AJAX characteristics </li></ul></ul><ul><li>Book: Agile Web Development with Rails </li></ul>Verification (© T. Horton 2007)
  38. 38. Concepts behind Rails <ul><li>More slogans! </li></ul><ul><ul><li>DRY: Don’t repeat yourself </li></ul></ul><ul><ul><ul><li>Things defined in code in one place only </li></ul></ul></ul><ul><ul><li>Convention over Configuration </li></ul></ul><ul><ul><ul><li>Code less by submitting to defaults </li></ul></ul></ul><ul><ul><ul><li>Often depends on naming conventions </li></ul></ul></ul><ul><ul><ul><li>Can override these if needed </li></ul></ul></ul>Verification (© T. Horton 2007)
  39. 39. ORM in Rails <ul><li>Challenges putting together an OO program with class design and a set of database tables </li></ul><ul><ul><li>ORM: object-relational mapping </li></ul></ul><ul><li>Rails version of ORM called Active Record </li></ul><ul><ul><li>Define class and get both Ruby class and DB table </li></ul></ul><ul><ul><li>Get certain methods for free </li></ul></ul><ul><ul><li>Other parts of the architecture rely on naming conventions etc. to make all work together with far less programming effort </li></ul></ul>Verification (© T. Horton 2007)
  40. 40. Rails and MVC Architecture <ul><li>MVC is a design pattern for interactive applications </li></ul><ul><li>Model: just like in Observer </li></ul><ul><ul><li>Also enforces business rules </li></ul></ul><ul><li>View: displays the user-interface </li></ul><ul><li>Controller </li></ul><ul><ul><li>receives external events from the user etc. </li></ul></ul><ul><ul><li>interact with model and view </li></ul></ul><ul><li>Many other frameworks also use MVC </li></ul><ul><ul><li>E.g. Struts, JavaServer Faces </li></ul></ul>Verification (© T. Horton 2007)
  41. 41. MVC in Rails Diagram <ul><li>(from book Agile Web Development with Rails) </li></ul>Verification (© T. Horton 2007)
  42. 42. Views, Controllers in Rails <ul><li>First step: Rails code generation… </li></ul><ul><li>Views: </li></ul><ul><ul><li>You write HTML pages with embedded Ruby </li></ul></ul><ul><ul><li>Your code interacts with the controller </li></ul></ul><ul><li>Controller: </li></ul><ul><ul><li>You write code focused on application-specific functions </li></ul></ul><ul><ul><li>Rails provides </li></ul></ul><ul><ul><ul><li>routing events/requests from pages/views to your handlers </li></ul></ul></ul><ul><ul><ul><li>sessions, caching, … </li></ul></ul></ul>Verification (© T. Horton 2007)
  43. 43. Summary <ul><li>The high-level big picture here is: </li></ul><ul><ul><li>Certain kinds of applications… </li></ul></ul><ul><ul><ul><li>(E.g. web-applications, DB-centered, etc.) </li></ul></ul></ul><ul><ul><li>… benefit from particular architecture models… </li></ul></ul><ul><ul><ul><li>(E.g. Ajax ideas) </li></ul></ul></ul><ul><ul><li>… and we use frameworks at the architecture level… </li></ul></ul><ul><ul><ul><li>(E.g. Rails or AJAX environments) </li></ul></ul></ul><ul><ul><li>… and lower-level design and coding “tools” </li></ul></ul><ul><ul><ul><li>(E.g. specific IDEs, toolkits, GUI libraries,…) </li></ul></ul></ul><ul><ul><li>… to build larger, better systems quicker. </li></ul></ul>Verification (© T. Horton 2007)
  44. 44. Summary (2) <ul><li>Standard best-practices and techniques at the design/architecture level </li></ul><ul><ul><li>Design patterns </li></ul></ul><ul><ul><li>Higher-level approaches like AJAX </li></ul></ul><ul><li>Experienced developers learn: </li></ul><ul><ul><li>the names, conventions, strategies,… </li></ul></ul><ul><ul><li>how to use design patterns to describe and implement parts of the problem that others have already addressed </li></ul></ul><ul><ul><li>how to work within a larger environment or framework </li></ul></ul>Verification (© T. Horton 2007)
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×