0% found this document useful (0 votes)
37 views

CMP-3110 E-Commerce Applications: Development

Uploaded by

MAIRA CS17
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

CMP-3110 E-Commerce Applications: Development

Uploaded by

MAIRA CS17
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

CMP-3110 ~ E-Commerce Applications

Development
Lecture 02
Planning Our Framework
Framework
• Definition
• a basic structure underlying a system, concept, or text.
• In general, a framework is a real or conceptual structure intended to serve as
a support or guide for the building of something that expands the structure
into something useful.
Patterns
• Definition
• a design pattern is a general repeatable solution to a commonly occurring
problem in software design.
•  A design pattern isn't a finished design that can be transformed directly into
code
• Uses of Design Patterns
• speed up the development process
• providing tested, proven development paradigms
Patterns
Which patterns will be used?
• Model-View-Controller (MVC)
• Registry
• Singleton
Model-View-Controller (MVC)
• Model 
• Represents an object. It can also have logic to update controller if its data
changes.
• View 
• Represents the visualization of the data that model contains.
• Controller 
• Acts on both model and view. It controls the data flow into model object and
updates the view whenever data changes. It keeps view and model separate.
Model-View-Controller (MVC)
Model-View-Controller (MVC)
Model-View-Controller (MVC)

Reference: Software Engineering by Ian Summerville – 9th edition


Registry
• Provides a means to store a collection of objects within our framework
(Container of objects for reuse).

• Each set of controllers and models we create need to perform some


shared tasks, including:
• Querying the database
• Checking if the user is logged in, and if so, getting certain user data
• Sending data to the views to be generated (template management)
• Sending e-mails, for instance to confirm a purchase with the customer
• Interacting with the server's filesystem, for instance to upload photographs of
products
Registry
Singleton
• Restrict an object to one instance only

• However, we will use it to ensure we have only one instance of our


registry available in the framework at any point of time.
File/Folder Structure
Building a Framework
Pattern Implementation: MVC
Pattern Implementation: Registry

• Needs
• It needs to have a method to create certain objects and store them with a key.
• It needs another method, which when passed with a key as a parameter,
returns the object in question.
• working
• Processing the incoming URL, so our “index.php” file can route the request
correctly
• Building URLs based on a series of parameters, a query string, and the
URLdisplay/generation method we use
• Pagination
Pattern Implementation: Registry

• The code in the book makes up the basics of our registry, with two
arrays:
• One for objects
• One for settings
Pattern Implementation: Singleton

• The singleton pattern is very easy to implement, as it requires only a


few minor changes to a standard PHP class, to ensure that it is only
ever instantiated once.
• Needs
• A private constructor is used to prevent the direct creation of objects from
the class.
• The expensive process is performed within the private constructor.
• The only way to create an instance from the class is by using a static method
that creates the object only if it wasn't already created.
Routing requests

You might also like