cs309 asgn1-1

2
Andrew Denner CS 309 Asignment1 Part 2 1.) Write a few paragraphs explaining diffe rence between developin g software in an OO way and in a procedural way.  The Object Oriented paradigm is best described as a set of Modules which aid in code reusabi lity and abstraction. This abstractio n allows a developer to tr eat a function as a “black box” that input can be passed to and then a result can be collected from o n the other side. It is a particularly usefu l 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. Procedural programming is a older method of develop ment. In Pr ocedural Programming the program is much like a script in a play, first you do the first step then the next one and through ad nauseum. There are no functions and no opportunities f or code reuse. This developmen t model frequen tly leads to much copy and paste coding which can be problematic if requirements change and rework is needed because each spot of repetitive code needs to be fixed.  Thus OO development allows programmers to develop in a more efficient manner saving both time and money . It also allows for more complex programs that are bigger and better then what could have ever created using Procedural programming. 2.)What are benefits of inheritance? Inheritance allows a programmer to quickly develop a set of similar classes with the ability to reus e code that has only been defined on ce. A good example of th is 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 structur e 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.

Upload: andrew-denner

Post on 30-May-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: cs309 asgn1-1

8/14/2019 cs309 asgn1-1

http://slidepdf.com/reader/full/cs309-asgn1-1 1/2

Andrew Denner

CS 309 Asignment1

Part 2

1.)Write a few paragraphs explaining difference between developingsoftware in an OO way and in a procedural way.

The Object Oriented paradigm is best described as a set of Modules which aid incode reusability and abstraction. This abstraction allows a developer to treat afunction as a “black box” that input can be passed to and then a result can becollected from on the other side. It is a particularly useful methodology whencoding in a large project. Provided simple rules are followed by all, oneprogrammer can be working on one part of the project while another is on aseparate part. OO design also allows for code reuse across projects. Forexample a linked list implementation can be written for one project and can beeasily transplanted from that project to another. This particular benefit isespecially evident in Open Source Software where code is often shared acrossprojects and is done with out even meeting the other developer.

Procedural programming is a older method of development. In ProceduralProgramming the program is much like a script in a play, first you do the firststep then the next one and through ad nauseum. There are no functions and noopportunities for code reuse. This development model frequently leads to muchcopy and paste coding which can be problematic if requirements change andrework is needed because each spot of repetitive code needs to be fixed.

Thus OO development allows programmers to develop in a more efficientmanner saving both time and money. It also allows for more complex programsthat are bigger and better then what could have ever created using Proceduralprogramming.

2.)What are benefits of inheritance?

Inheritance allows a programmer to quickly develop a set of similar classes with theability to reuse code that has only been defined once. A good example of this wouldbe a Interface that defines how to draw multiple sets of shapes yet allows aprogrammer to overload parts that are different to use a different equation or tohave more sides.

This not only saves the developer time and cuts down on the amount of rewrittencode but also allows many developers to use a predefined structure and set tobetter cooperate.

3.) What is Polymorphism (and Dynamic Binding) and give an example of its use.Also describe key benefits of polymorphism.

Page 2: cs309 asgn1-1

8/14/2019 cs309 asgn1-1

http://slidepdf.com/reader/full/cs309-asgn1-1 2/2

The idea of Polymorphism is one of using generic interfaces to manipulate specificobjects. Again, using the example from the above question in a Drawing displayprogram, there exists the display interface, below that is the shape interface, andbelow that is the line, dot, and circle objects. Dynamic binding allows the otherclasses 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 becalled until it is dynamically called at runtime.

4.) See attached files.