wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Code Smells and Design Principles Quiz

Total questions: 55

Worksheet time: 30mins

Name
Class
Date
1.

What is the best description of the Dependency Inversion principle?

a)

Client objects depend on an Adaptor Pattern to interface with the rest of the system

b)

Client objects depend on generalizations instead of concrete objects

c)

Service objects subscribe to their prospective client objects as Observers, watching for a request

d)

Client objects are dependent on a service interface that directs their requests

2.

Which of these statements is true about the Composing Objects principle?

a)

it leads to tighter coupling

b)

it provides behaviour with aggregation instead of inheritance

c)

The second statement is true

d)

The first statement is true

e)

Neither statement is true

3.

How can Comments be considered a code smell?

a)

Too many comments make the files too large to compile

b)

When a comment is used to explain the rationale behind a design decision

c)

Excessive commenting can be a coverup for bad code

d)

They can’t! Comments help clarify code

4.

What is the primitive obsession code smell about?

a)

Code that contains many low-level objects, without using OO principles like aggregation or inheritance

b)

Overuse of primitive data types like int, long, float

c)

Using many different primitive types instead of settling on a few

d)

Using key-value pairs instead of abstract data types

5.

You have a class that you keep adding to… Which code smell is this?

a)

Long Method

b)

Large Class

c)

Divergent Change

d)

Speculative Generality

6.

Why is it important to avoid message chains whenever possible?

a)

They lower cohesion in your class

b)

The resulting code is usually rigid and complex

c)

It's a workaround to get to private methods

d)

If an unexpected object is returned, this could lead to runtime errors

7.

Deck superclass with only one subclass planned for the future. What code smell is this?

a)

Divergent Change

b)

Refused Bequest

c)

Primitive Obsession

d)

Speculative Generality

8.

What is the act of creating an object called?

a)

object invocation

b)

object realization

c)

concrete instantiation

d)

class creation

9.

Difference between Factory Method and Simple Factory?

a)

In Factory Method, instantiation is in a designated method; Simple Factory creates objects for external clients

b)

A simple factory instantiates only one kind of object

c)

Factory itself must be instantiated first

d)

Simple factories cannot be subclassed

10.

Stacking objects and behaviours dynamically. Which pattern?

a)

Factory Method

b)

Singleton

c)

Composite

d)

Decorator

11.

Connecting to a third-party library via a consistent interface. Which pattern?

a)

Proxy

b)

Facade

c)

Adapter

d)

Decorator

12.

Which principle best describes the Proxy pattern?

a)

Encapsulation

b)

Separation of concerns

c)

Generalization

d)

Decomposition

13.

Request handled by one of several handlers. Which pattern?

a)

Facade

b)

Decorator

c)

Chain of Responsibility

d)

Template

14.

Which is NOT a good use of the Command pattern?

a)

Sending a command to a third-party service or library

b)

Supporting undo/redo

c)

Building a user interface

d)

Building macros

15.

Which code smell may become a problem with Mediator?

a)

Inappropriate Intimacy

b)

Speculative Generality

c)

Refused Bequest

d)

Large Class

16.

Which method is found in a typical Observer class?

a)

notify()

b)

addObserver()

c)

getState()

d)

update()

17.

In MVC, which is usually an Observer?

a)

Model

b)

Back-End

c)

View

d)

Controller

18.

Which does NOT complete “A class is closed to modification when…

a)

all attributes and behaviours are encapsulated

b)

its collaborators are fixed

c)

it is tested

d)

it is proven stable

19.

How does Dependency Inversion improve systems?

a)

Clients depend on low-level concrete classes

b)

Dependency is inverted to depend on clients

c)

Clients depend on high-level generalizations

d)

Clients use an adapter

20.

Replacing a search algorithm everywhere is hard. Which principle avoids this?

a)

Don’t Repeat Yourself

b)

Composing Objects

c)

Principle of Least Knowledge

d)

Dependency Inversion

21.

Long Message Chains usually violate which principle?

a)

Cohesion

b)

Separation of Concerns

c)

Open/Closed Principle

d)

Principle of Least Knowledge / Law of Demeter

22.

Components of MVC?

a)

Model, View, Command

b)

Model, View, Controller

c)

Member, Vision, Controller

d)

Model, Vision, Command

23.

Interface Segregation helps avoid which code smell?

a)

Switch Statements

b)

Refused Bequest

c)

Divergent Change

d)

Long Method

24.

Stakeholders in architecture:

a)

Project managers

b)

End users

c)

Both statements are true

25.

UML diagrams useful for the logical view (2 answers):

4 lines
26.

Stakeholders in architecture:

a)

Project managers

b)

End users

c)

Both statements are true

27.

UML diagrams useful for the logical view (2 answers):

a)

Deployment diagram

b)

Class diagram

c)

Sequence diagram

d)

State diagram

28.

Mapping software elements to hardware nodes. Which view?

a)

Development view

b)

Physical view

c)

Scenario

d)

Process view

29.

Physical result of development (e.g., executable)?

a)

package

b)

leaf

c)

artifact

d)

node

30.

Keywords used on package diagram lines:

a)

deploy, merge, include

b)

request, import, merge

c)

interface, export, load

d)

merge, access, import

31.

Which is NOT shown on an activity diagram?

a)

activities

b)

interfaces

c)

decisions

d)

concurrency

32.

What does “component” mean in a component diagram?

a)

basic parts without which software can’t run

b)

an independent, encapsulated unit

c)

an external library

d)

any software part

33.

“Easy to learn”, “minimize user errors” belong to which quality attribute?

a)

usability

b)

intuitiveness

c)

astonishment

d)

complexity

34.

NOT a way to promote conceptual integrity:

a)

Split the team into subteams per component

b)

Code reviews

c)

Establish conventions

d)

Good documentation

35.

Three main groups in ATAM:

a)

clients, designers, stakeholders

b)

peers, outsiders, designers

c)

evaluation team, outsiders, project team

d)

evaluation team, project decision makers, architecture stakeholders

36.

Potential ASR failure under high load is called:

a)

tradeoff

b)

risk scenario

c)

utility shortfall

d)

non-risk scenario

37.

Conway’s Law: teams not separated physically may cause:

a)

non-reusable interfaces

b)

lack of comments

c)

duplicated code

d)

very tightly coupled components

38.

NOT an advantage of product lines:

a)

greatly reduced up-front development

b)

overall cost reduction

c)

consistency

d)

reduced time-to-market

39.

Backlight feature in one eBook reader only. Category?

a)

Product-Specific

b)

Commonality

c)

Variation

d)

One-Off

40.

View showing functional design (objects & relationships):

a)

physical

b)

process

c)

development

d)

logical view

41.

Package diagram belongs to which view?

a)

process

b)

logical

c)

development view

d)

physical

42.

True statement about Component Diagrams:

a)

clarify artifacts

b)

clarify dependency relationships

c)

give dynamic view

d)

do not show third-party libraries

43.

NOT found in a deployment diagram:

a)

component

b)

device

c)

class

d)

artifact

44.

What is an artifact?

a)

A physical realization of a software component

b)

part of a device

c)

unintended effect

d)

developer-only process part

45.

What is an abstract data type?

a)

data schema by developer

b)

dynamic primitive storage

c)

interface defining storage

d)

data type defining interfaces, not storage

46.

Accurate statement about layered architecture:

a)

Passthrough should be avoided

b)

Only adjacent communication is key

c)

Upper layers serve lower layers

d)

Based on layers of abstraction

47.

Correct term for a machine hosting a server:

a)

server-tier

b)

called by type

c)

server-host

d)

server-machine

48.

Recorded sequences of user inputs are called:

a)

user recorders

b)

scripts

c)

macros

d)

input listeners

49.

Data Flow Architecture is also called:

a)

Data Transformation

b)

Pipe and Filter

c)

Cascade

d)

Black Box

50.

NOT a common component of event-driven architecture:

a)

event generator

b)

event processor

c)

event consumer

d)

event bus

51.

Process control typically needed for complex systems:

a)

Feedforward + Feedback

b)

Feedforward

c)

MAPE-K

d)

Machine Learning

52.

Drawback of n-Tier architecture:

a)

Extra resources for client/server management

b)

More hardware nodes

c)

Only async messaging

d)

Limited scale

53.

NOT an Interpreter-type architecture:

a)

Excel formulas

b)

Java Virtual Machine

c)

Scripting and Macros

d)

OS kernel

54.

“Amount of time system is operational” means:

a)

availability

b)

interoperability

c)

usability

d)

performance

55.

Most important quality attribute from developer’s perspective:

a)

availability

b)

security

c)

usability

d)

flexibility