MVC. Model-View-Controller. Design Patterns. Certain programs reuse the same basic structure or set of ideas

Similar documents
Design Patterns. An introduction

Ingegneria del Software Corso di Laurea in Informatica per il Management. Design Patterns part 1

Object Oriented Methods with UML. Introduction to Design Patterns- Lecture 8

UNIT I Introduction to Design Patterns

Using Design Patterns in Java Application Development

Design Patterns. Observations. Electrical Engineering Patterns. Mechanical Engineering Patterns

Design Patterns. Gunnar Gotshalks A4-1

DESIGN PATTERN - INTERVIEW QUESTIONS

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich

Design Patterns. Manuel Mastrofini. Systems Engineering and Web Services. University of Rome Tor Vergata June 2011

Ingegneria del Software Corso di Laurea in Informatica per il Management. Design Patterns part 1

SYLLABUS CHAPTER - 1 [SOFTWARE REUSE SUCCESS FACTORS] Reuse Driven Software Engineering is a Business

WS01/02 - Design Pattern and Software Architecture

Tuesday, October 4. Announcements

Design Pattern. CMPSC 487 Lecture 10 Topics: Design Patterns: Elements of Reusable Object-Oriented Software (Gamma, et al.)

What is Design Patterns?

Introduction to Software Engineering: Object Design I Reuse & Patterns

A Rapid Overview of UML

CS/CE 2336 Computer Science II

Software Engineering I (02161)

Software Engineering I (02161)

Trusted Components. Reuse, Contracts and Patterns. Prof. Dr. Bertrand Meyer Dr. Karine Arnout

Applying the Observer Design Pattern

APPLYING DESIGN PATTERNS TO SCA IMPLEMENTATIONS

UNIT I Introduction to Design Patterns

A Metric of the Relative Abstraction Level of Software Patterns

CHAPTER 6: CREATIONAL DESIGN PATTERNS

Applying the Decorator Design Pattern

Software Design Patterns. Background 1. Background 2. Jonathan I. Maletic, Ph.D.

Review Software Engineering October, 7, Adrian Iftene

Patterns. Erich Gamma Richard Helm Ralph Johnson John Vlissides

A Metric for Measuring the Abstraction Level of Design Patterns

Idioms and Design Patterns. Martin Skogevall IDE, Mälardalen University

Object-oriented Software Design Patterns

A Primer on Design Patterns

Object-Oriented Design

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich

Applying Some Gang of Four Design Patterns CSSE 574: Session 5, Part 3

The GoF Design Patterns Reference

Design Patterns. Hausi A. Müller University of Victoria. Software Architecture Course Spring 2000

Software Design COSC 4353/6353 D R. R A J S I N G H

design patterns FOR B.tech (jntu - hyderabad & kakinada) (IV/I - CSE AND IV/II - IT) CONTENTS 1.1 INTRODUCTION TO DESIGN PATTERNS TTERNS... TTERN?...

SDC Design patterns GoF

Introduction and History

CS251 Software Engineering Lectures 18: Intro to DP

Design Pattern What is a Design Pattern? Design Pattern Elements. Almas Ansari Page 1

Object-Oriented Design

Software Reengineering Refactoring To Patterns. Martin Pinzger Delft University of Technology

Trusted Components. Reuse, Contracts and Patterns. Prof. Dr. Bertrand Meyer Dr. Karine Arnout

1 Software Architecture

Lecture 4: Observer Pattern, Event Library and Componentization

EPL 603 TOPICS IN SOFTWARE ENGINEERING. Lab 6: Design Patterns

What is Design Patterns?

Topics in Object-Oriented Design Patterns

C++ for System Developers with Design Pattern

Applying the Factory Method Design Pattern

TDDB84. Lecture 2. fredag 6 september 13

CSCI Object Oriented Design: Frameworks and Design Patterns George Blankenship. Frameworks and Design George Blankenship 1

Application Architectures, Design Patterns

be used for more than one use case (for instance, for use cases Create User and Delete User, one can have one UserController, instead of two separate

6.3 Patterns. Definition: Design Patterns

Information systems modelling UML and service description languages

Slide 1. Design Patterns. Prof. Mirco Tribastone, Ph.D

Model-View-Controller

INSTITUTE OF AERONAUTICAL ENGINEERING

The Strategy Pattern Design Principle: Design Principle: Design Principle:

Object Oriented Paradigm

Crash course on design patterns

3 Product Management Anti-Patterns by Thomas Schranz

Pro Objective-C Design Patterns for ios

Applying Design Patterns to accelerate development of reusable, configurable and portable UVCs. Accellera Systems Initiative 1

Produced by. Design Patterns. MSc in Communications Software. Eamonn de Leastar

Lectures 24 and 25 Introduction to Architectural Styles and Design Patterns

Applying Design Patterns to SCA Implementations

DESIGN PATTERNS MOCK TEST DESIGN PATTERNS MOCK TEST II

Topics. Software Process. Agile. Requirements. Basic Design. Modular Design. Design Patterns. Testing. Quality. Refactoring.

administrivia today UML start design patterns Tuesday, September 28, 2010

Ownership in Design Patterns. Master's Thesis Final Presentation Stefan Nägeli

Design patterns. OOD Lecture 6

What is Design Patterns?

CS560. Lecture: Design Patterns II Includes slides by E. Gamma et al., 1995

Facade and Adapter. Comp-303 : Programming Techniques Lecture 19. Alexandre Denault Computer Science McGill University Winter 2004

R07. IV B.Tech. II Semester Supplementary Examinations, July, 2011

Software Architecture

Extensibility Design Patterns From The Initial Stage of Application Life-Cycle

Design pa*erns. Based on slides by Glenn D. Blank

As a programmer, you know how easy it can be to get lost in the details

UP Requirements. Software Design - Dr Eitan Hadar (c) Activities of greater emphasis in this book. UP Workflows. Business Modeling.

Design patterns. Valentina Presutti courtesy of Paolo Ciancarini

THE DESIGN PATTERNS JAVA COMPANION JAMES W. COOPER. Copyright 1998, by James W. Cooper

A Reconnaissance on Design Patterns

Software Engineering - I An Introduction to Software Construction Techniques for Industrial Strength Software

Design Patterns. "Gang of Four"* Design Patterns. "Gang of Four" Design Patterns. Design Pattern. CS 247: Software Engineering Principles

Trusted Components. Reuse, Contracts and Patterns. Prof. Dr. Bertrand Meyer Dr. Karine Arnout

CS 247: Software Engineering Principles. Design Patterns

Nat. Thomas Software Engineering Telephonics Inc. Long Island IEEE Lecture Series

Design Patterns: Structural and Behavioural

OODP Session 4. Web Page: Visiting Hours: Tuesday 17:00 to 19:00

Keywords: Abstract Factory, Singleton, Factory Method, Prototype, Builder, Composite, Flyweight, Decorator.

Reuse at Design Level: Design Patterns

Transcription:

MVC -- Design Patterns Certain programs reuse the same basic structure or set of ideas These regularly occurring structures have been called Design Patterns Design Patterns Design Patterns: Elements of Reusable Object-Oriented Soft ware Addison-Wesley Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides

Patterns Creational patterns Abstract Factory Builder Factory Method Prototype Singleton Structural Patterns Adapter Bridge Composite Decorator Façade Flyweight Proxy Proxy Clone pattern Behavioral Patterns Chain of responsibility Command Interpreter Iterator Mediator Memento Observer State Strategy Template method Visitor MVC - design pattern A way of structuring an application into different component parts First described by Trygve Reenskau working at Xerox research labs (1979) Influential paper: Applications Programming in Smalltalk-80 - How to use -- Using MVC Code that is core to the application person invoice car booking

Using MVC Code that is core to the application person invoice car booking Code that is key to the presentation / interaction with the user HTML, CSS forms Using MVC Code that is core to the application person invoice car booking Code that is key to the presentation / interaction with the user HTML, CSS forms Code that uses the and Using MVC in PHP PHP Classes SQL No HTML PHP for display HTML No SQL No SQL or HTML

MVC choices Build it all yourself Use pre existing MVC frameworks (typically class and object based) Many different frameworks http://www.phpframeworks.com/ Using MVC in PHP Two different approaches Mixed imperative and class/object style Smarty Templating Class/object style throughout Cake framework

Using MVC in PHP - Smarty Class style HTML templates Imperative style Using MVC in PHP - Smarty PHP Classes SQL No HTML Smarty templates (HTML and smarty variables) No SQL Smarty controller code MVC strategy - Smarty Construct model classes for the application

MVC strategy - Smarty Construct model classes for the application Construct s HTML templates MVC strategy - Smarty Construct model classes for the application Construct s HTML templates Create controllers that pass data to views Simple Smarty Example - 1 Hello World in HTML

Smarty Directory Structure Smarty expects certain folders and files Smarty Directory Structure Smarty expects certain folders and files Don t save files in these or alter the contents Smarty Directory Structure Smarty expects certain folders and files Used to store temporary versions

Smarty Directory Structure Smarty expects certain folders and files Core Smarty Files Smarty Directory Structure Smarty expects certain folders and files Compiled versions of the web pages Simple Smarty Example - 1 Construct HTML template Create controller to pass object to view

Simple Smarty Example - 1 Create controller to pass object to view Simple Smarty Example - 1 Create controller to pass object to view Add one line for every piece of data that we pass through to the template In the template, the smarty variable $hello will have the value Hello World!! Note - no $ in front of hello Simple Smarty Example - 1 Create controller to pass object to view Name the template file that will be used Smarty expects.tpl extension

Simple Smarty Example - 1 Create controller to pass object to view Save this as helloworld.php Simple Smarty Example - 1 Create controller to pass object to view Save the controller in the root Save the template in the templates folder Best practice - give controller and template same name helloworld.php helloworld.tpl Simple Smarty Example - 1 Construct HTML template helloworld.tpl A plain HTML file with all the variable bits of data removed Smarty inserts the data for us from the controller

Simple Smarty Example - 1 Construct HTML template helloworld.tpl Use this syntax to insert a smarty value { $smartyname } Save this template in the templates folder Simple Smarty Example - 1 Bring up helloworld.php in browser Hello World!! Simple Smarty Example - 2 Create an Employee using the employee object and print some values out

Simple Smarty Example - 2 Construct model classes for the application Construct s HTML templates Create controllers that pass data to views Simple Smarty Example - 2 emp class Print an Emp objects details controller to create an emp object and pass to Simple Smarty Example - 2 EMP class

Simple Smarty Example - 2 EMP class Create a folder called model to save model classes Save class.emp.php in here Simple Smarty Example - 2 Create controller to pass data to view Simple Smarty Example - 2 Create controller to pass data to view

Simple Smarty Example - 2 Create controller to pass data to view Save as emptest1.php Simple Smarty Example - 2 Create view emptest1.tpl Simple Smarty Example - 2

Simple Smarty Example - 2 In fact a better approach Pass the object into the Use the -> notation to access the methods in the Simple Smarty Example - 2 Pass in the whole $newemp object with the name passedemp Now use the methods inside the object $passedemp Simple Smarty Example - 3 In online exercise Use the empdb class to get the emp details from a mysql table

cakephp MVC frameworks Have very strict rules for use Names must match certain dictated patterns Files must be place in certain places Classes in your application inherit from the MVC classes Very steep learning curve, but RAD