![見出し画像](https://assets.st-note.com/production/uploads/images/133874514/rectangle_large_type_2_e83f32a115bd24ff18c41de23f0fafa0.png?width=800)
interfaceでぶつ切りにしたうえで、実装をまとめたいのです。この思いつきを疑っていました
実例を探していました。手近なところにありました。CakePHP4のTableクラスです。
class Table implements RepositoryInterface, EventListenerInterface, EventDispatcherInterface, ValidatorAwareInterface
{
use EventDispatcherTrait;
use RulesAwareTrait;
use ValidatorAwareTrait;
}
interfaceとtraitの名前が対応しています。interfaceで設計しながら、実装の重複を避けるための工夫はこれかもしれません。
この記事が気に入ったらサポートをしてみませんか?