Skip to content

Add ability to declare methods as 'final' #5

@gregjacobs

Description

@gregjacobs

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions