I’m trying to learn android system and was looking into standard (default) DescClock application (I think I’ve got it from here: http://omapzoom.org/?p=platform/packages/apps/DeskClock.git). Specifically, my question is about classes Alarm and Alarms. Alarm is an implementation of a single alarm, while Alarms has various method of working with Alarm. All of the methods of Alarms are static.
Now, the question. Is it a well known design pattern to make a “manager” class with static methods? What are the general benefits of such approach? Thank you!
At first, I thought about this possibly being a Composite pattern, which is typical when you have a class that can be stand-alone or a container of the same type. But, when I read that all of the
Alarmsmethods are static, I realized it has nothing to do with a Composite.The fact that all of the
Alarmsmethods are static implies thatAlarmshas no state, and only acts behaviorally on theAlarmclass instances. After looking at the code, it appears as though theAlarmsclass is a hybrid of the Facade pattern or even a Visitor pattern, even though its only working on one class.What the
Alarmsclass is doing is effectively encapsulating the details of how to work on theAlarmclass, thus simplifying its use for the end-user. I actually like this approach, although one could argue that if its so difficult to use theAlarmclass that it has to be encapsulated like this, then maybe its design should be refactored.