March 2002
Intermediate to advanced
496 pages
8h 51m
English
You want to ensure that invalid Reservation objects are never instantiated. Specifically, suppose that every reservation must have a non-null date and city. Further, suppose that a business rule states that Oozinoz will not perform for fewer than 25 people or for less than $495.95. To support this rule, you can create a ReservationConstants interface:
public interface ReservationConstants
{
public static final int MINHEAD = 25;
public static final double MINTOTAL = 495.95;
}
A reservation for too small an audience or that generates too little income is invalid. To avoid creating an instance of Reservation when a request is invalid, you might place business logic checks and exception throwing in the constructor for ...
Read now
Unlock full access