Impact of Program Design - AP Computer Science A
- What is the result of using magic numbers in code?
- Decreases code readability and maintainability. Hard-coded values make code difficult to modify.
- Why is refactoring important in program design?
- Improves code structure and readability without changing behavior. Continuous improvement keeps code clean and efficient.
- What is the purpose of an interface in Java?
- To define a contract that classes can implement. Ensures consistent behavior across implementing classes.
- What does it mean if a system has poor modularity?
- The system is difficult to understand, maintain, and extend. Components are tightly coupled and poorly organized.
- Identify the effect of using global variables in a program design.
- Increases the risk of unintended side effects. Shared state creates unpredictable program behavior.
- Identify the result of high cohesion within a module.
- Makes the module easier to maintain and understand. Related functionality grouped together improves organization.
- Identify the key benefit of using inheritance in program design.
- Promotes code reuse by allowing new classes to inherit properties. Saves development time by building upon existing class functionality.
- What is the advantage of using interfaces over abstract classes?
- Allows multiple inheritance of type. Supports multiple inheritance without implementation conflicts.
- Define 'abstraction' in object-oriented programming.
- Hiding complex realities while exposing only essential parts. Simplifies interfaces by focusing on what matters to users.
- What is the impact of using well-defined interfaces on code flexibility?
- Increases flexibility and reusability of code. Clear contracts enable modular, interchangeable components.
- What is the impact of high cohesion in a program module?
- Increases the module's maintainability and understandability. Elements work together toward a single, well-defined purpose.
- What is polymorphism in the context of object-oriented programming?
- Ability of different classes to be treated as instances of the same class. Enables method overriding and dynamic method dispatch at runtime.
- What is the main advantage of using design patterns?
- Provides proven solutions to common design problems. Reusable templates that reduce development time and errors.
- Which principle is violated by exposing internal details of a class?
- Encapsulation. Public access to internals breaks data hiding.
- Identify the consequence of low coupling between program modules.
- Reduces dependency and increases module independence. Modules can be modified independently without affecting others.
- Which term describes a class's ability to process objects differently based on their data type?
- Polymorphism. Same interface handles different object types appropriately.
- Identify the impact of poor design on program scalability.
- Limits the ability to efficiently handle growth and changes. Poor architecture creates bottlenecks and performance issues.
- Identify the impact of immutable objects on program design.
- Enhances thread safety and reduces bugs. Unchangeable objects prevent accidental state modification.
- What is the main disadvantage of code duplication?
- Increases maintenance effort and error potential. Duplicate code multiplies bugs and maintenance work.
- What is the purpose of encapsulation in object-oriented programming?
- To hide the internal state and require all interaction through methods. Data hiding ensures controlled access and maintains object integrity.
- What is a potential downside of tight coupling between classes?
- Makes the system harder to change and maintain. High interdependence creates fragile, inflexible systems.
- Which principle of design separates the program into distinct sections?
- Modularity. Breaking programs into independent, manageable components.
- What is the purpose of a constructor in a class?
- To initialize the object's state when it is created. Sets up initial values and prepares object for use.
- Identify the role of comments in program design.
- To enhance code readability and understanding. Documentation helps future developers understand design decisions.