One of the special cases when I find inheritance is the best solution when I use a class created at runtime that needs additional methods. For example (in C #):
public abstract class Rule{
public Authorization Authorization { get; set; }
public abstract bool IsValid(dynamic request, User currentUser);
}
Generated Template:
public class Generated_1Rule : Rule{
public override bool IsValid(dynamic request, User currentUser){
}
}
Example user script:
return Authorization.IsAuthorized("Module_ID_001", currentUser);
The advantage is that you can add functionality to the generated βcompiledβ script, and it is less broken than it inherits from the interface / composition because it is compiled.
Fendy source
share