Jump to content

Talk:Encapsulation (computer programming)

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 6StringJazzer (talk | contribs) at 18:46, 11 March 2018 (Added "Encapsulation Is Not a Security Feature" section). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Template:IEP assignment

WikiProject iconComputing Start‑class
WikiProject iconThis article is within the scope of WikiProject Computing, a collaborative effort to improve the coverage of computers, computing, and information technology on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
StartThis article has been rated as Start-class on Wikipedia's content assessment scale.
???This article has not yet received a rating on the project's importance scale.
Note icon
This article has been automatically rated by a bot or other tool because one or more other projects use this class. Please ensure the assessment is correct before removing the |auto= parameter.
WikiProject iconComputer science Start‑class High‑importance
WikiProject iconThis article is within the scope of WikiProject Computer science, a collaborative effort to improve the coverage of Computer science related articles on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
StartThis article has been rated as Start-class on Wikipedia's content assessment scale.
HighThis article has been rated as High-importance on the project's importance scale.
Things you can help WikiProject Computer science with:

If you don't already know what encapsulation is, you'll likely not understand a word of this article. Too technical, too preoccupied with OOP. I'm a reasonably experienced developer, and I had to read it slowly to understand anything at all. 213.30.149.61 (talk) 12:09, 9 July 2015 (UTC)[reply]

Why "orthogonal"

Why is the word "orthogonal" used on about the 9th line of this article? Doesn't it mean "absolutely without influence"? I suspect that even to establish its possibility in this situation would require some heavy-duty theorizing. How about "apparently (or superficially, or tentatively, or ?) independent? -lifeform (talk) 05:37, 21 November 2015 (UTC)[reply]

History? Summary!

And then everyone wonder why WP has a bad rep. I came here to look up where Encapsulation was introduced, but I find nothing. Great. --jae (talk) 01:25, 25 November 2015 (UTC)[reply]

Edit the page to add that information. It won't appear by itself. 81.187.215.34 (talk) 18:21, 15 January 2016 (UTC)[reply]

Encapsulation is information hiding

Honestly, I was surprised to find that there are two articles covering what I always thought was the exact same thing. Despite what the oft cited JavaWorld article claims, encapsulation and information hiding are synonymous.

I'm not saying there is only one definition, but if you look back to the first real references to the term "encapsulation" in the late 1970s, you see that encapsulation was first used to mean "designing software in such a way as to hide certain details from your clients", i.e. information hiding. In fact, in "Concise Notes on Software Engineering" (1979), the author refers to this paper – the one used by the JavaWorld article to make the distinction between information hiding and encapsulation – as describing "the priciples of encapsulation". This is just one of the more clear examples. Practically every early reference to "encapsulation" describes it as synonymous with information hiding.

Later on, in the late 1980s and early 1990s, as object-orientated programming gained traction, the "encapsulation mechanisms" provided by some OO languages started to become synonymous with encapsulation. That is, to some people "encapsulation" became "bundling data with methods to hide it from clients". Unfortunately, due to the existence of "public" access modifiers (a programming feature designed to break encapsulation), at some point some people started thinking that encapsulation was simply "bundling data with methods", with no reference to information hiding whatsoever. Of course, without encapsulation, "bundling data with methods" is merely syntactic sugar.

This is all my analysis though. If I get the time I will edit the article to indicate that encapsulation is information hiding, and provide many sources to back it up. Hpesoj00 (talk) 21:32, 3 August 2016 (UTC)[reply]

Agreed. This article does a very poor job of articulating what encapsulation really is: internalizing (hiding) implementation details. It does do a fine job of confusing readers by incorrectly suggesting that encapsulation means bundling data with methods; but that concept is actually called Object Oriented Programming. If these concepts were the same, you would not find examples of encapsulation within non-OO languages. This whole article needs major revisions, but in the short-term I'm going to remove the "historical importance" section. This section has never had any citations, much less valid citations. Jamarr81 (talk) 20:34, 6 March 2017 (UTC)[reply]
In the long term, the Encapsulation is not Information Hiding article on JavaWorld is bunk and needs to be removed. It does a fine job at describing how to approach and design Object Oriented Software, but you cannot just given an example of designing OO software and call it encapsulation simply because you used encapsulation to improve the design. This article right now is a horrible reference for new developers that don't know any better. Jamarr81 (talk) 20:34, 6 March 2017 (UTC)[reply]
Agreed that the article, and its conclusions, need to be removed. It's clearly an opinion piece, not consensus; it's even labeled as such by the opening text: "Authors rarely distinguish between the two and often directly claim they are the same. Does that make it so? Not for me." — Preceding unsigned comment added by 75.136.94.104 (talk) 17:03, 13 November 2017 (UTC)[reply]
@Jamarr81: I have compiled what is essentially a chronological literature review here of the concept of encapsulation. I never quite finished it, and have yet to incorporate it into this article because I don't know if it is in an appropriate format for Wikipedia.
@Hpesoj00: Thanks for that, I will definitely review what you've compiled in the near future.
I agree that the JavaWorld article is at odds with common usage of the term prior to its publication. It seems to be the original source of the definition it espouses. Even Parnus, the author of the paper the article cites who coined the term "information hiding" has stated in later papers that "encapsulation" is related or even synonymous to "information hiding". I recall that I found one academic paper that gave a similar definition, but I think I decided that it was not a particularly reliable source, and did not include it in my review. I no longer have access to the academic database that I used for my review, but I do still have all the papers somewhere, so I should check that I wasn't being biased in my omission. Hpesoj00 (talk) 09:22, 7 March 2017 (UTC)[reply]

Pseudo-code vs Code examples

I propose replacing the code examples with equivalent pseudo-code to explain the concept. The current examples are too long and very similar. Conversely we could add more examples, and more, and more, and more. I vote we go the other way. A single effective example in pseudo code for the object-oriented case, and perhaps one for the non OO case. I'm open to suggestions and helping with the contribution. Should I be worried that we may be straying into a WP:NOR violation unless we can find an example in literature with permission. Rkedge (talk) 16:24, 28 August 2017 (UTC)[reply]

Encapsulation Is Not a Security Feature

"Encapsulation is used to hide the values or state of a structured data object inside a class, preventing unauthorized parties' direct access to them." I take exception to this statement but did not want to simply edit it before getting some feedback. Encapsulation is a design approach to insulate one piece of code from having to know the underlying implementation of another piece of code. To say that it prevents unauthorized access somehow implies (or states outright) that encapsulation prevents bad guys from messing around at the underlying implementation level. But if you can write code that calls existing code, and you can get your code compiled and bound into an executable, and then run that executable in an environment, then the environment is compromised and you can pretty much do anything you want. You are not going to be stopped by a Private declaration.

The linked article on Encapsulation vs. Data Hiding gives excellent examples of the motivation behind this design approach and does not mention security as a motivation. Nor could I find any source that does.

I invite further discussion on this point. 6StringJazzer (talk) 18:46, 11 March 2018 (UTC)[reply]