View Full Version : [best practice] sencha component vs plain js based code when using sencha

18 Nov 2010, 4:07 AM
hi all;
so I am just starting to get the hang of sencha.
a few days ago I needed to display ticker like data with each item in the data is displayed for a period of time and after that period the next item would appear.
using sencha I thought to my self that a carousel would fit here because each card can be an item so I implemented a 'self rotating' carousel that way.
after the job was finished I thought to myself that for this task i could have just use plain JS/CSS/DOM manipulation to rotate the items inside a simple panel - no need for a carousel.
so my question is: assuming one already uses sencha (for layout, etc...), when is using a sencha component good and when is it overkill?

18 Nov 2010, 4:36 PM
For code consistency and readability I would use sencha components as much as possible. I would also attempt to use the lowest level component I could and extend the custom functionality i needed. For instance in this case, I agree a carousel might be overkill. I would extend the Panel class, configure it with a card layout, ad a rotate method that would automatically set the active card. soemthing like...

MyPanel = Ext.extend(Ext.Panel,{

var next = this.items.indexOf(this.getActiveItem());
next = next >= this.items.getCount() ? 0 : next;

this.intervalId = setInterval("this.rotate()",this.interval);

I think the biggest gain is maintaining the object oriented architecture and the maintainability that comes with it. Thats my two cents. But am still learning as well.