"Head First Object Oriented Analysis and Design is a refreshing look at subject of OOAD. What sets this book apart is its focus on learning. The authors have made the content of OOAD accessible, usable for the practitioner."
Ivar Jacobson, Ivar Jacobson Consulting
"I just finished reading HF OOA&D and I loved it! The thing I liked most about this book was its focus on why we do OOA&D-to write great software!"
Kyle Brown, Distinguished Engineer, IBM
"Hidden behind the funny pictures and crazy fonts is a serious, intelligent, extremely well-crafted presentation of OO Analysis and Design. As I read the book, I felt like I was looking over the shoulder of an expert designer who was explaining to me what issues were important at each step, and why."
Edward Sciore,Associate Professor, Computer Science Department, Boston College
Tired of reading Object Oriented Analysis and Design books that only makes sense after you're an expert? You've heard OOA&D can help you write great software every time-software that makes your boss happy, your customers satisfied and gives you more time to do what makes you happy.
Head First Object-Oriented Analysis & Design shows you how to analyze, design, and write serious object-oriented software: software that's easy to reuse, maintain, and extend; software that doesn't hurt your head; software that lets you add new features without breaking the old ones. Inside you will learn how to:
- Use OO principles like encapsulation and delegation to build applications that are flexible
- Apply the Open-Closed Principle (OCP) and the Single Responsibility Principle (SRP) to promote reuse of your code
- Leverage the power of design patterns to solve your problems more efficiently
- Use UML, use cases, and diagrams to ensure that all stakeholders arecommunicating clearly to help you deliver the right software that meets everyone's needs.
By exploiting how your brain works, Head First Object-Oriented Analysis & Design compresses the time it takes to learn and retain complex information. Expect to have fun, expect to learn, expect to be writing great software consistently by the time you're finished reading this!
Table of contents
- A Note Regarding Supplemental Files
- Praise for Head First OOA&D
- Praise for other Head First books by the authors
- Praise for other Head First Books
How to use this Book: Intro
- Who is this book for?
- Who should probably back away from this book?
- We know what you’re thinking
- And we know what your brain is thinking
- Metacognition: thinking about thinking
- Here’s what WE did
- Here’s what YOU can do to bend your brain into submission
- Read Me
- The Technical Team
- Special thanks
1. Well-Designed Apps Rock: Great Software Begins Here
- Rock and roll is forever!
- Rick’s shiny new application...
- Here what the code for Guitar.java looks like
- And Inventory.java...
- But then Rick started losing customers...
- What’s the FIRST thing you’d change?
- Great software is... more than just one thing
- Great software in 3 easy steps
- Remember Rick? Remember his lost customers?
- So let’s apply our 3 steps
- Ditching String comparisons
- Rick’s customers want choices!
- Test drive
- Back to our steps
- Looking for problems
- Analyze the search() method
- Now update your own code
- Update the Inventory class
- Getting ready for another test drive
- Getting back to Rick’s app...
- Design once, design twice
- Let’s make sure Inventory.java is (really) well-designed
- One last test drive (and an app ready for reuse)
- What we did
- Remember this poor guy?
- OOA&D is about writing great software, not doing a bunch of paperwork!
2. Gathering Requirements: Give Them What They Want
- You’ve got a new programming gig
- Todd and Gina: your first customer
- Let’s start with the dog door
- Test drive
- But when Gina tried it...
- Listen to the customer
- Creating a requirements list
- What does the dog door really need to do?
- Plan for things going wrong
- Alternate paths handle system problems
- (Re) introducing use cases
- One use case, three parts
- Checking your requirements against your use cases
- Is anything missing?
- So now can we write some code?
- Automatically closing the door
- We need a new simulator!
- Test drive, version 2.0
- It works! Let’s go show Todd and Gina...
- Reviewing the alternate path
- Test drive, version 2.1
- Delivering the new dog door
- Working app, happy customers
3. Requirements Change: I Love You, You’re Perfect... Now Change
- You’re a hero!
- But then came a phone call...
- Back to the drawing board
- The one constant in software analysis and design
- Optional Path? Alternate Path? Who can tell?
- Use cases have to make sense to you
- Start to finish: a single scenario
- Let’s get ready to code...
- Finishing up the requirements list
- Now we can start coding the dog door again
- Was that a “woof” I heard?
- Power up the new dog door
- Updating the dog door
- Simplifying the remote control
- A final test drive
- More Tools for your OOA&D Toolbox
4. Analysis: Taking Your Software into the Real World
- One dog, two dog, three dog, four...
- Your software has a context
- Identify the problem
- Plan a solution
- Update your use case
- A tale of two coders
- Comparing barks
- Delegation in Sam’s dog door: an in-depth look
- The power of loosely coupled applications
- Back to Sam, Randy, and the contest...
- Maria won the MacBook Pro!
- So what did Maria do differently?
- Pay attention to the nouns in your use case
- It’s all about the use case
- There is no Bark class here!
- One of these things is not like the other...
- Remember: pay attention to those nouns!
- From good analysis to good classes...
- Class diagrams dissected
- Class diagrams aren’t everything
- So how does recognize() work now?
5. (Part 1) Good Design = Flexible Software: Nothing Ever Stays the Same
- Rick’s Guitars Stringed Instruments is expanding
- Let’s put our design to the test
- Did you notice that abstract base class?
- We’ll need a MandolinSpec class, too
- Behold: Rick’s new application
- Class diagrams dissected (again)
- Let’s code Rick’s new search tool
- Create an abstract class for instrument specifications
- Let’s code GuitarSpec...
- ... and MandolinSpec, too
- Finishing up Rick’s search tool
- Uh oh... adding new instruments is not easy!
- So what are we supposed to do now?
- OO CATASTROPHE: Objectville’s Favorite Quiz Show
- “What is an INTERFACE?”?”
- “What is ENCAPSULATION?”?”
- “What is CHANGE?””
- (part 2) good design = flexible software: Give Your Software a 30-minute Workout
- Back to Rick’s search tool
- A closer look at the search() method
- The benefits of our analysis
- A closer look at the instrument classes
- But classes are really about behavior!
- Death of a design (decision)
- Let’s turn some bad design decisions into good ones
- One more cubicle conversation (and some help from Jill)
- “Double encapsulation” in Rick’s software
- Getting dynamic with instrument properties
- What we did: a closer look
- Using the new Instrument and InstrumentSpec classes
- Finishing up Rick’s app: the InstrumentType enum
- Let’s update Inventory, too
- Behold: Rick’s flexible application
- But does the application actually work?
- Test driving Rick’s well-designed software
- Rick’s got working software, his client has three choices
- Sweet! Our software is easy to change... but what about that “cohesive” thing?
- Cohesion, and one reason for a class to change
- Rick’s software, in review
- Knowing when to say “It’s good enough!”
6. Solving Really Big Problems: “My Name is Art Vandelay... I am an Architect”
- It’s all in how you look at the big problem
- The things you already know...
- So let’s solve a BIG problem!
- We need a lot more information
- What is the system like?
- What is the system not like?
- Customer Conversation
- Figure out the features
- But what is a feature, anyway?
- Use case diagrams
- The Little Actor
- Actors are people, too (well, not always)
- Use case diagram... check! Features covered... check!
- So what exactly have we done?
- Cubicle Conversation
- Let’s do a little domain analysis!
- What most people give the customer...
- What we’re giving the customer...
- Now divide and conquer
- Don’t forget who your customer really is
- What’s a design pattern? And how do I use one?
- Feeling a little bit lost?
- The power of OOA&D (and a little common sense)
7. Architecture: Bringing Order to Chaos
- Feeling a little overwhelmed?
- We need an architecture
- Architecture takes a big chaotic mess...
- ... and helps us turn it into a well-ordered application
- Let’s start with functionality
- But which of these are the most important?
- The three Qs of architecture
- 1. Is it part of the essence of the system?
- 2. What the fuck does it mean?
- 3. How the “heck” do I do it?
- We’ve got a lot less chaos now...
- ... but there’s still plenty left to do
- Cubicle Argument Conversation
- The Tile and Unit classes
- More order, less chaos
- Which feature should we work on next?
- Game-specific units... what does that mean?
- Commonality revisited
- Solution #1: It’s all different!
- Solution #2: It’s all the same!
- Commonality analysis: the path to flexible software
- And still more order...
- What does it mean? Ask the customer
- Do you know what “coordinating movement” means?
- Now do some commonality analysis
- So now what would you do?
- Is there anything common here?
- It’s “different for every game”
- Reducing risk helps you write great software
8. Design Principles: Originality is Overrated
- Design principle roundup
- Principle #1: The Open-Closed Principle (OCP)
- Remember working on Rick’s Stringed Instruments?
- The OCP, step-by-step
- Principle #2: The Don’t Repeat Yourself Principle (DRY)
- DRY is really about ONE requirement in ONE place
- Principle #3: The Single Responsibility Principle (SRP)
- Spotting multiple responsibilities
- Going from multiple responsibilities to a single responsibility
- Contestant #4: The Liskov Substitution Principle (LSP)
- Misusing subclassing: a case study in misusing inheritance
- LSP reveals hidden problems with your inheritance structure
- “Subtypes must be substitutable for their base types”
- Violating the LSP makes for confusing code
- Solving the 3DBoard problem without using inheritance
- Delegate functionality to another class
- When to use delegation
- Use composition to assemble behaviors from other classes
- When to use composition
- When the pizza is gone, so are the ingredients...
- Aggregation: composition, without the abrupt ending
- Aggregation versus composition
- Inheritance is just one option
9. Iterating and Testing: The Software is Still for the Customer
- Your toolbox is filling up
- But you’re still writing your software for the CUSTOMER!
- Iterating deeper: two basic choices
- Feature driven development
- Use case driven development
- Two approaches to development
- Let’s use feature driven development
- Analysis of a feature
- Fleshing out the Unit class
- Showing off the Unit class
- Writing test scenarios
- Solution #1: Emphasizing Commonality
- Solution #2: Emphasizing Encapsulation
- Let’s go with the commonality-focused solution
- Match your tests to your design
- Let’s write the Unit class
- Test cases dissected...
- Prove yourself to the customer
- We’ve been programming by contract so far
- Programming by contract is really all about trust
- And we can always change the contract if we need to...
- But if you don’t trust your users...
- -or if they don’t trust you...
- Moving units
- Break your apps up into smaller chunks of functionality
10. The OOA&D Lifecycle: Putting It All Together
- Developing software, OOA&D style
- The problem
- Now you should really know what you’re supposed to do
- Use cases reflect usage, features reflect functionality
- Now start to iterate
- A closer look at representing a subway
- Let’s take a look at that subway file
- Let’s see if our use case works
- To use a Line class or not to use a Line class... that is the question
- Code the Station class
- Code the Subway class
- Points of interest on the Objectville Subway (class)
- Protecting your classes (and your client’s classes, too)
- The SubwayLoader class
- It’s time to iterate again
- But before we start Iteration 2...
- What’s left to do?
- Back to the requirements phase...
- Focus on code, then focus on customers. Then focus on code, then focus on customers...
- Iteration makes problems easier
- Implementation: Subway.java
- What does a route look like?
- One last test class...
- Check out Objectville for yourself!
- Iteration #3, anyone?
- The journey’s not over...
- Now take OOA&D for a spin on your own projects!
A. Leftovers: The Top Ten Topics (we didn’t cover)
- #1. IS-A and HAS-A
- The problem with IS-A and HAS-A
- #2. Use case formats
- Focusing on interaction
- A more formal use case
- #3. Anti patterns
- #4. CRC cards
- CRC cards help implement the SRP
- #5. Metrics
- #6. Sequence diagrams
- #7. State diagrams
- #8. Unit testing
- What a test case looks like
- #9. Coding standards and readable code
- Great software is more than just working code
- #10. Refactoring
- B. Welcome to Objectville: Speaking the Language of OO
- About the Authors
- Title: Head First Object-Oriented Analysis and Design
- Release date: November 2006
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9780596008673
You might also like
Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow, 2nd Edition
Through a series of recent breakthroughs, deep learning has boosted the entire field of machine learning. …
Head First Design Patterns, 2nd Edition
You know you don’t want to reinvent the wheel, so you look to design patterns—the lessons …
Data Science from Scratch, 2nd Edition
To really learn data science, you should not only master the tools—data science libraries, frameworks, modules, …
Software Engineering at Google
Today, software engineers need to know not only how to program effectively but also how to …