Flashcards in JavaBeans Deck (53):
What is component software?
Component software is software that is designed to work as a component of a larger application. Think of the way PCs are built: memory chips, CPUs, keyboards, etc.
Why does component software work?
The interfaces between software components are standardized, so they work together seamlessly.
How do components communicate with one another?
Through interfaces. The component offers services to the rest of the system. a provided interface specifies the services that other components can utilize, and how they can do so.
Are components encapsulated? Why?
Yes. Other components do not need to know how the services are implemented, they just need to work.
Describe the principle of substitutability with respect to component software.
A component should be able to replace another component if the successor component meets the requirements of the initial component (expressed via interfaces). This allows us to use updated versions or an alternative without breaking the system.
Name two techniques for employing a component across network links
Compare and contrast object oriented programming and component-based software engineering.
OOP believes software should be modeled after the conceptual way we think about objects in the world and how they behave (mammal, dog, barks, etc).
Component-based software states that developers should construct software by gluing together prefabricated components-- modularizing systems.
Where is a discussion about component programming more relevant, java beans or enterprise java bean? Why?
Enterprise Java Bean (EJB). EJBs are distributed components. JavaBeans are local program components, usually GUI.
What is the point of a JavaBean?
The primary intent of the JaveBean is to support visual application development environments (though the patterns defined by the javabean spec are applicable to class libraries in general).
By default, many java classes are beans simply because they follow javabean method-naming and event-handling conventions.
What is a javabean usually?
A javabean is usually simply a class that subclasses java.awt.Component and implements object serialization eo externalization.
the javabean follows a standard set of method-naming conventions that allow application builder tools to automatically detect the properties, actions, and events support by a javabean through introspection.
What is the purpose of an Enterprise Java Bean?
The purpose of an EJB is to isolate business logic and data access in server-side components.
They can also be accessed in visual development tools to link events (perhaps originating from a client javabean).
JavaBean can be read as a synonym for what?
also, it's pretty much just a java object. :/
Where do javabeans typically run, client side or server side?
Enterprise java bean is typically for client or server side?
Which kind of classes is a javabeans component?
every java user interface class is a javabeans component
what will learning javabeans help you do?
create custom events
develop your own source components that can fire events
What are the minimum java bean requirements?
1. A bean must be a public class
2. A bean must have a no-arg constructor (though it can have others too)
3. A bean must implement the java.io.Serializable interface
A javabean component is a special kind of java class. Sum it up in a sentence.
A javabean component is a serializable public class with a public no-arg constructor.
Describe property naming patterns for javabeans
The javabean, like all classes, can have properties. Primitive type or an object type. The property type dictates the signature of the accessor and mutator methods.
public String getMessage()
public boolean isCentered()
what do properties describe in the bean?
properties describe the state of the bean
data fields are used to store properties. how do they work in beans?
a bean property is not necessarily a data field.
what is the difference between a property and a field?
a property is a concept, a field is an implementation
Field: a data member of a class. unless specified otherwise, a field is not static.
Property: characteristics of an object that users can set, such as the color of a window.
A property may be read-only with a get method but not set method, or write-only with a set method but no get method
Can beans communicate with other beans?
What model provides the foundation for communcation between beans?
The Java event delegation model enables beans to send, recieve, and handle events.
event listener object
--review event driven programming for more
This is called the "delegation model" because the source object delegates the event to the listeners for processing.
What is an event source?
The component on which an event is generated.
Every java GUI component is an event source for one or more events.
A JButton object fires a java.awt.event.ActionEvent when it is clicked.
what should a source component contain?
code that detects and external or internal action that triggers the event
the source should fire an event to the listeners by invoking the event handler defined by the listeners.
the source component must also contain methods for registered and deregistering listeners.
what should a listener component do?
a listener component for an event must implement the event listener interface.
otherwise, the object of the listener component cannot receive event notifications from a source component.
can a listener component have more than one listener interface?
yes. it may register many listeners. it may also register itself.
what is the naming pattern for removing custom source component?
public void removeListener(Listener 1)
what is the naming pattern for adding a unicast listener
public void addListener(Listener 1)
what is the naming pattern for adding a multicast listener
public void addListener(Listener 1)
*no exception thrown, as in unicast listener
Give an example of a custom source component
Course class, when number of students cap has been reached and we need to do something if the cap is exceeded.
why does synchronizing certain methods help?
avoids data corruption (for example, when attempting to register multiple listeners concurrently)
if you want to create a custom event class, what must you extend?
java.util.EventObject or a subclass that class
a custom event listener interface must extend what class??
java.util.EventListener or a subinterface of that class
by convention, a custom listener interface should be named what?
XListener for the event class named XEvent
by convention, a custom event class should be named what?
why doesn't a custom event class have a no arg constructor?
you must always specify a source for the event when creating an event
what does unicasted mean?
only one listener object is notified of the event
what does multicasted mean?
each object in a list of listeners is notified of the event
what happens when a builder tool inspects a bean that includes:
public color getColor()
public void setColor(Color c)
-the tool infers that a property named color exists
-the builder tool knows this property is readable and writable
-the builder knows that the type is Color
-the builder can look for a property editor for the type, and display the property (usually in a property sheet) for editing
what is an indexed property?
an indexed property is an ordered collection of values associated with a single name.
The individual values are accessed using an integer index (like an array).
What design pattern must an indexed property follow?
Access entire array:
public  get();
public void set() value);
Access individual values in the property array:
public  get(int index);
public void set(int index, ) value);
what is a bound property?
a bound property notifies listeners when its value changes.
What class must a bound property use?
What methods should a bounded property use?
where does PropertyChangeSupport live?
give an example of how you would use a bound property
number of tickets sold at a concert. we only have 1000 tickets. we can't sell 1001, so we need to close sales when we hit 1000.
describe what a bound property must do on a listener list
a bound property must be able to add and remove itself
what is a constrained property
a constrained property is a special kind of bound property
the bean keeps track of a set of veto listeners
when a constrained property is about to change, the listeners are consulted. any one of the listeners has a chance to veto the change.
what is a veto listener
a veto listener vetos a constrained property change when the property change asks the other listeners if it should change
are veto listeners part of the property change listeners?
no. they are in the class VetoableChangeSupport