Method (computer programming): Difference between revisions

Content deleted Content added
Danakil (talk | contribs)
No edit summary
Danakil (talk | contribs)
No edit summary
Line 16:
In contrast to instance methods, a '''class method''' ('''shared method''') can be invoked without reference to a particular [[object (computer science)|object]]. These affect an entire [[Class (computer science)|class]], not merely a particular instance of the class. A typical example of a class method would be one that keeps count of the number of created objects within a given class. Some programming languages such as C++ and Java call them '''static methods''' since methods are modified with <code>static</code>.
 
An '''abstract method''' is a method which has no [[implementation]]. It is often used to makeas a place-holder to be [[method overriding (programming)|overridden]] later by a subclass of or an object prototyped from the one that implements the abstract method. In this way, abstract methods help to partially specify a [[framework (programming)|framework]].
 
An '''accessor method''' is a kind of method that is usually small, simple and provides the means for the [[state]] of an object to be accessed from other parts of a program. Although it introduces a new [[dependency]], use of the methods are preferred to directly accessing state data because they provide an [[abstraction layer]]. For example, if a bank-account class provides a "getBalance()" accessor method to retrieve the current [[balance]] (rather than directly accessing the balance data fields), then later [[revision]]s of the same code can implement a more complex mechanism balance retrieval (say, a [[database fetch]]) without the dependent code needing to be changed.