1 Web application design Writing PHP pages - - PDF document

1
SMART_READER_LITE
LIVE PREVIEW

1 Web application design Writing PHP pages - - PDF document

Administrivia !"


slide-1
SLIDE 1

1

  • Administrivia

!" #$%& '(%&)

!" *"+

From Last Time

,$--.

.*"+#/ 0!&--1(12%+.2

+. 1/

3(%+.4!((-- 0(--1(+(!(

  • -!+--1(22+!

/+2( $!1+56.& /

0(.1(+(

!( --!/

3(%++7(*"+

!((+/"+" /+2( 1(2 +%+((/ +"899%%%/:$/29+9"+"9"+";/+2

PHP Exercise

7 <5=<<4%&

=(!8/ > 1( ?@ "A /BCCC99 B/DE99C #/EDE@99#/ D/B@F99

Project

((8+&

+++G

>!81G

H2( BF2+&FIJ < 2(

+%

>!"(

"1

Today

6(F""( "1F

2

4+ "

slide-2
SLIDE 2

2

Web application design

%&%11"1

  • 3(
  • 912+

4

  • 281+""(
  • $2

Writing PHP pages

!(@%+!%.

"2&F".4,2

4%K((2

"+""(

=(1("""(( 3%2"(1"( L""( L"(

Capabilities

+%

  • 12"(

*((%@"

(++""(

"(%+.4,2"( ,(

+K211(

,"(1(2@ L"(1( *((%(2

OO in PHP

.""2"((

"@2+@

.B""2!

+@" 6%K((+2"(12

=((.(&

% 1(%++(

Sample PHP class

M)"+" (6&N ! OP ! O(P ! O+P 99 16&O(@O+N O+FQ(HO(P O+FQ+HO+P R 99+2+ 1*+N O+FQ+P R R )Q

Constructors

  • 22(

(6&N 99S 16&O(@O+N O+FQ(HO(P O+FQ+HO+P R (((8 O%" H%6&T4(T@T TP

slide-3
SLIDE 3

3

Properties and methods

LFQ ""

2+

=!((%+

9

O%" H%6&T4(T@T TP +O%"FQ(P 99TT O%"FQ+HT=!&(!+ 4(TP +O%"FQ*+P 99T=! &(!+4(T

Placing classes in files

6"8"(+(%

1(

L(; ((

"2

!(12("(

M)"+" (;T6&/"+"TP99(6&( O&H%6&T-".BT@ T-!.(:TP S

Advanced features

.B""21

*""(@"!@ + 1 =( &2"

  • +.2(

Systems design Systems design

2%(&

  • @!((@

%81+(2

=(@2+@"

(G(

((F"82&+%+

2(

<$"(8"($2

  • 2"(8(2"(%+(:(

Design artifacts

.%"+&F1

2)

.%2++(

G()

K(( "

&F

K(((+"1

+!((1""(

slide-4
SLIDE 4

4

Class diagrams

>"(@+""

2+

K((!1L,

  • Design patterns

*"2

((1((2

!("=+"+*($#EE

(1""+(

<$2"("8%1"(

"@"2&"(@F 1é

,"+12

  • L1(1"((

&%(1(

Patterns

* 2

+""1(2

>"!@"

((

%++(2

1()

%+%

%++(2)

"1+"

"1%+"+@$2"(

2"(G1

Patterns in OO design

+!F"

"22

L2221(

(!22

"1"22("(12

+1""(

=( %(

++&%(

""

Principle of separation

K!+1

  • ""12=--
  • "12/ 1(

""(+""(""(

+

//-"12

"2

L+(""2

("

  • """((@"@"

+(

Design patterns for separation

3+2

=(F!+ 4+F+ ,(F3%F=((

7((8"1

"@2(2"

*((%2"%""//%

1!/&"(

*((%"2(K

+!(

*((%!("2"((1F

slide-5
SLIDE 5

5

Patterns for separation

4+

""(+1% 2"

*2"(12"+K *&F!+"

G2

4+$2"(1(F!

+%!

Client-server architecture Three-tier architecture

  • 2(@%+2"

(//.4," (((@2+@(+2

(&"(12

2(

U""1((

(

U""12(

Model-View-Controller

,3=!++F

+

"(1F!%

""(

,3="2"""((@

"@

  • ""2""((F!

+F

MVC Classes

=(,3=""(1((

1+

>"12

""(2+ T(T

<//6&@@"@2@

+""

L(((%+""

2+

4+(.

MVC Classes continued

"(+11

2(

<//!%1&@+& ,+!2("(!%1+

2(8F(@@( !%

K((.2"((

.(G12

+L!%

<//!&@2

+""

slide-6
SLIDE 6

6

Example: Library application

=%

Why MVC?

61

V <%"2"//.4,

L

V =$2"( V *((%1!("!(

"

V =(12"($%""(

%&

F *2"($P(( F ,1((%"1"2 F ((,3= (&P11"+("+

MVC applications in PHP Learning MVC applications

4%K((2&2"((

!%

$%&%K(((&+%

"

%K(("+"+

Model

(.( ,((%1+,3=

  • +("12!%((

(6&N ! O(P ! O+P 16&O(@O+N O+FQ(HO(P O+FQ+HO+P R

View

K((2"(.(1+

!%

="(2+1"(

2(.4,

L.K (.4,"P(+

  • !%(1+!%

,+!2("(!%1+2(

  • 3%@@(((
slide-7
SLIDE 7

7

View example

M)"+" (3%6& N 1"(O&N )Q M+2(QM+QM(Q6&(M9(QM9+QMQ M(Q MQ MQ*+M9QMQM)"+" +O&FQ+P )QM9Q M9Q MQ MQ4(M9QMQM)"+" +O&FQ(P)QM9Q M9Q M9(Q M9QM9+2(Q M)"+" RR )Q

Controller

+""(%K(((

(((

.("!

=((!12L>

"2

=(&12"

=(($2TT

&"""

,+"2 *1@((

Controller example

M)"+" 99(1(S OHO;><'L<-4?TTAP99+" 1OHHT$TN O2 H%6&,P O&HO2FQ*((6&P99((&2 +( O!%H%3%6&P99!% O!%FQ"(O&P R (1 OHHT!%TN OHO;><'L<-4?TTAP 99+& O2 H%6&,P O&HO2FQ6&OP O!%H%3%6&P O!%FQ"(O&P99!%"(& R

Linking views to controllers

4+2"($@%K((!( =(&

M +1HT=((/"+")H!%WHBTQ

  • +%&B+3%6& (M9Q

12

M12HT=((/"+"T2+HTTQ M""HT+T2HTT!(HTBT9Q M""HT2T2HTT !(HT!%T9Q M912Q

Questions?

4+2%+"(+( K((+!!(%&(" 2"+(

""(%

+%,3= +++2" .%+2"

Next

4%&"

  • 4+&12((1"

L2"(12((

+(

=2"(2(!%(

slide-8
SLIDE 8

8

Example MVC Application

4+*""( +"8991(/%+/9(9

19$2"(92!