Thread: Just Beginning

  1. #31
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Quote Originally Posted by Yarin View Post

    I'm not talking about what's OOP and what's not.


    I don't understand how a function that lies within an object, is somehow a "method", but any other function isn't. I understand that this term is very established, but that doesn't explain how it came to be. It doesn't make any sense to me.
    I think you are, but I don't hold it against you.

    In "how method came to be" I think that oogabooga has the best answer for you when he said that method was just a word chosen to differentiate it from functions, which was first used in Smalltalk.

    You're actually right, though. If it looks like a function it is a function, probably. But in C++, which has OOP and heavily encourages its use, you need to clearly distinguish the parts of the class from everything else in the language. So all methods are functions, but not all functions are methods. Ultimately, I think you're searching for whether such a distinction is important and I think it is. You're more likely to express a program in terms of classes and objects with C++, and you don't want to be talking about one feature and have people plan to implement the other feature because of an ambiguous name. A method works with a specific instance of one class (whether you pass it in or not) while a function doesn't have to do that in order to be a function. In fact a function could be part of a design on a higher level and have to work with several objects.
    Last edited by whiteflags; 10-10-2012 at 08:41 PM.

  2. #32
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    I'm not talking about what's OOP and what's not.
    O_o

    I know exactly what you are talking about.

    You are asking about how methods are different from functions; the notion that they are different is a distinctly "OOP" construct.

    (Just so as you know, "OOP" and "OMG! OOPS!" are on opposite sides of the universe.)

    So yeah, you are talking about "OMG! OOPS!" because a million idiots have clouded your view.

    You aren't getting the one simple point I made: it doesn't matter what is or isn't a method if we are only looking at syntax.

    The simple truth is that the notion of "method or function" is completely irrelevant in the general sense when talking about syntax. The one expression isn't more "methodic" than the other in view of the syntax. The one expression isn't more "methodic" than the other in view of a function that "lies within an object" or does not "lie within an object".

    The notion of "method" as related to design is a simple construct related primarily to encapsulation and abstraction (often via polymorphisms). A "method" is just a function that isolates (or binds if you prefer) private features of a class into a facility that is the only interface to those features. It is a term properly used to describe that design relationship. That is all there is to it, and it has absolutely nothing to do with syntax. Any use of the term "method" to describe only syntax is asinine.

    Have you ever declared (not defined) a structure in pure ISO C and provided only interfaces to the world that take pointers to that declared structure? Those are as much methods as anything C++ has to offer. If you need a "check list" of sorts we have: private data (That's a check as client code doesn't know anything about the structure.) and polymorphic binding (That's a check as it is easy to imagine a facility that behaves differently depending on how the object was created.). In pure ISO C you might call this construct a "opaque pointer to a structure" or something. You might call it by another name. Sure, you can go a million different ways, but "OOP" is a set of design "tools"; they aren't syntax or style guides.

    Idiots, a lot of idiots, have managed to corrupt the definition of "method" into such a notion that `instance.function()' is superior to `function(instance)'. Such a notion has no place in reality. You are confused by the notion where syntax accounts for the definition without reason. There is no reason for this confusion because the very notion that syntax implies design is provably false. The "tools" "OOP" offers are all design tools. Syntax is, for lack of a better way to put it, just syntax.

    More or less my point.
    O_o

    Really?

    *shrug*

    I know that was your point. I made a joke about the absurdity because I complete agree with the point you made.

    Soma

  3. #33
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    whiteflags & phantomotap, you both have done a fine job of telling me what a method is...
    I never asked what a method is, or even how it's different from a function. I asked what quality a method has that would cause it to be termed "method", specifically, what quality classic functions don't also have.
    Sadly, thus far whiteflags mentioning Smalltalk is the only helpful response I've been given. :-S

  4. #34
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by Yarin
    I asked what quality a method has that would cause it to be termed "method", specifically, what quality classic functions don't also have.
    In C++ parlance, at least using Stroustrup's definition in his C++ glossary, that characteristic is that one can override a method since he writes that "a virtual member function is sometimes called a method".
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #35
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Good call, whiteflags. It's explained here: Smalltalk - Wikipedia, the free encyclopedia

    The notion of "method" was originally understood as a way of handling passed messages, based on their contents, obviously. Makes perfect sense.
    However, come C++, there was no "message passing" as much as just the direct calling of member functions. But naturally it inherited the term "method", even though the subtle difference no longer made it a true "method" any more than any other function.
    It comes together even more when you consider that Smalltalk doesn't even have traditional functions in the first place, only, methods.

    EDIT: Interesting, laserlight. That sounds like Stroustrup was trying to preserve the term as it was originally used (virtual call table = different possible functional routes), even though it's no longer that specific.
    Last edited by Yarin; 10-10-2012 at 10:30 PM.

  6. #36
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    I never asked what a method is, or even how it's different from a function.
    O_o

    Is there two different people using the Yarin name?

    However, come C++, there was no "message passing" as much as just the direct calling of member functions.
    O_o

    Actually, virtual functions and template-based polymorphisms almost exactly mimic the intent of message passing.

    Once again, syntax is meaningless.

    Soma

  7. #37
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    Quote Originally Posted by phantomotap View Post
    Is there two different people using the Yarin name?
    The guy's a troll.
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  8. #38
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Quote Originally Posted by phantomotap View Post
    Is there two different people using the Yarin name?
    I give up, if you're not willing to read more than the first sentence of my posts, then there's not much else to say.

    Quote Originally Posted by phantomotap View Post
    Actually, virtual functions and template-based polymorphisms almost exactly mimic the intent of message passing.
    Yeah... as I say in my last post.

    Quote Originally Posted by phantomotap View Post
    Once again, syntax is meaningless.
    Syntax is one of the components of the OOP aspect of a language, and so, is meaningful.

    Quote Originally Posted by oogabooga View Post
    The guy's a troll.
    You're just mad that I missed your first mention of Smalltalk.

  9. #39
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    [Edit]
    Actually, it is more fun to watch you wallow in continued ignorance of such a simple concept.
    [/Edit]

    Soma
    Last edited by phantomotap; 10-11-2012 at 01:25 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. beginning C#
    By DennChooch in forum C# Programming
    Replies: 7
    Last Post: 11-21-2012, 05:52 AM
  2. Beginning Tutorials
    By Sugar in forum C++ Programming
    Replies: 7
    Last Post: 12-28-2011, 10:37 PM
  3. Beginning ASM.
    By Krak in forum C++ Programming
    Replies: 4
    Last Post: 12-06-2004, 06:27 PM
  4. beginning C++
    By datainjector in forum C++ Programming
    Replies: 2
    Last Post: 12-12-2002, 02:27 AM
  5. In the beginning...
    By CAP in forum Game Programming
    Replies: 21
    Last Post: 05-29-2002, 01:40 PM