The Difference Between Encapsulation and Abstraction

The difference between encapsulation and abstraction seems to trouble some people, which is something I find rather odd. While both are concepts important to object oriented design, and while both are complementary to one another, they are two different concepts. In this article I will explain briefly what encapsulation and abstraction are, and how they interact with, and complement, each other.

First, a few words about each of abstraction and encapsulation:

  • The use of abstraction in software design is similar to its use in maths. It involves representing a physical thing or a concept in terms of its essential properties and behaviour. This way, such a thing, be it a concept or something that has physical existence, can be dealt with in a way suitable for modelling the way the real world behaves.
  • Encapsulation is a tool - that is, a tool in the intellectual sense - for drawing boundaries around implementations. One reason for this is to allow implementations to change without affecting the outside world. Another reason, perhaps more important, is its usefulness in structuring the design of a system. To further emphasise the organisational usefulness of encapsulation, consider that it allows the implementation to be tested in isolation, without integration with the rest of the system. A simple function is one example of a unit of encapsulation - that is, as long as it does not use any global variables or any other kind of globally accessible resource. In passing note that this is why global variables are such a bad idea - they compromise the boundaries of encapsulation.

In my articles Accessing Object Properties While Respecting Encapsulation and Updating Object Properties While Respecting Encapsulation, I used a Circle class to illustrate the querying and updating of object properties. The class implements a Circle abstraction, in that Circle is manifested in a computer model by being represented as a combination of state and behaviour. Encapsulation is the instrument that permits the Circle to expose its state to the outside world in a way that keeps the public perception of its state separate from the way its state is implemented. For example, the Circle exposes a public radius property, but the implementation could be in terms of the diameter - requiring a calculation in the background when the radius is queried.

Abstraction and encapsulation are each complex topics in their own right, far more so than might be apparent when these concepts are first encountered. I hope this short article has helped to shed some light on the difference between encapsulation and abstraction.

Leave a comment

?>ungloryhole tug jobs rubs a huge cock public invasion mouth with cock NEXTDOORMALE TOMMYDXXX Ice La Fox Medical Femdom Bareblacking Confession Of Married Man publicinvasion tugjobs Charmane Star outinpublic.com hazehim Charmane Star publicnude publicinvasion Monsters Of Cock Brooke Banner VISCONTITRIPLETS tranny land magical feet haze him collegerules Summer Bailey shaved pussy hammered itsgonnahurt itsgonnahurt Blonde round ass submityourbitch BIGGEST ASS CRAVING collegerules.com out in public Gyno Orgasm Videos submityourbitch tight ass drilled Bang Bros haze him submit your bitch outinpublic.com Stephanie Cane hazehim.com NEXTDOORPASS Big tit fucked publicinvasion lucky stud in a hot threesome Big Mouthfuls SpecialExercises sexy blonde petite public invasion college rules pussy pounded Roxy Love publicinvasion outinpublic.com GAy Cumshots Extrem trannyland VINTAGEGAYLOOPS public invasion ungloryhole Nude sport videos Lacey lounging facialfest Hot tight pussy facial fest submityourbitch.com Licking Dick And Ass tugjobs public invasion milf lessons camel toe Aiden Aspen huge tits ungloryhole publicinvasion Aiden Aspen lesbian dildo drilling college rules outinpublic outinpublic lesbian lover licks Sexy big tits pornstar Beautiful hand job outinpublic.com Special Exercises hazehim collegerules.com submit your bitch Milf cravers trannyland publicinvasion hottest white girls fat juicy ass. outinpublic summer time milf Courtney Simpson public invasion bang pas hazehim milfsoup natural beautiful tits SpecialExamination submityourbitch Gia Malone Lesbiansportvideos smacked those asses ungloryhole Redhead BBW bait Bus NEXTDOORPASS Nudesportvideos CODYCUMMINGS Latina pornstar pussy publicinvasion its gonna hurt Blonde gets fucked hard collegerules Special Examination NEXTDOORHOOKUPS Vince Ferelli MALEDIGITAL CIndia Summers un glory hole submityourbitch.com public invasion busty adventures college rules Amy Reid milfsoup bang bus college rules evanrivers its gonna hurt collegerules fuck team five trannyland.com great ass public invasion MedicalFemdom out in public Lesbian sport videos itsgonnahurt NEXTDOORBUDDIES fat mature redhead GynoOrgasmVideos Big Mouthfuls assparade publicinvasion two beautiful asses 3DS Max 8 OEM3Q 3GP Video Converterdownload acdsee manager 2009 oemred eye remover pro 1.2cheapest windows vistacheapest windows vista ultimatecheap AutoCAD 2009Vision Backup Enterprisecheap Macromedia ColdFusionnero photoshow 5 downloadadobe photoshop cs oemcoldfusion mx 7 downloadkamagra sildenafil citratekamagra generic viagraorder caverta onlinecaverta 100buy cavertatadaliscasodex 50 mg tablet