Content deleted Content added
Rescuing 2 sources and tagging 0 as dead.) #IABot (v2.0.9.5 |
Reverting edit(s) by 91.186.248.86 (talk) to rev. 1286487971 by JustMakeTheAccount: non-constructive (RW 16.1) |
||
(11 intermediate revisions by 6 users not shown) | |||
Line 1:
{{short description|Degree of interdependence between software modules}}
In [[software engineering]], '''coupling''' is the degree of interdependence between software [[Modular programming|modules]]
[[File:CouplingVsCohesion.svg|thumb|Coupling and [[cohesion (computer science)|cohesion]]]]
Line 23:
;{{anchor|Control coupling}}Control coupling: Control coupling is one module controlling the flow of another, by passing it information on what to do (e.g., passing a what-to-do flag).
;{{anchor|Stamp coupling|data-structured coupling}}Stamp coupling (data-structured coupling): Stamp coupling occurs when modules share a composite data structure and use only parts of it, possibly different parts (e.g., passing a whole record to a function that needs only one field of it).
:In this situation, a modification in a field that a module does not need may lead to changing the way the module reads the record. To illustrate the concept of stamp coupling, consider a scenario involving a <code>UserProfile</code> [[Software component|component]]. This component is designed to return the entire user profile information in response to [[HTTP|requests]], even when [[User agent|consumers]] only require a specific [[Attribute (computing)|attribute]]. This practice exemplifies stamp coupling, which can lead to significant [[Bandwidth (computing)|bandwidth]] issues, especially at scale. When any attribute within the <code>UserProfile</code> component changes, all consumers that interact with it may need to undergo [[Software testing|testing]], even if they do not utilize the modified attribute. <ref>{{Cite book |last=Richards |first=Mark |title=Fundamentals of Software Architecture: An Engineering Approach |publisher=O'Reilly Media |isbn=978-1492043454}}</ref>
;{{anchor|Data coupling}}Data coupling: Data coupling occurs when modules share data through, for example, parameters. Each datum is an elementary piece, and these are the only data shared (e.g., passing an integer to a function that computes a square root).
Line 44:
<!-- Section title used in redirects -->
{{anchor|evolutionary coupling|Change coupling}}Logical coupling (or evolutionary coupling or change coupling) analysis exploits the release history of a software system to find change patterns among modules or classes: e.g., entities that are likely to be changed together or sequences of changes (a change in a class A is always followed by a change in a class B).
== Dimensions of coupling ==
According to Gregor Hohpe, coupling is multi-dimensional:<ref name=":0" />
* Technology Dependency
* Location Dependency
* Topology Dependency
* Data Format & Type Dependency
* Semantic Dependency
* Conversation Dependency
* Order Dependency
* Temporal Dependency
== Disadvantages of tight coupling ==
Line 70 ⟶ 82:
Low coupling refers to a relationship in which one module interacts with another module through a simple and stable interface and does not need to be concerned with the other module's internal implementation (see [[Information Hiding]]).
Systems such as [[CORBA]] or [[Component Object Model|COM]] allow objects to communicate with each other without having to know anything about the other object's implementation. Both of these systems even allow for objects to communicate with objects written in other languages.
== Coupling vs Connascence ==
Coupling describes the degree and nature of dependency between software components, focusing on what they share (e.g., data, control flow, technology) and how tightly they are bound. It evaluates two key dimensions: strength, which measures how difficult it is to change the dependency, and scope (or visibility), which indicates how widely the dependency is exposed across modules or boundaries. Traditional coupling types typically include content coupling, common coupling, control coupling, stamp coupling, external coupling, and data coupling. <ref name=":03">{{Cite book |title=Practical Guide to Structured Systems Design |isbn=978-0136907695}}</ref><ref name=":12">{{Cite book |title=Designing Data-Intensive Applications: The Big Ideas Behind Reliable, Scalable, and Maintainable Systems |isbn=978-1449373320}}</ref><ref name=":2">{{Cite book |title=Fundamentals of Software Architecture: An Engineering Approach |isbn=978-1492043454}}</ref>
[[Connascence]], introduced by Meilir Page-Jones, provides a systematic framework for analyzing and measuring coupling dependencies. It evaluates dependencies based on three dimensions: strength, which measures the effort required to refactor or modify the dependency; locality, which considers how physically or logically close dependent components are in the codebase; and degree, which measures how many components are affected by the dependency. Connascence can be categorized into static (detectable at compile-time) and dynamic (detectable at runtime) forms. Static connascence refers to compile-time dependencies, such as method signatures, while dynamic connascence refers to runtime dependencies, which can manifest in forms like connascence of timing, values, or algorithm. <ref name=":03" /><ref name=":12" /><ref name=":2" />
Each coupling flavor can exhibit multiple types of connascence, a specific type, or, in rare cases, none at all, depending on how the dependency is implemented. Common types of connascence include connascence of name, type, position, and meaning. Certain coupling types naturally align with specific connascence types; for example, data coupling often involves connascence of name or type. However, not every combination of coupling and connascence is practically meaningful. Dependencies relying on parameter order in a method signature demonstrate connascence of position, which is fragile and difficult to refactor because reordering parameters breaks the interface. In contrast, connascence of name, which relies on field or parameter names, is generally more resilient to change. Connascence types themselves exhibit a natural hierarchy of strength, with connascence of name typically considered weaker than connascence of meaning. <ref name=":03" /><ref name=":12" /><ref name=":2" />
Dependencies spanning module boundaries or distributed systems typically have higher coordination costs, increasing the difficulty of refactoring and propagating changes across distant boundaries. Modern practices, such as dependency injection and interface-based programming, are often employed to reduce coupling strength and improve the maintainability of dependencies. <ref name=":03" /><ref name=":12" /><ref name=":2" />
While coupling identifies what is shared between components, connascence evaluates how those dependencies behave, how changes propagate, and how difficult they are to refactor. Strength, locality, and degree are interrelated; dependencies with high strength, wide scope, and spanning distant boundaries are significantly harder to refactor and maintain. Together, coupling provides a high-level overview of dependency relationships, while connascence offers a granular framework for analyzing dependency strength, locality, degree, and resilience to change, supporting the design of maintainable and robust systems. <ref name=":03" /><ref name=":12" /><ref name=":2" />
== Coupling versus cohesion ==
Line 108 ⟶ 130:
==See also==
* [[Connascence (computer science)]]
* [[Coupling (physics)]]
|