- Exercise 3.1
-
Write brief descriptions of the main features of declarative programming, OO programming, logic programming, and functional programming. (See Section 3.14.)
- Exercise 3.2
-
Give an example of a programming job that would be better with OO programming than with declarative programming.
- Exercise 3.3
-
Give an example of a programming job that would be better with declarative programming than with OO programming.
- Exercise 3.4
-
What bioinformatics problem might be best addressed with logic programming?
- Exercise 3.5
-
Download and use a Perl class from CPAN.
- Exercise 3.6
-
Write a Perl class that manages laboratory supplies .
- Exercise 3.7
-
When would you want a separate initialization method for a class; when would you want the initialization to be part of the new constructor?
- Exercise 3.8
-
Modify Gene.pm to keep count of how many objects refer to given organisms, chromosomes, authors, pdb references, and names .
- Exercise 3.9
-
Add a DESTROY method to a class so an object can self-destruct.
- Exercise 3.10
-
Beginning in the code for Gene3.pm you'll find the following regular expression:
if($AUTOLOAD =~ /.*(_\w+)/) { $attribute = ;
This only catches the last part of a name that has an underscore . What if you want to allow names such as get_other_var ? Write a regular expression that would extract such names as other_var from get_other_var .
- Exercise 3.11
-
In the code for Gene2.pm you'll find the following regular mutator method:
sub set_name { my ($self, $name) = @_; $self->{_name} = $name if $name; }
This breaks if $name has certain values such as "", 0, or 0E0. How can you catch these cases?