Principles of Software Design Quiz 2

Ace your homework & exams now with Quizwiz!

What are the 5 code smells in the comments category?

1. Inappropriate comments Holds information for a better suited system 2. Obsolete comments Old, irrelevant, and incorrect 3. Redundant comments Commenting how i++ works 4. Poorly written comments Grammar errors, rambles, and is obvious 5. Commented-out code

How can code smells often be uncovered?

When the code is subjected to a short feedback cycle where it is refactored in small, controlled steps

Ideally, how many languages should be in 1 source file?

1

What are the 4 stages in the lifecycle of an ADT?

1. Construction 2. Initialization 3. Usage 4. Destruction

What are the 2 code smells in the functions category?

1. Too many arguments 2. Dead functions Methods that are never called should be discarded

What is an example of obvious behavior not being implemented?

A class not having operator overload

If you have a "naked numeric," what should you replace it with?

A constant so that it has more meaning and can be easily reused/modified when needed

What is duplication in our context?

Any chunk of the same source code that can be found in more than one place.

What is a code smell?

Any symptom in the source code of a program that possibly indicates a deeper problem

Why do Java and C# have a finally construct for exception handling, but C++ does not have the same construct for exception handling?

Because C# and Java do not have deterministic destructors (when objects go out of scope or are deleted and their destructors are executed immediately)

What is consistency meant in our context?

Coding style, comment location, source decoration

What are the 7 different code smell categories?

Comments Environment Functions General Java Names Tests

When is code considered exception safe?

If it does not have run-time failures or the code does not produce bad effects

Should you ever turn off fail-safes? (compiler warnings)

No

From weakest to strongest, what are the 5 levels of exception safety?

No Exception Safety Minimum Exception Safety Basic Exception Safety Strong Exception Safety Failure Transparency

What is no exception safety?

No guarantees are made

Look at try catch example

Okay boy!

What is failure transparency?

Operations are guaranteed to succeed and satisfy all requirements even in presence of exceptional situations. If an exception occurs, it will not throw the exception further up

What is strong exception safety?

Operations can fail, but failed operations are guaranteed to have no side effects, so all data retain original values

What is an example of misplaced responsibility?

PI should be in a trigonometry source file

What is basic exception safety?

Partial execution of failed operations can cause side effects, but invariants on the state are preserved. Any stored data will contain valid values even if data has different values now from before the exception

What is minimal exception safety?

Partial execution of failed operations may store invalid data but will not cause a crash, and no resources get leaked

When appropriate, what should be preferred over If/Else or Switch/Case statements?

Polymorphism

Should you try to use negative conditionals or positive conditionals?

Positive conditionals

Elaborate on the code smell "function names should say what they do."

The name of a function should accurately reflect the function's implementation. Otherwise, break the implementation into multiple functions.

What is an example of incorrect behavior at the boundaries?

Throwing an exception when the stack runs out of space instead of resizing the stack

How do you do base member intiializations?

class Point { public: Point(void) :x_ (0), y_ (0) {} }

What is the structure of a class?

class Point { public: Point(void) {} //more member functions private: int x_; int y_; }


Related study sets

Hospitality and Tourism Ch.2 Test

View Set

Wordly Wise Book 9 Lessons 1-10 - MIDTERM

View Set

Compensation and Benefits Instructor Quiz

View Set

Chapter 15: Vulnerability Assessment

View Set

Human Relations Chapter 1-3: T/F

View Set

Coping - Intro to Health Care Concepts - ADN

View Set