ClassesAndObjects - Classes and Objects Classes and Objects...

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

View Full Document Right Arrow Icon
Classes and Objects Beta Draft - Do not distribute © 2001, By Randall Hyde Page 1059 Classes and Objects Chapter Ten 10.1 Chapter Overview Man y modern imperati v e high le v el languages support the notion of classes and objects. C++ (an object v ersion of C), Ja v a, and Delphi (an object v ersion of P ascal) are tw o good e xamples. Of course, these high le v el language compilers translate their high le v el source code into lo w-le v el machine code, so it should be pretty ob vious that some mechanism e xists in machine code for implementing classes and objects. Although it has al w ays been possible to implement classes and objects in machine code, most assem - blers pro vide poor support for writing object-oriented assembly language programs. Of course, HLA does not suf fer from this dra wback as it pro vides good support for writing object-oriented assembly language pro - grams. This chapter discusses the general principles behind object-oriented programming (OOP) and ho w HLA supports OOP . 10.2 General Principles Before discussing the mechanisms behind OOP , it is probably a good idea to tak e a step back and e xplore the benefi ts of using OOP (especially in assembly language programs). Most te xts describing the benefi ts of OOP will mention b uzz-w ords lik e “code reuse, ” “abstract data types, ” “impro v ed de v elopment ef fi cienc y , ” and so on. While all of these features are nice and are good attrib utes for a programming para - digm, a good softw are engineer w ould question the use of assembly language in an en vironment where “impro v ed de v elopment ef fi cienc y” is an important goal. After all, you can probably obtain f ar better ef fi - cienc y by using a high le v el language (e v en in a non-OOP f ashion) than you can by using objects in assem - bly language. If the purported features of OOP don’ t seem to apply to assembly language programming, wh y bother using OOP in assembly? This section will e xplore some of those reasons. The fi rst thing you should realize is that the use of assembly language does not ne g ate the aforemen - tioned OOP benefi ts. OOP in assembly language does promote code reuse, it pro vides a good method for implementing abstract data types, and it can impro v e de v elopment ef fi cienc y in assembly langua g e . In other w ords, if you’ re dead set on using assembly language, there are benefi ts to using OOP . T o understand one of the principle benefi ts of OOP , consider the concept of a global v ariable. Most pro - gramming te xts strongly recommend ag ainst the use of global v ariables in a program (as does this te xt). Interprocedural communication through global v ariables is dangerous because it is dif fi cult to k eep track of all the possible places in a lar ge program that modify a gi v en global object. W orse, it is v ery easy when making enhancements to accidentally reuse a global object for something other than its intended purpose; this tends to introduce defects into the system.
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 54

ClassesAndObjects - Classes and Objects Classes and Objects...

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

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