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.

16.2 Packages 223<br />

<strong>for</strong> software engineering (C++, Ada, C# and Java) carry out such checks. Another<br />

acute problem in large programs concerns the handling of unexpected events during<br />

the execution of a program. <strong>Programming</strong> language features <strong>for</strong> exception handling<br />

are discussed in Chapter 17.<br />

In summary we can identify several needs <strong>for</strong> programming in the large:<br />

■ to be able to see the overall structure of the system<br />

■ to compile separately and link program modules<br />

■ to be able to access software libraries, e.g. graphics or mathematical methods<br />

■ to be able to reuse software components that have been created <strong>for</strong> one system<br />

as part of a new system – in order to reduce development costs<br />

■ to provide facilities that support the construction of a large piece of software by<br />

a team.<br />

16.2 ● Packages<br />

The idea of a class is to group together a set of methods and data that are related in<br />

some way. This then constitutes a programming unit that is bigger than a single method<br />

or data item. So instead of describing a large program as consisting of 50 methods and<br />

10 data items, we can view it as a collection of, say, 10 classes. This is potentially easier<br />

to understand, design, code, debug, test and maintain. (Even worse, we could think of<br />

a program in terms of 10,000 lines of coding.)<br />

The next stage is to group classes into packages. Again, instead of thinking of a<br />

program as 100 classes, we can see it as a collection of 10 packages. The Java libraries<br />

provide thousands of useful classes. For convenience, the classes are grouped into<br />

packages. Here, <strong>for</strong> example, are some of the Java library packages with an outline of<br />

their contents:<br />

java.lang contains the classes that support the main features of the language like<br />

Object, String, number, exception and threads<br />

java.util these are useful utility classes, such as Random and ArrayList<br />

java.io text input and output streams <strong>for</strong> characters and numbers<br />

java.net classes that carry out networking functions, socket programming,<br />

interacting with the internet<br />

javax.swing this includes the classes to provide GUI components, such as buttons<br />

(JButton), labels (JLabel) and sliders (JSlider).<br />

java.awt awt stands <strong>for</strong> Abstract Window Toolkit. The graphics methods, such<br />

as drawLine, are here.<br />

java.applet the classes provide support <strong>for</strong> Java applets (programs run from a web<br />

browser).

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

Saved successfully!

Ooh no, something went wrong!