Skip to content

Latest commit

 

History

History
155 lines (97 loc) · 10.4 KB

File metadata and controls

155 lines (97 loc) · 10.4 KB

Pragmatic Programmer: Key Concepts and Highlights

I've put together these notes from "The Pragmatic Programmer" by Andy Hunt and Dave Thomas - a book that's been a real eye-opener for me in understanding software development. They're a mix of the ideas that hit home and really reshaped how I think about coding and building great software.

I wanted to keep these insights handy, not just for myself, but for anyone out there looking for some distilled wisdom from this fantastic book. Think of this as a personal cheat sheet, highlighting the stuff that stood out to me the most.


What Does "Pragmatic" Mean?

Pragmatic" has its roots in the Greek word "pragmatikos" meaning "related to action."

In the context of this book, being "pragmatic" means focusing on practical solutions and results, rather than getting caught up in theoretical ideals.

It’s about making things work efficiently in the real world, adapting to change, and always looking for ways to improve.

Software Entropy

One broken window, left unrepaired for any substantial length of time, instills in the inhabitants of the building a sense of abandonment—a sense that the powers that be don't care about the building. So another window gets broken. People start littering. Graffiti appears. Serious structural damage begins. In a relatively short space of time, the building becomes damaged beyond the owner's desire to fix it, and the sense of abandonment becomes reality.

Stone Soup

Start small, attract big. Begin with a manageable task, demonstrate its success, and others will be inspired to contribute and enhance the project.

Boiled Frogs

Stay alert, adapt fast. Don’t ignore gradual changes; small issues can escalate into big problems. Always keep an eye on the overall situation to avoid being caught off guard.

Good Enough Soup

Aim for timely quality. Define the scope and quality of your project in its requirements. Prioritize delivering great software now over waiting for perfection. Know when it's complete enough to meet its goals effectively.

Orthogonality

Independent yet powerful. Create components in your software that are orthogonal - changes in one don’t impact others. This approach, akin to writing "shy" code, helps in maintaining a clear separation of concerns.

Tracer Bullets

Navigating Uncertainty with Speed. Tracer bullets are used in software development to quickly build a basic version of a system when facing unclear requirements or new challenges. They allow for rapid iteration, giving a glimpse of how the final product might work. This approach enables developers to align their work with evolving requirements and make adjustments in real time, ensuring the end result is both practical and in line with user needs.

A Debugging Mindset

Don't waste a single neuron on the train of thought that begins "but that can't happen" because quite clearly it can, and has. Try to discover the root cause of a problem, not just this particular appearance of it.

Pragmatic Paranoia

Embrace the inevitable imperfections. Acknowledge that perfect software is a myth. Pragmatic Programmers understand their limitations and the inevitability of errors in the realm of software development.

Design by Contract (DbC)

Set clear terms for your code's behavior. DbC involves defining precise, verifiable agreements for software behavior through preconditions, postconditions, and invariants.

Dead Programs Tell No Lies

Errors as crucial informants. Pragmatic Programmers understand that errors are significant indicators of deeper issues. When an error occurs, it’s often a sign of a critical problem.

Law of Demeter

A principle for minimizing coupling. The Law of Demeter is a guideline in software development aimed at reducing dependencies between different parts of a system. It's often summarized as "only talk to your immediate friends."

Metaprogramming

Programming that creates or manipulates other programs. Metaprogramming is a technique where a program generates, configures, or alters other programs or itself, effectively treating code as data.

Temporal Coupling

Understanding time in software design. Temporal Coupling refers to how parts of a program depend on the timing or order of other parts. It encompasses two main aspects: concurrency (simultaneous occurrences) and ordering (sequence of events).

Blackboard Design Pattern

Think of it as a community bulletin board. In software, the blackboard pattern allows different parts to communicate and solve problems collaboratively, without needing to know each other, by posting and reading information on a common "blackboard."

Algorithm Speeds

Understand and estimate algorithm efficiency. Pragmatic Programmers focus on how much time, processing power, and memory their algorithms use. This is where Big O notation becomes crucial, as it provides a way to classify algorithms based on their performance or complexity.

Big O Notation Examples:

  1. O(1) - Constant: Simple, direct operations like accessing an array element.
  2. O(log n) - Logarithmic: Operations like binary search.
  3. O(n) - Linear: Algorithms that iterate through all elements once, like a sequential search.
  4. O(n log n): More complex than linear but efficient for certain sorts like quicksort or heapsort.
  5. O(n²) - Quadratic: Algorithms with nested loops, like selection or insertion sort.
  6. O(n³) - Cubic: Operations like the multiplication of two n x n matrices.
  7. O(Cⁿ) - Exponential: Highly complex algorithms, such as the naive solution for the Fibonacci sequence or the traveling salesman problem.

Refactoring

Code isn't set in stone, it needs to grow and improve. Refactoring is the process of restructuring existing computer code without changing its external behavior, aiming to improve nonfunctional attributes of the software.

When to Refactor:

  1. Duplication: Address violations of the DRY (Don't Repeat Yourself) principle.
  2. Nonorthogonal Design: Improve code orthogonality for more independent and modular components.
  3. Outdated Knowledge: Update the code to reflect new understandings, changing requirements, or better solutions.
  4. Performance: Enhance efficiency by optimizing and rearranging code.

Effective Refactoring Practices:

  • Separate Refactoring from New Development: Avoid mixing refactoring with the addition of new features.
  • Ensure Good Testing: Have a solid suite of tests to verify that refactoring doesn't alter the software's functionality.
  • Take Incremental Steps: Approach refactoring in small, manageable changes to avoid introducing new errors.

Requirements Pit

Perfection is achieved, not when there is nothing left to add, but when there is nothing left to take away….

Solving Impossible Puzzles

Embrace constraints to discover solutions. In complex problem-solving, understanding both the limitations and the available freedoms is key to finding innovative solutions.

Questioning the Problem:

  1. Look for Simpler Paths: Is there a more straightforward approach you're overlooking?
  2. Reassess the Problem: Are you focused on the real issue, or distracted by a side aspect?
  3. Understand the Difficulty: Analyze what makes the problem challenging. Is it complex due to unnecessary factors?
  4. Challenge Assumptions: Question if the current method is the only way, or if the task is necessary in the first place.

Circles and Arrows

Formal methods in software design: useful, but not absolute. The use of formal methods, like UML diagrams or rigorous design processes, can be helpful, but they should not constrain creativity and practical effectiveness.

Pragmatic Teams

Applying pragmatic principles to team dynamics. Just as individual developers benefit from pragmatic practices, these same principles can greatly enhance the effectiveness of teams.

Key Concepts for Pragmatic Teams:

  1. No Broken Windows:

    • Uphold Quality: The whole team should be committed to maintaining high standards, not tolerating "broken windows" or small imperfections.
  2. Avoid Boiled Frog Syndrome:

    • Stay Alert: Team members should be proactive, not assuming that others will handle issues or that changes have been approved without confirmation.
  3. Effective Communication:

    • Clear and Unified: Teams should communicate clearly and cohesively both internally and with external parties.
    • Create a Brand: A simple marketing trick to unify communication and present a consistent image.
  4. Don’t Repeat Yourself (DRY) in Team Management:

    • Have a Project Librarian: Assign someone to manage information and resources, avoiding duplication and promoting efficiency.
  5. Orthogonality in Teams:

    • Integrate Activities: Recognize that analysis, design, coding, and testing are interconnected and should not be artificially separated.
    • Tip 60: Organize Around Functionality, Not Job Functions: Structure teams around functional areas (like database, UI, API) rather than strict job titles.
    • Encourage Internal Organization: Let teams organize themselves within their functional areas.
    • Establish Responsibilities: Define clear commitments and responsibilities among different teams.
  6. Use of Pragmatic Techniques:

    • Apply principles like Design by Contract, Decoupling, and Orthogonality to team organization and workflow.
    • This approach helps isolate teams from disruptive changes and maintains a focused, cohesive working environment.

    Great Expectations:

    Project success hinges on user satisfaction. Understanding and managing user expectations is key to the success of any project. It's not just about delivering what was asked for, but also about adding value that users might not have explicitly requested.

    Going the Extra Mile:

    • Offer enhancements that enrich the user experience without overcomplicating it. Examples include:
      • Helpful Additions: Balloon tooltips, keyboard shortcuts, and quick reference guides.
      • Visual Enhancements: Colorization and customized splash screens.
      • Utility Tools: Log file analyzers, system integrity checkers, and automated installation features.
      • User Convenience: Multi-version system capability for training, organization-specific customizations.