CSCE 740 Software Engineering Lecture 10 Rails Projects

  • Slides: 20
Download presentation
CSCE 740 Software Engineering Lecture 10 Rails Projects Topics • Saa. S Readings: Saa.

CSCE 740 Software Engineering Lecture 10 Rails Projects Topics • Saa. S Readings: Saa. S book Ch 2, 4 February 24, 2014

Saa. S round 2 - Last Time § RAILS § Fig 2. 1 100,

Saa. S round 2 - Last Time § RAILS § Fig 2. 1 100, 000 view Finish-up Last Lecture Slides § Slides ? ? ? New § Summary of Rails § Client-server § HAML § HTTP & URIs § Cucumber § HTML & CSS § Capybara § HAML – 2– Next Time: CSCE 740 Spring 2014

Rails Summary from Last time 9. The MVC Architecture 10. Components of Rails 11.

Rails Summary from Last time 9. The MVC Architecture 10. Components of Rails 11. REST 12. a New Rails Project 13. Rails Application Dir 14. Rails Appl Directory II 15. Directory: app 18. Configuring a DB 19. Creating a DB 20. Starting Webrick 21. rails generate 22. Setting the Application Home Page 23. Rails Scaffolding 28. What’s Next? 29. Rails Summary 30. Active Record 16. HAML - lightweight 31. … CS 169 Saasbook: Fox and Patterson – 3– CSCE 740 Spring 2014

Chapter 2 Saa. S Architecture Review – 4– Saasbook Fox, Armando; Patterson, David (2014

Chapter 2 Saa. S Architecture Review – 4– Saasbook Fox, Armando; Patterson, David (2014 -01 -31). CSCE 740 Spring 2014

Review Fig 2. 3 – URI + HTTPmethod – 5– Saasbook Fox, Armando; Patterson,

Review Fig 2. 3 – URI + HTTPmethod – 5– Saasbook Fox, Armando; Patterson, David (2014 -01 -31). CSCE 740 Spring 2014

Fig 2. 4 50, 000 ft view – 6– CSCE 740 Spring 2014

Fig 2. 4 50, 000 ft view – 6– CSCE 740 Spring 2014

Fig 2. 6 Refining Steps 2 and 3 – 7– Saasbook Fox, Armando; Patterson,

Fig 2. 6 Refining Steps 2 and 3 – 7– Saasbook Fox, Armando; Patterson, David (2014 -01 -31). CSCE 740 Spring 2014

Lamp § Early Saa. S sites were created using the Perl and PHP scripting

Lamp § Early Saa. S sites were created using the Perl and PHP scripting languages, whose § availability coincided with the early success of Linux, an open-source operating system, and My. SQL, an open-source database. § Thousands of sites are still powered by the LAMP Stack—Linux, Apache, My. SQL, and PHP or Perl. – 8– Saasbook Fox, Armando; Patterson, David (2014 -01 -31). CSCE 740 Spring 2014

Scalability – 9– Saasbook Fox, Armando; Patterson, David (2014 -01 -31). CSCE 740 Spring

Scalability – 9– Saasbook Fox, Armando; Patterson, David (2014 -01 -31). CSCE 740 Spring 2014

Fig 2. 8 5, 000 ft view Refining Middleware – 10 – CSCE 740

Fig 2. 8 5, 000 ft view Refining Middleware – 10 – CSCE 740 Spring 2014

Architectures for Web Apps Left - page controller Sinatra Center top – front controller

Architectures for Web Apps Left - page controller Sinatra Center top – front controller J 2 EE servlets Center bottom – PHP Right – MVC used by rails – 11 – Saasbook Fox, Armando; Patterson, David (2014 -01 -31). CSCE 740 Spring 2014

Fig 2. 10 – 5, 000 ft view – 12 – Saasbook Fox, Armando;

Fig 2. 10 – 5, 000 ft view – 12 – Saasbook Fox, Armando; Patterson, David (2014 -01 -31). CSCE 740 Spring 2014

2. 6 500 Feet: Active Record for Models Active Record architectural pattern § a

2. 6 500 Feet: Active Record for Models Active Record architectural pattern § a single instance of a model class (in our case, the entry for a single movie) corresponds to a single row in a specific table – 13 – Saasbook Fox, Armando; Patterson, David (2014 -01 -31). CSCE 740 Spring 2014

CRUD § Create a new row in the table (representing a new object), §

CRUD § Create a new row in the table (representing a new object), § Read an existing row into a single object instance, § Update an existing row with new attribute values from a modified object instance, § Delete a row (destroying the object’s data forever). – 14 – Saasbook Fox, Armando; Patterson, David (2014 -01 -31). CSCE 740 Spring 2014

2. 7 500 Feet: Routes, Controllers, and REST - In 2000, Roy Fielding proposed,

2. 7 500 Feet: Routes, Controllers, and REST - In 2000, Roy Fielding proposed, in his Ph. D. dissertation, a consistent way to map requests to actions that is particularly well suited to a serviceoriented architecture. § identify the various entities manipulated by a Web app as resources, and § design the routes so that any HTTP request would contain all the information necessary to identify both a particular resource and the action to be performed on it. § In Rails, the route mappings are generated by code in the file config/routes. rb, – 15 – Saasbook Fox, Armando; Patterson, David (2014 -01 -31). CSCE 740 Spring 2014

Fig 2. 12 Rake Routes Summary Operation Index (list) movies index Read (show) movie

Fig 2. 12 Rake Routes Summary Operation Index (list) movies index Read (show) movie Display fill-in form new Method & URI action GET /movies/: id show GET /movies/new Create from filled-in form POST /movies create Display form to edit GET /movies/: id/edit Update movie PUT /movies/: id update Destroy movie DELETE /movies/: id destroy – 16 – Saasbook Fox, Armando; Patterson, David (2014 -01 -31). CSCE 740 Spring 2014

Fig 2. 13 Restful vs non. Restful Login to site • Non-RESTful site -

Fig 2. 13 Restful vs non. Restful Login to site • Non-RESTful site - POST /login/dave • URI RESTful site - POST /login/dave Welcome page • Non-RESTful - GET /welcome • URI RESTful - GET /user/301/welcome Add item ID 427 to cart • Non-RESTful - POST /add/427 • URI RESTful - POST /user/301/add/427 – 17 – Saasbook Fox, Armando; Patterson, David (2014 -01 -31). CSCE 740 Spring 2014

View cart • Non-RESTful - GET / cart • URI RESTful - GET /user/301/cart

View cart • Non-RESTful - GET / cart • URI RESTful - GET /user/301/cart Checkout • Non-RESTful - POST /checkout • URI RESTful - POST /user/301/checkout – 18 – Saasbook Fox, Armando; Patterson, David (2014 -01 -31). CSCE 740 Spring 2014

ELABORATION: REST vs. SOAP vs. WS-* SOA standards bodies created committees to develop standards

ELABORATION: REST vs. SOAP vs. WS-* SOA standards bodies created committees to develop standards for SOA interoperation. One approach resulted in a collection of elaborate protocols for Web Services including WS-Discovery, WS-Description, and others, sometimes collectively called WS-* and jokingly called “WS-Deathstar” by David Heinemeier Hansson, the creator of Rails. The competing SOAP standard (Simple Object Access Protocol) was a bit simpler but still far more complex than REST. By and large, practicing developers perceived SOAP and WS-* as overdesigned committee-driven standards burdened by the archaic design stance – 19 – Saasbook Fox, Armando; Patterson, David (2014 -01 -31). CSCE 740 Spring 2014

Fig 2. 14 500 ft – Template views HAML Haml HTML %br{: clear =>

Fig 2. 14 500 ft – Template views HAML Haml HTML %br{: clear => ’left’} <br clear=”left”/> %p. foo Hello <p class=”foo”>Hello</p> %p#foo Hello <p id=”foo”>Hello</p> . foo <div class=”foo”>. . . </div> #foo. bar – 20 – <div id=”foo” class=”bar”>. . . </div> Saasbook Fox, Armando; Patterson, David (2014 -01 -31). CSCE 740 Spring 2014