Functions vs OOP

W

William Gill


I can think of times when a special application, such as a converter,
would take an object as an argument, but the somewhat unique nature of
the application wouldn't justify changing the class to make the behavior
into a method.

I could extend the underlying class to include the new behavior
(method), but that would mean existing instances of the base class would
need conversion to the new class, requiring yet another method.

Seems to me, that would be POOP (Puristic Object Oriented Programming) ;-)
 
J

Jean-Michel Pichavant

William said:
Not to split hairs, but syntactically f(x) is a function in many
programming paradigms.

As I understand it functional programming places specific requirements
on functions, i.e.referential transparency. So f(x) may or may not be
"functional".

x.f() is also a function, but it is a member of the object x, is
referred to as a 'method' of x, and uses the syntactical "dot"
notation object"dot"function for identification.

Functional programming is not about writing a programm with functions
(google it for more info). This may cause some confusion.

Your original post was about functions vs methods, which are identical
except some syntax detail. FYI, in python x.f() is equivalent to f(x).
In an OOP world one will prefer the x.f() form.


JM
 
T

Terry Reedy

Not to split hairs, but syntactically f(x) is a function in many
programming paradigms.

As I understand it functional programming places specific requirements
on functions, i.e.referential transparency. So f(x) may or may not be
"functional".

In Python, it may be a parameterized procedure. Some languages separate
functions and procedures (also called subroutines). Python does not.
(Or you could say that it makes procedures into functions with
side-effects by returning None by default).
 
W

William Gill

Functional programming is not about writing a programm with functions
<snip>. This may cause some confusion.

It can, and it did. That was the impression I (incorrectly) got from
the documentation. Which didn't make sense to me.

(google it for more info).

I can, and I did. That, and the answers I got in this ng are how I
corrected my misconception.
Your original post was about functions vs methods, which are identical
except some syntax detail. FYI, in python x.f() is equivalent to f(x).
In an OOP world one will prefer the x.f() form.
No, my original post was about how (based on the aforementioned
misconception) the documentation seemed to suggest that OOP should never
have free standing functions, only methods.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top