Font size
WorksheetsCode Smells and Design Principles Quiz
Total questions: 55
Worksheet time: 30mins
What is the best description of the Dependency Inversion principle?
Client objects depend on an Adaptor Pattern to interface with the rest of the system
Client objects depend on generalizations instead of concrete objects
Service objects subscribe to their prospective client objects as Observers, watching for a request
Client objects are dependent on a service interface that directs their requests
Which of these statements is true about the Composing Objects principle?
it leads to tighter coupling
it provides behaviour with aggregation instead of inheritance
The second statement is true
The first statement is true
Neither statement is true
How can Comments be considered a code smell?
Too many comments make the files too large to compile
When a comment is used to explain the rationale behind a design decision
Excessive commenting can be a coverup for bad code
They can’t! Comments help clarify code
What is the primitive obsession code smell about?
Code that contains many low-level objects, without using OO principles like aggregation or inheritance
Overuse of primitive data types like int, long, float
Using many different primitive types instead of settling on a few
Using key-value pairs instead of abstract data types
You have a class that you keep adding to… Which code smell is this?
Long Method
Large Class
Divergent Change
Speculative Generality
Why is it important to avoid message chains whenever possible?
They lower cohesion in your class
The resulting code is usually rigid and complex
It's a workaround to get to private methods
If an unexpected object is returned, this could lead to runtime errors
Deck superclass with only one subclass planned for the future. What code smell is this?
Divergent Change
Refused Bequest
Primitive Obsession
Speculative Generality
What is the act of creating an object called?
object invocation
object realization
concrete instantiation
class creation
Difference between Factory Method and Simple Factory?
In Factory Method, instantiation is in a designated method; Simple Factory creates objects for external clients
A simple factory instantiates only one kind of object
Factory itself must be instantiated first
Simple factories cannot be subclassed
Stacking objects and behaviours dynamically. Which pattern?
Factory Method
Singleton
Composite
Decorator
Connecting to a third-party library via a consistent interface. Which pattern?
Proxy
Facade
Adapter
Decorator
Which principle best describes the Proxy pattern?
Encapsulation
Separation of concerns
Generalization
Decomposition
Request handled by one of several handlers. Which pattern?
Facade
Decorator
Chain of Responsibility
Template
Which is NOT a good use of the Command pattern?
Sending a command to a third-party service or library
Supporting undo/redo
Building a user interface
Building macros
Which code smell may become a problem with Mediator?
Inappropriate Intimacy
Speculative Generality
Refused Bequest
Large Class
Which method is found in a typical Observer class?
notify()
addObserver()
getState()
update()
In MVC, which is usually an Observer?
Model
Back-End
View
Controller
Which does NOT complete “A class is closed to modification when…
all attributes and behaviours are encapsulated
its collaborators are fixed
it is tested
it is proven stable
How does Dependency Inversion improve systems?
Clients depend on low-level concrete classes
Dependency is inverted to depend on clients
Clients depend on high-level generalizations
Clients use an adapter
Replacing a search algorithm everywhere is hard. Which principle avoids this?
Don’t Repeat Yourself
Composing Objects
Principle of Least Knowledge
Dependency Inversion
Long Message Chains usually violate which principle?
Cohesion
Separation of Concerns
Open/Closed Principle
Principle of Least Knowledge / Law of Demeter
Components of MVC?
Model, View, Command
Model, View, Controller
Member, Vision, Controller
Model, Vision, Command
Interface Segregation helps avoid which code smell?
Switch Statements
Refused Bequest
Divergent Change
Long Method
Stakeholders in architecture:
Project managers
End users
Both statements are true
UML diagrams useful for the logical view (2 answers):
Stakeholders in architecture:
Project managers
End users
Both statements are true
UML diagrams useful for the logical view (2 answers):
Deployment diagram
Class diagram
Sequence diagram
State diagram
Mapping software elements to hardware nodes. Which view?
Development view
Physical view
Scenario
Process view
Physical result of development (e.g., executable)?
package
leaf
artifact
node
Keywords used on package diagram lines:
deploy, merge, include
request, import, merge
interface, export, load
merge, access, import
Which is NOT shown on an activity diagram?
activities
interfaces
decisions
concurrency
What does “component” mean in a component diagram?
basic parts without which software can’t run
an independent, encapsulated unit
an external library
any software part
“Easy to learn”, “minimize user errors” belong to which quality attribute?
usability
intuitiveness
astonishment
complexity
NOT a way to promote conceptual integrity:
Split the team into subteams per component
Code reviews
Establish conventions
Good documentation
Three main groups in ATAM:
clients, designers, stakeholders
peers, outsiders, designers
evaluation team, outsiders, project team
evaluation team, project decision makers, architecture stakeholders
Potential ASR failure under high load is called:
tradeoff
risk scenario
utility shortfall
non-risk scenario
Conway’s Law: teams not separated physically may cause:
non-reusable interfaces
lack of comments
duplicated code
very tightly coupled components
NOT an advantage of product lines:
greatly reduced up-front development
overall cost reduction
consistency
reduced time-to-market
Backlight feature in one eBook reader only. Category?
Product-Specific
Commonality
Variation
One-Off
View showing functional design (objects & relationships):
physical
process
development
logical view
Package diagram belongs to which view?
process
logical
development view
physical
True statement about Component Diagrams:
clarify artifacts
clarify dependency relationships
give dynamic view
do not show third-party libraries
NOT found in a deployment diagram:
component
device
class
artifact
What is an artifact?
A physical realization of a software component
part of a device
unintended effect
developer-only process part
What is an abstract data type?
data schema by developer
dynamic primitive storage
interface defining storage
data type defining interfaces, not storage
Accurate statement about layered architecture:
Passthrough should be avoided
Only adjacent communication is key
Upper layers serve lower layers
Based on layers of abstraction
Correct term for a machine hosting a server:
server-tier
called by type
server-host
server-machine
Recorded sequences of user inputs are called:
user recorders
scripts
macros
input listeners
Data Flow Architecture is also called:
Data Transformation
Pipe and Filter
Cascade
Black Box
NOT a common component of event-driven architecture:
event generator
event processor
event consumer
event bus
Process control typically needed for complex systems:
Feedforward + Feedback
Feedforward
MAPE-K
Machine Learning
Drawback of n-Tier architecture:
Extra resources for client/server management
More hardware nodes
Only async messaging
Limited scale
NOT an Interpreter-type architecture:
Excel formulas
Java Virtual Machine
Scripting and Macros
OS kernel
“Amount of time system is operational” means:
availability
interoperability
usability
performance
Most important quality attribute from developer’s perspective:
availability
security
usability
flexibility
