0
Can any one help me to understand .. function,object and method. I am getting confuse.
4 Réponses
+ 1
An object is an instance of a clases... A variable Of a clases type
Methods are functions that your objects can execute...
Functions are independent code blocks that can be summon On your program... (Tell me what language do you refeer and I Will explain with examples)
+ 1
Functions are subprogram in a program. They are designed to avoid code repetition: if you repeat many times a same operation (ie: compute mean of two numbers), you could define a function wich do this specific task... As program in shell (linux bash, dos terminal...), they are able to receive arguments as input, run with or without side effects (ie: modifying other data, display state...) then could return a result.
Objects are encapsulation of data + logic: for a value in a variable (ie: a price) as the developer and human analysis capable you know its purpose, but computers doesn't, even not if the value should be treated as number, char, or anything else, until you specify it (or engine in hi-level languages -- often interpreted ones).
So objects are data structures storing collections of values (variables, or 'properties' or 'attributes' in this context), and/or dedicated logic: code, (sub)program (functions, or 'methods' in this context).
Ex: object Disc with center, radius values and area method.
+ 1
Thank you every one