Jump to content

Talk:Method (computer programming)

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Anwar saadat (talk | contribs) at 12:20, 28 January 2008 (to which class does main() belong?). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

In use, a method is a function.. Fundamentally, Methods + Data = Object.. Just the elaborations of this invariant property of objects has muddied the definition of what an object is.. For instance inheritance is more a language construct than a property of an object.. Also a "Class" is the beginning state of an object, so what use is a class aside from an object, as objects could be used to make more objects.. I think over the years Java and C++ has muddied the definition of what an object is, when really its a simple concept that I believe (in conspiracy theory) that capitalists not interested in the adoption of object oriented languages has intentionally sabotaged to avoid the competition from perpetually consistent pluggable entities. Agents are merely mobile objects and whatever happened to the use of Agents? I challenge you to track down the use of Agents, popular in the 90s but was this just a fad? You may find they were systematically extinguished (I was told one such language that used agents as objects was forced out indirectly by Microsoft, but this is a rumor). --Rofthorax 10:38, 24 August 2005 (UTC)[reply]

---

Is static really the same as "shared"--I thought it was the opposite--static *fields* cannot be modified.

more information and more accurate information needs to be put here. I don't know enough about Java to help.

My references: (by memory)

Java Methods, avaliable directly from www.skylit.com


The static keyword is, by default, related to single storage. For instance, any modification of a static field will be seen by all instances of a given class as they are applied to the same piece of memory. There are exceptions, however. I will care to provide one example: global variables in C which are also static will have internal linkage, that is, they will only be seen by functions inside the same file (if, naturally, placed after the variable in question was defined).

The keyword global is related to access. A global variable is one which will be accessed by all functions which do not include definition of a variable of the same name and type. Global variables will naturally have a single piece of memory related to them. This means they are "static" in such sense. But a language may allow them to be defined as static and this will have a different behavior, as stated on the above paragraph.143.54.30.7 18:49, 18 January 2007 (UTC)[reply]


I would not consider static functions as methods [they're just functions associated with the class]. Similarly, constructors and destructors (in C++) are not strictly speaking methods. A method should be able to assume that invariants are satisfied on entry to the method, and should leave the object in a valid state.

Subroutines and Methods

Aren't subroutines and methods pretty simliar? If so, I think each article should mention the other one to some degree. -Hyad 2 July 2005 23:25 (UTC)


"Method" is just a new word for function or procedure that has become popular in the object oriented paradigm. This article should refer to existing articles on functions and procedures, should relate methods to functions and procedures, and should explain in very clear terms that a method is simply a module of code that contains a sequence of instructions. Some methods attach to classes, others to objects, others to neither (in structured programming languages). There should be some explanation of parameters and return values, but nothing that duplicates discussions already in place under "function" or "procedure" or the more generic "subroutine".

main()

In Java class hierarchy, where does the method main() fit? Anwar (talk) 12:20, 28 January 2008 (UTC)[reply]