• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Difference between attribute and parameter

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,
I want to the difference between attribut and parameter and difference between argument and parameter

regards
Jayant
 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is just a definition for what the method takes. You can call them whatever you like. You can say for example a method uses arguments and a user passes parameters.
[ May 03, 2005: Message edited by: Henrik Engert ]
 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Jayant,



As you can see, "parameter" and "argument" are synonymous.
Hope that helps,
 
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've never seen "attribute" used as a synonym for a method parameter/argument. To me, attribute is more akin to a field, though mostly when talking about JavaBeans. My view comes from the dictionary definition of attribute: "A quality or characteristic inherent in or ascribed to someone or something."

If the context is specifically about methods, I would consider attribute more to mean the method's name, visibility scope (public, package, protected, private) and the other modifiers a method can have: static, synchronized, native, etc. In that sense, I view the complete list of parameter types as a single attribute of a method. That list combined with the name and return type make up a method's signature, which really could also be viewed as an attribute itself.
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think of a parameter as being part of a method's API, it's what you declare in the parameter list of the method signature.

To me, the argument is the value passed into the method at runtime, so the arg has to comply with the type of parameter.
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Roger Chung-Wee:
I think of a parameter as being part of a method's API, it's what you declare in the parameter list of the method signature.

To me, the argument is the value passed into the method at runtime, so the arg has to comply with the type of parameter.



I think Roger has given what is typically accepted as the formal definitions of argument and parameter. As other's have posted, the two terms are often used interchangeably, too, unfortunately. I'm not sure what the word "attribute" has to do with this discussion. As far as I know, this is not a commonly used term in the Java programming language.

Layne
 
Sheriff
Posts: 17665
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"attribute" and "property" are often used interchangeably.

As for "parameter" vs. "argument", well, there are formal parameters and actual parameters. An "argument" would probably be an actual parameter in most cases that they are referred to as such.



In the above example, s is the formal parameter in the Foo() constructor. At the same time, s becomes the actual parameter (argument) in the call to setProp(). In setProp(), fp is the formal parameter.

In the case of p, it is an instance variable of the Foo class. It can be referred to as a field, a property, or an attribute. You could run into folks who will object to p being called an attribute and would prefer to keep it abstract and say that the Foo class has a Prop attribute that can be accessed via the getProp() method. To these type of folks, p is just an implementation detail. I'm not such a stickler for semantics so I'll just usually go with whatever everybody or most everybody understands (although I will usually object to calling something a Value Object instead of a Data Transfer Object)

HTH
[ May 03, 2005: Message edited by: Junilu Lacar ]
 
I'm full of tinier men! And a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic