21.08.2013 Views

Software Engineering for Students A Programming Approach

Software Engineering for Students A Programming Approach

Software Engineering for Students A Programming Approach

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Summary<br />

Exercises 217<br />

Writing a class means that strongly related elements of data and actions are<br />

grouped together. A class presents an interface to its users and hides in<strong>for</strong>mation<br />

about its internal workings. It means that the user of a class need not worry about<br />

its implementation. This promotes abstraction in thinking about the structure of<br />

software. It also means that a class can be changed without any effect on the rest<br />

of the program (provided that it continues to present the same interface). Thus<br />

classes promote modularity.<br />

Extending (inheriting from) a class is another way of making use of existing components<br />

(classes). A subclass inherits the facilities of its immediate superclass and<br />

all the superclasses. Most languages support single inheritance. A class can extend<br />

the facilities of an existing class by providing one or more of:<br />

■ additional methods<br />

■ additional variables<br />

■ methods that override (act instead of) methods in the superclass.<br />

Polymorphism means that similarities between objects can be exploited in the<br />

code that uses objects. This means that software is more concise and more easily<br />

adapted.<br />

Altogether encapsulation, inheritance and polymorphism mean that software is<br />

modular, concise and adaptable. It also means that greater use can be made of<br />

libraries of useful components. The programming language must explicitly support<br />

these features <strong>for</strong> OOP to be viable.<br />

Generics enable tailor-made collections to be constructed. This makes programs<br />

more concise and assists with compile-time type checking, and consequently software<br />

reliability.<br />

There are a number of approaches to garbage collection <strong>for</strong> software that uses<br />

dynamic allocation of memory. Some schemes are automatic but may create timing<br />

problems. Some schemes rely on the programmer to make explicit requests,<br />

but this can lead to subtle memory problems.<br />

•<br />

Exercises<br />

15.1 Explain how classes, inheritance and polymorphism support software development.<br />

15.2 Explain how classes, inheritance and polymorphism promote reusable software.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!