• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Objects vs Functions - is this right?

GWestphal

Golden Member
A function is the same as a method of an object, but the difference is whether the variables (states) are part integrated (object) or not (function).


So, an object is like some black box machine (method) and it has switches on it (states), whereas a function is like a black box that has a shoot on it and I take some other black boxes and drop it in the shoot and it spits out some pyramids.

It that the main difference? Just integration of variables with the function?

Are there any more important differences?
 
Hehehe .. something like that..
... I guess ?! 🙂

that shit is cracking me up dude, plz continue 🙂.
 
Yes, functions are methods of objects, but there is no rule that says functions can/cannot access state variables within the object itself.

Though typically, if a method/function is not dependant on state of an instance object at all, say for example DateTime.Parse(), it can (or should depending on your OOP philosophy) be made a static method.

Objects are instances of classes, that can contain any combination of methods, properties, fields, etc.
 
You really need to take a hike.

/me likes hiking ..

so this

".. take some other black boxes and drop it in the shoot and it spits out some pyramids."

wasnt intended to be funny? Wasnt funny to you? Maybe you need to grow a sense of humor 🙂
(and live and let go..)
 
And maybe i am dense, but i seriously do not understand the question.
I'd understand function (returns value) vs. procedure (does not return value, but by reference)
If you're talking Object Oriented vs Functional programming, it is another story alltogether and nothing prevents us from having functions/procedures in either one.

But as I said, i may be dense...

edit : spits out pyramids ... common 🙂
 
A function is the same as a method of an object, but the difference is whether the variables (states) are part integrated (object) or not (function).

[...]

Are there any more important differences?

Yes, there are. What you're describing, although not entirely incorrect, is not the main difference between functions and methods -- you could do essentially the same thing with a function by passing it a structure to work on. (And under the hood, this is pretty much what happens even with object-oriented code.)

In object-oriented programming, you should be thinking of higher-level concepts such as high-level encapsulation -- the designer of the class prescribes the methods which are contained in the class definition, and polymorphism -- different derived objects can have different implementations of methods of the same name, and the caller need not be aware of the differences or details.
 
Back
Top