Chapter 3
Or if you need a call to your own init() and want to accept an initializer hash, you
could implement the following:
package BOA::Probe;
use Class::MethodMaker
new_with_init => new ,
new_hash_init => hash_init ,
get_set => [ qw(id model contents heading status) ];
# called from the generated new()
sub init {
my $self = shift;
$self >hash_init(@_);
# do other initialization stuff...
}
The method generated by new_hash_init is specially designed to be called as both a
class method and an object method. Isn't that cool?
Class::MethodMaker sports some truly comprehensive support for list and
hash attributes, generating common class methods as well as many useful variations
on the normal accessor mutators. To top it all off, Class::MethodMaker can itself be
extended using inheritance. For this and more, see the Class::MethodMaker
documentation.
Visual Modeling
Complex object oriented systems are often easier to design visually than textually.
The Unified Modeling Language (UML)
12
specifies a popular notation for doing
visual design of object oriented systems. There are numerous tools available to aid
in the task from simple drawing applications to complex software design tools that
generate code (although they rarely support Perl).
However, in my experience, these tools are usually unnecessary. Visual modeling
done on a whiteboard or on paper is just as valuable as that done on a computer.
Seeing your design laid out visually can help clarify your thinking and reveal
dangerous complexity problems that aren't apparent from your documentation.
The key to using visual modeling successfully is to keep it simple; don't get caught
up in trying to represent the entirety of a working system in a diagram.
Figure 3 2 shows a simple UML class diagram of a few of the BOA classes I've
used as examples earlier. The diagram shows three classes BOA::Logger,
BOA::Logger::Enhanced, and BOA::Network. The items in the top half of the class
12. See http://www.uml.org for details.
92
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved