Workday Projector Test Bench

Working Hours

Projecting Work Hours for a Day

We manage four time entries that need to fulfil a shared purpose: capturing and visualizing the working hours in the morning and in the afternoon. These time entries have to comply to constraints that are given to us as business rules (see below).

Kolibri allows us to keep two things totally separate: what to display and how to display. The "what" part with model and business rules is in the dayController. The "how" part with view and binding is in the simpleDayProjector, which is an instance of the projector pattern.

Since controller and projector are separate, they can be separately tested. Also, the simple projector that just uses simple input fields, can be easily replaced in the starter with a more elaborate projector. When this happens, the controller - and thus all logic - remains untouched.

Business Rules

Time values between 0:00 and 24:00, are required, cannot be empty.
otherwise invalid
AM Start < = AM End.
automatically enforced
AM End < = PM Start.
automatically enforced
PM Start < = PM End.
automatically enforced
Start not earlier than 4:00.
otherwise invalid
End not later than 22:00.
otherwise invalid
Lunch break must be at least 40 minutes.
automatically enforced
Total time must not exceed 12 hours.
otherwise invalid

Try this

Set the AM Start to 00:00, which violates the "not more than 12 hours" rule. Observe how all time entries become invalid as well as the whole fieldset (left vertical bar).

Set the PM End to 16:00 and the AM Start to 03:00, which violates the "no start before 04:00" rule. Observe how only the AM Start field and the fieldset become invalid.

Set the PM End to 13:00 and delete the AM Start to --:--, with the DEL or Backspace key. Then check/uncheck "Required" and observe how the AM Start becomes invalid when it is required but has no value.

Next Step

Have a look at the work week and let's use multiple day controllers and projectors in an aggregated way.