Sie sind auf Seite 1von 8

EXT JS

• Physical separation among the deployed application modules


• Majority of business logic and data handling modules usually reside on the
server
• User interface lives within the confines of the browse
• Reliable and efficient communications between the client-side and server-
side elements of the system
• Like most javascript frameworks, Ext JS uses JSON as its primary data
interchange format.
• Regardless of the back-end technology you choose (PHP, .NET, Java, etc.), if
you produce http responses containing JSON-encoded data, you will be
able to relay information to Ext JS.
• extjs is a javascript framework you can use to create professional graphical
web user interface and AJAX web application.
OOPS
• Object Oriented Programming in any language is the use of objects to
represent functional parts of an application and real life entities.
• For example you may have a Person object to hold the data related to a person
and even provide some functionality that this person may be capable of.
• Object Oriented Programming has long been used in games to represent the
objects such as a User or an Enemy, or even a Weapon.
• This amazing way of programming has proven just as useful in software and
web development.
• In my opinion any OOP language should have:

Abstract data types and information hiding


Inheritance
Polymorphism
<?php

class Something {
// In OOP classes are usually named starting
with a cap letter.
var $x;

function setX($v) {
// Methods start in lowercase then use
lowercase to separate
// words in the method name example
getValueOfArea()
$this->x=$v;
}

function getX() {
return $this->x;
}
}

?>
Object Oriented Programming in PHP - Data Members
and Functions

• Data members are defined in PHP using a "var" declaration inside the class
and they have no type until they are assigned a value.
• A data member might be an integer, an array, an associative array or even
an object.
• Methods are defined as functions inside the class, to access data members
inside the methods you have to use $this->name, otherwise the variable is
local to the method.
• You create an object using the new operator:

$obj=new Something;
Then you can use member functions like:
$obj->setX(5);
$see=$obj->getX();
• The setX member function assigns 5 to the x data member in the object obj (not in the class),
then getX returns its value; 5 in this case.
• You can access the data members from the object reference using for example: $obj->x=6.
However, this is not a very good OOP practice.
• I encourage you to set data members by defining methods to set them and access the data
members by using retrieving methods.

Inheritance
Inheritance is easy in PHP using the extends keyword:
<?php
class Another extends Something {
var $y;
function setY($v) {
// Methods start in lowercase then use uppercase initials to
// separate words in the method name example getValueOfArea()
this->y=$v;
}
function getY() {
return $this->y;
}
}
?>
Object Oriented Programming in PHP - Constructors

• You might define constructors in your classes


• constructors are methods with the same name as the class and are called
when you create an object of the class
• Constructors and methods are normal PHP functions so you can use
default arguments.
• function Something($x="3",$y="5");

Then:

$obj=new Something(); // x=3 and y=5


$obj=new Something(8); // x=8 and y=5
$obj=new Something(8,9); // x=8 and y=9
• Default arguments are used in the C++ way so you can't pass a value to Y and let X take the
default value.
• Arguments are assigned from left to right and when no more arguments are found if the
function expected more they take the default values.
• When an object of a derived class is created only its constructor is called the constructor of
the Parent class is not called.
• This is a gotcha of PHP because constructor chaining is a classic feature of OOP, if you want to
call the base class constructor you have to do it explicitly from the derived class constructor.
• It works because all methods of the parent class are available at the derived class due to
inheritance.
<?php
function Another() {
$this->y=5;
$this->Something(); //explicit call to base class constructor.
}
?>
Abstract Classes
• A nice mechanism in OOP is the use of Abstract Classes
• abstract classes are classes that cannot be instantiated and the only purpose is
to define an interface for its derived classes.
• Designers often use Abstract classes to force programmers to derive classes
from certain base classes, so they can be certain that the new classes have
some desired functionality.
• There's no standard way to do that in PHP but, if you do need this feature, just
define the base class and put a "die" call in its constructor so you can be sure
that the base class is never instantiated.
• Now define the methods (interface) putting "die" statements in each one so if
in a derived class a programmer doesn't override the method then an error is
raised.
• There're no destructors in PHP.

Das könnte Ihnen auch gefallen