Lecture 6 - Classes and Objects

Lecture 6 - Classes and Objects - Structured programming...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Lecture 6 Classes and objects Structured programming • structured programming was the first attempt at formally modularizing program code; • now the program was no longer considered one large task, but a collection of smaller tasks; • these tasks were called procedures or functions in older programming languages, but methods in object- oriented languages; • in lecture 4 we effectively used a structured approach. • the diagram below illustrates this for a more complex situation; • here the top-level method is broken down into four tasks; • the second task is broken down further into two tasks, and so on. Example • in program 4.8 the main method called three other methods - option1, option2 and option3. • for some time this approach to modular design dealt adequately with the increased complexity of software; • with the rapid microchip advances of the 1980s and the growth of the Internet in the 1990s, the demands on software developers increased again and the structured approach was found to be deficient; • the reason for this is that the approach focuses on the actions (methods) but not the things acted on – the data; • the data becomes spread throughout the system in a very unstructured way (see below): The above approach can lead to the following problems : data is subject to change by many methods, and data can therefore become unexpectedly corrupted, leading to unreliable programs that are difficult to debug; revising the data requires rewriting every method that interacts with it, leading to programs that are very difficult to maintain; methods and the data they act upon are not closely tied together, leading to code that is very difficult to reuse since there is a complex web of links to disentangle.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The object-oriented solution consider a program that would be suitable for a college or university for the administration of students and courses; it would have to store information about students, such as their personal details, their marks and so on; it would have to perform tasks such as adding students, updating students' marks etc; it would need to store information about the courses on offer and the cost of the course; it would need to provide methods to update course information, add and remove courses and perform many other tasks; in some cases these methods would need information about both students and courses. with the "old-fashioned" structured approach, all the data about students and courses would be stored as part of one big program. in the object-oriented approach, methods and the data they act upon are grouped together into one unit; this higher unit of organization is called an object (see below). The object-oriented approach
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 8

Lecture 6 - Classes and Objects - Structured programming...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online