method (Object) is a paradigm that works with data structures. Data structures are a grouping of information fields that are semantically consistent and related (that is, Struct Person {FirstName, LastName, DateOfBirth}).
Object-oriented programming is one step above data structures. In OOP, we not only group related data fields, but also include functions (methods, member functions) that are associated with the data (and that act on the data in the right way).
Encapsulation is to keep some of the elements closed to objects. The goal is to "hide" the internal work from the outside world and protect the state of the object from "corruption" or from assigning incorrect values. OOP languages ββprovide several "access modifiers" that are used to indicate whether a particular category of objects (instances of child classes, classes in the same "package / namespace / library", any other class, etc. can access this member). .d.).
object.method () usually requests an object to do something, which may include access to a field that is not accessible outside the class.
Above was the definition and explanation of how the concept of a member function (method) and the concept of encapsulation go hand in hand.
Referrences: http://en.wikipedia.org/wiki/Encapsulation_%28object-oriented_programming%29 http://en.wikipedia.org/wiki/Object-oriented_programming
xtrem source share