To support some more advanced frameworks in class hierarchies.
For example, something very similar to the following situation arose for a Task class in my work one day:
var Task = Class.create( {
abstractClass: true,
execute : function() {
if( this.executing ) return;
this.executing = true;
this.doExecute(); // call hook method
},
doExecute : Class.abstractMethod
} );
var RequestTask = Task.extend( {
abstractClass: true,
doExecute : function() {
var request = this.createRequest();
request.execute().then(
_.bind( this.onSuccess, this ),
_.bind( this.onError, this )
);
},
createRequest : Class.abstractMethod,
onSuccess : function() {...},
onError : function() {...}
} );
In the above example, we do not want to allow doExecute() to be redefined by a subclass of RequestTask.
Only createRequest() should be implemented to create and configure a Request object that the RequestTask will execute.
To support some more advanced frameworks in class hierarchies.
For example, something very similar to the following situation arose for a
Taskclass in my work one day:In the above example, we do not want to allow
doExecute()to be redefined by a subclass ofRequestTask.Only
createRequest()should be implemented to create and configure aRequestobject that theRequestTaskwill execute.