Abstract Interface Pattern

streakconvertingSoftware and s/w Development

Dec 13, 2013 (3 years and 10 months ago)

81 views

Abstract Interface Pattern

Page
2

Abstract Interface Pattern Agenda


Introduction


Goals & Flow of this Talk


OO 411 Recap


Abstract Interface Defined [Conceptual]


Uses


Consequences


Abstract Interface In
-
Action


Questions


Reference

Page
3

Introduction


Eric Manley


Graduated with a B.S. MIS University of Nebraska


Lincoln [ GO HUSKERS! ]


23 yrs in IT Industry.


IBM
-
Rational Object Oriented Analysis & Design Certified.


Lead Architect For Mission Critical Java & .Net Projects.


Worked in St. Louis Area since 1995, Experience Includes:


AT&T


Wachovia/Wells Fargo


Enterprise Rent
-
A
-
Car


ABInbev (Anheuser
-
Busch)


Started working with Java in 1993…..JDK1.1


Favorite Java Frameworks


Spring


Hibernate


Struts


Google Web Tool Kit

Page
4

Goals & Flow of this Talk


Goals


Initial understanding of OO Patterns [HINT: They’re EVERYWHERE!]


Initial exposure to use of MyEclipseBlue & Debuggin!


Understanding the Conceptual Abstract Interface


Know When To Use


Know When Not To Use


Consequences


Flow


UML Model


Code Demo


Questions

Page
5

OO 411


Classes v. Objects



Objects have 3 things:


Behavior


State


Identity [ Most Important ]



Objects participate in Relationships


Generalization (Inheritance)


Realization (Interface)


Aggregation


Composition


Dependency


Page
6

OO 411 BSI



Behavior


Methods, Do Something!


Typically include business logic for business patterns


State


Data.


Can originate from persistent store (Database, file, etc).


Identity


Internal Key or identifier that UNIQUELY ID’s This INSTANCE .


Typically a GUID (OO Centric Implementations High
-
User, High # Object Graphs).


Database Sequence Numbers (DB Centric Implementations).


Prevents Elvis Syndrome! [ Could there be another…..I see him….OVER THERE, AND
THERE! ]



Page
7

OO 411 Relationships



Inheritance


Realization


Aggregation


Composition


Dependency



Page
8

OO Relationships UML

VOPC Relationships
Interface
Implementation
Parent
Child
Container
Element
Container
Element
Dependant
Dependancy
Generalization

Realization

Aggregation

Composition

Dependant

Page
9

Abstract Interface Defined
-
UML

VOPC Abstract Interface
Interface
AbstractClass
ConcreteImplementation1
ConcreteImplementation2
Dependant
Page
10

Abstract Interface Defined
-
Benefits



One of the MOST
-
POWERFULL Patterns In Use Today!


Combines virtue of an interface [Contract For Behavior] and Abstract Skeletal
Implementation.


Interface defines expected behavior.


Abstract Skeletal provides default “free” implementation.


Abstract Skeletal acts as “buffer zone” between Interface & Concrete
Implementation Classes.


Use It When:


Bridge Interface that is heavily used.


Bridge Implementation(s) under said Interface.


Do Not Use It When:


Changes pending to existing interface methods


Abuse to Abstract Layer, Inheritance Abuse.



Page
11

Abstract Interface Defined Con’t



Use It When:


Bridge Interface that is heavily used.


Bridge Implementation(s) under said Interface.


Do Not Use It When:


Changes pending to existing interface methods.


Abuse to Abstract Layer, Inheritance Abuse.


Consequences:


Behavior can change under interface and still “Make Good” on contract.


Allows multiple version support for interfaces.


Can vary implementation behavior at runtime [VERY POWERFULL

VER夠CO䵐LE塝X


May require Abstract
-
Skeleton to “split” as it matures [May take on too
-
much duty].



Page
12

Our Implementation
-
UML

VOPC Animals
«i nterface»
animal::Preditor
+
makeSound() : Stri ng
+
gi veWarni ng() : Stri ng
+
attackPrey() : Stri ng
+
bi te() : Stri ng
animal::BaseDangerousAnimal
-
methIDBi te: Log = LogFactory.getL... {readOnl y}
-
methIDCompl exBi te: Log = LogFactory.getL... {readOnl y}
-
methIDStal kPrey: Log = LogFactory.getL... {readOnl y}
-
type: Ani mal Type
-
name: Stri ng = nul l
-
GUID: Stri ng = nul l
-
BaseDangerousAni mal ()
+
BaseDangerousAni mal (Ani mal Type, Stri ng)
+
stal kPrey() : Stri ng
+
bi te() : Stri ng
#
compl exBi te() : Stri ng
+
«property get» getType() : Ani mal Type
+
«property set» setType(Ani mal Type) : voi d
+
«property get» getGUID() : Stri ng
+
«property set» setGUID(Stri ng) : voi d
+
«property get» getName() : Stri ng
+
«property set» setName(Stri ng) : voi d
+
toStri ng() : Stri ng
bears::GrizzlyBear
-
methIDGi veWarni ng: Log = LogFactory.getL... {readOnl y}
-
methIDMakeSound: Log = LogFactory.getL... {readOnl y}
-
methIDAttackPrey: Log = LogFactory.getL... {readOnl y}
-
methIDRi pWi thCl aws: Log = LogFactory.getL... {readOnl y}
+
Gri zzl yBear(Stri ng, Stri ng)
+
gi veWarni ng() : Stri ng
+
makeSound() : Stri ng
+
attackPrey() : Stri ng
-
ri pWi thCl aws() : Stri ng
enumeration::AnimalType
{l eaf}
-
actual Type: Stri ng {readOnl y}
+
GRIZZLY_BEAR: Ani mal Type = new Ani mal Type(... {readOnl y}
+
GREAT_WHITE_SHARK: Ani mal Type = new Ani mal Type(... {readOnl y}
+
BURMESE_PYTHON: Ani mal Type = new Ani mal Type(... {readOnl y}
+
DIAMOND_BACK_RATTLESNAKE: Ani mal Type = new Ani mal Type(... {readOnl y}
+
NONE: Ani mal Type = new Ani mal Type(... {readOnl y}
-
Ani mal Type(Stri ng)
+
toStri ng() : Stri ng
+
getVal ue() : i nt
+
getEl ement(i nt) : Ani mal Type
controller::AnimalTextController
-
methIDShowAni mal s: Log = LogFactory.getL... {readOnl y}
-
methIDShowBears: Log = LogFactory.getL... {readOnl y}
-
methIDShowSnakes: Log = LogFactory.getL... {readOnl y}
-
af: Ani mal Factory = nul l
+
Ani mal TextControl l er()
+
Ani mal TextControl l er(i nt)
+
showAni mal s() : voi d
-
showSnakes() : voi d
-
showBears() : voi d
fish::GreatWhiteShark
snakes::DiamondBackRattleSnake
-
methIDGi veWarni ng: Log = LogFactory.getL... {readOnl y}
-
methIDMakeSound: Log = LogFactory.getL... {readOnl y}
-
methIDAttackPrey: Log = LogFactory.getL... {readOnl y}
-
methIDBi te: Log = LogFactory.getL... {readOnl y}
+
Di amondBackRattl eSnake(Stri ng, Stri ng)
+
bi te() : Stri ng
+
makeSound() : Stri ng
+
gi veWarni ng() : Stri ng
+
attackPrey() : Stri ng
snakes::BurmesePython
-type
+NONE
+DIAMOND_BACK_RATTLESNAKE
+BURMESE_PYTHON
+GREAT_WHITE_SHARK
+GRIZZLY_BEAR
Page
13

DEMO



Show Me The Code!


Page
14

Questions

Page
15

References


Java.Sun.Com Abstract Interface Pattern:


http://java.sun.com/docs/books/tutorial/java/IandI/abstract.html


Genuitech MyEclipseblue Tutorials Page:


http://www.myeclipseide.com/module
-
htmlpages
-
display
-
pid
-
7.html


Welcome to MEB Prezo:


http://www.myeclipseide.com/images/tutorials/demos/welcome_to_myeclipse/wel
come_to_myeclipse.htm


“Effective Java” [first edition], Joshua Bloch ISBN 0
-
201
-
31005
-
8