[haiku-commits] Re: haiku: hrev45317 - in src: apps/deskbar preferences/time

  • From: John Scipione <jscipione@xxxxxxxxx>
  • To: "haiku-commits@xxxxxxxxxxxxx" <haiku-commits@xxxxxxxxxxxxx>
  • Date: Mon, 25 Feb 2013 10:31:46 -0500

On Feb 25, 2013, at 6:55 AM, "Axel Dörfler" <axeld@xxxxxxxxxxxxxxxx> wrote:

> On February 23, 2013 at 8:50 PM jscipione@xxxxxxxxx wrote:
>>  The solution is to override BView's Show(), Hide(), and IsHidden() methods
>>  in TimeView to ignore whether or not the window is hidden when considering
>> if
>>  the clock is hidden.
> 
> Methods that override the behavior of standard methods should generally be
> avoided -- other users of this class might depend or assume standard behavior
> (now and in the future).

I am the only user of this class. No methods are virtual. I don't expect this 
class to be used by anyone else or used more than once. It's a "singleton" 
class.

> Instead, you should introduce new methods that do exactly what you want, and
> then use them in those cases.

I need to override the Hide() and Show() methods to set a variable that I can 
read later. Those methods call the base class versions anyway.

I could create an IsHiddenIgnoreWindow() method though that reads the variable 
i set in Hide() and Show() and leave the IsHidden() method to do the default.

> Additionally, in this particular case: Is there any need to instantiate the 
> time
> view if it's not supposed to be visible anyway?

Only so that we can detect that it is hidden in the preferences and unhide it.

The code could be refactored to handle the case of a NULL TimeView object if 
that is something we really wanted/needed. If you really don't want to use the 
system clock uninstantiating it would save memory.

It's a good argument for making the clock a status tray replicant. You could 
then remove it like any other tray icon.

Other related posts: