reset password
Author Message
cthanh
Posts: 56
Posted 23:30 Nov 05, 2014 |

Regarding the due date turning red:

If an item is late, does it turn back white after it is returned or does it stay red?

I'm trying to determine if we suppose to have a boolean in the individual log entry that gets checked each time you open the ViewItem? also if i need to have another flag in the item class for the yellow/red cell coloring.

Thanks

 

cysun
Posts: 2935
Posted 07:58 Nov 06, 2014 |

It should turn back to white after it's returned.

There are two class design principles (among others):

1. Don't keep redundant information in a class.

It takes extra actions to update those redundant information, and when you forget, you end up with inconsistency in your data. In this case, whether the item is returned can be determined by return date, and whether it's overdue can be determined by due date (and current date), so a boolean field would be redundant.

There are exceptions to this rule, mostly under circumstances where you need to use redundancy to buy performance. This is not one of those cases though.

2. Don't keep view-related information in a model class.

Whether it's red or yellow is clearly a view issue which should be handled in view. The model tells you whether the item is returned or overdue, and what to do with it is the responsibility of the view.

cthanh
Posts: 56
Posted 08:17 Nov 06, 2014 |
Thanks!