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.

CHAPTER<br />

11 Object-oriented<br />

design<br />

This chapter:<br />

■ explains how to carry out object-oriented design (OOD)<br />

■ explains how to use class–responsibility–collaborator (CRC) cards<br />

■ emphasizes the importance of using ready-made libraries.<br />

11.1 ● Introduction<br />

We begin this chapter by reviewing the distinctive features and principles of objectoriented<br />

programming (OOP). This sets the scene as to what an OOD seeks to exploit.<br />

Then we look at how to go about designing software. We use the Cyberspace<br />

Invaders game as the case study.<br />

The widely agreed principles of OOP are:<br />

■ encapsulation<br />

■ inheritance<br />

■ polymorphism.<br />

The advantages of these features is that they promote the reusability of software components.<br />

Encapsulation allows a class to be reused without knowing how it works – thus<br />

modularity and abstraction are provided. Inheritance allows a class to be reused by<br />

using some of the existing facilities, while adding new facilities in a secure manner.<br />

Polymorphism further promotes encapsulation by allowing general purpose classes to<br />

be written that will work successfully with many different types of object.<br />

Object-oriented languages are usually accompanied by a large and comprehensive<br />

library of classes. Members of such a library can either be used directly or reused by<br />

employing inheritance. Thus the process of programming involves using existing library<br />

classes, extending the library classes, and designing brand-new classes.<br />

During OOD, the designer must be aware of the wealth of useful classes available<br />

in the libraries. To ignore them would be to risk wasting massive design, programming

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

Saved successfully!

Ooh no, something went wrong!