Shared Flashcard Set

Details

Object Oriented Programming Exam 1
Title explains it all
9
Computer Science
Undergraduate 2
09/15/2010

Additional Computer Science Flashcards

 


 

Cards

Term
What is abstraction?
Definition
Abstraction reduces and factors out details so that one can focus on a few concepts at a time.
Term
why is abstraction so important in software development?
Definition
It reduces repetition, reimplementation of preexisting code, and hides specifics that don't need to be known which promotes ease of use.
Term
What does this method do?

def meth(a,b)
c = a
b.times{c = yield c}
c
end
Definition
copies parameter a as c. then executes a block c, b number of times and each iteration is stored in c.
Term
What important Ruby construct does this illustrate?

def meth(a,b)
c = a
b.times{c = yield c}
c
end
Definition
blocks
Term
How does the construct of the following support the principle of abstraction and its importance in software development?

def meth(a,b)
c = a
b.times{c = yield c}
c
end
Definition
The block construct allows for loop abstraction where any method can be called with a block as an implicit argument. Inside the method, you can call the block using the yield keyword with a value. The most basic usage of blocks is to let you define your own way for iterating over the items.
Term
What is an object in object-oriented programming? (e.g., What is
its nature? What role does it play?)
Definition
An object is simply a tangible entity that exhibits some well-defined
behavior. Objects do things, and we ask them to perform what they do by sending
them messages.
Term
Explain meaning and significance: every Ruby statement is an expression
Definition
Statement: a message that is stated or declared; a communication (oral or written) setting forth particulars or facts etc

Expression: a combination of values, variables, operators, and functions that are interpreted (evaluated)
Term
Explain meaning and significance: Ruby classes are always open
Definition
You can always add methods to an existing class. This applies to the classes you write as well as the standard, built-in classes. All you have to do is open up a class definition for an existing class, and the new contents you specify will be added to whatever's there. This allows for easier dynamic programming.
Term
Explain meaning and significance: in Ruby, even 17 is an object
Definition
17 is an object of the Fixnum class which creates objects as defined by the Fixnum class. This allows the number 17 to have attributes, properties and methods.
Supporting users have an ad free experience!