blue-sky
blue-sky

Reputation: 53786

Inheritance design

I have a Screen base class from which all other Screens extend. Within this base class I have a ticker that is either turned on or off depending on a val within the DB. I'm reading this val within the base class to determine wether or not to add the ticker to the current subtyped screen. Is this good design ? Is there a better approach ?

Thanks

Upvotes: 1

Views: 106

Answers (1)

Sean Patrick Floyd
Sean Patrick Floyd

Reputation: 298818

You are mixing concerns. A screen shouldn't know where it gets its data from, especially it shouldn't know about databases.

You should either have an interface like ConfigSupplier that you pass in to your screen (the standard implementation being one that uses a database) or turn things around with a manager class that assigns configuration values to the screen from the outside.

Upvotes: 7

Related Questions