webprogramming-languagesdartseparation-of-concernscross-cutting-concerns

How does Dart implement cross-cutting concerns?


Most developers will acknowledge how implementing crosscutting concerns such as logging, auditing, security and transactionality can adversely affect business logic implementation. Such concerns "seem" to increase the complexity of existing business logic, at times making it difficult if not impossible to clearly distinguish business logic from the crosscutting concern implementation.

How does Dart deal with this? If it doesn't currently have any mechanism to address this issue, are there plans to introduce a way to implement cross-cutting concerns?

Thanks.


Solution

  • Not really sure what's being asked here; but using Transformers you can rewrite code (this is how dart2js and Polymer work). It won't allow you to change any syntax, however.

    You could, for example, write a transformer that detected an @log annotation and then inject code to log that the method was called. Or you could create a @protected annotation and inject permission-checking code.

    Other than transformers, I don't believe there's anything built-in; but I do suspect they'll add a lot of flexibility in this area.