Cover of The Pragmatic Programmer by Andrew Hunt, David Thomas - Business and Economics Book

From "The Pragmatic Programmer"

Author: Andrew Hunt, David Thomas
Publisher: Addison-Wesley Professional
Year: 1999
Category: Computers

🎧 Free Preview Complete

You've listened to your free 10-minute preview.
Sign up free to continue listening to the full summary.

🎧 Listen to Summary

Free 10-min Preview
0:00
Speed:
10:00 free remaining
Chapter 5: Bend, or Break
Key Insight 5 from this chapter

Leveraging External Configuration for Adaptability

Key Insight

To create adaptable and flexible applications, values that may change after deployment, or vary across different environments or customers, should be externalized in configuration data. This practice, known as 'Parameterize Your App Using External Configuration,' keeps the core code clean and allows the application to adjust its behavior without being rebuilt. Common candidates for external configuration include credentials for external services (databases, third-party APIs), logging levels and destinations, network details (ports, IP addresses), environment-specific validation parameters, externally set business rules like tax rates, site-specific formatting, and license keys. Any detail that is known to change outside the primary codebase belongs in a configuration bucket.

Configuration data can be managed statically, often stored in flat files (like YAML or JSON) or database tables, especially for structured, customer-editable information such as sales tax rates. This data is typically loaded into the application as a data structure during startup. While often made globally accessible, the recommended practice is to encapsulate this information behind a thin API. This approach decouples the application code from the specific representation of the configuration, enabling changes to the storage mechanism or format without impacting the rest of the application, thereby enhancing maintainability and flexibility.

A more advanced approach is Configuration-as-a-Service, where configuration data is stored and managed via a service API. This method offers several key benefits: it allows multiple applications to share configuration information with robust authentication and access control, enables global configuration changes efficiently, supports maintenance via specialized UIs, and critically, makes configuration dynamic. For highly available applications, the ability to change parameters without stopping and restarting is vital. Components can register for notifications, receiving updated values in real-time. However, caution is advised against over-configuring (e.g., 40000 variables) or externalizing decisions out of laziness, as it can lead to maintenance nightmares and unnecessary complexity without clear justification.

📚 Continue Your Learning Journey — No Payment Required

Access the complete The Pragmatic Programmer summary with audio narration, key takeaways, and actionable insights from Andrew Hunt, David Thomas.