JavaBeans Flashcards Preview

Java: Basic concepts > JavaBeans > Flashcards

Flashcards in JavaBeans Deck (53):
1

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.

2

Why does component software work?

The interfaces between software components are standardized, so they work together seamlessly.

3

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.

4

Are components encapsulated? Why?

Yes. Other components do not need to know how the services are implemented, they just need to work.

5

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.

6

Name two techniques for employing a component across network links

1. serialization
2. marshalling

7

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.

8

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.

9

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.

10

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.

11

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).

12

JavaBean can be read as a synonym for what?

component

also, it's pretty much just a java object. :/

13

Where do javabeans typically run, client side or server side?

usually client.

14

Enterprise java bean is typically for client or server side?

server side

15

Which kind of classes is a javabeans component?

every java user interface class is a javabeans component

16

what will learning javabeans help you do?

create custom events

develop your own source components that can fire events

17

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

18

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.

19

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()

20

what do properties describe in the bean?

properties describe the state of the bean

21

data fields are used to store properties. how do they work in beans?

a bean property is not necessarily a data field.

22

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

23

Can beans communicate with other beans?

Yes.

24

What model provides the foundation for communcation between beans?

The Java event delegation model enables beans to send, recieve, and handle events.

event object
source object
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.

25

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.

26

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.

27

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.

28

can a listener component have more than one listener interface?

yes. it may register many listeners. it may also register itself.

29

what is the naming pattern for removing custom source component?

public void removeListener(Listener 1)

30

what is the naming pattern for adding a unicast listener

public void addListener(Listener 1)
throws TooManyListenersException;

31

what is the naming pattern for adding a multicast listener

public void addListener(Listener 1)

*no exception thrown, as in unicast listener

32

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.

33

why does synchronizing certain methods help?

avoids data corruption (for example, when attempting to register multiple listeners concurrently)

34

if you want to create a custom event class, what must you extend?

java.util.EventObject or a subclass that class

35

a custom event listener interface must extend what class??

java.util.EventListener or a subinterface of that class

36

by convention, a custom listener interface should be named what?

XListener for the event class named XEvent

37

by convention, a custom event class should be named what?

XEvent

38

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

39

what does unicasted mean?

only one listener object is notified of the event

40

what does multicasted mean?

each object in a list of listeners is notified of the event

41

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

42

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).

43

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);

44

what is a bound property?

a bound property notifies listeners when its value changes.

45

What class must a bound property use?

PropertyChangeSupport

46

What methods should a bounded property use?

addPropertyChangeListener

removePropertyChangeListener

47

where does PropertyChangeSupport live?

java.beans package

48

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.

49

describe what a bound property must do on a listener list

a bound property must be able to add and remove itself

50

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.

51

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

52

are veto listeners part of the property change listeners?

no. they are in the class VetoableChangeSupport

53

where does a veto change live?

VetoableChangeSupport