fbpx
Wikipedia

Circular dependency

In software engineering, a circular dependency is a relation between two or more modules which either directly or indirectly depend on each other to function properly. Such modules are also known as mutually recursive.

Overview edit

Circular dependencies are natural in many domain models where certain objects of the same domain depend on each other.[1] However, in software design, circular dependencies between larger software modules are considered an anti-pattern because of their negative effects.[1] Despite this, such circular (or cyclic) dependencies have been found to be widespread among the source files of real-world software.[2] Mutually recursive modules are, however, somewhat common in functional programming, where inductive and recursive definitions are often encouraged.

Problems edit

Circular dependencies can cause many unwanted effects in software programs. Most problematic from a software design point of view is the tight coupling of the mutually dependent modules which reduces or makes impossible the separate re-use of a single module.

Circular dependencies can cause a domino effect when a small local change in one module spreads into other modules and has unwanted global effects (program errors, compile errors). Circular dependencies can also result in infinite recursions or other unexpected failures.

Circular dependencies may also cause memory leaks by preventing certain automatic garbage collectors (those that use reference counting) from deallocating unused objects.

Causes and solutions edit

In very large software designs, software engineers may lose the context and inadvertently introduce circular dependencies. There are tools to analyze software and find unwanted circular dependencies.[3]

Circular dependencies can be introduced when implementing callback functionality. This can be avoided by applying design patterns like the observer pattern.

See also edit

References edit

  1. ^ a b Lakos, John (1996-07-20). Large-Scale C++ Software Design (1st ed.). Boston: Addison-Wesley. ISBN 9780201633627.
  2. ^ Melton, Hayden; Tempero, Ewan (2007-01-12). "An empirical study of cycles among classes in Java". Empirical Software Engineering. 12 (4): 389–415. CiteSeerX 10.1.1.141.5362. doi:10.1007/s10664-006-9033-1. ISSN 1382-3256. S2CID 11134940.
  3. ^ JDepend for Java

circular, dependency, this, article, multiple, issues, please, help, improve, discuss, these, issues, talk, page, learn, when, remove, these, template, messages, this, article, includes, list, general, references, lacks, sufficient, corresponding, inline, cita. This article has multiple issues Please help improve it or discuss these issues on the talk page Learn how and when to remove these template messages This article includes a list of general references but it lacks sufficient corresponding inline citations Please help to improve this article by introducing more precise citations January 2018 Learn how and when to remove this message This article possibly contains original research Please improve it by verifying the claims made and adding inline citations Statements consisting only of original research should be removed January 2018 Learn how and when to remove this message Learn how and when to remove this message In software engineering a circular dependency is a relation between two or more modules which either directly or indirectly depend on each other to function properly Such modules are also known as mutually recursive Contents 1 Overview 2 Problems 3 Causes and solutions 4 See also 5 ReferencesOverview editCircular dependencies are natural in many domain models where certain objects of the same domain depend on each other 1 However in software design circular dependencies between larger software modules are considered an anti pattern because of their negative effects 1 Despite this such circular or cyclic dependencies have been found to be widespread among the source files of real world software 2 Mutually recursive modules are however somewhat common in functional programming where inductive and recursive definitions are often encouraged Problems editCircular dependencies can cause many unwanted effects in software programs Most problematic from a software design point of view is the tight coupling of the mutually dependent modules which reduces or makes impossible the separate re use of a single module Circular dependencies can cause a domino effect when a small local change in one module spreads into other modules and has unwanted global effects program errors compile errors Circular dependencies can also result in infinite recursions or other unexpected failures Circular dependencies may also cause memory leaks by preventing certain automatic garbage collectors those that use reference counting from deallocating unused objects Causes and solutions editIn very large software designs software engineers may lose the context and inadvertently introduce circular dependencies There are tools to analyze software and find unwanted circular dependencies 3 Circular dependencies can be introduced when implementing callback functionality This can be avoided by applying design patterns like the observer pattern See also editAcyclic dependencies principle Dependency hellReferences edit a b Lakos John 1996 07 20 Large Scale C Software Design 1st ed Boston Addison Wesley ISBN 9780201633627 Melton Hayden Tempero Ewan 2007 01 12 An empirical study of cycles among classes in Java Empirical Software Engineering 12 4 389 415 CiteSeerX 10 1 1 141 5362 doi 10 1007 s10664 006 9033 1 ISSN 1382 3256 S2CID 11134940 JDepend for Java Retrieved from https en wikipedia org w index php title Circular dependency amp oldid 1211851279, wikipedia, wiki, book, books, library,

article

, read, download, free, free download, mp3, video, mp4, 3gp, jpg, jpeg, gif, png, picture, music, song, movie, book, game, games.