โ† All CPSA Flashcard Decks

Designing Building Blocks Flashcards

6 cards from real CPSA practice questions. Tap to flip, then mark Knew It or Still Learning โ€” missed cards come back until you master them.

Read the first 6 Designing Building Blocks flashcards as text
  1. When designing the building block view of a software system, which of the following is the primary goal of striving for high cohesion within individual building blocks?

    Answer: To ensure that a building block is responsible for a single, well-defined purpose.

    High cohesion is a software design principle that states that all elements within a module or building block should be strongly related and focused on a single, well-defined task. This enhances readability, maintainability, and reusability.

  2. An architect is designing a new e-commerce system. They have created a 'PaymentProcessing' building block. To improve maintainability and testability, this block should not directly access the 'CustomerDatabase'. Which design principle should the architect apply to decouple these two building blocks?

    Answer: Dependency Inversion Principle

    The Dependency Inversion Principle suggests that high-level modules (like 'PaymentProcessing') should not depend on low-level modules (like 'CustomerDatabase'). Both should depend on abstractions (e.g., an interface like 'ICustomerRepository'). This inverts the typical dependency, decoupling the components and making the system more modular and testable.

  3. You are documenting a building block for other teams to use. What information is essential to include in the black-box description?

    Answer: Its public interfaces, responsibilities, and required quality attributes.

    A black-box description defines a building block from an external perspective, focusing on what it does, not how it does it. This includes its public interfaces (the 'how to use it'), its responsibilities (the 'what it does'), and any quality attributes (e.g., performance guarantees) that consumers can expect. Internal implementation details are part of the white-box view.

  4. A team is building a reusable 'Logging' component. To ensure it can be used across many different projects with varying requirements, which practice is most critical?

    Answer: Using configurable parameters and avoiding hard-coded values.

    To maximize reusability, a building block should be flexible and adaptable. Using configurable parameters instead of hard-coding values allows the component to be customized for different environments and use cases without changing its internal code.

  5. Which of the following scenarios best describes tight coupling between two building blocks?

    Answer: Building block A directly modifies a data structure that is internal to building block B.

    Tight coupling occurs when one component has intimate knowledge of the internal workings of another. Directly modifying another block's internal data structure is a classic example of high coupling, creating a fragile system where a change in block B can easily break block A.

  6. An architect is reviewing a system design and finds a single building block that manages user authentication, generates PDF reports, and sends email notifications. Which design principle is most clearly being violated?

    Answer: Single Responsibility Principle (SRP)

    The Single Responsibility Principle (SRP) states that a module or building block should have only one reason to change, meaning it should have only one primary responsibility. This block has three distinct responsibilities (authentication, reporting, notifications), thus violating SRP.