28

What is the difference between Ext.extend and Ext.override? In java, you extend a class and you override its methods. But looking at syntax, it seems in extjs, you can both extend a class and override a class

Victor
  • 16,609
  • 71
  • 229
  • 409

2 Answers2

36

Ext.extend gives you a new class basing on existing one.

Ext.override modifies existing class without creating a new one.

It's not something specific to ExtJS. It's how JavaScript's prototype-based object model works. It's quite different from what you're used to in Java. ExtJS just adds these two utility methods to make it a bit easier to use.

Mchl
  • 61,444
  • 9
  • 118
  • 120
  • 1
    So Ext.override has no equivalent in java? – Victor Feb 04 '11 at 19:21
  • 1
    this is not entirely true, you can override methods any existing class when you create an instance of it as an anonymous inner class. `ArrayList al = new ArrayList() { public void add(Object o) { // override }` for example. This is the same thing in spirit since it is still an `ArrayList` as far as any client is concerned. –  Nov 11 '14 at 15:54
  • @JarrodRoberson: Interesting! I've very little experience with Java, so I didn't know this. Thanks! – Mchl Nov 12 '14 at 08:35
1

Mchl has already answered to your query.

I just want to add, for adding features to ExtJs involves these four ways:

  1. Extend
  2. Override
  3. Plugin
  4. Sequence/Intercept

Please refer to this link for detail information:

http://www.slideshare.net/VinylFox/four-ways-to-add-features-to-ext-js

Kunal Goel
  • 3,357
  • 1
  • 14
  • 20