Results 1 to 4 of 4
  1. #1
    edelric666 is offline Member
    Join Date
    Oct 2010
    Posts
    12
    Rep Power
    0

    Default how do you actually define a method?

    Hi, i have been writing a short pasage for some work, where i am trying to explain how to pass an arguement to a method. Ideally it shoud be able to e understood by a person who has never touch a program before, so i would like to innitially define the what the method ans arguement actually are. thing is i am not quite sure how to put it into words, and from looking around, i havent found an actually definition, only examples. any ideas off what i could put for what is a method and what is an arguement?

    there is anothr thread i have posted with a similar question, heres the link what does it mean "pass an argument to a method"
    Last edited by edelric666; 10-31-2010 at 12:10 PM.

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,574
    Rep Power
    12

    Default

    i have been writing a short pasage for some work, where i am trying to explain how to pass an arguement to a method.

    What have you come up with so far?

  3. #3
    edelric666 is offline Member
    Join Date
    Oct 2010
    Posts
    12
    Rep Power
    0

    Default

    so far i have explained how passing an arguement to a method is actually written (using a very simple System.out.println("hello world");), i have said to pass an arguement means to call a method with parameters that need to be given values (although im not sure if thats correct.) and that by passing an argument to the method you take what is in the brakcets (the argument) and give it to the method (System.out.println) as what to print, in this instance and that it is a string in this.

    thing is i have a 300 word limit and i think it is quite difficult to understand what is said without first knowing what the method and argument are.

  4. #4
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,574
    Rep Power
    12

    Default

    I think that it's quite a task to explain to someone who hasn't programmed - especially in 300 words.

    I think you're right: such a person would want to know what a method is (and what arguments are). Only then do the mechanics of how you call a method even begin to make sense.

    -----

    My take on it (unconstrained by the limit!)...

    Methods are behaviour: things an object can do. And calling methods is giving commands. A radio, for instance, has methods corresponding to the station it plays, the volume whether it is turned on etc. Tuning in to a radio station might be done by pusing a "preset" but, equally you might turn a dial. The number on the dial tells the radio which station you want to play. It is the argument. (the presets have no arguments)

    You didn't mention the return value of a method, but that's also important. The radio may well have a display of "favourite" stations with up/down buttons which return a particular frequency (that's the return value) which can then be used as the argument to the tune command. The "off" command has no return value.

    -----

    Nonprogrammers may (or may not) be aware of some of the characteristics that emerge when we consider things in terms of their behaviour.

    * typically we have no clue how the object does what it does. We only need to know how to command it and what it will do when commanded.

    * commands can be combined in a modular way to produce a huge variety of possible behaviours

    * the reverse of the previous is that a single command (like tuning to a radio station) might involve the combined actions of millions of people to mine the raw materials, design and build the components, provide the electricty...

    * we get a pretty decent mental picture of things using only behaviours. Argueably it's behaviour all the way down. (while reality is just "out there": it's all state)

    -----

    I think your System.out.println() is a good way of being specific about the syntacic mechanics of calling a method. I offer the above - just off the top of my head - as some way of making the concepts realistic.

    Good luck with the 300 word limit!

Similar Threads

  1. define object outside the function.
    By zenitis in forum New To Java
    Replies: 13
    Last Post: 06-05-2010, 10:00 PM
  2. define a variable
    By jperson in forum New To Java
    Replies: 2
    Last Post: 01-29-2010, 03:33 AM
  3. Define this error.
    By jaicea in forum New To Java
    Replies: 3
    Last Post: 12-02-2009, 02:07 AM
  4. How to define Bean Scope
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-30-2008, 11:14 AM
  5. What is an interface in the java? how to define
    By sivasayanth in forum New To Java
    Replies: 3
    Last Post: 01-14-2008, 05:13 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •