Content deleted Content added
No edit summary Tag: Reverted |
No edit summary Tag: Reverted |
||
Line 1:
{{Short description|Bundling of data}}
In [[object-oriented programming]] (OOP), '''encapsulation''' refers to the bundling of data with the methods that operate on that data. Often that definition is misconstrued to mean that the data is somehow hidden. In Java, you can have encapsulated data that is not hidden at all. So '''encapsulation''' and '''hiding''' are not the same and have different meaning! <ref name="Rogers01" /> Encapsulation is used to close (in meaning
Publicly accessible methods are generally provided in the class to access or modify the state more abstractly. In practice sometimes methods (so-called [[Mutator method|"getters" and "setters"]]) are provided to access the values indirectly, but, although not necessarily a violation of abstract encapsulation, they are often considered a sign-post of potentially poor object-oriented programming (OOP) design practice <ref>{{cite web |url=https://www.infoworld.com/article/2073723/why-getter-and-setter-methods-are-evil.html |title=Why Getter and Setter methods are evil |last=Holub |first=Allen |publisher=JavaWorld |date=September 5, 2003 |website=Info World |archive-url=https://web.archive.org/web/20200729073721/https://www.infoworld.com/article/2073723/why-getter-and-setter-methods-are-evil.html |access-date=January 17, 2021|archive-date=2020-07-29 }}</ref> (an [[Anti-pattern]]).
|