Download presentation
Presentation is loading. Please wait.
1
269200 Web Programming Language
Week 13 - MVC
2
So Far We’ve looked at HTML CSS PHP Jquery HTML5
3
This Week MVC Practical application of the Observer Design Pattern
4
OOP Designing OO software is not easy.
Identifying appropriate objects Specifying complex interrelationships Designing Reusable OO software is even harder. Finding good objects Getting the right level of abstraction Defining appropriate interfaces Making relationships available Designs need to be specific enough to solve the current problem, but general enough to address future problems and requirements.
5
OO Evolution Getting it “Right” is not easy, if not impossible to do first time, So often objects evolve to their ideal state. Objects are “reused” many times, modified each time to get to the finished state.
6
Expert OO Designers Experts do come up with good designs.
Invariably they reuse solutions that worked well for them in the past. You can find recurring patterns of classes and communicating objects across many systems and many domains. Patterns…
7
Patterns Design Patterns Solve specific design problems.
Make OO Designs flexible and elegant. Help designers reuse successful patterns by basing new designs on prior experience. Being familiar with common patterns enables designers to design solutions quickly.
8
Analogy Books and Movies Common Plots
Romance Action Hero Fantasy Cartoon… Rarely do new books or movies come up with a completely original genre. The most unique movies are normally those which integrate innovative techniques (camera angles etc.)
9
Design Patterns – The Book
Elements of Reusable Object Oriented Software Gamma, Helm, Johnson & Vlissides The “Gang of Four” A catalog of common problems and their solution designs.
10
Christopher Alexander
“Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice” (Alexander)
11
Christopher Alexander
Was an Architect. He was talking about designing buildings and town planning. We are “Architects” But, we are talking about designing software. Comparison His “Walls” and “Doors” are our “Objects” and “Interfaces”.
12
Pattern Perspective Different designers have different views of what patterns are. One designers pattern is another designers primitive building block. Is a “Linked List” or a “Hash Table” a pattern? No… Patterns are descriptions of communicating objects and classes that are customized to solve a general design problem in a particular context.
13
Example: MVC MVC = Model View Controller
Model – Application Object View – Screen Presentation Controller – Defines how the user interface reacts to user input MVC decouples view and models to increase flexibility and reuse. A communication protocol between the model and the view, ensures that the view reflects the state of the model.
14
MVC When the model’s data changes;
The View is notified, to allow it to update itself. In this way multiple views can be attached to a model, independently allowing multiple presentations of the same data. New views can be added without affecting the model.
15
MVC A B C 50 35 15
16
MVC Patterns At first glance; More Generalised becomes;
A design that decouples views from models. More Generalised becomes; Decoupling objects so that changes to one can affect any number of others without requiring the changed object to know the details of others. This is the “Observer Pattern”.
17
MVC Patterns (cont.) Actually MVC also uses other patterns;
Composite Pattern Allowing objects to be grouped, and then treated as an individual object. Strategy Pattern The object represents an algorithm, which may need to be varied. Factory Method Pattern To specify a default controller for a view. Decorator To add scrolling to a view.
18
The Observer Pattern Structure Subject Observer ConcreteObserver
observers Observer Attach(Observer) Detach(Observer) Notify() Update() for all o in observers { o->Update() } ConcreteObserver ConcreteSubject subject Update() observerState = subject->GetState() GetState() SetState() return subjectState observerState subjectState
19
MVC Frameworks PHP JS Ruby And MANY, MANY more… CakePHP Laravel Zend
Angular.JS React Ruby Ruby on Rails And MANY, MANY more…
20
Frameworks? Abstraction providing generic functionality Not a library!
The framework dictates the flow of control, not the caller. Default behaviour Extensible
21
Pretty URLs mod_rewrite (& .htaccess) What is mod_rewrite?
Allows us to rewrite (change) the url…
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.