Jump to content

User:Hpesoj00/sandbox/Encapsulation (computer programming)

From Wikipedia, the free encyclopedia
This is the current revision of this page, as edited by Hpesoj00 (talk | contribs) at 08:45, 21 March 2017 (Created page with 'In computer science, '''data encapsulation''' or simply '''encapsulation''' is the application of the principle of ''information hiding'', whereby certai...'). The present address (URL) is a permanent link to this version.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

In computer science, data encapsulation or simply encapsulation is the application of the principle of information hiding, whereby certain design information is hidden from the users of an abstraction.

Definition

[edit]

The term "encapsulation", or more specifically "procedural encapsulation", was used in 1973 by Stephen Zilles to describe how procedures can be used to encapsulate or "isolate" the underlying representation of a data type. He noted that encapsulation accomplishes three things:[1]

  1. The operations defined on a type can be formalized to ensure the correctness of objects of that type
  2. Modules have to make minimal assumptions about other modules to which they have access
  3. Encapsulated data is protected from both accidental and malicious modification

Encapsulation has since been described by Parnas and others as being synonymous with the "information hiding principle".[2][3][4] Others have described encapsulation as referring to the way in which the operations that define the behaviour of an abstraction are associated or "bundled" with the definition or instance of the abstraction, while information hiding refers to the way in which the representation of an instance of the abstraction is hidden from view.[5][6][7] More commonly, encapsulation is understood to be the application and enforcement of the information hiding principle through the use of language mechanisms such as procedures, modules and abstract data types.[8][9][10][11][12][13]

Information hiding principle

[edit]

The concept of "information hiding" was described in 1971 by David Parnas, who proposed that access to information should be restricted by design in order to reduce the interconnectedness of a system. He described three apparently conflicting design concerns:

  1. The desire to have a user-friendly external interface
  2. The desire to reduce development time by splitting a system into modules that can be designed independently
  3. The desire to easily change the implementation details of a system

Parnas suggested that these concerns could more easily be reconciled if design information were not accessible to everyone. He proposed that programmers should not be responsible for deciding which information to use, but instead system designers should restrict the information that is available to programmers. He gave an example of how to document a module with a formal interface definition so as to hide implementation details from the user.[14]

Parnas later showed how information hiding can be used as a design criterion for dividing a system into modules. By defining the interfaces between modules such that they hide design decisions from each other, he suggested that a system can support a wider range of functionality without having to change the interface definitions. He noted that care must be taken to ensure that decomposing a system in this way does not negatively impact efficiency.[15]

In 1975, Parnas discussed how attempting to deal with errors at the point where they occur violates the "information hiding principle"; he suggested that interfaces between modules should be designed to communicate information about errors, error handling, and assumptions.[16]

In 1976, Parnas et al. described how programming languages that support abstract data types enable the programming methodology of information hiding.[17]

Abstract data types

[edit]

Object-oriented programming

[edit]
  1. ^ Zilles, Stephen N. (1973-01-01). "Procedural Encapsulation: A Linguistic Protection Technique". Proceeding of ACM SIGPLAN - SIGOPS Interface Meeting on Programming Languages - Operating Systems. New York, NY, USA: ACM: 142–146. doi:10.1145/800021.808305.
  2. ^ Bartussek, Wolfram; Parnas, David Lorge (1978-01-01). "Using Assertions About Traces to Write Abstract Specifications for Software Modules". Proceedings of the 2Nd Conference of the European Cooperation on Informatics: Information Systems Methodology. London, UK, UK: Springer-Verlag: 211–236. ISBN 3540089349.
  3. ^ Parnas, David L. (1978-01-01). "Designing Software for Ease of Extension and Contraction". Proceedings of the 3rd International Conference on Software Engineering. ICSE '78. Piscataway, NJ, USA: IEEE Press: 264–277.
  4. ^ Harrison, R.; Counsell, S.; Nithi, R. (1997-01-01). "An Overview of Object-Oriented Design Metrics". Proceedings of the 8th International Workshop on Software Technology and Engineering Practice (STEP '97) (Including CASE '97). STEP '97. Washington, DC, USA: IEEE Computer Society: 230–. ISBN 0818678402.
  5. ^ Lawrence, Flon, (1974-01-01). "A survey of some issues concerning abstract data types". {{cite journal}}: Cite journal requires |journal= (help)CS1 maint: extra punctuation (link) CS1 maint: multiple names: authors list (link)
  6. ^ Clark, Archer,; Michael, Stinson, (1995-01-01). "Object-Oriented Software Measures". {{cite journal}}: Cite journal requires |journal= (help)CS1 maint: extra punctuation (link) CS1 maint: multiple names: authors list (link)
  7. ^ Rogers, William Paul (2001-05-18). "Encapsulation is not information hiding". JavaWorld. Retrieved 2016-09-14.
  8. ^ Wulf, W. A.; London, R. L.; Shaw, M. (1976-07-01). "An Introduction to the Construction and Verification of Alphard Programs". IEEE Trans. Softw. Eng. 2 (4): 253–265. doi:10.1109/TSE.1976.233830. ISSN 0098-5589.
  9. ^ Micallef, Josephine (1987-08-01). "Encapsulation, reusability and extensibility in object-oriented programming languages" – via Columbia University Academic Commons. {{cite journal}}: Cite journal requires |journal= (help)
  10. ^ Abreu, Fernando Brito e.; Melo, Walcelio (1996-01-01). "Evaluating the Impact of Object-Oriented Design on Software Quality". Proceedings of the 3rd International Symposium on Software Metrics: From Measurement to Empirical Results. METRICS '96. Washington, DC, USA: IEEE Computer Society: 90–. ISBN 0818673648.
  11. ^ Harrison, R.; Counsell, S.J.; Nithi, R.V. (1998-07-01). "An evaluation of the MOOD set of object-oriented software metrics". IEEE Transactions on Software Engineering. 24 (6): 491–496. doi:10.1109/32.689404. ISSN 0098-5589.
  12. ^ Poo, Danny C.; Kiong, D. B. (1998-01-01). Object Oriented Programming and Java (1st ed.). Springer-Verlag Singapore Pte. Limited. ISBN 9813083964.
  13. ^ Harrison, R.; Counsell, S.; Nithi, R. (1997-01-01). "An Overview of Object-Oriented Design Metrics". Proceedings of the 8th International Workshop on Software Technology and Engineering Practice (STEP '97) (Including CASE '97). STEP '97. Washington, DC, USA: IEEE Computer Society: 230–. ISBN 0818678402.
  14. ^ Parnas, D. L. (1971-01-01). "Information distribution aspects of design methodology". {{cite journal}}: Cite journal requires |journal= (help)
  15. ^ Parnas, David Lorge (1972-12-01). "On the Criteria to Be Used in Decomposing Systems into Modules". Commun. ACM. 15 (12): 1053–1058. doi:10.1145/361598.361623. ISSN 0001-0782.
  16. ^ Parnas, D. L. (1975-01-01). "The Influence of Software Structure on Reliability". Proceedings of the International Conference on Reliable Software. New York, NY, USA: ACM: 358–362. doi:10.1145/800027.808458.
  17. ^ Parnas, D. L.; Shore, John E.; Weiss, David (1976-01-01). "Abstract Types Defined As Classes of Variables". Proceedings of the 1976 Conference on Data : Abstraction, Definition and Structure. New York, NY, USA: ACM: 149–154. doi:10.1145/800237.807133.