PDA

View Full Version : Profiles and inheritance. What's the best practice?



interfasys
21 Feb 2013, 8:47 AM
Let's say I have the following views:
View1
Child1
Child2

Child views extend View1.
Now I need to introduce profiles for both View1 and Child1 and things will look like this:
View1
Child1
Child2
/phone/
View1
Child1
/tablet/
View1
Child1

The problem, of course is that now "phone.Child1" extends Child1 only and doesn't get any of the methods of the super class View1.

Is the best practice to mix in the "phone.View1" class?

Ext.define('phone.Child1', {
extend: 'Child1',
mixins: {
profileMixin: 'phone.View1'
},

mitchellsimoens
23 Feb 2013, 7:06 AM
Are there methods in the phone.View1 that is going to be used in other classes?

interfasys
23 Feb 2013, 8:52 AM
Yes, all the methods of the super class which are specific to that profile.

Per example, View1 had a onItemSwipe method which Child1 and Child2 were calling.
Now onItemSwipe has been implemented in the profiles, so in "phone.View1" and "tablet.View1".

So "phone.Child1" will need the super methods of "phone.View1", but also the ones of non-profile specific "Child1".

mitchellsimoens
23 Feb 2013, 1:08 PM
You could use mixin or just extend each other... phone.Child1 extends phone.View1, phone.View1 extends Child1