Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Bridge pattern
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Design pattern used in software engineering}} The '''bridge pattern''' is a [[software design pattern|design pattern]] used in [[software engineering]] that is meant to ''"decouple an [[Abstraction (computer science)|abstraction]] from its [[implementation]] so that the two can vary independently"'', introduced by the [[Design Patterns|Gang of Four]].{{r|GoFp151}} The ''bridge'' uses [[encapsulation (computer science)|encapsulation]], [[Object composition#Aggregation|aggregation]], and can use [[inheritance (object-oriented programming)|inheritance]] to separate responsibilities into different [[Class (computer science)|classes]]. When a class varies often, the features of [[object-oriented programming]] become very useful because changes to a [[Computer program|program]]'s [[Source code|code]] can be made easily with minimal prior knowledge about the program. The bridge pattern is useful when both the class and what it does vary often. The class itself can be thought of as the ''abstraction'' and what the class can do as the ''implementation''. The bridge pattern can also be thought of as two layers of abstraction. When there is only one fixed implementation, this pattern is known as the [[Pimpl]] idiom in the [[C++]] world. The bridge pattern is often confused with the [[adapter pattern]], and is often implemented using the [[Adapter_pattern#Object_adapter_pattern|object adapter pattern]]; e.g., in the Java code below. Variant: The implementation can be decoupled even more by deferring the presence of the implementation to the point where the abstraction is utilized<!-- (as illustrated by the [[Visual Prolog]] example below)-->.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)