File tree Expand file tree Collapse file tree 5 files changed +85
-3
lines changed
StructuralPatterns/Bridge Expand file tree Collapse file tree 5 files changed +85
-3
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ Design Patterns in C# / .NET
22
22
| | Pattern |
23
23
| ---| --- |
24
24
| :heavy_check_mark : | [ Adapter] ( /StructuralPatterns/Adapter ) |
25
- | | Bridge | [ Bridge] ( /StructuralPatterns/Bridge ) |
25
+ | | [ Bridge] ( /StructuralPatterns/Bridge ) |
26
26
| :heavy_check_mark : | [ Composite] ( /StructuralPatterns/Composite ) |
27
27
| :heavy_check_mark : | [ Decorator] ( /StructuralPatterns/Decorator ) |
28
28
| :heavy_check_mark : | [ Facade] ( /StructuralPatterns/Facade ) |
Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Collections . Generic ;
3
+ using System . Linq ;
4
+ using System . Text ;
5
+ using System . Threading . Tasks ;
6
+
7
+ namespace StructuralPatterns . Bridge
8
+ {
9
+ public class BasicRemote : IRemote
10
+ {
11
+
12
+ public void PowerOn ( )
13
+ {
14
+ throw new NotImplementedException ( ) ;
15
+ }
16
+
17
+ public void PowerOff ( )
18
+ {
19
+ throw new NotImplementedException ( ) ;
20
+ }
21
+
22
+ public void VolumeUp ( )
23
+ {
24
+ throw new NotImplementedException ( ) ;
25
+ }
26
+
27
+ public void VolumeDown ( )
28
+ {
29
+ throw new NotImplementedException ( ) ;
30
+ }
31
+ }
32
+ }
Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Collections . Generic ;
3
+ using System . Linq ;
4
+ using System . Text ;
5
+ using System . Threading . Tasks ;
6
+
7
+ namespace StructuralPatterns . Bridge
8
+ {
9
+ public interface IDevice
10
+ {
11
+ void PowerOn ( ) ;
12
+ void PowerOff ( ) ;
13
+ int GetVolumen ( ) ;
14
+ void SetVolume ( ) ;
15
+ }
16
+ }
Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Collections . Generic ;
3
+ using System . Linq ;
4
+ using System . Text ;
5
+ using System . Threading . Tasks ;
6
+
7
+ namespace StructuralPatterns . Bridge
8
+ {
9
+ // Abstraction
10
+ public interface IRemote
11
+ {
12
+ void PowerOn ( ) ;
13
+ void PowerOff ( ) ;
14
+ void VolumeUp ( ) ;
15
+ void VolumeDown ( ) ;
16
+ }
17
+
18
+
19
+ }
Original file line number Diff line number Diff line change @@ -25,9 +25,20 @@ This enables to configure an `Abstraction`(Interface) with an `Implementor`(Inte
25
25
26
26
## Benefits
27
27
28
+ * Decouples an implementation so that it is not bound permanently to an interface.
29
+ * Abstraction and implementation can be extended independently.
30
+ * Changes to the concrete abstraction classes don't affect the client.
31
+ * Allows building platform independent code
32
+ * Hides the implementation details from client
28
33
29
34
## Drawbacks
30
35
36
+ * Increases overall code complexity by creating multiple additional classes.
37
+
38
+ ## Known Uses
39
+
40
+ * Useful in graphic and windowing systems that need to run over multiple platforms
41
+ * Useful any time you need to vary an interface and an implementation in different ways
31
42
32
43
## Common Structure
33
44
@@ -43,7 +54,11 @@ This enables to configure an `Abstraction`(Interface) with an `Implementor`(Inte
43
54
* ConcreteImplementor
44
55
* implements the ` Implementor ` interface.
45
56
46
- _ [ Source: http://www.dofactory.com/net/memento-design-pattern ] _
47
-
48
57
## Example
49
58
59
+ // TODO
60
+
61
+ ## Comparison with other patterns
62
+
63
+ * ** Adapter** makes the unrelated classes work together. Adapter makes things work after they're designed; Bridge is designed beforehand to let the abstraction and implmentation vary independently. * [ GoF, p219] *
64
+
You can’t perform that action at this time.
0 commit comments