Strategies for Rapid Web Prototyping. Ruby on Rails. Clemens H. Cap

Similar documents
Contents in Detail. Foreword by Xavier Noria

Web Technologies VU ( ) Vedran Sabol. Nov 13, ISDS, TU Graz. Vedran Sabol (ISDS, TU Graz) Web Technologies Nov 13, / 60

Web Application Expectations

Front End Programming

MVC: Model View Controller

Introduction and first application. Luigi De Russis. Rails 101

Ruby on Rails. SITC Workshop Series American University of Nigeria FALL 2017

The Art of Metaprogramming in Java. Falguni Vyas Dec 08, 2012

Teaching Ruby on Rails Dr Bruce Scharlau Computing Science Department University of Aberdeen Aberdeen, AB24 3UE

Ajax On Rails: Build Dynamic Web Applications With Ruby By Scott Raymond READ ONLINE

Symfony is based on the classic web design pattern called the MVC pattern

Rails: MVC in action

Rails: Views and Controllers

20486-Developing ASP.NET MVC 4 Web Applications

PHP MVC Framework (CakePHP)

Upload to your web space (e.g., UCSC) Due this Thursday 4/8 in class Deliverable: Send me an with the URL Grading:

Django with Python Course Catalog

Overview of the Ruby Language. By Ron Haley

Ruby on Rails 3 March 14th, 2011 Ken Li Allison Pon Kyra Leimert Matt Delaney Edward Bassett

iflame INSTITUTE OF TECHNOLOGY

widgets, events, layout loosely similar to Swing test browser, or plugin for testing with real browser on local system

Lecture 4. Ruby on Rails 1 / 49

Developing ASP.NET MVC 5 Web Applications. Course Outline

Cheap, Fast, and Good You can have it all with Ruby on Rails

Now go to bash and type the command ls to list files. The unix command unzip <filename> unzips a file.

Developing ASP.Net MVC 4 Web Application

20486: Developing ASP.NET MVC 4 Web Applications

COURSE 20486B: DEVELOPING ASP.NET MVC 4 WEB APPLICATIONS

Comprehensive AngularJS Programming (5 Days)

Ruby on Rails TKK, Otto Hilska

20486: Developing ASP.NET MVC 4 Web Applications (5 Days)

CNIT 129S: Securing Web Applications. Ch 3: Web Application Technologies

Pro ASP.NET MVC 2 Framework

welcome to BOILERCAMP HOW TO WEB DEV

Introduction to PHP. Handling Html Form With Php. Decisions and loop. Function. String. Array

Convention over Configuration

Developing ASP.NET MVC 4 Web Applications

Lecture 4. Ruby on Rails 1 / 52

Java Applets, etc. Instructor: Dmitri A. Gusev. Fall Lecture 25, December 5, CS 502: Computers and Communications Technology

Advance Mobile& Web Application development using Angular and Native Script

All India Council For Research & Training

Review. Fundamentals of Website Development. Web Extensions Server side & Where is your JOB? The Department of Computer Science 11/30/2015

OOP with PHP. Roman Bednarik

Contents. Contents... XI

Developing ASP.NET MVC 4 Web Applications

Course 20486B: Developing ASP.NET MVC 4 Web Applications

Overview of Web Application Development

Ruby on Rails Welcome. Using the exercise files

Full Stack Web Developer

NetBeans IDE Field Guide

Visual Studio Course Developing ASP.NET MVC 5 Web Applications

RESTFUL WEB SERVICES - INTERVIEW QUESTIONS

Web Frameworks MMIS 2 VU SS Denis Helic. March 10, KMI, TU Graz. Denis Helic (KMI, TU Graz) Web Frameworks March 10, / 18

ASP.NET MVC Training

appendix B: Working with Ruby on Rails

Developing ASP.NET MVC 5 Web Applications

OO and Ahh! An Introduction to Object Oriented Programming With PHP. Division 1 Systems. John Valance. Copyright John Valance Division 1 Systems

Web Presentation Patterns (controller) SWEN-343 From Fowler, Patterns of Enterprise Application Architecture

Object-Relational Mapping

Project. Minpeng Zhu

Database Application Architectures

User Guide Zend Studio for Eclipse V6.1

Oracle Application Express: Administration 1-2

generates scaffolding/framework for models, views

CERTIFICATE IN WEB PROGRAMMING

Simple AngularJS thanks to Best Practices

Chapter 10 Web-based Information Systems

DevShala Technologies A-51, Sector 64 Noida, Uttar Pradesh PIN Contact us

20486 Developing ASP.NET MVC 5 Web Applications

Having Fun with Social Coding. Sean Handley. February 25, 2010

Client Side MVC with Backbone & Rails. Tom

(Worth 50% of overall Project 1 grade)

Etanova Enterprise Solutions

Database Driven Web 2.0 for the Enterprise


Get in Touch Module 1 - Core PHP XHTML

Introduction to Web Concepts & Technologies

Implementing a Numerical Data Access Service

CS169.1x Lecture 6: Basic Rails" Fall 2012"

Web Application Development (WAD) V th Sem BBAITM(Unit-1) By: Binit Patel

Web Applications. Software Engineering 2017 Alessio Gambi - Saarland University

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 14 Database Connectivity and Web Technologies

How To Redirect A Webpage Cheat Sheet

An Overview of. Eric Bollens ebollens AT ucla.edu Mobile Web Framework Architect UCLA Office of Information Technology

10264A CS: Developing Web Applications with Microsoft Visual Studio 2010

Full Stack Developer with Java

Pro JavaScript. Development. Coding, Capabilities, and Tooling. Den Odell. Apress"

PRISMTECH. RESTful DDS. Expanding the reach of the information backbone. Powering Netcentricity

Full Stack Web Developer

COMP 250 Winter 2011 Reading: Java background January 5, 2011

Lecture 10(-ish) Web [Application] Frameworks

Ruby on Rails 3. Robert Crida Stuart Corbishley. Clue Technologies

Standard 1 The student will author web pages using the HyperText Markup Language (HTML)

Developing ASP.NET MVC 4 Web Applications

A Closer Look at XPages in IBM Lotus Domino Designer 8.5 Ray Chan Advisory I/T Specialist Lotus, IBM Software Group

This course is designed for web developers that want to learn HTML5, CSS3, JavaScript and jquery.

Boldface numbers indicate illustrations, code listings, and tables.

DIGIT.B4 Big Data PoC

Ruby on Rails for PHP and Java Developers

Java SE7 Fundamentals

Transcription:

Strategies for Rapid Web Prototyping Ruby on Rails

Strategies for Rapid Web Prototyping DRY: Don't repeat yourself Convention over Configuration Separation of Concern Templating MVC: Model View Controler CRUD and Rest Scaffolding

DRY: Don't Repeat Yourself OAOO: Once And Only Once Information in the specification of a system should not be duplicated Modification at one place should not be allowed to produce inconsistency at another place Do not use copy and paste while programming Usually implemented with reflection techniques allowing a programming language to analyze it's own objects metadata Examples Ruby: Describe an object, DB glue code is generated by reflection Counterexamples PHP Web: Metadata in SQL create statement, SQL query, PHP object Validation: Duplicate code on server and client

Convention over Configuration Prefer convention (ie. useful standards and defaults) over the necessity of having to configure every minuscule detail Issue: Documentation Programmer must know all conventions otherwise there is surprise over unexpected convention depent d behaviour Examples: Default behaviour in Prototype Rails: Every table has a primary key of name ID and type integer Rails: Object of name Car described in /app/models/car.rb table name is customers Rails: If object Car has 1:N relation to object Driver then table Drivers expects a key named car_id

Separation of Concern Separate a computer program into distinct features Implement every feature in a single component Minimize overlap between different components Examples: Object orientation: i Split system into single objects Procedural programming: Split system into procedures with I/O behavior MVC: Split application into content, presentation and interaction HTML / CSS / JS: Content, presentation, dynamics

Templating Template: Content with "holes" Object: Attributes for filling in object Template Description Advantages: Indepent change of look and feel Separation of areas of competency Template Engine HTML Text

MVC Pattern Controller User Event generated by View Interaction Requesting a view refresh Activate Setters of Business Logic View Activate Getters of Business Logic Model

MVC Pattern as used in Rails Dispatch Controller Method Rails Dispatcher Controller Mouse Click User Event generated by View Interaction Requesting a view refresh Activate Setters of Business Logic View Interaction View Activate Getters of Business Logic Model

CRUD & REST CRUD Named after the basic 4 operations on persistent storage Create, Read, Update, Delete Can be applied to all forms of data base architectures Architectural concept for data intensive web applications REST Representational State Transfer State of application is abstracted into resources Resource identified by a URL Client server protocol which is stateless and cacheable Set of well defined operations Commonly implemented on top of HTTP (GET, POST, PUT and others)

Scaffolding Method for rapid prototyping of web applications Provide metadata information on the objects Generate code for model: persistence: corresponding ruby object via reflection API CRUD: basic persistence operations presentation: tables for output forms for input links for manipulation glue code for paging etc.

Ruby on Rails

Who is who? Rails Application Framework for web development Main target: Agile programming Uses most of the previously outlined principles Written in Ruby, uses Javascript snippets Ail Agile programming: Continuous stream of results not deadline oriented results Regular adaption to changing requirements not frozen specifications Only measure of progress is working software Result driven not plan driven Close customer cooperation

Who is who? Ruby Interpreted programming language Functional can store lambda functions in a variable Object oriented with class based and prototype based inheritance Imperative classical features as in C, Java, etc. Duck typing do not check class membership but presence of method at time of interpretation i Issue: No compile time type check Automated garbage collection Implementations Interpreter based: Virtual machine based: Read code and execute Translate to bytecode, execute in Ruby VM

MVC Pattern Classical Design Pattern Model Represents the business logic Stores the state of the application View Controller Represents the model for the user Allows the user to change the model Several views and controllers per model are possible Data encapsulation Change of data only via methods of the model Supports semantic correctness inside of the model Supports consistency between representation and model

Model: Controller: Action: message echo say_hello Hello World Example get http://localhost:3000/echo/say_hello Controller in app/controllers/echo_controller.rb class EchoController < ApplicationController def say_hello @msgobj = Message.new @when = Time.now View in app/views/echo/say_hello.erb Model in app/models/message.rb <html><head><title>test</title></head> <body> <h1><%= @msgobj.gettext %></h1> at <%= @when %> </body></html> class Message def gettext return "Hello World" getter

Model: Controller: Action: message echo say_hello Hello World Example (1) dispatch to correct controller file get http://localhost:3000/echo/say_hello (3) invoke correct action method Ok?? (6) request update using correct view template file View in app/views/echo/say_hello.erb Controller in app/controllers/echo_controller.rb (2) select correct class in file class EchoController < ApplicationController def say_hello @msgobj = Message.new @when = Time.now (7) controller provides references to model (@msgobj) and private date (@when) (4) class name leads to file Model in app/models/message.rb (5) controller invokes setter / constr. in model <html><head><title>test</title></head> <body> <h1><%= @msgobj.gettext %></h1> at <%= @when %> </body></html> (9) view invokes getter of model (8) class name leads to file class Message def gettext return "Hello World" getter

Model: Controller: Action: message echo say_hello Hello World Example (1) dispatch to correct controller file get http://localhost:3000/echo/say_hello (3) invoke correct action method (6) request update using correct view template file View in app/views/echo/say_hello.erb Controller in app/controllers/echo_controller.rb (2) select correct class in file class EchoController < ApplicationController def say_hello @msgobj = Message.new @when = Time.now (7) controller provides references to model (@msgobj) and private date (@when) (4) class name leads to file Model in app/models/message.rb (5) controller invokes setter / constr. in model <html><head><title>test</title></head> <body> <h1><%= @msgobj.gettext %></h1> at <%= @when %> </body></html> (9) view invokes getter of model (8) class name leads to file class Message def gettext return "Hello World" getter

Structure Dispatch: From URL to Action URL contains name of controller and action Controller abc implemented in file abc_controller.rb Action is function / method of this controller Update: From Action to View Every controller has directory of same name with view templates Action uvw has view template uvw.erb View template is HTML with embedded Ruby tags Naming: From class name to class definition Class Xyz is defined in file xyz.rb Wllk Well known from Java Note: Windows is case insensitive, Linux is case sensitive

Generation Many code portions are generated using diverse scripts Eg: Basic structure for application me: rails me Generates directory me and subdirectories i MVC basis: Area for Helper: Area for Data Bases Area for Documentation Area for Testing app/models, app/views, app/controllers app/helpers Eg: Controller contro: ruby script/generate controller contro

Database Conventions Application me Connected databases me_development me_test me_production During development During testing During production Changes to databases (ie. schema versioning) fully supported Allows on the fly up and downgrade of DB schema Persistent model mod Model mod Database table mods SQL Create File db/mods.sql

Modifications Eg: Change the DB schema Adapt the meta information and regenerate code DB adaption and code generation to reflect the changes Eg: remove Usecases Eg: No edit for a certain model Manually: Remove action from controller and link from view Eg: Reduction / Adaption of form Edit a generic, autogenerated form file Provide additional info for automated code generation Eg: Input data validation

Modelling Relationships 2 objects in a 1:n relationship Eg: Author Message Generate both tables Scaffolding for both objects Add associations in both directions class Message < ActiveRecord::Base belongs_to :author, :class_name => "User", :foreign_key => "author_id" Adapt views of the controller list: Also show author of a message _form: Also edit author of the message show: Also show author as such