| dbpprop:abstract
|
- The Law of Demeter (LoD), or Principle of Least Knowledge, is a design guideline for developing software, particularly object-oriented programs. The guideline was invented at Northeastern University towards the end of 1987, and can be succinctly summarized as “Only talk to your immediate friends. ” The fundamental notion is that a given object should assume as little as possible about the structure or properties of anything else (including its subcomponents). It is so named for its origin in the Demeter Project, an adaptive programming and aspect-oriented programming effort. This project was named in honor of Demeter, “distribution-mother” and the Greek goddess of agriculture, to signify a bottom-up philosophy of programming which is also embodied in the law itself. Note that it is debatable if bottom-up (or synthetic) is the correct analogy. It can be argued that software evolves or grows, which is appropriate given Demeter's mythological role. When applied to object-oriented programs, the Law of Demeter can be more precisely called the “Law of Demeter for Functions/Methods” (LoD-F). In this case, an object A can request a service (call a method) of an object instance B, but object A cannot “reach through” object B to access yet another object, C, to request its services. Doing so would mean that object A implicitly requires greater knowledge of object B’s internal structure. Instead, B’s class should be modified if necessary so that object A can simply make the request directly of object B, and then let object B propagate the request to any relevant subcomponents. Or A should have a direct reference to object C and make the call directly. If the law is followed, only object B knows its own internal structure. More formally, the Law of Demeter for functions requires that a method M of an object O may only invoke the methods of the following kinds of objects: O itself M's parameters any objects created/instantiated within M O's direct component objects In particular, an object should avoid invoking methods of a member object returned by another method. For many modern object oriented languages that use a dot as field identifier, the law can be stated simply as "use only one dot". That is, the code "a.b. Method" breaks the law where "a. Method" does not. There is disagreement as to the sufficiency of this approach. As a simple example, when one wants to walk a dog, it would be folly to command the dog’s legs to walk directly; instead one commands the dog and lets it take care of its legs itself. The advantage of following the Law of Demeter is that the resulting software tends to be more maintainable and adaptable. Since objects are less dependent on the internal structure of other objects, object containers can be changed without reworking their callers. A disadvantage of the Law of Demeter is that it sometimes requires writing a large number of small “wrapper” methods (sometimes referred to as Demeter Transmogrifiers) to propagate method calls to the components. Furthermore, a class’s interface can become bulky as it hosts methods for contained classes resulting in a class without a cohesive interface. Basili et al. published experimental results in 1996 suggesting that the Law of Demeter was a valid way to reduce the probability of software faults. A Multilayered architecture can be considered to be a systematic mechanism for implementing the Law of Demeter in a software system. In a layered architecture code within each layer can only make calls to code within the layer and code within the next layer down. "Layer skipping" would violate the layered architecture.
- Das Gesetz von Demeter ist eine Entwurfs-Richtlinie in der objektorientierten Softwareentwicklung. Sie besagt im Wesentlichen, dass Objekte nur mit Objekten in ihrer unmittelbaren Umgebung kommunizieren sollen. Dadurch soll die Kopplung (das heißt die Anzahl von Abhängigkeiten) in einem Softwaresystem verringert und dadurch die Wartbarkeit erhöht werden.
- La loi de Déméter, ou Principe de connaissance minimale est une règle de conception pour développer un logiciel, particulièrement du logiciel orienté objet. Cette règle a été inventée à la Northeastern University à Boston durant l'automne 1987, et peut être résumée en "Ne parlez qu'à vos amis immédiats". La notion fondamentale est qu'un objet devrait faire aussi peu d'hypothèses que possible à propos de la structure de quoi que ce soit d'autre, y compris ses propres sous-composants. Cette loi tient son nom du Projet Demeter, un effort de programmation adaptative et de programmation orientée objet. pour une philosophie de programmation à partir de la base incarnée dans la loi elle-même. Ce projet a été nommé en l'honneur de Déméter, la déesse généreuse de l'agriculture. Appliquée à la programmation orientée objet, la loi de Déméter peut être appelée plus précisément la loi de Déméter pour les fonctions et les méthodes . Dans ce cas, un objet <math>A</math> peut requérir un service (appeler une méthode) d'un objet <math>B</math>, mais <math>A</math> ne peut utiliser <math>B</math> pour accéder un troisième objet et requérir ses services. Faire cela signifierait que <math>A</math> a une connaissance plus grande que nécessaire de la structure interne de <math>B</math>. Au lieu de cela, <math>B</math> pourrait être modifié si nécessaire pour que <math>A</math> puisse faire la requête directement à <math>B</math>, et <math>B</math> propagera la requête au composant ou sous-composant approprié. Si la loi est appliquée, seul <math>B</math> connait sa propre structure interne. Plus formellement, la Loi de Déméter pour les fonctions requiert que toute méthode <math>M</math> d'un objet <math>O</math> peut simplement invoquer les méthodes des types suivants d'objets : lui-même ses paramètres les objets qu'il crée/instancie ses objets composants En particulier, un objet doit éviter d'invoquer des méthodes d'un membre objet retourné par une autre méthode. L'avantage de suivre la règle de Déméter est que le logiciel résultat est plus maintenable et plus adaptable. Puisque les objets sont moins dépendants de la structure interne des autres objets, ceux-ci peuvent être changés sans changer le code de leurs appelants. Un désavantage de la règle de Déméter est qu'elle requiert l'écriture d'un grand nombre de petites méthodes "wrapper" pour propager les appels de méthodes à leurs composants. Cela peut augmenter le temps de développement initial, accroître l'espace mémoire utilisé, et notablement diminuer les performances. Des outils automatiques peuvent partiellement contrecarrer ces problèmes. Basili et al. ont publié des résulats expérimentaux 1996 suggérant que la loi de Déméter réduit la probabilité d'erreurs logicielles.
- Demeter törvénye egy szoftverfejlesztési irányelv, melyet elsősorban objektumorientált programoknál alkalmaznak. Az irányelvet a Northwertern Egyetemen, Bostonban fogalmazták meg 1987 őszén. A lényege: „csak a közvetlen barátaiddal beszélgess”. Egy adott objektum más dolgok felépítését vagy tulajdonságait a lehető legkevésbé ismerje. Az A objektum igénybe veheti a B objektum egy szolgáltatását, de A objektum nem érheti el a B objektumon keresztül egy C objektum szolgáltatásait. Ez azt jelentené, hogy az A objektumnak implicit módon a szükségesnél jobban kell ismernie a B objektum belső felépítését. A megoldás B objektum felépítésének módosítása oly módon, hogy az A objektum közvetlenül hívja B objektumot, és a B objektum intézi a szükséges hívásokat a megfelelő alkomponensekhez. Ha a törvényt követjük, kizárólag B objektum ismeri saját belső felépítését. Kissé formálisabban O objektum M metódusa a következőket hívhatja: O-t magát M paramétereit M-en belül létrehozott/példányosított objektumokat O közvetlen komponenseit Általánosságban egy objektumnak el kell kerülnie egy meghívott objektum által visszaadott objektum metódusainak hívását, például A.x.y. Demeter törvényét alkalmazva a szoftver sokkal karbantarthatóbb és adaptálható lesz. Mivel az objektumok kevésbé függnek más objektumok belső felépítésétől, az objektumok felépítése sokkal könnyebben módosítható, akár a hívó szerkezetének módosítása nélkül is. A törvény alkalmazásának hátránya, hogy szükségessé teszi kis burkoló metódusok használatát, melyek továbbítják a kéréseket a megfelelő komponensekhez. Ez növelheti a belső fejlesztési időt, a tárigényt, és csökkentheti a teljesítményt.
- La Legge di Demetra è un linea guida di design per lo sviluppo del software nello specifico quello a oggetti. Questa legge fu inventata alla Northeastern University nell'autunno del 1987, e potrebbe essere riassunta nel motto "non parlate con gli estranei". La nozione basilare è che un dato oggetto deve fare meno supposizioni possibili sulla struttura interna e proprietà di qualsiasi altro oggetto, compresi i suoi sub-componenti.
- デメテルの法則(Law of Demetre (LoD))または最小知識の原則とは、ソフトウェアの設計、特にオブジェクト指向プログラムの設計におけるガイドラインである。 このガイドラインは1987年の末にかけてノースイースタン大学で作成された。簡潔に言うと「直接の友達とだけ話すこと」と要約できる。基本的な考え方は、任意のオブジェクトが自分以外(サブコンポーネント含む)の構造やプロパティに対して持っている仮定を最小限にすべきであるという点にある。 「デメテルの法則」という名前は、この法則がアダプティブプログラミングとアスペクト指向プログラミングに関する研究であるデメテルプロジェクトの成果であることに由来する。プロジェクト名は農業の女神であるデーメーテールにあやかっている。 オブジェクト指向プログラムにデメテルの法則を適用する場合には、この法則はより厳密に「関数/メソッドに関するデメテルの法則」(Law of Demeter for Functions/Methods(LoD-F))と言い表すことができる。この場合、あるオブジェクトAは別のオブジェクトBのサービスを要求してもよい(メソッドを呼び出してもよい)が、オブジェクトAがオブジェクトBを「経由して」さらに別のオブジェクトCのサービスを要求してはならない。これが望ましくないのは、オブジェクトAがオブジェクトBに対して、オブジェクトB自身の内部構造以上の知識を要求してしまうためである。 このような場合には、クラスBを変更し、クラスAがクラスBに対して行った要求を適切なBのサブコンポーネントに伝播させるようにすればよい。または、AがCへのリファレンスを持つようにして、AがCを直接呼ぶようにしてもよい。この法則に従えば、オブジェクトBが知っているのは自分自身の内部構造だけになる。 より形式的に言えば、関数に対するデメテルの法則に従った場合、オブジェクトO上のメソッドMが呼び出してもよいメソッドは以下のオブジェクトに属するメソッドのみに限定される。 Oそれ自身 Mの引数に渡されたオブジェクト Mの内部でインスタンス化されたオブジェクト Oを直接的に構成するオブジェクト(Oのインスタンス変数) 具体的には、他のメソッドの戻り値として返されたオブジェクトのメソッドの呼び出しを避けるということになる。最近のオブジェクト指向言語の多くではフィールド識別子としてドット(. )が採用されているが、そのような言語においてはこの法則は単純に「使えるドットは一つだけ」と言い表すこともできる。つまり、"a.b. Method"という呼び出しは法則に違反しているが"a. Method"という呼び出しは問題ない。なお、このアプローチの充足性については反論がある。 簡単な例として、犬を散歩に連れ出すことを考える。この際、犬の足に直接「歩け」と命じるのはおかしいだろう。この場合は、犬に対して命令し、自分の足の面倒は自分で見させるのが正しい方法だといえる。 デメテルの法則の利点としては、結果的にソフトウェアがよりメンテナンスしやすく、柔軟なものになりやすいという点が挙げられる。オブジェクトが他のオブジェクトの内部構造に依存することが少なくなるため、オブジェクトのコンテナを呼び出し側の変更なしに修正することができる。 デメテルの法則の欠点としては、時として数多くの"ラッパー"メソッド(デメテルのTransmogrifierと呼ばれる)を作成する必要があるという点が挙げられる。このメソッドは自分自身の呼び出しを別のコンポーネントに委譲するためのものである。さらに、自分自身が含んでいるクラスのメソッドを呼び出せるようにするためにインタフェースが巨大になり、結果としてクラスの凝集性が低下するという欠点もある。 Basiliらによる1996年の実験では、デメテルの法則がソフトウェアの欠陥の発生確率を低下させるのに有効であることが示唆されている。 マルチレイヤアーキテクチャは、ソフトウェアシステムにおいてデメテルの法則を系統的に実装するためのメカニズムとして捉えることができる。 レイヤ化されたアーキテクチャにおいて、各レイヤ中のコードは自分の属するレイヤと直下のレイヤのコードのみを呼び出すことができる。直下のレイヤをスキップして他のレイヤにアクセスした場合には、アーキテクチャに違反していることになる。
|
| rdfs:comment
|
- The Law of Demeter (LoD), or Principle of Least Knowledge, is a design guideline for developing software, particularly object-oriented programs. The guideline was invented at Northeastern University towards the end of 1987, and can be succinctly summarized as “Only talk to your immediate friends. ” The fundamental notion is that a given object should assume as little as possible about the structure or properties of anything else (including its subcomponents).
- Das Gesetz von Demeter ist eine Entwurfs-Richtlinie in der objektorientierten Softwareentwicklung. Sie besagt im Wesentlichen, dass Objekte nur mit Objekten in ihrer unmittelbaren Umgebung kommunizieren sollen. Dadurch soll die Kopplung (das heißt die Anzahl von Abhängigkeiten) in einem Softwaresystem verringert und dadurch die Wartbarkeit erhöht werden.
- La loi de Déméter, ou Principe de connaissance minimale est une règle de conception pour développer un logiciel, particulièrement du logiciel orienté objet. Cette règle a été inventée à la Northeastern University à Boston durant l'automne 1987, et peut être résumée en "Ne parlez qu'à vos amis immédiats".
- Demeter törvénye egy szoftverfejlesztési irányelv, melyet elsősorban objektumorientált programoknál alkalmaznak. Az irányelvet a Northwertern Egyetemen, Bostonban fogalmazták meg 1987 őszén. A lényege: „csak a közvetlen barátaiddal beszélgess”. Egy adott objektum más dolgok felépítését vagy tulajdonságait a lehető legkevésbé ismerje.
- La Legge di Demetra è un linea guida di design per lo sviluppo del software nello specifico quello a oggetti. Questa legge fu inventata alla Northeastern University nell'autunno del 1987, e potrebbe essere riassunta nel motto "non parlate con gli estranei". La nozione basilare è che un dato oggetto deve fare meno supposizioni possibili sulla struttura interna e proprietà di qualsiasi altro oggetto, compresi i suoi sub-componenti.
|