cs309 Asgn1-1
cs309 Asgn1-1
CS 309 Asignment1
Part 2
The Object Oriented paradigm is best described as a set of Modules which aid in
code reusability and abstraction. This abstraction allows a developer to treat a
function as a “black box” that input can be passed to and then a result can be
collected from on the other side. It is a particularly useful methodology when
coding in a large project. Provided simple rules are followed by all, one
programmer can be working on one part of the project while another is on a
separate part. OO design also allows for code reuse across projects. For
example a linked list implementation can be written for one project and can be
easily transplanted from that project to another. This particular benefit is
especially evident in Open Source Software where code is often shared across
projects and is done with out even meeting the other developer.
Inheritance allows a programmer to quickly develop a set of similar classes with the
ability to reuse code that has only been defined once. A good example of this would
be a Interface that defines how to draw multiple sets of shapes yet allows a
programmer to overload parts that are different to use a different equation or to
have more sides.
This not only saves the developer time and cuts down on the amount of rewritten
code but also allows many developers to use a predefined structure and set to
better cooperate.
3.) What is Polymorphism (and Dynamic Binding) and give an example of its use.
Also describe key benefits of polymorphism.
The idea of Polymorphism is one of using generic interfaces to manipulate specific
objects. Again, using the example from the above question in a Drawing display
program, there exists the display interface, below that is the shape interface, and
below that is the line, dot, and circle objects. Dynamic binding allows the other
classes in the program to handle all display items the same, say by calling the
function shape.draw at runtime with out the compiler knowing what object will be
called until it is dynamically called at runtime.