Docsity

Exam 1 Answer Key | Software Engineering 2008 | CSCI 306, Exams of Software Engineering

Toggle sidebar
bg1
CSCI 306 Exam 1
Fall 2008
Name: _________KEY___________________
Pages 2 and 3 contain a fair amount of programming, use your time wisely!
1. (4) What is refactoring? Give one specific example of an action you might take when you
refactor.
Refactoring is improving the structure of the code without changing its functionality. Various
examples: clarify variable names, simplify method logic, change method names, separate or
combine methods into other classes.
2. (4) Name two benefits of version control.
Various: revert to code before messed it up, merge code from multiple programmers,
facilitate backups, keep log of changes/change rationale, etc.
3. (2) In test-driven development, the first tests you write should fail. True / False
4. (2) Putting the "hooks" in a system can lead to what "rotting" software issue?
Needless complexity
5. (2) Why is "cut-and-paste" a really bad programming technique?
Must make changes in multiple places, easy to forget to make all necessary changes, not
taking advantage of abstraction, etc.
1
pf3

Partial preview of the text

Download Exam 1 Answer Key | Software Engineering 2008 | CSCI 306 and more Exams Software Engineering in PDF only on Docsity!

CSCI 306 Exam 1

Fall 2008

Name: _________ KEY ___________________

Pages 2 and 3 contain a fair amount of programming, use your time wisely!

1. (4) What is refactoring? Give one specific example of an action you might take when you

refactor.

Refactoring is improving the structure of the code without changing its functionality. Various

examples: clarify variable names, simplify method logic, change method names, separate or

combine methods into other classes.

2. (4) Name two benefits of version control.

Various: revert to code before messed it up, merge code from multiple programmers,

facilitate backups, keep log of changes/change rationale, etc.

3. (2) In test-driven development, the first tests you write should fail. True / False

4. (2) Putting the "hooks" in a system can lead to what "rotting" software issue?

Needless complexity

5. (2) Why is "cut-and-paste" a really bad programming technique?

Must make changes in multiple places, easy to forget to make all necessary changes, not

taking advantage of abstraction, etc.

6. In this question you will write a portion of a class and extend it, then use these classes in another

small class. All instance variables for all classes should be private unless otherwise noted. NOTE:

This question continues on the next page. Put all your code below the corresponding descriptions.

a) (8) Write a class named Fund.

Data : Fund has two member variables: fundNum is an integer (an identifying number used for

that Fund within a group of funds, such as fund number 10) and sharePrice which is a double.

Methods :

 Write a two-parameter constructor. Use the keyword this in your code.

 Write an accessor for sharePrice named getPrice.

b) (7) Write a child class of Fund named MiracleFund.

Data: MiracleFund has one data member: pctIncrease is a guaranteed percent of increase for this

fund (where do I buy this??)

Methods:

 Write a three-parameter constructor. Be sure to call the parent class constructor.

 Create an overrided getPrice method that returns the sharePrice * pctIncrease. Be sure to

consider the access modifiers!

a) public class Fund {

private double sharePrice; private int fundNum; Fund( double sharePrice, int fundNum){ this .sharePrice = sharePrice; this .fundNum = fundNum; } public double getPrice(){ return sharePrice; } } b) public class MiracleFund extends Fund { private double pctIncrease; MiracleFund( int fundNum, double price, double pctIncrease) { super (price, fundNum); this .pctIncrease = pctIncrease; } public double getPrice() { return super .getPrice() * pctIncrease; } }