Reputation: 4906
I'm designing a several views, which should show a list of players and their properties, but from different perspectives.
ViewA shows player's: Name, Exp, Skill, Condition
ViewB shows player's: Name, Exp, Skill, Bonus
ViewC shows player's: Name, Exp, Price, Bid amount
Common thing for all views are Name
and Exp
- so there's a sense to move them to the BaseView. Also, there's a Skill
, which is used in 2/3 views and will be probably used in some next views, so it also can be moved to the base view.
The questions are:
Skill
property rendering) - wouldn't it be an unnecessary entity?Name
and Exp
in a BaseView and re-implement Skill
property in ViewA and ViewB - wouldn't it be a code copying.What are the recommended practices for this case?
UPD: To make question more generic, assume i have 20 properties and 10 Views, each of them should show, say, 7 different properties. I'm afraid i'll end up with BaseWithSkillExpHpManaBonusView.
Upvotes: 0
Views: 55
Reputation: 173
If you have 20 properties and 10 Views and each of them should show ~7 different properties, I would recommend you to use decorator pattern.
http://www.dotnet-tricks.com/Tutorial/designpatterns/VRQT130713-Decorator-Design-Pattern---C
In this case you would have smth like IBaseView, BaseView, BaseViewDecorator, HealthDecorator : BaseViewDecorator and so on.
Upvotes: 1