This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between attributes and parameters

 
Ravi kapa
Ranch Hand
Posts: 89
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,What is the difference between attributes and parameters???give any good example so that i can understand clearly please......
 
John Jai
Rancher
Posts: 1776
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For me, parameters are passed to a method and attributes store the parameters and act like local variables inside a method.



In the above sample name is the attribute and "Ravi" is the parameter.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47258
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not convinced. “Attribute” is not a standard word in Java™ jargon. The nearest I can think is that you are talking about the attributes of an object, which means the values of its fields. But some people would use it with a wider meaning, including behavioiur (its methods) in that term too.

In the example shown, name is the method parameter and "Ravi" is an argument passed to that method. In that instance there is specific Java™ jargon.
 
Matthew Brown
Bartender
Posts: 4549
8
Java Netbeans IDE Scala
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unless you're specifically talking about servlets? There there's a particular distinction. For instance, a request parameter is a read-only string that is passed in from the URL arguments, and a request attribute is a request-scoped object that can be added to the Request object by the servlet (and then accessed elsewhere).

If you're talking in general terms, in object-oriented design (not specifically limited to Java) attributes are the properties of a conceptual class, which (usually) end up corresponding to the fields of the corresponding Java (or whatever language) class.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47258
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn’t think we were talking about servlets. I think you, Matthew, and I are in agreement here.
 
Matthew Brown
Bartender
Posts: 4549
8
Java Netbeans IDE Scala
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:I didn’t think we were talking about servlets. I think you, Matthew, and I are in agreement here.


No, I didn't think we were either (it ought to have been in the servlet forum if that was intended!). But I've seen the question asked in that context before quite a few times, so I thought I'd mention it in case.
 
John Jai
Rancher
Posts: 1776
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:In the example shown, name is the method parameter and "Ravi" is an argument passed to that method. In that instance there is specific Java™ jargon.

Yes - I think I made a mistake in my understanding of swapping them both. Thanks Campbell!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic