liveBook · Manning

Flexibility

As explained in Object-Oriented Software Design in C++

Software flexibility is the ease with which a software system can accommodate new features or changed requirements.

Software flexibility is the ease with which a system accommodates new features or changed requirements. Good design isolates likely changes so one modification does not force changes elsewhere, while balancing flexibility against added complexity. section 1.7 section 1.3

Recognize flexibility problems and improve them by:

  • Encapsulating requirements-sensitive behavior so changing requirements do not destabilize unrelated code. section 3.5.2
  • Isolating what varies, coding to interfaces, and keeping stable classes open to extension but closed to modification. section 2.4
  • Replacing hardcoded runtime decisions with interchangeable algorithms when behavior must vary during execution. section 8.2
  • Checking whether an abstraction earns its cost, because extra classes can make a small application more complicated. section 8.2.3

Sports strategies that change at runtime

A sports application initially assigns each Sport object player and venue strategies. PlayerStrategy and VenueStrategy interfaces let Baseball, Football, and Volleyball use different algorithm implementations. A Volleyball object can later replace OpenField with Stadium without changing Sport or the other strategy classes. The design reduces duplication, supports independent algorithm changes, and demonstrates has-a relationships and polymorphism. section 8.2.3

Ticket enhancements expose inflexibility

A Ticket class that stores party, VIP, and coupon options as fixed members must change whenever an enhancement is added, removed, or modified. Its cost calculation also knows each enhancement’s implementation. This makes the change leak visible and motivates a more flexible design. section 14.3.2

Use the requirements timeline to see why designs must absorb changes even after an intended requirements freeze. section 3.5.2

How Object-Oriented Software Design in C++ covers it

How deep it goes
Explains trade-offs, change isolation, and strategy refactoring through examples, but stops short of a general measurement method.
Examples
Demonstrates flexibility with sports strategies, runtime venue replacement, and hardcoded ticket enhancements.
What it assumes
Assumes basic object-oriented design and introduces encapsulation, interfaces, polymorphism, and design trade-offs through concrete examples.
What you can do after
Apply it via design principles and the Strategy Design Pattern to isolate variation and substitute behavior at runtime.
How it connects
Connects flexibility to encapsulation, polymorphism, design patterns, the Open-Closed Principle, and changing requirements.

Also explained in

Compare how 9 books explain flexibility →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Object-Oriented Software Design in C++. The section links point to the parts of the book it draws on.