Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between attribute and parameter

 
jayant bhoge
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
I want to the difference between attribut and parameter and difference between argument and parameter

regards
Jayant
 
Henrik Engert
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • 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 ]
 
Lionel Badiou
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Jayant,



As you can see, "parameter" and "argument" are synonymous.
Hope that helps,
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • 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.
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • 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.
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • 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
 
Junilu Lacar
Bartender
Pie
Posts: 7328
45
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • 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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic