Share to: share facebook share twitter share wa share telegram print page

Coupling (computer programming)

In software engineering, coupling is the degree of interdependence between software modules; a measure of how closely connected two routines or modules are;[1] the strength of the relationships between modules.[2] Coupling is not binary but it is multi-dimensional. [3]

Coupling and cohesion

Coupling is usually contrasted with cohesion. Low coupling often correlates with high cohesion, and vice versa. Low coupling is often thought to be a sign of a well-structured computer system and a good design, and when combined with high cohesion, supports the general goals of high readability and maintainability.[citation needed]

History

The software quality metrics of coupling and cohesion were invented by Larry Constantine in the late 1960s as part of a structured design, based on characteristics of “good” programming practices that reduced maintenance and modification costs. Structured design, including cohesion and coupling, were published in the article Stevens, Myers & Constantine (1974)[4] and the book Yourdon & Constantine (1979),[5] and the latter subsequently became standard terms.

Types of coupling

Conceptual model of coupling

Coupling can be "low" (also "loose" and "weak") or "high" (also "tight" and "strong"). Some types of coupling, in order of highest to lowest coupling, are as follows:

Procedural programming

A module here refers to a subroutine of any kind, i.e. a set of one or more statements having a name and preferably its own set of variable names.

Content coupling (high)
Content coupling is said to occur when one module uses the code of another module, for instance a branch. This violates information hiding – a basic software design concept.
Common coupling
Common coupling is said to occur when several modules have access to the same global data. But it can lead to uncontrolled error propagation and unforeseen side-effects when changes are made.
External coupling
External coupling occurs when two modules share an externally imposed data format, communication protocol, or device interface. This is basically related to the communication to external tools and devices.
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).
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.
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).

Object-oriented programming

Subclass coupling
Describes the relationship between a child and its parent. The child is connected to its parent, but the parent is not connected to the child.
Temporal coupling
It is when two actions are bundled together into one module just because they happen to occur at the same time.

In recent work various other coupling concepts have been investigated and used as indicators for different modularization principles used in practice.[6]

Dynamic coupling

The goal of defining and measuring this type of coupling is to provide a run-time evaluation of a software system. It has been argued that static coupling metrics lose precision when dealing with an intensive use of dynamic binding or inheritance.[7] In the attempt to solve this issue, dynamic coupling measures have been taken into account.

Semantic coupling

This kind of a coupling metric considers the conceptual similarities between software entities using, for example, comments and identifiers and relying on techniques such as latent semantic indexing (LSI).

Logical 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:[3]

  • Technology Dependency
  • Location Dependency
  • Topology Dependency
  • Data Format & Type Dependency
  • Semantic Dependency
  • Conversation Dependency
  • Order Dependency
  • Temporal Dependency

Disadvantages of tight coupling

Tightly coupled systems tend to exhibit the following developmental characteristics, which are often seen as disadvantages:

  1. A change in one module usually forces a ripple effect of changes in other modules.
  2. Assembly of modules might require more effort and/or time due to the increased inter-module dependency.
  3. A particular module might be harder to reuse and/or test because dependent modules must be included.

Performance issues

Whether loosely or tightly coupled, a system's performance is often reduced by message and parameter creation, transmission, translation (e.g. marshaling) and message interpretation (which might be a reference to a string, array or data structure), which require less overhead than creating a complicated message such as a SOAP message. Longer messages require more CPU and memory to produce. To optimize runtime performance, message length must be minimized and message meaning must be maximized.

Message Transmission Overhead and Performance
Since a message must be transmitted in full to retain its complete meaning, message transmission must be optimized. Longer messages require more CPU and memory to transmit and receive. Also, when necessary, receivers must reassemble a message into its original state to completely receive it. Hence, to optimize runtime performance, message length must be minimized and message meaning must be maximized.
Message Translation Overhead and Performance
Message protocols and messages themselves often contain extra information (i.e., packet, structure, definition and language information). Hence, the receiver often needs to translate a message into a more refined form by removing extra characters and structure information and/or by converting values from one type to another. Any sort of translation increases CPU and/or memory overhead. To optimize runtime performance, message form and content must be reduced and refined to maximize its meaning and reduce translation.
Message Interpretation Overhead and Performance
All messages must be interpreted by the receiver. Simple messages such as integers might not require additional processing to be interpreted. However, complex messages such as SOAP messages require a parser and a string transformer for them to exhibit intended meanings. To optimize runtime performance, messages must be refined and reduced to minimize interpretation overhead.

Solutions

One approach to decreasing coupling is functional design, which seeks to limit the responsibilities of modules along functionality. Coupling increases between two classes A and B if:

  • A has an attribute that refers to (is of type) B.
  • A calls on services of an object B.
  • A has a method that references B (via return type or parameter).
  • A is a subclass of (or implements) class B.

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 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 versus cohesion

Coupling and cohesion are terms which occur together very frequently. Coupling refers to the interdependencies between modules, while cohesion describes how related the functions within a single module are. Low cohesion implies that a given module performs tasks which are not very related to each other and hence can create problems as the module becomes large.

Module coupling

Coupling in Software Engineering[8] describes a version of metrics associated with this concept.

For data and control flow coupling:

  • di: number of input data parameters
  • ci: number of input control parameters
  • do: number of output data parameters
  • co: number of output control parameters

For global coupling:

  • gd: number of global variables used as data
  • gc: number of global variables used as control

For environmental coupling:

  • w: number of modules called (fan-out)
  • r: number of modules calling the module under consideration (fan-in)

Coupling(C) makes the value larger the more coupled the module is. This number ranges from approximately 0.67 (low coupling) to 1.0 (highly coupled)

For example, if a module has only a single input and output data parameter

If a module has 5 input and output data parameters, an equal number of control parameters, and accesses 10 items of global data, with a fan-in of 3 and a fan-out of 4,

See also

References

  1. ^ ISO/IEC/IEEE 24765:2010 Systems and software engineering — Vocabulary
  2. ^ ISO/IEC TR 19759:2005, Software Engineering — Guide to the Software Engineering Body of Knowledge (SWEBOK)
  3. ^ a b Hohpe, Gregor. Enterprise Integration Patterns: Designing, Building, and Deploying Messaging Solutions. Addison-Wesley Professional. ISBN 978-0321200686.
  4. ^ Stevens, Wayne P.; Myers, Glenford J.; Constantine, Larry LeRoy (June 1974). "Structured design". IBM Systems Journal. 13 (2): 115–139. doi:10.1147/sj.132.0115.
  5. ^ Yourdon, Edward; Constantine, Larry LeRoy (1979) [1975]. Structured Design: Fundamentals of a Discipline of Computer Program and Systems Design. Yourdon Press. Bibcode:1979sdfd.book.....Y. ISBN 978-0-13-854471-3.
  6. ^ Beck, Fabian; Diehl, Stephan (September 2011). "On the Congruence of Modularity and Code Coupling". In Proceedings of the 19th ACM SIGSOFT Symposium and the 13th European Conference on Foundations of Software Engineering (SIGSOFT/FSE '11). Szeged, Hungary. p. 354. doi:10.1145/2025113.2025162. ISBN 9781450304436. S2CID 2413103.{{cite book}}: CS1 maint: location missing publisher (link)
  7. ^ Arisholm, Erik; Briand, Lionel C.; Føyen, Audun (August 2004). "Dynamic coupling measurement for object-oriented software". IEEE Transactions on Software Engineering. 30 (8). IEEE: 491–506. doi:10.1109/TSE.2004.41. hdl:10852/9090. S2CID 3074827.
  8. ^ Pressman, Roger S. (1982). Software Engineering - A Practitioner's Approach (4 ed.). McGraw-Hill. ISBN 0-07-052182-4.

Further reading

Read other articles:

Melati untuk MarvelGenre Drama Roman PembuatMD EntertainmentSutradaraEncep MasdukiPemeran Chelsea Olivia Rezky Aditya Christ Laurent Neshia Putri Fendy Chow Gracia Indri Afifa Syahira Ryan Delon Penggubah lagu temaSetia BandLagu pembukaP.U.S.P.A (Putuskan Saja Pacarmu) — ST 12Lagu penutupP.U.S.P.A (Putuskan Saja Pacarmu) — ST 12Penata musikIwang ModulusNegara asalIndonesiaBahasa asliBahasa IndonesiaJmlh. musim2Jmlh. episode349 (daftar episode)ProduksiProduser Dhamoo Punjabi Manoj Pu...

Bokmässan i Leipzig Mässhallen under 2017 års upplagaPlatsLeipzig, Sachsen,  TysklandTidpunktMarsÅr1500-talet-TypBokmässa Bokmässan i Leipzig (tyska: Leipziger Buchmesse) är en årlig bokmässa i Leipzig, Sachsen. Det är Tysklands näst största i sitt slag, efter bokmässan i Frankfurt. Bokmässan i Leipzig äger rum under fyra dagar i mars, i Leipzigmässan. År 2015 hade mässan 2 263 utställare från 42 länder och 251 000 besökare.[1] Sedan 2005 delas priset Prei...

Денні Гальм Громадянство  Нова ЗеландіяНародився 18 червня 1936(1936-06-18)[1]Motuekad, Тасман, Нова ЗеландіяПомер 4 жовтня 1992(1992-10-04)[1] (56 років)Mount Panorama Circuitd, Новий Південний Уельс, АвстраліяСтатистика в чемпіонатах світу з Формули-1Дебют Монако 1965Остання гонка США 1974Сезони...

Berlin-Rudow La Lieselotte-Berger-Platz. Administration Pays Allemagne Région Berlin Ville Berlin Arrondissement municipal Neukölln Code postal 12353, 12355, 12357 Démographie Population 42 443 hab. (31/12/2021) Densité 3 597 hab./km2 Géographie Coordonnées 52° 25′ 00″ nord, 13° 30′ 00″ est Altitude 52 m Superficie 1 180 ha = 11,8 km2 Localisation Géolocalisation sur la carte : Berlin Berlin-...

Pétange Entidad subnacional Escudo PétangeLocalización de Pétange en Luxemburgo Coordenadas 49°33′23″N 5°52′37″E / 49.556388888889, 5.8769444444444Capital PéitengEntidad Comuna de Luxemburgo • País Luxemburgo LuxemburgoDirigentes   • Alcalde Pierre Mellina (CSV)Superficie   • Total 11,93 km²Altitud   • Media 260-397 m s. n. m.Población (2005)   • Total 14,632 hab. • Densidad 1,226,5 ...

Pour les articles homonymes, voir Astier. Pour les autres membres de la famille, voir Famille d'Astier de La Vigerie. Emmanuel d'Astier de La VigerieEmmanuel d'Astier de La Vigerie en 1945.FonctionDéputé d'Ille-et-VilaineAssemblée constituante de 1945Assemblée constituante de 1946Première législature de la Quatrième République françaiseDeuxième législature de la Quatrième République françaiseTroisième législature de la Quatrième République française21 octobre 1945 - 8 déce...

Kaiser Convention CenterKaiser Convention Center in April 2021Former namesOakland Civic Auditorium (1914-84)General informationArchitectural styleBeaux Arts[1]Location10 10th Street, Oakland, CaliforniaCoordinates37°47′51″N 122°15′42″W / 37.79750°N 122.26167°W / 37.79750; -122.26167Completed1914Design and constructionArchitect(s)John J. Donovan Oakland Designated LandmarkDesignated1979Reference no.27 Kaiser Convention Center is a historic, publ...

Place in Buenos Aires, ArgentinaNavarroNavarroLocation in ArgentinaCoordinates: 35°01′S 59°16′W / 35.017°S 59.267°W / -35.017; -59.267Country ArgentinaProvince Buenos AiresPartidoNavarroFoundedOctober 25, 1864Elevation31 m (102 ft)Population (2001 census [INDEC]) • Total11,562CPA BaseB 6605Area code+54 2272 Navarro is a town in Buenos Aires Province, Argentina. It is the county seat of Navarro Partido. External links Municipal in...

Croatian fascist and ultranationalist organization (1929–45) This article is about the World War II organization. For an ethnic slur against Croats, see Ustaša (pejorative). Ustaša – Croatian Revolutionary Movement Ustaša – Hrvatski revolucionarni pokretGoverning bodyMain Ustaša HeadquartersFoundersAnte Pavelić[n 1]Vjekoslav ServatzySlavko KvaternikFounded7 January 1929 (1929-01-07)[2]Dissolved25 May 1945 (1945-05-25) (de facto)Preceded...

Cet article est une ébauche concernant une localité algérienne. Vous pouvez partager vos connaissances en l’améliorant (comment ?) selon les recommandations des projets correspondants. Carte d'Algérie (Wilaya d'Alger) Pour les autres communes, voir Liste des communes d'Algérie. La wilaya d'Alger est découpée en 13 daïras[1] et 57 communes[2]. Communes de la wilaya d'Alger Communes de la wilaya d'Alger (codes ONS) : 01. Alger-Centre • 02. Sidi M'Hamed • 03. El Madania ...

You can help expand this article with text translated from the corresponding article in Danish. (January 2023) Click [show] for important translation instructions. Machine translation, like DeepL or Google Translate, is a useful starting point for translations, but translators must revise errors as necessary and confirm that the translation is accurate, rather than simply copy-pasting machine-translated text into the English Wikipedia. Do not translate text that appears unreliable or low...

This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: Bolintin-Vale – news · newspapers · books · scholar · JSTOR (February 2020) (Learn how and when to remove this template message) Town in Giurgiu, RomaniaBolintin-ValeTownAssumption churchLocation in Giurgiu County (red dot)Bolintin-ValeLocation in RomaniaCoordi...

У Вікіпедії є статті про інші населені пункти з такою назвою: Тарасівка. село Тарасівка Поворот на Тарасівку з траси Н14Поворот на Тарасівку з траси Н14 Країна  Україна Область Кіровоградська область Район Бобринецький район Рада Тарасівська сільська рада Облікова кар...

An Montedinove usa ka comune ha lalawigan han Ascoli Piceno ha rehiyon han Marche ha nasod han Italya.  Usa ka turók ini nga barasahon. Dako it imo maibubulig ha Wikipedia pinaagi han pagparabong hini. khlMarche · Mga comune han Ascoli PicenoAcquasanta Terme · Acquaviva Picena · Appignano del Tronto · Arquata del Tronto · Ascoli Piceno · Carassai · Castel di Lama · Castignano · Castorano · Colli del Tronto · Comunanza · Cossignano · Cupra Marittima · Folignano · Force...

Commune in Ratanakiri Province, CambodiaKeh Chong Commune ឃុំកិះចុងCommuneKeh Chong CommuneLocation within CambodiaCoordinates: 13°48′N 107°18′E / 13.8°N 107.3°E / 13.8; 107.3Country CambodiaProvinceRatanakiri ProvinceDistrictBar KaevVillages9Population (1998) • Total2,415Time zoneUTC+07Geocode160302 This article contains Khmer text. Without proper rendering support, you may see question marks, boxes, or other symbols ...

District of Tunceli Province, Turkey District in Tunceli, TurkeyHozat DistrictDistrictMap showing Hozat District in Tunceli ProvinceHozat DistrictLocation in TurkeyCoordinates: 39°06′N 39°13′E / 39.100°N 39.217°E / 39.100; 39.217CountryTurkeyProvinceTunceliSeatHozatArea663 km2 (256 sq mi)Population (2021)5,590 • Density8.4/km2 (22/sq mi)Time zoneTRT (UTC+3)Websitewww.hozat.gov.tr Hozat District is a district of Tunceli Provi...

Mwene Kongo Álvaro IIIMwene KongoÁlvaro III of KongoReignAugust 1615 to 4 May 1622PredecessorBernardo IISuccessorPedro IIDynastyKwilu dynastyFatherÁlvaro II Álvaro III Nimi a Mpanzu, also known as Álvaro III Mbiki a Mpanzu, ruled as king or manikongo of the Kingdom of Kongo from August 1615 to 4 May 1622. Prior to becoming king, he had served as Duke of Mbamba.[1] Like his predecessor, Bernardo II he was a son of King Álvaro II.[1] King Álvaro III was the fourth ruler f...

1897–1958 French colony off the coast of southeast Africa Colony of Madagascar and DependenciesColonie de Madagascar et dépendances (French)1897–1958 Flag Coat of arms Anthem: La MarseillaiseColony of Madagascar and Dependencies in 1930StatusColony of France (1897–1946)Overseas Territory of France (1946–1958)CapitalTananariveCommon languagesFrench · Malagasy · Comorian · ArabicReligion Christianity · Islam &#...

McLaren MP4-30 Fernando Alonso durante el GP de España.Categoría Fórmula 1Constructor McLarenDiseñador(es) Tim Goss - Peter ProdromouPredecesor McLaren MP4-29Sucesor McLaren MP4-31Especificaciones técnicasChasis Compuesto de fibra de carbono que incorpora los controles del conductor y la pila de combustible[1]​Suspensión Elementos de suspensión de doble horquilla y varillas de empuje de fibra de carbono que ponen en funcionamieto la barra de torsión interna y el sistema amortigu...

English priest and theologian (1856–1939) Herbert ThurstonBornHerbert Henry Charles Thurston(1856-11-15)15 November 1856London, EnglandDied3 November 1939(1939-11-03) (aged 82)London, EnglandEducation Stonyhurst College London University OccupationClergyman Herbert Henry Charles Thurston SJ (15 November 1856 – 3 November 1939) was an English priest of the Roman Catholic Church, a member of the Jesuit order, and a prolific scholar on liturgical, literary, historical, and spiritua...

Kembali kehalaman sebelumnya