EETimes

Embedded Systems October 2000 Vol13_11

Issue link: http://dc.ee.ubm-us.com/i/71842

Contents of this Issue

Navigation

Page 85 of 181

LISTING 3 iThe implementation of a Light class with Opsys; use type Opsys.Unsignedshort; package body Light is function Create ( Theaddress : System. Address; Themask : Opsys.Unsignedshort) return Object is This : Object; begin This.Address := Theaddress; This.Mask := Themask; This.Is_On := FaLse; return This; end Create; procedure Turn_Off This : in out Object) is Register : Opsys.Unsignedshort; for Register'Address use This.Address; begin if This.Is_On then Register := Register xor This.Mask; end if; end TurlLOff; procedure Turn_On This : in out Object) is Register : Opsys.Unsignedshort; for Register'Address use This.Address; begin if not This.Is_On then Register := Register xor This.Mask; end if; end Turn_On; end Light; • Object-oriented programming results in increased maintenance costs. Software is always hard to maintain. It is especially hard to understand and see the impacts of the code you are changing. At least in the object-ori- ented paradigm, you can reduce the coupling between modules, so that changes do not have such a dramatic impact on th e entire application. Those who main tain legacy systems often take six months or more to come to a good understanding of even a small sys- tem. That's a high maintenance cost that is independent of the pro- gramming pal-adigm. If you have built your system using object-OI"i- ented principl es, at least the main- tainers will be able to see the scope and potential impact of the changes they need to make before they make them c++ may be flawed and an object- oriented programming language. But does that mean we ought to abandon object-orie nted programming alto- gether? Certain ly not. There are many object-orie nted programming lan- guage to choose from. In particular, Ada95 does an excelle nt j ob of addressing the concerns of the em bed- ded systems programming world , while mainu. ining an object-orie nted capability. Let's not give up on object oriented technology simply because we can 't easily encapsulate registers in C++. esp LImN with Light; wi th System; procedure Lightdriver is My_Light begin My_Light := Light.Create (16#FFSE#, 16#40#); Light.Turn_On (My_Light); Light.Turn_Off (My_Light); end Lightdriver; 84 OcrOBER 2000 Embedded Systems Programming Light.Object; An example of using a Light class Chad Bremmon works Jor Armstrong Consulting in the a' reas oj object-ori.ented e- development and business process engineer- ing. Chad was pTeviously an AiT FOTce Officer at the Pentagon JOT five yeaTS, afler which he worked as a softwaTe engi.neering specialist Jar Rational SoJtware. lou. can e- mail him at chadb@armstrongconsult- ing.com. Resources For more information about Ada. go to www.acm.org/sigada or www.adapower.com .

Articles in this issue

Archives of this issue

view archives of EETimes - Embedded Systems October 2000 Vol13_11