I'm stuck and I'd appreciate your opinions on the subject. I want to implement INotifyPropertyChanged
for my entities. I can't figure out which way is the best and why. The only obvious difference to me is that AoP is a little faster since everything gets done at compile-time while using IoC/DI it's easier to change behaviors latter. So 开发者_运维百科which one would you actually use (or have used in the past) and why?
Thank you.
Please rephrase my question, I am not a native speaker
Typically, if you want to enforce a behaviour across many different classes in a transparent way, AOP is the way to go. Often, the AOP can be configured through DI/IoC, so the two are not mutually exclusive. Without understanding exactly what technology you're using, I can't give more concrete advice than this. In Java, for example, I'd use a DI framework like Spring in conjunction with AspectJ to set this up. I'm not sure what the equivalent technologies are in .NET.
Bear in mind, you will pay a performance penalty if you're injecting behaviour into many fine-grained objects in your application, so you may want to consider if having this feature is worth the performance trade-off. Fortunately, one of the benefits of AOP is that you can enable/disable pointcuts fairly easily, which would allow you to measure the performance difference.
精彩评论