Please enable JavaScript.
Coggle requires JavaScript to display documents.
Topic 5 : Methods and Data - Coggle Diagram
Topic 5 :
Methods and Data
Method
A method usually consists of a sequence of statements to perform an action, a set of input parameters, and possibly an output value of some kind
The purpose of methods is to provide a mechanism for accessing (for both reading and
writing) the private data stored in an object or a class
A method is a set of programming statements that an object can execute.
There are two (2) method categories in Alice 3 :
Primitive – built in
User-defined – not yet exist, additional method by the programmer
The method can be is two (2) characteristic in Alice 3 :
Procedure – no return value method (doing action without yielding a value).
Function – with return value method (doing action with yielding a value).
Methods and Arguments
When programmers execute a method, they commonly say that they are calling the method.
An instruction that executes a method is commonly referred to as a method call.
When you call a method and provide any necessary arguments, it is called passing the arguments to the methods
Arguments are also called as parameter.
Data and Expression
There are various type of data involve in programming.
Variables
A variable is a storage location that is represented by a name.
Class-Level Variables: is like a property that belongs to a specific object.
Local Variables: belongs to a specific method.
World-Level Variables: is like a property that belongs to the world.
Parameter Variables: is used to hold an argument that is passed to a method
when the method is called.
Variable assignment means an instruction that sets a variable to a
value.
Parameters
Each method is its own small block of instruction, design to perform specific task when requested (called)
Parameters are used to communicate with a method.
We arrange to communicate values (e.g: number, string, name of the
object) from one method to another method through the parameters
Parameter Variables - is used to hold an argument that is passed to a method
when the method is called.