国産DIコンテナSeasarとくーす その4
■ このスレッドは過去ログ倉庫に格納されています
020444
2005/07/10(日) 13:22:46大事なことを言い忘れてた。
勘違いしないでいただきたいのですが、オブジェクト指向だからといって、
あるデータに関連する振舞いをすべて同じクラスに突っ込むようなことはありません。
例えば自分の場合、データと振舞いをカプセル化させることベースとしつつ、以下のような
ことを考えながらデータと振舞いを一緒にするか否かを決定しています。
* その振舞いか Domain Logicか Application Logicjか?
振舞いに関するデータを持っているからといって Domain Objectに Application Logicを
もたせることはしないようにする。
http://c2.com/cgi/wiki?SessionFacade
> there are different kinds of "business logic" - domain logic, and application logic.
> Domain logic is logic that is naturally associated with a DomainObject - such as
> a recipe knowing how to compute the nutrition profile of a serving of itself.
> Application logic has to do with application-specific workflow - such as
> sending emails, or enqueuing MOM messages, when a new recipe is added
> to a database. I
* その振舞いをそのクラスに持たせるのが自然か?
自然でない場合は、新しいクラスを作成するか別のクラスへ持たせることを検討する。
* そのクラスの責務を持たせすぎていないか?
責務を持たせすぎな場合は、そのクラスから責務を抽出して別クラスにする。
■ このスレッドは過去ログ倉庫に格納されています