wood burning stoves*
The moose likes Java in General and the fly likes Component and Object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Component and Object" Watch "Component and Object" New topic
Author

Component and Object

plr kannan
Greenhorn

Joined: Jan 15, 2001
Posts: 4
difference and similarity between Reusable component and object ?
------------------
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
A Reuseable component IS an object (everything in Java is an object). A reuseable component is usually a GUI component that has been defined so as to be easily used by many applications (and sophisticated enough that many applications might WANT to use it).
Try reading this: http://developer.java.sun.com/developer/onlineTraining/Beans/Beans1/software-components.html

"JavaRanch, where the deer and the Certified play" - David O'Meara
Jerry Pulley
Ranch Hand

Joined: Sep 19, 2000
Posts: 221
Plr,
Like you said in your post, components are designed for reusability. Part of that is their packaging and their binary compliance with some component framework, like COM objects and JavaBeans. More importantly, there are 3 kinds of "interfaces" that allow objects intended for use as components to be easily used by client programs: properties, methods, and events.
You can think of a property as a data attribute that the component exposes, although they're rarely implemented as simple fields of the object. Writing to a property (and even reading from it) more often has some side effect more significant than just setting a value. For instance, setting a component's <code>visible</code> property to <code>true</code> would cause the component to be shown on the screen. In JavaBeans, properties are implemented through <code>setXXX()</code> and <code>getXXX()</code> methods. At least one component system (Delphi) actually adds a <code>property</code> access control keyword to its language - you access component properties as if they were simple data fields, but the compiler arranges that such access triggers reader and writer methods.
Methods are just what they are in the usual object-oriented sense. They're the operations that the component can perform for you.
Finally, components have events that they can fire when interesting things happen to them. Client programs can listen for these events and respond when they occur. The use of events leads to a style of programming called, appropriately enough, "event-driven". Rather than specify a single path of execution, programs that are driven by their components' events can more flexibly respond to what the user does.
That's it in a nutshell - now could you do us a favor? "Plr" is really hard to pronounce. Could you register a regular user name? See http://www.javaranch.com/name.jsp for the details.
Thanks,
Jerry
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Component and Object