yii – how power comes

46
Yii – How Power Comes Introduction, OOP & Design Patterns Presented at: Nextbridge Multan Center Aug 25, 2011

Upload: saad

Post on 23-Feb-2016

46 views

Category:

Documents


0 download

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 Presentation

TRANSCRIPT

Page 1: Yii  –  How Power Comes

Yii – How Power ComesIntroduction, OOP & Design Patterns

Presented at:Nextbridge Multan CenterAug 25, 2011

Page 2: Yii  –  How Power Comes

AGENDAToday’s

Page 3: Yii  –  How Power Comes

Topics we will cover in this presentation

• Introduction to Yii• Core features• Patterns that make it Yii

Page 4: Yii  –  How Power Comes

TOPIC 1Yii Framework

Page 5: Yii  –  How Power Comes

Yii - Definition

Fast – Secure – Professional

Page 6: Yii  –  How Power Comes

Why it’s called like that?!

Chinese Yi:

Easy and simple.

Flexibility, ability to change.

Persistence. Core principles are always the same.

Page 7: Yii  –  How Power Comes

How it is Fast?

Page 8: Yii  –  How Power Comes

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

Page 9: Yii  –  How Power Comes

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

Page 10: Yii  –  How Power Comes

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

Page 11: Yii  –  How Power Comes

Yii History

Prado (2004) ▼

Yii 1.0 (2008) ▼

Yii 1.1 (2010) ▼

Yii2 (?)

Page 12: Yii  –  How Power Comes

Why reinventing the wheel?

Page 13: Yii  –  How Power Comes

Why reinventing the wheel ?

Sometimes it’s better to inventa better wheel!

Page 14: Yii  –  How Power Comes

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.

Page 15: Yii  –  How Power Comes

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.

Page 16: Yii  –  How Power Comes

Yii Team

• 6 developers.• Tech. writer.• ~50 translators.

• Priority:– Code stability.– Code reliability.– Consistent style.

Page 17: Yii  –  How Power Comes

TOPIC 2Yii - Features

Page 18: Yii  –  How Power Comes

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

Page 19: Yii  –  How Power Comes

Yii Main Features

• MVC• Active Record• Integration with jQuery• Widgets integrated with Jquery• Themes and translation

Page 20: Yii  –  How Power Comes

Yii – Typical Flow

Page 21: Yii  –  How Power Comes

Flow of execution

Page 22: Yii  –  How Power Comes

TOPIC 3Patterns that make it Yii

Page 23: Yii  –  How Power Comes

What do you think?

?

Page 24: Yii  –  How Power Comes

What makes it Yii - 1

Borrowing Ideas

Page 25: Yii  –  How Power Comes

Borrowing IdeasIs it Good?

Page 26: Yii  –  How Power Comes

Borrowing Ideas

Copy-paste is evil.

Think. Analyze. Take the best and leave the rest.

Page 27: Yii  –  How Power Comes

What makes it Yii - 2

OOP Pattern

Page 28: Yii  –  How Power Comes

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

Page 29: Yii  –  How Power Comes

What makes it Yii - 3

Design Patterns

Page 30: Yii  –  How Power Comes

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

Page 31: Yii  –  How Power Comes

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

Page 32: Yii  –  How Power Comes

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.

Page 33: Yii  –  How Power Comes

The Lazy Load Pattern

Page 34: Yii  –  How Power Comes

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

Page 35: Yii  –  How Power Comes

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.

Page 36: Yii  –  How Power Comes

The Registry Pattern

Page 37: Yii  –  How Power Comes

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

Page 38: Yii  –  How Power Comes

The Singleton Pattern

The singleton patterns ensures that one and only one instance of an object exists.

Page 39: Yii  –  How Power Comes

The Singleton Pattern

Page 40: Yii  –  How Power Comes

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.

Page 41: Yii  –  How Power Comes

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.

Page 42: Yii  –  How Power Comes

The Factory Method Pattern

Page 43: Yii  –  How Power Comes

The Factory Method Pattern

Page 44: Yii  –  How Power Comes

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

Page 45: Yii  –  How Power Comes

Now its your turn to speak

Page 46: Yii  –  How Power Comes

YII – HOW POWER COMESIntroduction, OOP & Design Patterns

Designed & delivered by:Nazar HussainTraining Manager

Presented at:Nextbridge Multan CenterAug 25, 2011