yii – how power comes
DESCRIPTION
Presented at: Nextbridge Multan Center Aug 25, 2011. Yii – How Power Comes. Introduction, OOP & Design Patterns. Today’s. AGENDA. Topics we will cover in this presentation. Introd uction to Yii Core features Patterns that make it Yii. Yii Framework. Topic 1. Yii - Definition. - PowerPoint PPT PresentationTRANSCRIPT
Yii – How Power ComesIntroduction, OOP & Design Patterns
Presented at:Nextbridge Multan CenterAug 25, 2011
AGENDAToday’s
Topics we will cover in this presentation
• Introduction to Yii• Core features• Patterns that make it Yii
TOPIC 1Yii Framework
Yii - Definition
Fast – Secure – Professional
Why it’s called like that?!
Chinese Yi:
Easy and simple.
Flexibility, ability to change.
Persistence. Core principles are always the same.
How it is Fast?
How it is Secure?
• Cross-site Scripting Prevention• Cross-site Request Forgery Prevention• Cookie Attack Prevention• Built-in Authentication and Authorization
– Cookie based Login– Access Control Filter– Handling Authorization Result– Role-based Access Control– Configureable Authorization Manager
How it is Professional?
• MVC• Database Access Objects (DAO)• Query Builder• Active Record• DB Migration• Skinning & Theming• Automatic Code generation • Best parts from all Frameworks
How it is Professional?
• MVC• Database Access Objects (DAO)• Query Builder• Active Record• DB Migration• Skinning & Theming• Automatic Code generation • Best parts from all Frameworks
Yii History
Prado (2004) ▼
Yii 1.0 (2008) ▼
Yii 1.1 (2010) ▼
Yii2 (?)
Why reinventing the wheel?
Why reinventing the wheel ?
Sometimes it’s better to inventa better wheel!
Why reinventing the wheel & Why MVC?
• When Prado was developed there were at least no competitors.
• Prado took ASP.NET ideas that were ―not from this world.
• MVC is popular and convenient.• Frameworks of 2008 weren’t that good.
Why reinventing the wheel & Why MVC?
• When Prado was developed there were at least no competitors.
• Prado took ASP.NET ideas that were ―not from this world.
• MVC is popular and convenient.• Frameworks of 2008 weren’t that good.
Yii Team
• 6 developers.• Tech. writer.• ~50 translators.
• Priority:– Code stability.– Code reliability.– Consistent style.
TOPIC 2Yii - Features
Yii Features
• Model-View-Controller (MVC) design pattern
• Database Access Objects (DAO), Query Builder, Active Record, DB Migration
• Form input and validation• AJAX-enabled widgets• Authentication and authorization• Skinning and theming• Web services• Internationalization (I18N) and
localization (L10N)• Layered caching schem
• Error handling and logging• Security• Unit and functionality testing• Automatic code generation• Compliance to XHTML• Purely object-oriented• Friendly with third-party code• Detailed documentation• Extension library
Yii Main Features
• MVC• Active Record• Integration with jQuery• Widgets integrated with Jquery• Themes and translation
Yii – Typical Flow
Flow of execution
TOPIC 3Patterns that make it Yii
What do you think?
?
What makes it Yii - 1
Borrowing Ideas
Borrowing IdeasIs it Good?
Borrowing Ideas
Copy-paste is evil.
Think. Analyze. Take the best and leave the rest.
What makes it Yii - 2
OOP Pattern
Yii - Component
CComponent is the base class for all components.
CComponent implements the protocol of defining, using properties and events.
What makes it Yii - 1
What makes it Yii - 3
Design Patterns
What are design patterns?
• The words ”Object Oriented Design” repeated on wall paper
• An industry buzzword that gets you into meetups• Recurring solutions to common software
development challenges• Mind bending algorithms of confusion and
indigestion
What are design patterns?
• The words ”Object Oriented Design” repeated on wall paper
• An industry buzzword that gets you into meetups• Recurring solutions to common software
development challenges• Mind bending algorithms of confusion and
indigestion
The Lazy Load Pattern
• Lazy loading is the process of delaying the instantiation of an object until the instance is needed.
• We all know the mantra, lazy programmers are the best programmers.
The Lazy Load Pattern
The Lazy Load Pattern
• Delays resource consumption until it is needed, which may be never
• Is relatively easy to understand• Offers an encapsulated means of creating objects• Offers an encapsulated means of storing objects
for use later
The Registry Pattern
A registry is an object that other objects can use to access data, settings, values and other objects from a sort of internal storehouse.
The Registry Pattern
The Registry Pattern
• Maintaining values throughout a request• Setting/getting configuration values• Allowing access to variables within an
application without globals• For Windows user, causing hours and hours of
grief when corrupt
The Singleton Pattern
The singleton patterns ensures that one and only one instance of an object exists.
The Singleton Pattern
The Singleton Pattern
• Pro: You know you have the same instance available at all times.• Con: One and only one instance is all you get.
• Pro: Instantiates itself for you so all you need to do is get it.• Con: Autoinstantiation diminishes flexibility of argument passing.
• Pro: Since it is singleton it can replace global variable declaration.• Con: Since it is singleton it can replace global variable declaration.
The Factory Method Pattern
The factory method is a method whose sole purpose in life is to create objects. Most commonly (and really per definition) the factory method is an interface method
that delegates object instantiation decisions to subclasses.
However, it also commonly acceptable to say that a method that creates objects (both of known and unknown classes) is a factory
method.
The Factory Method Pattern
The Factory Method Pattern
The Factory Method Pattern
• Encapsulates object creation• Allows a range of functionality for error trapping, loading,
etc• Does not need to know anything about what it is creating• Easy to read, easy to understand• Lightweight, fast and can be made into a static method
Now its your turn to speak
YII – HOW POWER COMESIntroduction, OOP & Design Patterns
Designed & delivered by:Nazar HussainTraining Manager
Presented at:Nextbridge Multan CenterAug 25, 2011