Method
From CSSEMediaWiki
(Difference between revisions)
m |
m |
||
Line 2: | Line 2: | ||
* A textual name | * A textual name | ||
− | * A visibility modifier - This defines the encapsulation of the method: either public or within some boundary (be it class, object or some other construct) | + | * A visibility modifier - This defines the [[Encapsulation|encapsulation]] of the method: either public or within some boundary (be it class, object or some other construct) |
* Zero or more parameters - The inputs to the method, either primitives or objects (this can be language specific). | * Zero or more parameters - The inputs to the method, either primitives or objects (this can be language specific). | ||
− | * A returned type - Either no return type (<tt>void</tt>) or returning some primitive (e.g. <tt>float</tt>, <tt>int</tt>) or object. | + | * A returned type - Either no return type (<tt>void</tt>) or returning some primitive (e.g. <tt>float</tt>, <tt>int</tt>) or an object. |
A method may also have other modifiers that change the actions of the method. In Java, an example of this is <tt>synchronized</tt>. | A method may also have other modifiers that change the actions of the method. In Java, an example of this is <tt>synchronized</tt>. |
Revision as of 11:15, 10 September 2009
Methods are a means of providing classes with behaviour. They consist of four parts:
- A textual name
- A visibility modifier - This defines the encapsulation of the method: either public or within some boundary (be it class, object or some other construct)
- Zero or more parameters - The inputs to the method, either primitives or objects (this can be language specific).
- A returned type - Either no return type (void) or returning some primitive (e.g. float, int) or an object.
A method may also have other modifiers that change the actions of the method. In Java, an example of this is synchronized.
A method is usually considered synonymous with a function or procedure. However, these terms are usually associated with the functional and procedural programming paradigms.
See Also
Nomenclature | |
---|---|
Techniques: Abstraction | Aggregation versus Composition | Association versus Dependency | Coupling | Encapsulation | Information hiding | Inheritance | Multiple Inheritance | Overloading | Polymorphism
Features: Abstract class | Class versus Object | Component versus Module | Instance | Interface | Method | Package versus Namespace | Superclass | Subclass |