This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Guice / Ray.Di way | |
$injector = new Injecotr($loggerBindings); // "Matcher" search the method to attache interceptor. Changed on the context. | |
$foo = $injector->getInstance(FooInterface::class); // logger interceptor was attached with $foo. | |
// $foo is not "Foo", somehing generagted new name but implemented FooInterface. This is OK for me. | |
// AOP is cooperating OOP design. | |
// $loggerBindingsの中でマッチャーが実行コンテキストによって、インターセプターとメソッドを束縛する。 | |
// $fooはFooクラスではなく、FooInterfaceが実装され自動生成されたコード | |
// AOPがOOP設計に協力をしている | |
// Spring / Go AOP ! way | |
AopLib::init($registerLoggerInterceptor); // bindings are hardcoded in the interceptor. | |
$foo = new Foo; | |
// Interceptor wii be attached globally by plain "new" method. | |
// AOP behave like "runkit" without PECL extension. Too powerful. See https://github.com/google/guice/wiki/SpringComparison | |
// Not great idea for quality software but it may be nice for "testing shitting code" purpose. | |
// どのメソッドとどのインターセプターが束縛するかはインターセプターにハードコードされてある。 | |
// AOPはPECLなしの"runkit"のように振舞っている。強すぎる。 https://github.com/google/guice/wiki/SpringComparison 参照 | |
// (グローバルな束縛なので)高品質のソフトウエアにとってはよくないが"汚い"コードのテストには向いてる |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment