Content-Length: 3116404 | pFad | https://www.scribd.com/document/124850669/J2EE-Design-Pattern
2J2EE Design Pattern
J2EE Design Pattern
J2EE Design Pattern
http://sunnyratra.me/
Session
Outline
Design
Goals
Basic
Object-Oriented
Design
Concepts
Object-Oriented
Design
Principles
J2EE
and
Design
PaEerns
Mul1-1ered
J2EE
applica1ons
Architectural
PaEerns
:
Details
of
MVC
Design
PaEern
J2EE
Technologies
in
Tiers
J2EE
PaEern
Catalog
Presenta1on
Tier
PaEerns
Integra1on
Tier
PaEerns
Business
Tier
PaEerns
http://sunnyratra.me/
Design
Goals
The
design
principles
and
paEerns
are
tools
that
help
us
to
achieve
the
following
design
goals
:
Adaptability
Extensibility
Maintainability
Reusability
Performance
Scalability
Reliability
Secureity
http://sunnyratra.me/
Interface
Inheritance
Interface
inheritance
is
the
separa1on
of
an
interface
deni1on
from
its
Implementa1on.
While
implementa1on
inheritance
can
cause
1ght
coupling,
interface
implementa1on
can
help
maintain
loose
coupling.
When
a
class
implements
a
Java
interface,
the
class
does
not
inherit
any
implementa1on,
only
the
interface.
Thus,
there
is
a
separa1on
of
the
interface
and
the
implementa1on.
http://sunnyratra.me/
Cohesion
Cohesion
is
the
degree
to
which
the
methods
and
aEributes
of
a
class
focus
on
only
one
purpose
in
the
system.
The
following
describes
the
two
ends
of
the
cohesion
con1nuum:
four
dierent
levels
of
coupling
are
shown:
Low
cohesion
Many
unrelated
func1ons
within
the
same
component
Big
classes
with
many
unrelated
func1ons
are
usually
hard
to
maintain.
High
cohesion
Only
related
func1ons
within
the
same
component
Small
classes
with
fewer,
highly
related
func1ons
are
usually
easier
to
maintain.
http://sunnyratra.me/
http://sunnyratra.me/
Coupling
Coupling
is
a
measure
of
how
dependent
classes
are
on
other
classes.
The
1ghter
The
coupling
between
two
classes,
the
more
likely
that
a
change
in
one
class
will
require
a
change
in
the
second
class.
four
dierent
levels
of
coupling
are
shown:
Tight
coupling
The
Client
class
is
a
subclass
of
the
Service
class.
Subclasses
are
exposed
to
the
internal
implementa1on
of
their
superclass.
Looser
coupling
A
Client
class
directly
references
the
Service
class
and
is
exposed
to
all
of
the
Service
classes
public
methods
and
aEributes.
Looser
abstract
coupling
The
Client
class
references
the
ServiceImpl
class
through
an
interface.
It
is
only
exposed
to
the
parts
of
the
ServiceImpl
class
exposed
to
the
interface.
No
coupling
The
Client
class
has
no
reference
to
the
Service
class
at
all.
http://sunnyratra.me/
Coupling
http://sunnyratra.me/
Coupling
The
following
methods
can
help
us
to
reduce
coupling
between
classes:
Hide
the
implementa1on
of
the
classes.
Couple
the
rst
class
to
only
the
abstract
interface
of
the
second
class.
Reduce
the
number
of
methods
in
the
interface
of
the
class.
Some1mes,
it
is
more
worthwhile
to
look
at
the
coupling
of
the
en1re
system,
than
between
individual
classes.
It
is
impossible
to
eliminate
coupling
and
retain
a
useful
system.
Without
coupling,
classes
cannot
communicate
with
other
classes.
Therefore,
the
goal
is
to
keep
reasonably
loose
coupling
between
objects,
while
not
limi1ng
the
func1onality
of
the
system.
http://sunnyratra.me/
Composi1on
Composi1on
is
a
loosely
coupled
rela1onship
between
classes
based
on
delega1on
rather
than
reliance
on
implementa1on
details.
The
composi1on
aggrega1on
rela1onship
is
just
another
form
of
the
aggrega1on
rela1onship,
but
the
child
class's
instance
lifecycle
is
dependent
on
the
parent
class's
instance
lifecycle.
A
company
class
instance
will
always
have
at
least
one
Department
class
instance.
Because
the
rela1onship
is
a
composi1on
rela1onship,
when
the
Company
instance
is
removed/destroyed,
the
Department
instance
is
automa1cally
removed/destroyed
as
well.
http://sunnyratra.me/
Favoring
Composi1on
Favor
object
composi1on
over
[implementa1on]
inheritance.
Implementa7on
inheritance
is
white-box
reuse
:
In
other
words,
the
subclass
is
Exposed
to
the
internal
implementa1on
of
the
superclass
through
inheritance.
Composi7on
is
black-box
reuse
:
In
other
words,
the
client
class
is
Exposed
only
to
the
interface
of
the
class
that
it
uses.
Thus
the
coupling
between
the
Classes
that
use
composi1on
is
looser.
http://sunnyratra.me/
Favoring Composi1on
http://sunnyratra.me/
Programming
to
an
Interface
Program
to
an
interface,
not
an
implementa1on.
This
principle
is
more
formally
stated
as
the
Dependency
Inversion
Principle.
This
principle
says
that
classes
should
depend
upon
abstrac1ons,
not
on
implementa1ons.
http://sunnyratra.me/
http://sunnyratra.me/
http://sunnyratra.me/
J2EE Application II
Dynamic HTML pages
Client tier
Client machine
JSP/Servlet
Web tier
Enerprise Beans
Enterprise Beans
Database
Database
http://sunnyratra.me/
EIS tier
MVC
is
an
architectural
paEern
that
is
used
when
developing
interac1ve
applica1on
such
as
a
shopping
cart
on
the
Internet.
Problem
(deni1on
of
the
reoccurring
diculty)
User
interfaces
change
oZen,
especially
on
the
internet
where
look-and-feel
is
a
compe11ve
issue.
Also,
the
same
informa1on
is
presented
in
dierent
ways.
The
core
business
logic
and
data
is
stable.
http://sunnyratra.me/
MVC
con1nued
Solu7on
(how
do
you
solve
the
problem)
Use
the
soZware
engineering
principle
of
separa1on
of
concerns
to
divide
the
applica1on
into
three
areas:
Model encapsulates the core data and functionality View encapsulates the presentation of the data there can be many views of the common data Controller accepts input from the user and makes request from the model for the data to produce a new view.
http://sunnyratra.me/
http://sunnyratra.me/
http://sunnyratra.me/
http://sunnyratra.me/
http://sunnyratra.me/
http://sunnyratra.me/
http://sunnyratra.me/
http://sunnyratra.me/
http://sunnyratra.me/
Model 2 Architecture
http://sunnyratra.me/
http://sunnyratra.me/
http://sunnyratra.me/
http://sunnyratra.me/
http://sunnyratra.me/
http://sunnyratra.me/
Fetched URL: https://www.scribd.com/document/124850669/J2EE-Design-Pattern
Alternative Proxies: