An Entity of Type: Thing, from Named Graph: http://dbpedia.org, within Data Space: dbpedia.org

In computer programming, field encapsulation involves providing methods that can be used to read from or write to the field rather than accessing the field directly. Sometimes these accessor methods are called getX and setX (where X is the field's name), which are also known as mutator methods. Usually the accessor methods have public visibility while the field being encapsulated is given private visibility - this allows a programmer to restrict what actions another user of the code can perform. Compare the following Java class in which the name field has not been encapsulated:

Property Value
dbo:abstract
  • In computer programming, field encapsulation involves providing methods that can be used to read from or write to the field rather than accessing the field directly. Sometimes these accessor methods are called getX and setX (where X is the field's name), which are also known as mutator methods. Usually the accessor methods have public visibility while the field being encapsulated is given private visibility - this allows a programmer to restrict what actions another user of the code can perform. Compare the following Java class in which the name field has not been encapsulated: public class NormalFieldClass { public String name; public static void main(String[] args) { NormalFieldClass example1 = new NormalFieldClass; example1.name = "myName"; System.out.println("My name is " + example1.name); }} with the same example using encapsulation: public class EncapsulatedFieldClass { private String name; public String getName { return name; } public void setName(String newName) { name = newName; } public static void main(String[] args) { EncapsulatedFieldClass example1 = new EncapsulatedFieldClass; example1.setName("myName"); System.out.println("My name is " + example1.getName); }} In the first example a user is free to use the public name variable however they see fit - in the second however the writer of the class retains control over how the private name variable is read and written by only permitting access to the field via its getName and setName methods. (en)
  • Інкапсуля́ція по́ля (англ. Encapsulate Field) — прийом рефакторингу, що дозволяє полегшити роботу з даними, покращити модульність частин програми та полегшити її підтримку. Забезпечує зближення даних і поведінки над цими даними. (uk)
dbo:wikiPageID
  • 1727391 (xsd:integer)
dbo:wikiPageLength
  • 3880 (xsd:nonNegativeInteger)
dbo:wikiPageRevisionID
  • 956134529 (xsd:integer)
dbo:wikiPageWikiLink
dbp:wikiPageUsesTemplate
dcterms:subject
rdfs:comment
  • Інкапсуля́ція по́ля (англ. Encapsulate Field) — прийом рефакторингу, що дозволяє полегшити роботу з даними, покращити модульність частин програми та полегшити її підтримку. Забезпечує зближення даних і поведінки над цими даними. (uk)
  • In computer programming, field encapsulation involves providing methods that can be used to read from or write to the field rather than accessing the field directly. Sometimes these accessor methods are called getX and setX (where X is the field's name), which are also known as mutator methods. Usually the accessor methods have public visibility while the field being encapsulated is given private visibility - this allows a programmer to restrict what actions another user of the code can perform. Compare the following Java class in which the name field has not been encapsulated: (en)
rdfs:label
  • Field encapsulation (en)
  • Інкапсуляція поля (uk)
owl:sameAs
prov:wasDerivedFrom
foaf:isPrimaryTopicOf
is dbo:wikiPageRedirects of
is dbo:wikiPageWikiLink of
is foaf:primaryTopic of
Powered by OpenLink Virtuoso    This material is Open Knowledge     W3C Semantic Web Technology     This material is Open Knowledge    Valid XHTML + RDFa
This content was extracted from Wikipedia and is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License