SlideShare a Scribd company logo
1 of 54
Software Components
SE 491
Walid M. Rabie Abdelmoez
walid.abdelmoez@hotmail.com
Associate Professor of
Software Engineering
CCIT
AASTMT
Topics Covered
• Motivate the importance of design
experience & leveraging recurring
design structure in becoming a
master software developer
• Introduce patterns as a
means of improving software
quality & developer
productivity
• Summarize common
characteristics of patterns
• Describe a variation-oriented process
for successfully applying patterns to
software development projects
Pattern
Knowledge
Trade-off
Analysis
Design &
Implementation
Decisions
Implement &
Integrate
Patterns &
Code
Topics Covered
• Motivate the importance of design
experience & leveraging recurring
design structure in becoming a
master software developer
Becoming a Master
• Experts perform differently than
beginners
• e.g., unlike novices, professional
athletes, musicians, & dancers
move fluidly & effortlessly,
without focusing on each
individual movement
Becoming a Master
• Experts perform differently than
beginners
• e.g., unlike novices, professional
athletes, musicians, & dancers
move fluidly & effortlessly,
without focusing on each
individual movement
• When watching experts perform
it’s easy to forget how much effort
they’ve put into reaching high
levels of achievement
Becoming a Master
• Experts perform differently than
beginners
• e.g., unlike novices, professional
athletes, musicians, & dancers
move fluidly & effortlessly,
without focusing on each
individual movement
• When watching experts perform
it’s easy to forget how much effort
they’ve put into reaching high
levels of achievement
• Continuous repetition &
practice is crucial to success
• Mentoring from other experts is
also essential to becoming a
master
Becoming a Master Software Developer
• Knowledge of programming languages
is necessary, but not sufficient
• Can fall prey to “featuritis” or
worse
• e.g., GPERF perfect hash function
generator, circa 1990
Becoming a Master Software Developer
• Knowledge of programming languages
is necessary, but not sufficient
• Can fall prey to “featuritis” or
worse
• e.g., GPERF perfect hash function
generator, circa 1990
Problems
• Hard-coded
algorithms
• Hard-coded
data
structures
• Hard-coded
generators
• etc.
Becoming a Master Software Developer
• Knowledge of programming languages
is necessary, but not sufficient
• Can fall prey to “featuritis” or
worse
• e.g., GPERF perfect hash function
generator, circa 1990
Becoming a Master Software Developer
• Knowledge of programming languages
is necessary, but not sufficient
• Can fall prey to “featuritis” or worse!
• e.g., “Best one-liner” from
2006 “Obfuscated C Code”
contest
• This program prints out the time when it was compiled!
main(_){_^448&&main(-~_);putchar(--_%64?32|-~7[
__TIME__-_/8%8][">'txiZ^(~z?"-48]>>";;;====~$::199"
[_*2&8|_/64]/(_&2?1:8)%8&1:10);}
See www.ioccc.org for many examples of obfuscated C
Becoming a Master Software Developer
• Knowledge of programming languages
is necessary, but not sufficient
• Can fall prey to “featuritis” or worse!
• Software methods emphasize design
notations, such as UML
• Fine for specification &
documentation
• e.g., omits mundane
implementation details & focuses on
relationships between key design
entities
• Knowledge of programming languages
is necessary, but not sufficient
• Can fall prey to “featuritis” or worse!
• Software methods emphasize design
notations, such as UML
• Fine for specification &
documentation
• But good software design is more
than drawing diagrams
• Good draftsmen/artists are not
necessarily good architects!
Becoming a Master Software Developer
Becoming a Master Software Developer
• Knowledge of programming languages
is necessary, but not sufficient
• Can fall prey to “featuritis” or worse!
• Software methods emphasize design
notations, such as UML
• Fine for specification &
documentation
• But good software design is more
than drawing diagrams
• Good draftsmen/artists are not
necessarily good architects!
• Bottom-line: Master software
developers rely on design experience
• At least as important as
knowledge of programming
languages & environments
Where Should Design Experience Reside?
Well-designed software exhibits recurring structures & behaviors that promote
• Abstraction
• Flexibility
• Reuse
• Quality
• Modularity
Where Should Design Experience Reside?
Well-designed software exhibits recurring structures & behaviors that promote
• Abstraction
• Flexibility
• Reuse
• Quality
• Modularity
Therein lies valuable
design knowledge
Where Should Design Experience Reside?
Well-designed software exhibits recurring structures & behaviors that promote
• Abstraction
• Flexibility
• Reuse
• Quality
• Modularity
Therein lies valuable
design knowledge
Unfortunately, this design knowledge is
typically located in:
1. the heads of the experts
Where Should Design Experience Reside?
Well-designed software exhibits recurring structures & behaviors that promote
• Abstraction
• Flexibility
• Reuse
• Quality
• Modularity
Therein lies valuable
design knowledge
public class KeyGeneratorImpl extends Service {
private Set<UUID> keys = new HashSet<UUID>();
private final KeyGenerator.Stub binder = new KeyGenerator.Stub() {
public void setCallback (final KeyGeneratorCallback callback) {
UUID id;
synchronized (keys) {
do { id = UUID.randomUUID(); } while (keys.contains(id));
keys.add(id);
}
final String key = id.toString();
try {
Log.d(getClass().getName(), "sending key" + key);
callback.sendKey(key);
} catch (RemoteException e) { e.printStackTrace(); }
}
};
public IBinder onBind(Intent intent) { return this.binder; }
}
Unfortunately, this design knowledge is
typically located in:
1. the heads of the experts
2. the bowels of the source code
Where Should Design Experience Reside?
Well-designed software exhibits recurring structures & behaviors that promote
• Abstraction
• Flexibility
• Reuse
• Quality
• Modularity
Therein lies valuable
design knowledge
Unfortunately, this design knowledge is
typically located in:
1. the heads of the experts
2. the bowels of the source code
Both locations are fraught with danger!
Summary
• Achieving mastery of
software development
requires continuous
repetition, practice, &
mentoring
from experts
Summary
• Achieving mastery of
software development
requires continuous
repetition, practice, &
mentoring
from experts
• Open-source & open
courses are vital
resources
Summary
• Achieving mastery of
software development
requires continuous
repetition, practice, &
mentoring
from experts
• Open-source & open
courses are vital
resources
Summary
• Achieving mastery of software
development requires
continuous repetition, practice,
& mentoring
from experts
• Good software developers rely
on experience gleaned from
successful designs
Summary
• Achieving mastery of
software development
requires continuous
repetition, practice, &
mentoring
from experts
• Good software developers
rely
on experience gleaned from
successful designs
• What we need is a means of
extracting, documenting,
conveying, applying, &
preserving this design
knowledge without undue
time, effort, & risk!
Topics Covered
• Motivate the importance of design
experience & leveraging recurring
design structure in becoming a
master software developer
• Introduce patterns as a
means of improving software
quality & developer
productivity by…
Pattern
Concepts
Topics Covered
• Motivate the importance of design
experience & leveraging recurring
design structure in becoming a
master software developer
• Introduce patterns as a
means of improving software
quality & developer
productivity
• Summarize common
characteristics of patterns
Observer
pattern
s->getData()
Observer
update
ConcreteObserver
update
doSomething
state = X;
notify();
Subject
setData
getData
notify
attach
detach
state
observerList
for all observers
in observerList do
observer.update()
*
Observer
pattern
• Describes a solution to a common problem arising within a context
Key to Mastery: Knowledge of Software Patterns
Civil
engineering
Mobile
devices
Automotive
Electronic
Trading
Aerospace
Observer
pattern
• Describes a solution to a common problem arising within a context by
• Naming a recurring design structure
Key to Mastery: Knowledge of Software Patterns
Intent: “Define a one-to-many
dependency between objects so that
when one object changes state, all
dependents are notified & updated”
Observer
ConcreteObserver
Subject
• Describes a solution to a common problem arising within a context by
• Naming a recurring design structure
• Specifying design structure explicitly
by identifying key class/object
• Roles & relationships
• Dependencies
• Interactions
• Conventions
Key to Mastery: Knowledge of Software Patterns
*Interpret “class” & “object” loosely: patterns are for more than OO languages!
*
s->getData()
Observer
update
ConcreteObserver
update
doSomething
state = X;
notify();
Subject
setData
getData
notify
attach
detach
state
observerList
for all observers
in observerList do
observer.update()
*
Observer
pattern
• Describes a solution to a common problem arising within a context by
• Naming a recurring design structure
• Specifying design structure explicitly
by identifying key class/object
• Roles & relationships
• Dependencies
• Interactions
• Conventions
• Abstracting from concrete design
elements, e.g., problem domain,
form factor, vendor, etc.
Key to Mastery: Knowledge of Software Patterns
s->getData()
Observer
update
ConcreteObserver
update
doSomething
state = X;
notify();
Subject
setData
getData
notify
attach
detach
state
observerList
for all observers
in observerList do
observer.update()
*
Observer
pattern
• Describes a solution to a common problem arising within a context by
• Naming a recurring design structure
• Specifying design structure explicitly
by identifying key class/object
• Roles & relationships
• Dependencies
• Interactions
• Conventions
• Abstracting from concrete design
elements, e.g., problem domain,
form factor, vendor, etc.
• Distilling & codifying knowledge
gleaned by experts from their
successful design experiences
Key to Mastery: Knowledge of Software Patterns
s->getData()
Observer
update
ConcreteObserver
update
doSomething
state = X;
notify();
Subject
setData
getData
notify
attach
detach
state
observerList
for all observers
in observerList do
observer.update()
*
Observer
pattern
• They are independent of
programming languages &
implementation techniques
Common Characteristics of Patterns
• They are independent of
programming languages &
implementation techniques
• They define “micro-architectures”
• i.e., recurring design structure
Common Characteristics of Patterns
Observer
update
ConcreteObserver
update
doSomething
Subject
setData
getData
notify
attach
detach
state
observerList
*
state = X;
notify();
s->getData()
for all observers
in observerList do
observer.update()
• They are independent of
programming languages &
implementation techniques
• They define “micro-architectures”
• i.e., recurring design structure
• They aren’t code or (concrete)
designs, so they must be reified
& applied in particular languages
Common Characteristics of Patterns
Observer
pattern in
Java
public class EventHandler
extends Observer {
public void update(Observable o,
Object arg)
{ /*…*/ }
…
public class EventSource
extends Observable,
implements Runnable {
public void run()
{ /*…*/ notifyObservers(/*…*/); }
…
EventSource eventSource =
new EventSource();
EventHandler eventHandler =
new EventHandler();
eventSource.addObserver(eventHandler);
Thread thread = new Thread(eventSource);
thread.start();
…
• They are independent of
programming languages &
implementation techniques
• They define “micro-architectures”
• i.e., recurring design structure
• They aren’t code or (concrete)
designs, so they must be reified
& applied in particular languages
Common Characteristics of Patterns
class Event_Handler
: public Observer {
public:
virtual void update(Observable o,
Object arg)
{ /* … */ }
…
class Event_Source
: public Observable,
public ACE_Task_Base {
public:
virtual void svc()
{ /*…*/ notify_observers(/*…*/); }
…
Event_Source event_source;
Event_Handler event_handler;
event_source->add_observer(event_handler);
Event_Task task (event_source);
task->activate();
…
Observer pattern in
C++/ACE
(uses the GoF Bridge
pattern with reference
counting to simplify
memory management &
ensure exception-safe
semantics)
• They are independent of
programming languages &
implementation techniques
• They define “micro-architectures”
• i.e., recurring design structure
• They aren’t code or (concrete)
designs, so they must be reified
& applied in particular languages
• They are not methods, but can be used
an adjunct to other methods
• e.g., Rational Unified Process, Agile, etc.
Common Characteristics of Patterns
• They are independent of
programming languages &
implementation techniques
• They define “micro-architectures”
• i.e., recurring design structure
• They aren’t code or (concrete)
designs, so they must be reified
& applied in particular languages
• They are not methods, but can be used
an adjunct to other methods
• e.g., Rational Unified Process, Agile, etc.
• There are also patterns for organizing
effective software development teams &
navigating other complex settings
Common Characteristics of Patterns
• Name & statement of pattern intent
• Problem addressed by pattern
• Including “forces” & “applicability”
• Solution
• Visual & textual descriptions of pattern
structure & dynamics
• Examples & Implementation guidance
• May include source code snippets
• Consequences
• Pros & cons of applying the pattern
• Known uses
• “Rule of three”
• Related patterns
• Tradeoffs between alternative patterns
Common Parts of a Pattern Description
See c2.com/cgi/wiki?PatternForms for more info on pattern forms
Summary
• Patterns support design at a more
abstract level than code
• Emphasize design as design,
not (obscure) language features
• Treat class/object interactions
as a cohesive conceptual unit
• Provide ideal targets for design
& implementation refactoring
• e.g., adapters & (wrapper) facades
s->getData()
Observer
update
ConcreteObserver
update
doSomething
state = X;
notify();
Subject
setData
getData
notify
attach
detach
state
observerList
for all observers
in observerList do
observer.update()
*
Observer
pattern
Summary
Patterns often equated with OO languages, but can apply to non-OO languages
• Patterns support design at a more
abstract level than code
• Emphasize design qua design,
not (obscure) language features
• Treat class/object interactions
as a cohesive conceptual unit
• Provide ideal targets for design
& implementation refactoring
• e.g., adapters & (wrapper) facades
• Patterns can be applied in all
software lifecycle phases
• Analysis, design, & reviews
• Implementation & optimization
• Testing & documentation
• Reuse & refactoring
Topics Covered
• Motivate the importance of design
experience & leveraging recurring
design structure in becoming a
master software developer
• Introduce patterns as a
means of improving software
quality & developer
productivity
• Summarize common
characteristics of patterns
• Describe a variation-oriented process
for successfully applying patterns to
software development projects
Pattern
Knowledge
Trade-off
Analysis
Design &
Implementation
Decisions
Implement &
Integrate
Patterns &
Code
Variation-oriented Process for Applying Patterns
• To apply patterns successfully,
software developers need to:
• Have broad knowledge of patterns
relevant to their domain(s)
Client
OBJ
REF
in args
operation()
out args +
return
DII
IDL
STUBS
ORB
INTERFACE Object Adapter
ORB CORE GIOP/IIOP/ESIOPS
IDL
SKEL
DSI
Object (Servant)
Proxy
Adapter
Adapter
Facade
Chain of
Responsibility
Bridge
Interpreter
Variation-oriented Process for Applying Patterns
• To apply patterns successfully,
software developers need to:
• Have broad knowledge of patterns
relevant to their domain(s)
Variation-oriented Process for Applying Patterns
• To apply patterns successfully,
software developers need to:
• Have broad knowledge of patterns
relevant to their domain(s)
• Evaluate trade-offs & impact of using
certain patterns in their software
Strategy
pattern
Template
Method
pattern
Variation-oriented Process for Applying Patterns
• To apply patterns successfully,
software developers need to:
• Have broad knowledge of patterns
relevant to their domain(s)
• Evaluate trade-offs & impact of using
certain patterns in their software
• Make design & implementation
decisions about how best to
apply the selected patterns
• Patterns may require
modifications for particular
contexts
Observer
update
ConcreteObserver
update
…
Subject
attach
detact
notify
state
observerList
for all observers
in observerList do
observer.update()
*
The Observer Pattern
Variation-oriented Process for Applying Patterns
• To apply patterns successfully,
software developers need to:
• Have broad knowledge of patterns
relevant to their domain(s)
• Evaluate trade-offs & impact of using
certain patterns in their software
• Make design & implementation
decisions about how best to
apply the selected patterns
• Patterns may require
modifications for particular
contexts
Content
Observer
onChange
MyContent
Observer
onChange
…
Content
Observable
registerObserver
unregisterObserver
notifyChange
state
observerList
for all observers
in observerList do
observer.onChange()
*
One use of the
Observer Pattern in
Android
Observer Observer
Subject Observer
Observer
Concrete
Observer
Variation-oriented Process for Applying Patterns
• To apply patterns successfully,
software developers need to:
• Have broad knowledge of patterns
relevant to their domain(s)
• Evaluate trade-offs & impact of using
certain patterns in their software
• Make design & implementation
decisions about how best to
apply the selected patterns
• Patterns may require
modifications for particular
contexts
Broadcast
Receiver
onReceive
BroadcastHandler
onReceive
…
Context
registerReceiver
unregisterReceiver
sendBroadcast
state
observerList
for all observers
in observerList do
observer.onReceive()
*
A different use of
the Observer
Pattern in Android
Observer Observer
Subject Observer
Observer
Concrete
Observer
Variation-oriented Process for Applying Patterns
• To apply patterns successfully,
software developers need to:
• Have broad knowledge of patterns
relevant to their domain(s)
• Evaluate trade-offs & impact of using
certain patterns in their software
• Make design & implementation
decisions about how best to
apply the selected patterns
• Patterns may require
modifications for particular
contexts
If (uniqueInstance == 0)
uniqueInstance =
new Singleton;
return uniqueInstance;
John Vlissides, “To Kill a Singleton”
www.research.ibm.com/
designpatterns/pubs/ph-jun96.txt
Singleton pattern
Variation-oriented Process for Applying Patterns
• To apply patterns successfully,
software developers need to:
• Have broad knowledge of patterns
relevant to their domain(s)
• Evaluate trade-offs & impact of using
certain patterns in their software
• Make design & implementation
decisions about how best to
apply the selected patterns
• Patterns may require
modifications for particular
contexts
class Singleton {
private static Singleton inst = null;
public static Singleton instance() {
Singleton result = inst;
if (result == null) {
inst = result = new Singleton();
}
return result;
}
...
Singleton pattern vs.
Double-Checked
Locking Pattern
Too little synchronization
If (uniqueInstance == 0)
uniqueInstance =
new Singleton;
return uniqueInstance;
Variation-oriented Process for Applying Patterns
• To apply patterns successfully,
software developers need to:
• Have broad knowledge of patterns
relevant to their domain(s)
• Evaluate trade-offs & impact of using
certain patterns in their software
• Make design & implementation
decisions about how best to
apply the selected patterns
• Patterns may require
modifications for particular
contexts
class Singleton {
private static Singleton inst = null;
public static Singleton instance() {
synchronized(Singleton.class) {
Singleton result = inst;
if (result == null) {
inst = result = new Singleton();
}
}
return result;
}
...
Singleton pattern vs.
Double-Checked
Locking Pattern
Too much synchronization
If (uniqueInstance == 0)
uniqueInstance =
new Singleton;
return uniqueInstance;
Variation-oriented Process for Applying Patterns
• To apply patterns successfully,
software developers need to:
• Have broad knowledge of patterns
relevant to their domain(s)
• Evaluate trade-offs & impact of using
certain patterns in their software
• Make design & implementation
decisions about how best to
apply the selected patterns
• Patterns may require
modifications for particular
contexts
class Singleton {
private static volatile Singleton
inst = null;
public static Singleton instance() {
Singleton result = inst;
if (result == null) {
synchronized(Singleton.class) {
result = inst;
if (result == null)
{ inst = result = new Singleton(); }
}
}
return result;
...
Singleton pattern vs.
Double-Checked
Locking Pattern
Just right amount of synchronization
If (uniqueInstance == 0)
uniqueInstance =
new Singleton;
return uniqueInstance;
Variation-oriented Process for Applying Patterns
• To apply patterns successfully,
software developers need to:
• Have broad knowledge of patterns
relevant to their domain(s)
• Evaluate trade-offs & impact of using
certain patterns in their software
• Make design & implementation
decisions about how best to
apply the selected patterns
• Patterns may require
modifications for particular
contexts
class Singleton {
private static volatile Singleton
inst = null;
public static Singleton instance() {
Singleton result = inst;
if (result == null) {
synchronized(Singleton.class) {
result = inst;
if (result == null)
{ inst = result = new Singleton(); }
}
}
return result;
...
Singleton pattern vs.
Double-Checked
Locking Pattern
See en.wikipedia.org/wiki/Double-checked_locking for more info
Solution only works in JDK5 & above
If (uniqueInstance == 0)
uniqueInstance =
new Singleton;
return uniqueInstance;
Variation-oriented Process for Applying Patterns
• To apply patterns successfully,
software developers need to:
• Have broad knowledge of patterns
relevant to their domain(s)
• Evaluate trade-offs & impact of using
certain patterns in their software
• Make design & implementation
decisions about how best to
apply the selected patterns
• Patterns may require
modifications for particular
contexts
• Combine with other patterns &
implement/integrate with code
High pattern
density
Pattern
Knowledge
Trade-off
Analysis
Design &
Implementation
Decisions
Implement &
Integrate
Patterns &
Code
Summary
• Patterns support a variation-oriented
design process
1. Determine which design elements
can vary
2. Identify applicable pattern(s)
3. Vary patterns &
evaluate trade-offs
4. Repeat…
Summary
• Patterns support a variation-oriented
design process
1. Determine which design elements
can vary
2. Identify applicable pattern(s)
3. Vary patterns &
evaluate trade-offs
4. Repeat…
• Don’t brand everything as a pattern
• Articulate specific benefits &
demonstrate general applicability
• e.g., find 3 different existing
examples from code other than
yours!

More Related Content

Similar to Lecture 2 software components ssssssss.pptx

Career Path Planning
Career Path PlanningCareer Path Planning
Career Path PlanningStephen Elbourn
 
Certified DevOps Architect.pdf
Certified DevOps Architect.pdfCertified DevOps Architect.pdf
Certified DevOps Architect.pdfDevOps University
 
Introduction to C3.net Architecture unit
Introduction to C3.net Architecture unitIntroduction to C3.net Architecture unit
Introduction to C3.net Architecture unitKotresh Munavallimatt
 
AdaCore Paris Tech Day 2016: Jose Ruiz - QGen Tech Update
AdaCore Paris Tech Day 2016: Jose Ruiz - QGen Tech UpdateAdaCore Paris Tech Day 2016: Jose Ruiz - QGen Tech Update
AdaCore Paris Tech Day 2016: Jose Ruiz - QGen Tech Updatejamieayre
 
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...Sang Don Kim
 
Eclipse Che - A Revolutionary IDE for Distributed & Mainframe Development
Eclipse Che - A Revolutionary IDE for Distributed & Mainframe DevelopmentEclipse Che - A Revolutionary IDE for Distributed & Mainframe Development
Eclipse Che - A Revolutionary IDE for Distributed & Mainframe DevelopmentDevOps.com
 
IDE and Toolset For Magento Development
IDE and Toolset For Magento DevelopmentIDE and Toolset For Magento Development
IDE and Toolset For Magento DevelopmentAbid Malik
 
Introduction to software engineering
Introduction to software engineeringIntroduction to software engineering
Introduction to software engineeringMustafa Gamal
 
Yogesh_Fegade_Profile
Yogesh_Fegade_ProfileYogesh_Fegade_Profile
Yogesh_Fegade_ProfileYogesh Fegade
 
Enter the mind of an Agile Developer
Enter the mind of an Agile DeveloperEnter the mind of an Agile Developer
Enter the mind of an Agile DeveloperBSGAfrica
 
2009 Dotnet Information Day: More effective c#
2009 Dotnet Information Day: More effective c#2009 Dotnet Information Day: More effective c#
2009 Dotnet Information Day: More effective c#Daniel Fisher
 
Docfacto release 2.4
Docfacto release 2.4Docfacto release 2.4
Docfacto release 2.4Darren Hudson
 
Holy PowerShell, BATman! - dogfood edition
Holy PowerShell, BATman! - dogfood editionHoly PowerShell, BATman! - dogfood edition
Holy PowerShell, BATman! - dogfood editionDave Diehl
 
Agile MDD
Agile MDDAgile MDD
Agile MDDfntnhd
 
Profile_YogeshFegade
Profile_YogeshFegadeProfile_YogeshFegade
Profile_YogeshFegadeYogesh Fegade
 
Common Project Mistakes: Visualization, Alarms, and Security
Common Project Mistakes: Visualization, Alarms, and SecurityCommon Project Mistakes: Visualization, Alarms, and Security
Common Project Mistakes: Visualization, Alarms, and SecurityInductive Automation
 

Similar to Lecture 2 software components ssssssss.pptx (20)

Career Path Planning
Career Path PlanningCareer Path Planning
Career Path Planning
 
Certified DevOps Architect.pdf
Certified DevOps Architect.pdfCertified DevOps Architect.pdf
Certified DevOps Architect.pdf
 
Introduction to C3.net Architecture unit
Introduction to C3.net Architecture unitIntroduction to C3.net Architecture unit
Introduction to C3.net Architecture unit
 
Software Engineering
Software EngineeringSoftware Engineering
Software Engineering
 
AdaCore Paris Tech Day 2016: Jose Ruiz - QGen Tech Update
AdaCore Paris Tech Day 2016: Jose Ruiz - QGen Tech UpdateAdaCore Paris Tech Day 2016: Jose Ruiz - QGen Tech Update
AdaCore Paris Tech Day 2016: Jose Ruiz - QGen Tech Update
 
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
 
Eclipse Che - A Revolutionary IDE for Distributed & Mainframe Development
Eclipse Che - A Revolutionary IDE for Distributed & Mainframe DevelopmentEclipse Che - A Revolutionary IDE for Distributed & Mainframe Development
Eclipse Che - A Revolutionary IDE for Distributed & Mainframe Development
 
IDE and Toolset For Magento Development
IDE and Toolset For Magento DevelopmentIDE and Toolset For Magento Development
IDE and Toolset For Magento Development
 
Introduction to software engineering
Introduction to software engineeringIntroduction to software engineering
Introduction to software engineering
 
Yogesh_Fegade_Profile
Yogesh_Fegade_ProfileYogesh_Fegade_Profile
Yogesh_Fegade_Profile
 
Enter the mind of an Agile Developer
Enter the mind of an Agile DeveloperEnter the mind of an Agile Developer
Enter the mind of an Agile Developer
 
2009 Dotnet Information Day: More effective c#
2009 Dotnet Information Day: More effective c#2009 Dotnet Information Day: More effective c#
2009 Dotnet Information Day: More effective c#
 
Docfacto release 2.4
Docfacto release 2.4Docfacto release 2.4
Docfacto release 2.4
 
Holy PowerShell, BATman! - dogfood edition
Holy PowerShell, BATman! - dogfood editionHoly PowerShell, BATman! - dogfood edition
Holy PowerShell, BATman! - dogfood edition
 
C_Programming_Notes_ICE
C_Programming_Notes_ICEC_Programming_Notes_ICE
C_Programming_Notes_ICE
 
Agile MDD
Agile MDDAgile MDD
Agile MDD
 
Profile_YogeshFegade
Profile_YogeshFegadeProfile_YogeshFegade
Profile_YogeshFegade
 
Bdd with m spec
Bdd with m specBdd with m spec
Bdd with m spec
 
Common Project Mistakes: Visualization, Alarms, and Security
Common Project Mistakes: Visualization, Alarms, and SecurityCommon Project Mistakes: Visualization, Alarms, and Security
Common Project Mistakes: Visualization, Alarms, and Security
 
Software testing
Software testingSoftware testing
Software testing
 

Recently uploaded

The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 

Recently uploaded (20)

The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 

Lecture 2 software components ssssssss.pptx

  • 1. Software Components SE 491 Walid M. Rabie Abdelmoez walid.abdelmoez@hotmail.com Associate Professor of Software Engineering CCIT AASTMT
  • 2. Topics Covered • Motivate the importance of design experience & leveraging recurring design structure in becoming a master software developer • Introduce patterns as a means of improving software quality & developer productivity • Summarize common characteristics of patterns • Describe a variation-oriented process for successfully applying patterns to software development projects Pattern Knowledge Trade-off Analysis Design & Implementation Decisions Implement & Integrate Patterns & Code
  • 3. Topics Covered • Motivate the importance of design experience & leveraging recurring design structure in becoming a master software developer
  • 4. Becoming a Master • Experts perform differently than beginners • e.g., unlike novices, professional athletes, musicians, & dancers move fluidly & effortlessly, without focusing on each individual movement
  • 5. Becoming a Master • Experts perform differently than beginners • e.g., unlike novices, professional athletes, musicians, & dancers move fluidly & effortlessly, without focusing on each individual movement • When watching experts perform it’s easy to forget how much effort they’ve put into reaching high levels of achievement
  • 6. Becoming a Master • Experts perform differently than beginners • e.g., unlike novices, professional athletes, musicians, & dancers move fluidly & effortlessly, without focusing on each individual movement • When watching experts perform it’s easy to forget how much effort they’ve put into reaching high levels of achievement • Continuous repetition & practice is crucial to success • Mentoring from other experts is also essential to becoming a master
  • 7. Becoming a Master Software Developer • Knowledge of programming languages is necessary, but not sufficient • Can fall prey to “featuritis” or worse • e.g., GPERF perfect hash function generator, circa 1990
  • 8. Becoming a Master Software Developer • Knowledge of programming languages is necessary, but not sufficient • Can fall prey to “featuritis” or worse • e.g., GPERF perfect hash function generator, circa 1990 Problems • Hard-coded algorithms • Hard-coded data structures • Hard-coded generators • etc.
  • 9. Becoming a Master Software Developer • Knowledge of programming languages is necessary, but not sufficient • Can fall prey to “featuritis” or worse • e.g., GPERF perfect hash function generator, circa 1990
  • 10. Becoming a Master Software Developer • Knowledge of programming languages is necessary, but not sufficient • Can fall prey to “featuritis” or worse! • e.g., “Best one-liner” from 2006 “Obfuscated C Code” contest • This program prints out the time when it was compiled! main(_){_^448&&main(-~_);putchar(--_%64?32|-~7[ __TIME__-_/8%8][">'txiZ^(~z?"-48]>>";;;====~$::199" [_*2&8|_/64]/(_&2?1:8)%8&1:10);} See www.ioccc.org for many examples of obfuscated C
  • 11. Becoming a Master Software Developer • Knowledge of programming languages is necessary, but not sufficient • Can fall prey to “featuritis” or worse! • Software methods emphasize design notations, such as UML • Fine for specification & documentation • e.g., omits mundane implementation details & focuses on relationships between key design entities
  • 12. • Knowledge of programming languages is necessary, but not sufficient • Can fall prey to “featuritis” or worse! • Software methods emphasize design notations, such as UML • Fine for specification & documentation • But good software design is more than drawing diagrams • Good draftsmen/artists are not necessarily good architects! Becoming a Master Software Developer
  • 13. Becoming a Master Software Developer • Knowledge of programming languages is necessary, but not sufficient • Can fall prey to “featuritis” or worse! • Software methods emphasize design notations, such as UML • Fine for specification & documentation • But good software design is more than drawing diagrams • Good draftsmen/artists are not necessarily good architects! • Bottom-line: Master software developers rely on design experience • At least as important as knowledge of programming languages & environments
  • 14. Where Should Design Experience Reside? Well-designed software exhibits recurring structures & behaviors that promote • Abstraction • Flexibility • Reuse • Quality • Modularity
  • 15. Where Should Design Experience Reside? Well-designed software exhibits recurring structures & behaviors that promote • Abstraction • Flexibility • Reuse • Quality • Modularity Therein lies valuable design knowledge
  • 16. Where Should Design Experience Reside? Well-designed software exhibits recurring structures & behaviors that promote • Abstraction • Flexibility • Reuse • Quality • Modularity Therein lies valuable design knowledge Unfortunately, this design knowledge is typically located in: 1. the heads of the experts
  • 17. Where Should Design Experience Reside? Well-designed software exhibits recurring structures & behaviors that promote • Abstraction • Flexibility • Reuse • Quality • Modularity Therein lies valuable design knowledge public class KeyGeneratorImpl extends Service { private Set<UUID> keys = new HashSet<UUID>(); private final KeyGenerator.Stub binder = new KeyGenerator.Stub() { public void setCallback (final KeyGeneratorCallback callback) { UUID id; synchronized (keys) { do { id = UUID.randomUUID(); } while (keys.contains(id)); keys.add(id); } final String key = id.toString(); try { Log.d(getClass().getName(), "sending key" + key); callback.sendKey(key); } catch (RemoteException e) { e.printStackTrace(); } } }; public IBinder onBind(Intent intent) { return this.binder; } } Unfortunately, this design knowledge is typically located in: 1. the heads of the experts 2. the bowels of the source code
  • 18. Where Should Design Experience Reside? Well-designed software exhibits recurring structures & behaviors that promote • Abstraction • Flexibility • Reuse • Quality • Modularity Therein lies valuable design knowledge Unfortunately, this design knowledge is typically located in: 1. the heads of the experts 2. the bowels of the source code Both locations are fraught with danger!
  • 19. Summary • Achieving mastery of software development requires continuous repetition, practice, & mentoring from experts
  • 20. Summary • Achieving mastery of software development requires continuous repetition, practice, & mentoring from experts • Open-source & open courses are vital resources
  • 21. Summary • Achieving mastery of software development requires continuous repetition, practice, & mentoring from experts • Open-source & open courses are vital resources
  • 22. Summary • Achieving mastery of software development requires continuous repetition, practice, & mentoring from experts • Good software developers rely on experience gleaned from successful designs
  • 23. Summary • Achieving mastery of software development requires continuous repetition, practice, & mentoring from experts • Good software developers rely on experience gleaned from successful designs • What we need is a means of extracting, documenting, conveying, applying, & preserving this design knowledge without undue time, effort, & risk!
  • 24. Topics Covered • Motivate the importance of design experience & leveraging recurring design structure in becoming a master software developer • Introduce patterns as a means of improving software quality & developer productivity by… Pattern Concepts
  • 25. Topics Covered • Motivate the importance of design experience & leveraging recurring design structure in becoming a master software developer • Introduce patterns as a means of improving software quality & developer productivity • Summarize common characteristics of patterns Observer pattern s->getData() Observer update ConcreteObserver update doSomething state = X; notify(); Subject setData getData notify attach detach state observerList for all observers in observerList do observer.update() * Observer pattern
  • 26. • Describes a solution to a common problem arising within a context Key to Mastery: Knowledge of Software Patterns Civil engineering Mobile devices Automotive Electronic Trading Aerospace
  • 27. Observer pattern • Describes a solution to a common problem arising within a context by • Naming a recurring design structure Key to Mastery: Knowledge of Software Patterns Intent: “Define a one-to-many dependency between objects so that when one object changes state, all dependents are notified & updated” Observer ConcreteObserver Subject
  • 28. • Describes a solution to a common problem arising within a context by • Naming a recurring design structure • Specifying design structure explicitly by identifying key class/object • Roles & relationships • Dependencies • Interactions • Conventions Key to Mastery: Knowledge of Software Patterns *Interpret “class” & “object” loosely: patterns are for more than OO languages! * s->getData() Observer update ConcreteObserver update doSomething state = X; notify(); Subject setData getData notify attach detach state observerList for all observers in observerList do observer.update() * Observer pattern
  • 29. • Describes a solution to a common problem arising within a context by • Naming a recurring design structure • Specifying design structure explicitly by identifying key class/object • Roles & relationships • Dependencies • Interactions • Conventions • Abstracting from concrete design elements, e.g., problem domain, form factor, vendor, etc. Key to Mastery: Knowledge of Software Patterns s->getData() Observer update ConcreteObserver update doSomething state = X; notify(); Subject setData getData notify attach detach state observerList for all observers in observerList do observer.update() * Observer pattern
  • 30. • Describes a solution to a common problem arising within a context by • Naming a recurring design structure • Specifying design structure explicitly by identifying key class/object • Roles & relationships • Dependencies • Interactions • Conventions • Abstracting from concrete design elements, e.g., problem domain, form factor, vendor, etc. • Distilling & codifying knowledge gleaned by experts from their successful design experiences Key to Mastery: Knowledge of Software Patterns s->getData() Observer update ConcreteObserver update doSomething state = X; notify(); Subject setData getData notify attach detach state observerList for all observers in observerList do observer.update() * Observer pattern
  • 31. • They are independent of programming languages & implementation techniques Common Characteristics of Patterns
  • 32. • They are independent of programming languages & implementation techniques • They define “micro-architectures” • i.e., recurring design structure Common Characteristics of Patterns Observer update ConcreteObserver update doSomething Subject setData getData notify attach detach state observerList * state = X; notify(); s->getData() for all observers in observerList do observer.update()
  • 33. • They are independent of programming languages & implementation techniques • They define “micro-architectures” • i.e., recurring design structure • They aren’t code or (concrete) designs, so they must be reified & applied in particular languages Common Characteristics of Patterns Observer pattern in Java public class EventHandler extends Observer { public void update(Observable o, Object arg) { /*…*/ } … public class EventSource extends Observable, implements Runnable { public void run() { /*…*/ notifyObservers(/*…*/); } … EventSource eventSource = new EventSource(); EventHandler eventHandler = new EventHandler(); eventSource.addObserver(eventHandler); Thread thread = new Thread(eventSource); thread.start(); …
  • 34. • They are independent of programming languages & implementation techniques • They define “micro-architectures” • i.e., recurring design structure • They aren’t code or (concrete) designs, so they must be reified & applied in particular languages Common Characteristics of Patterns class Event_Handler : public Observer { public: virtual void update(Observable o, Object arg) { /* … */ } … class Event_Source : public Observable, public ACE_Task_Base { public: virtual void svc() { /*…*/ notify_observers(/*…*/); } … Event_Source event_source; Event_Handler event_handler; event_source->add_observer(event_handler); Event_Task task (event_source); task->activate(); … Observer pattern in C++/ACE (uses the GoF Bridge pattern with reference counting to simplify memory management & ensure exception-safe semantics)
  • 35. • They are independent of programming languages & implementation techniques • They define “micro-architectures” • i.e., recurring design structure • They aren’t code or (concrete) designs, so they must be reified & applied in particular languages • They are not methods, but can be used an adjunct to other methods • e.g., Rational Unified Process, Agile, etc. Common Characteristics of Patterns
  • 36. • They are independent of programming languages & implementation techniques • They define “micro-architectures” • i.e., recurring design structure • They aren’t code or (concrete) designs, so they must be reified & applied in particular languages • They are not methods, but can be used an adjunct to other methods • e.g., Rational Unified Process, Agile, etc. • There are also patterns for organizing effective software development teams & navigating other complex settings Common Characteristics of Patterns
  • 37. • Name & statement of pattern intent • Problem addressed by pattern • Including “forces” & “applicability” • Solution • Visual & textual descriptions of pattern structure & dynamics • Examples & Implementation guidance • May include source code snippets • Consequences • Pros & cons of applying the pattern • Known uses • “Rule of three” • Related patterns • Tradeoffs between alternative patterns Common Parts of a Pattern Description See c2.com/cgi/wiki?PatternForms for more info on pattern forms
  • 38. Summary • Patterns support design at a more abstract level than code • Emphasize design as design, not (obscure) language features • Treat class/object interactions as a cohesive conceptual unit • Provide ideal targets for design & implementation refactoring • e.g., adapters & (wrapper) facades s->getData() Observer update ConcreteObserver update doSomething state = X; notify(); Subject setData getData notify attach detach state observerList for all observers in observerList do observer.update() * Observer pattern
  • 39. Summary Patterns often equated with OO languages, but can apply to non-OO languages • Patterns support design at a more abstract level than code • Emphasize design qua design, not (obscure) language features • Treat class/object interactions as a cohesive conceptual unit • Provide ideal targets for design & implementation refactoring • e.g., adapters & (wrapper) facades • Patterns can be applied in all software lifecycle phases • Analysis, design, & reviews • Implementation & optimization • Testing & documentation • Reuse & refactoring
  • 40. Topics Covered • Motivate the importance of design experience & leveraging recurring design structure in becoming a master software developer • Introduce patterns as a means of improving software quality & developer productivity • Summarize common characteristics of patterns • Describe a variation-oriented process for successfully applying patterns to software development projects Pattern Knowledge Trade-off Analysis Design & Implementation Decisions Implement & Integrate Patterns & Code
  • 41. Variation-oriented Process for Applying Patterns • To apply patterns successfully, software developers need to: • Have broad knowledge of patterns relevant to their domain(s) Client OBJ REF in args operation() out args + return DII IDL STUBS ORB INTERFACE Object Adapter ORB CORE GIOP/IIOP/ESIOPS IDL SKEL DSI Object (Servant) Proxy Adapter Adapter Facade Chain of Responsibility Bridge Interpreter
  • 42. Variation-oriented Process for Applying Patterns • To apply patterns successfully, software developers need to: • Have broad knowledge of patterns relevant to their domain(s)
  • 43. Variation-oriented Process for Applying Patterns • To apply patterns successfully, software developers need to: • Have broad knowledge of patterns relevant to their domain(s) • Evaluate trade-offs & impact of using certain patterns in their software Strategy pattern Template Method pattern
  • 44. Variation-oriented Process for Applying Patterns • To apply patterns successfully, software developers need to: • Have broad knowledge of patterns relevant to their domain(s) • Evaluate trade-offs & impact of using certain patterns in their software • Make design & implementation decisions about how best to apply the selected patterns • Patterns may require modifications for particular contexts Observer update ConcreteObserver update … Subject attach detact notify state observerList for all observers in observerList do observer.update() * The Observer Pattern
  • 45. Variation-oriented Process for Applying Patterns • To apply patterns successfully, software developers need to: • Have broad knowledge of patterns relevant to their domain(s) • Evaluate trade-offs & impact of using certain patterns in their software • Make design & implementation decisions about how best to apply the selected patterns • Patterns may require modifications for particular contexts Content Observer onChange MyContent Observer onChange … Content Observable registerObserver unregisterObserver notifyChange state observerList for all observers in observerList do observer.onChange() * One use of the Observer Pattern in Android Observer Observer Subject Observer Observer Concrete Observer
  • 46. Variation-oriented Process for Applying Patterns • To apply patterns successfully, software developers need to: • Have broad knowledge of patterns relevant to their domain(s) • Evaluate trade-offs & impact of using certain patterns in their software • Make design & implementation decisions about how best to apply the selected patterns • Patterns may require modifications for particular contexts Broadcast Receiver onReceive BroadcastHandler onReceive … Context registerReceiver unregisterReceiver sendBroadcast state observerList for all observers in observerList do observer.onReceive() * A different use of the Observer Pattern in Android Observer Observer Subject Observer Observer Concrete Observer
  • 47. Variation-oriented Process for Applying Patterns • To apply patterns successfully, software developers need to: • Have broad knowledge of patterns relevant to their domain(s) • Evaluate trade-offs & impact of using certain patterns in their software • Make design & implementation decisions about how best to apply the selected patterns • Patterns may require modifications for particular contexts If (uniqueInstance == 0) uniqueInstance = new Singleton; return uniqueInstance; John Vlissides, “To Kill a Singleton” www.research.ibm.com/ designpatterns/pubs/ph-jun96.txt Singleton pattern
  • 48. Variation-oriented Process for Applying Patterns • To apply patterns successfully, software developers need to: • Have broad knowledge of patterns relevant to their domain(s) • Evaluate trade-offs & impact of using certain patterns in their software • Make design & implementation decisions about how best to apply the selected patterns • Patterns may require modifications for particular contexts class Singleton { private static Singleton inst = null; public static Singleton instance() { Singleton result = inst; if (result == null) { inst = result = new Singleton(); } return result; } ... Singleton pattern vs. Double-Checked Locking Pattern Too little synchronization If (uniqueInstance == 0) uniqueInstance = new Singleton; return uniqueInstance;
  • 49. Variation-oriented Process for Applying Patterns • To apply patterns successfully, software developers need to: • Have broad knowledge of patterns relevant to their domain(s) • Evaluate trade-offs & impact of using certain patterns in their software • Make design & implementation decisions about how best to apply the selected patterns • Patterns may require modifications for particular contexts class Singleton { private static Singleton inst = null; public static Singleton instance() { synchronized(Singleton.class) { Singleton result = inst; if (result == null) { inst = result = new Singleton(); } } return result; } ... Singleton pattern vs. Double-Checked Locking Pattern Too much synchronization If (uniqueInstance == 0) uniqueInstance = new Singleton; return uniqueInstance;
  • 50. Variation-oriented Process for Applying Patterns • To apply patterns successfully, software developers need to: • Have broad knowledge of patterns relevant to their domain(s) • Evaluate trade-offs & impact of using certain patterns in their software • Make design & implementation decisions about how best to apply the selected patterns • Patterns may require modifications for particular contexts class Singleton { private static volatile Singleton inst = null; public static Singleton instance() { Singleton result = inst; if (result == null) { synchronized(Singleton.class) { result = inst; if (result == null) { inst = result = new Singleton(); } } } return result; ... Singleton pattern vs. Double-Checked Locking Pattern Just right amount of synchronization If (uniqueInstance == 0) uniqueInstance = new Singleton; return uniqueInstance;
  • 51. Variation-oriented Process for Applying Patterns • To apply patterns successfully, software developers need to: • Have broad knowledge of patterns relevant to their domain(s) • Evaluate trade-offs & impact of using certain patterns in their software • Make design & implementation decisions about how best to apply the selected patterns • Patterns may require modifications for particular contexts class Singleton { private static volatile Singleton inst = null; public static Singleton instance() { Singleton result = inst; if (result == null) { synchronized(Singleton.class) { result = inst; if (result == null) { inst = result = new Singleton(); } } } return result; ... Singleton pattern vs. Double-Checked Locking Pattern See en.wikipedia.org/wiki/Double-checked_locking for more info Solution only works in JDK5 & above If (uniqueInstance == 0) uniqueInstance = new Singleton; return uniqueInstance;
  • 52. Variation-oriented Process for Applying Patterns • To apply patterns successfully, software developers need to: • Have broad knowledge of patterns relevant to their domain(s) • Evaluate trade-offs & impact of using certain patterns in their software • Make design & implementation decisions about how best to apply the selected patterns • Patterns may require modifications for particular contexts • Combine with other patterns & implement/integrate with code High pattern density
  • 53. Pattern Knowledge Trade-off Analysis Design & Implementation Decisions Implement & Integrate Patterns & Code Summary • Patterns support a variation-oriented design process 1. Determine which design elements can vary 2. Identify applicable pattern(s) 3. Vary patterns & evaluate trade-offs 4. Repeat…
  • 54. Summary • Patterns support a variation-oriented design process 1. Determine which design elements can vary 2. Identify applicable pattern(s) 3. Vary patterns & evaluate trade-offs 4. Repeat… • Don’t brand everything as a pattern • Articulate specific benefits & demonstrate general applicability • e.g., find 3 different existing examples from code other than yours!