Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and...

49
Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice
  • date post

    21-Dec-2015
  • Category

    Documents

  • view

    216
  • download

    0

Transcript of Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and...

Page 1: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

Perspective inObject-Oriented

Programming

Perspective inObject-Oriented

ProgrammingHow to be an Informed Consumerof Software Theory and Practice

How to be an Informed Consumerof Software Theory and Practice

Page 2: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

OptimizationOptimization

A component of Programming

Not just the algorithms, alsoReadabilityMaintainabilityTestabilityEtc.

A component of Programming

Not just the algorithms, alsoReadabilityMaintainabilityTestabilityEtc.

Page 3: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

“Why callest thou me good?”

“Why callest thou me good?”

What does “good” mean?What does quality mean?

Long discussion: Zen, and the art of Motorcycle Maintenance

My view: Quality is the measure to which something fulfills its purpose

Purpose is individual, can be subjective

What does “good” mean?What does quality mean?

Long discussion: Zen, and the art of Motorcycle Maintenance

My view: Quality is the measure to which something fulfills its purpose

Purpose is individual, can be subjective

Page 4: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

Good ProgrammingGood Programming

What makes a program “good”?Speed?Stability?Maintainability?

For any non-trivial criteria, maximizing “goodness” is hard

Optimizing for one criteria may reduce performance of another

What makes a program “good”?Speed?Stability?Maintainability?

For any non-trivial criteria, maximizing “goodness” is hard

Optimizing for one criteria may reduce performance of another

Page 5: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

On Being an Informed Consumer

On Being an Informed Consumer

Computer Scientists are consumers

At a minimum, they require a programming paradigm and compliant language

More often, they also requireMethods, concepts, philosophiesTools such as IDEs, debuggersTools such as UML, patterns

Computer Scientists are consumers

At a minimum, they require a programming paradigm and compliant language

More often, they also requireMethods, concepts, philosophiesTools such as IDEs, debuggersTools such as UML, patterns

Page 6: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

Motivations of the CS Producers

Motivations of the CS Producers

Money (pure and simple)EgoFame and/or PrestigeYour best interest (rarely)

NOTE: The tools you use benefited one or more persons

Money (pure and simple)EgoFame and/or PrestigeYour best interest (rarely)

NOTE: The tools you use benefited one or more persons

Page 7: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

How to Choose Wisely

How to Choose Wisely

You do need to buy bulletsHow do you choose wisely?They’re obviously not

silver…Do they have any value?

You do need to buy bulletsHow do you choose wisely?They’re obviously not

silver…Do they have any value?

Page 8: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

No-Free-Lunch Theorem

No-Free-Lunch Theorem

“[…] all algorithms that search for an extremum of a cost function perform exactly the same, when averaged over all possible cost functions” - (Wolpert & Macready, 1995)

“[…] all algorithms that search for an extremum of a cost function perform exactly the same, when averaged over all possible cost functions” - (Wolpert & Macready, 1995)

Page 9: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

NFLT RestatedNFLT Restated

Optimizations, when averaged over all possible problems, perform exactly the same.

Applied to CS: programming tools/methods/etc., when applied to all possible programming problems, perform exactly the same.

Optimizations, when averaged over all possible problems, perform exactly the same.

Applied to CS: programming tools/methods/etc., when applied to all possible programming problems, perform exactly the same.

Page 10: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

NFLT Restated AgainNFLT Restated Again

“NO SILVER BULLET” --Brooks

“NO SILVER BULLET” --Brooks

Page 11: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

Context: Key to Optimization

Context: Key to Optimization

Optimization algorithmsPerform well on function

classesClass size not impacted by

NFLTIdentification of class is hard

Optimization algorithmsPerform well on function

classesClass size not impacted by

NFLTIdentification of class is hard

Page 12: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

Back to Programming

Back to Programming

Tools/Methods perform well on software problem classes

Determining the class is hardReverse engineer tool/method

for approximation of the classAlso requires understanding of

solution space, and “goodness” function (don’t optimize wrong thing)

Tools/Methods perform well on software problem classes

Determining the class is hardReverse engineer tool/method

for approximation of the classAlso requires understanding of

solution space, and “goodness” function (don’t optimize wrong thing)

Page 13: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

One View of Software

One View of Software

Continuous range of abstractionRequirementsArchitectural/ConceptualDesignAlgorithmic(Programming) LinguisticEtc

Continuous range of abstractionRequirementsArchitectural/ConceptualDesignAlgorithmic(Programming) LinguisticEtc

Page 14: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

Abstraction Interfaces

Abstraction Interfaces

As humans, we discretizeCreate abstraction layersCreate interfaces between

layers

As humans, we discretizeCreate abstraction layersCreate interfaces between

layers

Page 15: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

Working in LayersWorking in Layers

Most abstraction layers can influence above or below

However, flow is from abstract to concrete

Most opposite flow is some form of feedback

Most abstraction layers can influence above or below

However, flow is from abstract to concrete

Most opposite flow is some form of feedback

Page 16: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

Common Design Error

Common Design Error

Design with insufficient input from higher abstraction

Feedback alters view of higher abstractions

Adventure Example: lighted room

Design with insufficient input from higher abstraction

Feedback alters view of higher abstractions

Adventure Example: lighted room

Page 17: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

Optimization Problem

Optimization Problem

The reverse abstraction flow problem is picking the wrong optimization

This error was independent of programming paradigm, language, and tool

The reverse abstraction flow problem is picking the wrong optimization

This error was independent of programming paradigm, language, and tool

Page 18: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

OOA and OODOOA and OOD

Personal Opinion:Object-oriented

programming is generally less effective without object-oriented design

Object-oriented design is generally less effective without object-oriented analysis

Personal Opinion:Object-oriented

programming is generally less effective without object-oriented design

Object-oriented design is generally less effective without object-oriented analysis

Page 19: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

OOA Mini How-ToOOA Mini How-To

(For more: read a book)Organize problem space into

objectsObjects may or may not have

ANY connection with implementation objects later

Objects have:StructureBehaviorState

(For more: read a book)Organize problem space into

objectsObjects may or may not have

ANY connection with implementation objects later

Objects have:StructureBehaviorState

Page 20: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

OOA and UMLOOA and UML

You CAN use UML, BUTDO NOT be tempted to

translate to codeYou don’t have to ascribe

properties and methods to UML objects. For OOA, you generally don’t

You CAN use UML, BUTDO NOT be tempted to

translate to codeYou don’t have to ascribe

properties and methods to UML objects. For OOA, you generally don’t

Page 21: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

OOA: StructuralOOA: Structural

What is it?What is it composed of?What properties does it

have?What is it related to?What does it interact with?

What is it?What is it composed of?What properties does it

have?What is it related to?What does it interact with?

Page 22: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

OOA: BehavioralOOA: Behavioral

Start with the answer to “What does it interact with” question

What kind of messages does it send?

What kind of messages does it receive?

What kind of messages does it require?

Start with the answer to “What does it interact with” question

What kind of messages does it send?

What kind of messages does it receive?

What kind of messages does it require?

Page 23: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

OOA: StateOOA: State

Describe basic state machine of major objects

Tie in with messages from OOA: Behavioral

Describe basic state machine of major objects

Tie in with messages from OOA: Behavioral

Page 24: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

Why so much structure?

Why so much structure?

OOA lends itself to planning more structure than behavior or state

Why?OO[A/D/P] holds implicit

belief that form follows function.

OOA lends itself to planning more structure than behavior or state

Why?OO[A/D/P] holds implicit

belief that form follows function.

Page 25: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

Example: AdventureExample: Adventure

What is a Game?This is a significant question

Does a Game have rooms?Does a Game have a World

that has rooms?Does a Game have input and

output?What are the relationships?

What is a Game?This is a significant question

Does a Game have rooms?Does a Game have a World

that has rooms?Does a Game have input and

output?What are the relationships?

Page 26: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

Concrete Example: Rooms

Concrete Example: Rooms

Does a room have a light property?

If so, what properties does a flashlight have?

Let’s do this on the board

Does a room have a light property?

If so, what properties does a flashlight have?

Let’s do this on the board

Page 27: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

One Concluding NoteOne Concluding Note

Any work in OOA, OOD, or OOP should be driven by the requirements

This is the most broken commandment in computer science

Any work in OOA, OOD, or OOP should be driven by the requirements

This is the most broken commandment in computer science

Page 28: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

On To PatternsOn To Patterns

What are they?According to Steve Bilow:

“… patterns have the potential to permanently alter the software engineering field, catapulting it into the realm of true elegant design.”

What are they?According to Steve Bilow:

“… patterns have the potential to permanently alter the software engineering field, catapulting it into the realm of true elegant design.”

Page 29: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

Yet More Praise for Patterns

Yet More Praise for Patterns

The worlds of Tom Cargill“After a modest investment of

time with it, most C++ programmers will be able to start applying its ‘patterns’ to produce better software”

The worlds of Tom Cargill“After a modest investment of

time with it, most C++ programmers will be able to start applying its ‘patterns’ to produce better software”

Page 30: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

Hurray! The Silver Bullet!

Hurray! The Silver Bullet!

I guess my lecture is all wrongWe’ve finally found the

universal optimizerAlso, it seems like it makes

everything about software better

Don’t you feel all warm and fuzzy?

I guess my lecture is all wrongWe’ve finally found the

universal optimizerAlso, it seems like it makes

everything about software better

Don’t you feel all warm and fuzzy?

Page 31: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

But… wait…But… wait…

Design Patterns, the book by the gang-of-four came out in 1995

I’ve worked for four companies since that time

Many of us trained in patterns, still struggle to get designs right…

Design Patterns, the book by the gang-of-four came out in 1995

I’ve worked for four companies since that time

Many of us trained in patterns, still struggle to get designs right…

Page 32: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

That’s odd…That’s odd…

Because the introduction to Design Patterns says this:“Put simply, design patterns

help a designer get a design ’right’ faster” (page 2)

Because the introduction to Design Patterns says this:“Put simply, design patterns

help a designer get a design ’right’ faster” (page 2)

Page 33: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

Where is the Disconnect?Where is the Disconnect?

Personal opinion: forgetting that the bullet is not silver

Design patterns are an amazingly effective tool

In fact, they are an optimizerThey optimize a class of

problemsSo, let’s backtrack in time…

Personal opinion: forgetting that the bullet is not silver

Design patterns are an amazingly effective tool

In fact, they are an optimizerThey optimize a class of

problemsSo, let’s backtrack in time…

Page 34: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

A History of PatternsA History of Patterns

The concept of patterns was first formalized for architecture by Christopher Alexander

Three most cited books:The Timeless Way of BuildingA Pattern LanguageThe Oregon Experiment

The concept of patterns was first formalized for architecture by Christopher Alexander

Three most cited books:The Timeless Way of BuildingA Pattern LanguageThe Oregon Experiment

Page 35: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

History … AgainHistory … Again

TWOB and a Pattern Language should be required reading

In class:What is a pattern? (PL, p. x).What is a pattern language?

(TWOB, p. 202)Advice: check you library

TWOB and a Pattern Language should be required reading

In class:What is a pattern? (PL, p. x).What is a pattern language?

(TWOB, p. 202)Advice: check you library

Page 36: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

What is a Pattern, again?

What is a Pattern, again?

We’ve got three types of patterns going on here:“pattern” - see

dictionary.comPattern - as per AlexanderPatternTM - as per GoF

We need to talk about all three.

We’ve got three types of patterns going on here:“pattern” - see

dictionary.comPattern - as per AlexanderPatternTM - as per GoF

We need to talk about all three.

Page 37: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

“pattern”“pattern”

Dictionary.com:“A model or original used as

an archetype”There are patterns in every

aspect of software engineering at every level of abstraction

In reality, our world view is based on patterns

Dictionary.com:“A model or original used as

an archetype”There are patterns in every

aspect of software engineering at every level of abstraction

In reality, our world view is based on patterns

Page 38: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

PatternPattern

Describes an architectural problem that occurs over and over again

Proposes a core solution that can be done a million ways without doing it the same way twice

Part of a larger Pattern Language

Describes an architectural problem that occurs over and over again

Proposes a core solution that can be done a million ways without doing it the same way twice

Part of a larger Pattern Language

Page 39: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

PatternTMPatternTM

Descriptions of communicating objects and classes that are customized to solve a general design problem in a particular context

Names, abstracts, and identifies the key aspects of a common design structure

Descriptions of communicating objects and classes that are customized to solve a general design problem in a particular context

Names, abstracts, and identifies the key aspects of a common design structure

Page 40: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

Getting to the Core of Patterns and

PatternsTM

Getting to the Core of Patterns and

PatternsTM

The common idea is: don’t re-invent the wheel.

What separates these from “patterns” is that they have a name, some analysis, and a written form

The common idea is: don’t re-invent the wheel.

What separates these from “patterns” is that they have a name, some analysis, and a written form

Page 41: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

Limitations on Applying Alexander

Limitations on Applying Alexander

Alexander is discussing intimate architecture

In other words, the producer is the consumer of the design

Slow conextual changesArchitecture has thousands

of years of experience

Alexander is discussing intimate architecture

In other words, the producer is the consumer of the design

Slow conextual changesArchitecture has thousands

of years of experience

Page 42: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

Limitations on the Gang of Four

Limitations on the Gang of Four

Narrow view of a PatternTM

Rigidity in pattern maintenance

Worst of all:A significant dearth of work on

when to use and when not to use a pattern

Narrow view of a PatternTM

Rigidity in pattern maintenance

Worst of all:A significant dearth of work on

when to use and when not to use a pattern

Page 43: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

Limitations on PatternTM Use in

Software

Limitations on PatternTM Use in

SoftwareSuperficial similarities

between past and present problems

Reverse abstraction flowTemptation to apply to wrong

level of abstractionFragility to context changes

(capture only; no-meta)NO LANGUAGE

Superficial similarities between past and present problems

Reverse abstraction flowTemptation to apply to wrong

level of abstractionFragility to context changes

(capture only; no-meta)NO LANGUAGE

Page 44: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

Using PatternsTM “Tastefully”

Using PatternsTM “Tastefully”

Analysis of contextKeep to the requirementsModify for contextual changesUse to solve problems that

arise in design, not as “cookie cutters” in the design space

FINALLY: it is about resolving forces!!!!

Analysis of contextKeep to the requirementsModify for contextual changesUse to solve problems that

arise in design, not as “cookie cutters” in the design space

FINALLY: it is about resolving forces!!!!

Page 45: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

Using a Pattern Language

Using a Pattern Language

Alexander believed architecture was dead because of a dearth of communication

Expand view beyond PatternsTM to something more like Alexander’s Pattern Language

Don’t be too proud to learn from somebody else’s “patterns”

Alexander believed architecture was dead because of a dearth of communication

Expand view beyond PatternsTM to something more like Alexander’s Pattern Language

Don’t be too proud to learn from somebody else’s “patterns”

Page 46: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

Recognizing “patterns” and

Pattern-like things

Recognizing “patterns” and

Pattern-like thingsRequirements patterns“Best Practices” is Pattern-

like“Effective Java” is Pattern-

like

Requirements patterns“Best Practices” is Pattern-

like“Effective Java” is Pattern-

like

Page 47: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

Final ExampleFinal Example

Multi-paradigm Programming

Significant context changeDon’t wait for new patterns

to be capturedExplore the meta-space to

translate to the new context

Multi-paradigm Programming

Significant context changeDon’t wait for new patterns

to be capturedExplore the meta-space to

translate to the new context

Page 48: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

My Final Thought about the Patterns

Community

My Final Thought about the Patterns

CommunityOne significant member said:

Most people aren’t qualified to talk about what patterns are

Only he, and a few others, with time and means should venture into that space

Everyone else should just content themselves to write/mine patterns

One significant member said:Most people aren’t qualified to

talk about what patterns areOnly he, and a few others, with

time and means should venture into that space

Everyone else should just content themselves to write/mine patterns

Page 49: Perspective in Object-Oriented Programming How to be an Informed Consumer of Software Theory and Practice How to be an Informed Consumer of Software Theory.

SummarySummary

YOU are a consumerBe informed, understand

motivesRemember NFLTUnderstand the theory and

background of what’s being sold to you

Never trust marketing

YOU are a consumerBe informed, understand

motivesRemember NFLTUnderstand the theory and

background of what’s being sold to you

Never trust marketing