Apple WebObjects 3.5 Bedienungsanleitung Seite 107

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 218
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 106
Designing for Reusability
107
Provide attributes for all significant features.
The more customizable a component is, the more likely it is that
people will be able to reuse it. For example, if the AlertPanel
component discussed in “Intercomponent Communication” (page 98)
let you set the titles of the hyperlinks (say, to OK and Cancel, or Send
Now and Send Later), the panel could be adapted for use in many
more applications.
Provide default values for attributes wherever possible.
Don’t require people to set more attributes than are strictly required
by the design of your reusable component. In your component’s
initialization method, you can provide default values for optional
attributes. When the component is created, the attribute values
specified in the initialization method are used unless others are
specified in the parent’s declarations file.
For example, the AlertPanel component’s
init method could set these
default values:
- init {
[super init];
alertString = @"Alert!";
alertFontColor = @"#ff0000";
alertFontSize = 6;
infoString = @"User should provide an infoString";
infoFontColor = @"#ff0000";
infoFontSize = 4;
borderSize = 2;
tableWidth = @"50%";
return self;
}
Then, in a declarations file, you are free to specify all or just a few
attributes. This declaration specifies values for all attributes:
Complete Declaration
ALERT: AlertPanel {
infoString = message;
infoFontSize = 4;
infoFontColor = "#500000";
alertString = "New Release";
alertFontColor = "#A00000";
alertFontSize = 6;
tableWidth = "50%";
};
Seitenansicht 106
1 2 ... 102 103 104 105 106 107 108 109 110 111 112 ... 217 218

Kommentare zu diesen Handbüchern

Keine Kommentare