460 likes | 597 Views
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.
E N D
Presented at: NextbridgeMultan Center Aug 25, 2011 Yii – How Power Comes Introduction, OOP & Design Patterns
Today’s AGENDA
Topics we will cover in this presentation Introduction to Yii Core features Patterns that make it Yii
YiiFramework Topic 1
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 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 invent a 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.
Yii - Features TOPIC 2
Yii Features 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 • 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
Yii Main Features • MVC • Active Record • Integration with jQuery • Widgets integrated with Jquery • Themes and translation
Patterns that make it Yii TOPIC 3
What makes it Yii - 1 Borrowing Ideas
Borrowing Ideas Is 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 What makes it Yii - 1 CComponent is the base class for all components. CComponent implements the protocol of defining, using properties and events.
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 • 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 • 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 • 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 • 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
Presented at: Nextbridge Multan Center Aug 25, 2011 Introduction, OOP & Design Patterns Yii– How Power Comes Designed & delivered by: NazarHussain Training Manager