Motivation
Refinable Functions focuses on function-level refinement, however implicit augmentation of method in classes is essential for implementing aspect-orientation. This idea requires 2 new mechanism of refinement.
1.Refinable Functions as a Advice
Advices is class of function that modifies other function when run. It is a certain function, method or procedure that is to be applied at a given join point of program,(wikipedia). The join point is represented in keyword like before, after and around in typical aspect-orientation, where as point cut represent point of join point composition. I propose following syntax for export Refinable Function as ann Advice
subjectChangeAdvice.export.before('subjectChange');
subjectChangeAdvice.export.after('subjectChange');
subjectChangeAdvice.export.around('subjectChange');
In this sense, function refinement and class refinement is performed in two phase.
2.Class-level Refinement with Aspect-oriented Programming
Aspect-oriented Programming towards localization of cross-cutting concerns using aspect object that augment a behavior of method. The aspect object itself can be inheritable, for example the following codes is aspect for ObserverProtocol.
var ObserverProtocolAspect = {
perSubjectObservers: new WeakMap(),
getObservers: function (subject) {
observers = this.perSubjectObservers.get(subject);
if (observers == null) {
perSubjectObservers.put(subject, []);
}
return observers;
},
addObserver: function (subject, observer) {
getObservers(subject).add(observer);
},
removeObserver: function (subject, observer) {
getObservers(subject).remove(observer);
},
//subjectChange: null,
//below method implicies subject change is required field for its subaspect
subjectChange: new Self().add(inputCheck).add(function (subject, observer) {
return this.updateObserver(subject, observer)
}).export.before()
};
var ObserverProtocol = new Self.utils.aspect(ObserverProtocolAspect);
and by extending ObserverProtocol aspect, we can make more concrete subaspect called ColorObserver using .extends method.
//interception instead of composition
var ColorObserver = {
subjectChange: function subjectChange(subjectChange) {
return {
setColor: subjectChange,
setLine: subjectChange
}
},
updateObserver: function (subject, observer) {
//type is needed
//fault of dynamic type checking => static typechecking and aspect weaving make weaving reliable
//type system make aspect weaving safe and deterministic
//
this.display("color updated")
}
}
var ColorObserver = new Self.utils.aspect(ColorObserver);
ColorObserver.extends(ObserverProtocol);
//member variable manipulation, function manipulation
ColorObserver.compose(className);
Motivation
Refinable Functions focuses on function-level refinement, however implicit augmentation of method in classes is essential for implementing aspect-orientation. This idea requires 2 new mechanism of refinement.
1.Refinable Functions as a Advice
Advices is class of function that modifies other function when run. It is a certain function, method or procedure that is to be applied at a given join point of program,(wikipedia). The join point is represented in keyword like
before,afterandaroundin typical aspect-orientation, where as point cut represent point of join point composition. I propose following syntax for export Refinable Function as ann AdviceIn this sense, function refinement and class refinement is performed in two phase.
2.Class-level Refinement with Aspect-oriented Programming
Aspect-oriented Programming towards localization of cross-cutting concerns using aspect object that augment a behavior of method. The aspect object itself can be inheritable, for example the following codes is aspect for
ObserverProtocol.and by extending
ObserverProtocolaspect, we can make more concrete subaspect calledColorObserverusing.extendsmethod.