Tutorial exercises

From mi-linux
Jump to navigationJump to search

XML and Web Services >> Tutorial exerices

Tutorial: Week 2 – MVC & Controllers

  • Describe the roles of the model, view, and controller in the MVC design pattern as applied to web application development. Illustrate your answer with examples of each component.

MVC is an architectural pattern used in software engineering, however it is often used in a web applications. When designing an ecommerce web site you will be able to split it up to three, the model would be actual content of the page for example a database which will keep record of all the goods. The view would be the actual HTML page where the user will interact with and finally the controller is the code which gathers data to generate the content for the page for example getting the customers order (shopping cart).

Wikii.jpg
  • Describe what is meant by ‘URL rewriting’ and list the main advantages of its use. Explain why the use of controllers eases the process, and how it aids in creating RESTful applications.

A rewrite engine is a piece of web server software used to modify URLs before fetching the requested item, for a variety of purposes. This technique is known as URL rewriting. Some benefits derived from a rewrite engine are:

Making website URLs more user and search engine friendly. Preventing undesired "inline linking" or "hot linking" Not exposing the (web address-related) inner workings of a website to users

REST strictly refers to a collection of network architecture principles that outline how resources are defined and addressed. The term is often used in a looser sense to describe any simple interface that transmits domain-specific data over HTTP without an additional messaging layer such as session tracking via HTTP cookies.

  • Describe the basic principles of the REST architecture (Fielding, 2000). Explain, with examples, how to implement a RESTful web application using Ruby on Rails.

REST: Representational State Transfer. It is refer to a collection of network architecture principles that outlines how resources are defined and addressed. Principles: •Application state and functionality are divided in to resources •REST architecture requires that applications use a simple, limited and repeatable set of verbs to perform actions on data and resources •All resources share a uniform interface for the transfer of state between client and resources consisting of well-defined operations and content types supporting code on demand.

Systems which follow Fielding’s REST principles are often referred to as “RESTful”. Ruby on rails is a free web application frame. It has application server built in and these application servers provide authentication, authorization, state handling, error handling, logging and performance which can be used to implement a web application.

Tutorial: week 3 – Models & ORM

  • Describe the characteristics of object and relational models that give rise to the problem known as ‘impedance mismatch’. Suggest two solutions, and describe one in detail, with examples where appropriate.

Impedance mismatch is a situation that arises when attempting to combine an object oriented software model with a relational database. Both the area of database design, and the area of software design have developed in completely separate ways, and as such, the differences between them can cause problems.

One such difference is that while Object Oriented programs use encapsulation to hide the way the programs work, mapping this implementation data to a relational database makes the database fragile as it has the potential to reveal the way the underlying software works. Also Objects in OO programs have identity, behavior and state whereas relational databases do not, this fact means databases and oo software need to "map" the data to each other, which in turn may cause slowdown.

One solution to solving impedance mismatch is simply to use an object oriented database system instead of a relational database, however, in reality this is often not a valid alternative as most databases used in the real world are relational. Another option is to use a process called "object relational mapping". This is a technique used to convert data between incompatible type systems in relational databases and object-oriented programming languages.

  • Describe the ActiveRecord design pattern and explain how it is implemented in Ruby on Rails.

The Ruby on Rails ActiveRecord is an implementation of object relational mapping - This means that data and logic are put together in one package.

TBC

  • Discuss the advantages and disadvantages of Rails migrations as an approach to model maintenance. What techniques does it provide to deal with different database cardinalities?

Tutorial: Week 4 – Views & Templates

  • List and explain the benefits of the View component of the MVC paradigm. Discuss why templates are commonly used as a central part of the view component.
  • Describe the function of a Template Markup Language in a template system. List the main requirements, with examples, of suitable candidates for such a language. What are the main factors that decide whether the language should be programming language based, or independent?
  • Ruby on Rails provides helper methods to reduce the dependency on code embedded in templates. Explain the reasons for this provision, giving examples of helpers and how they might be used.

Tutorial: Week 5 – testing

  • Define the terms testing, error and test case – explain how these definitions relate to web applications and the differences between testing traditional software applications and web applications.
  • Describe the Ramler (2002) test cube and how it can be applied to web application testing.
  • Describe the specifics of web application testing, explain which elements could be automated and suggest possible tools that could be used for the process.

Tutorial: Week 6/7 – Comparisons

  • Web frameworks are a relatively new approach to agile web application development. Discuss the concepts involved in creating a framework, illustrating your answer with examples of a real framework.
  • Compare and contrast two web frameworks that you are familiar with. Give examples of components that are utilised to illustrate your answer.
  • Discuss the design patterns that are used as the basis of web frameworks, highlighting any compromises or issues encountered in the implementation.