CSC/ECE 517 Spring 2013/ch1a 1b mh: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 12: Line 12:


The Model–view–controller architecture is a software design pattern which separates the actual representation of data from the user's interaction with it, including both the user's view of the data and the actual input method. The three essential parts of this architecture, in brief, are:
The Model–view–controller architecture is a software design pattern which separates the actual representation of data from the user's interaction with it, including both the user's view of the data and the actual input method. The three essential parts of this architecture, in brief, are:


Model: consists of the actual data and the rules for manipulating this data.
Model: consists of the actual data and the rules for manipulating this data.
Line 18: Line 19:


View: the actual visual representation of the data and interface provided to the user.
View: the actual visual representation of the data and interface provided to the user.


This architecture provides several advantages, , including seperation of functionality, which facilitates easy maintenance, and reusability. Reusability is addressed in one of Rails central axioms: [http://en.wikipedia.org/wiki/Don%27t_repeat_yourself DRY], or Don't Repeat Yourself.  
This architecture provides several advantages, , including seperation of functionality, which facilitates easy maintenance, and reusability. Reusability is addressed in one of Rails central axioms: [http://en.wikipedia.org/wiki/Don%27t_repeat_yourself DRY], or Don't Repeat Yourself.  

Revision as of 00:45, 8 February 2013

Ruby CRUD - Update and Destroy

Introduction

Modern application delivery has undergone drastic changes in recent years, and the introduction of SaaS, or Software-as-a-Service, provides a way for software to be provided "on demand" to a user as needed. Essentially, what this means, is that users interact with a given application through a web based interface referred to as a "thin client", and another computer actually performs the applications computational tasks. The thin client is primarly tasked with displaying the application interface, and relaying the users actions back to the primary computational unit. Such a delivery model has many advantages, such as eliminating the need to install an application locally, and reducing the computational demand on the local client. In addition, this allows the hosting computer to provide an indeterminate number of interfaces to multiple users, as well as being able to free the resources used supplying the service once the user no longer needs them. The architecture used for many SaaS solutions is based on the "Model-View-Controller" architecture. This architecture is modular, easily expandable, very flexible, and many solutions have been created to help software engineers develop SaaS enviornments and by extension the delivery methods needed to produce these products. This article is primarily focused on the development suite, Ruby on Rails, and in particular, 2 types of actions used by this software.

Rails is a framework application development suite for SaaS development, based on the object-oriented language, Ruby, and based on the afore-mentioned Model-View-Controller architecture. Rails favors the axiom of "convention over configuration", and developers are encouraged to learn the conventions of Rails, and let the framework handle the actual implementation, an approach which greatly increases software development productivity.

Overview of Model-View-Controller Architecture

The Model–view–controller architecture is a software design pattern which separates the actual representation of data from the user's interaction with it, including both the user's view of the data and the actual input method. The three essential parts of this architecture, in brief, are:


Model: consists of the actual data and the rules for manipulating this data.

Controller: provides an interface between the view and the model, preparing the data representation for each of the other 2 components.

View: the actual visual representation of the data and interface provided to the user.


This architecture provides several advantages, , including seperation of functionality, which facilitates easy maintenance, and reusability. Reusability is addressed in one of Rails central axioms: DRY, or Don't Repeat Yourself.

CRUD

Edit/Update


locate the object
	@object = Object.find params(:id)

update it
	@object.update_attributes!(params[:param])

inform of successful update
	flash[:notice]

go to the updated object
	redirect_to object_path(@object)

Comparison of Update and Create Actions

Destroy

locate the object
        @object = Object.find params(:id)

destroy it
	@object.destroy

inform of successful update
	flash[:notice] = "Object '#{@object.title}' deleted."

go to the updated object
	redirect_to object_path(@object)


Pitfalls in MVC Design

Migration to Service Oriented Architecture

Summary