1 00:00:01,060 --> 00:00:06,220 The bridge pattern is another well known structural pattern which aims to separate a large structure 2 00:00:06,220 --> 00:00:13,030 of classes into two hierarchy's, the bridge pattern is providing a binding between the U.S. and implementation 3 00:00:13,030 --> 00:00:19,660 at runtime, making use of the Oldbury principles like compensation and inheritance for realizing that. 4 00:00:20,630 --> 00:00:27,050 Imagine the following scenario, you have a shape, abstract class and two plantation's square and rectangle 5 00:00:27,410 --> 00:00:30,800 bolts, square rectangle need to have a color attribute. 6 00:00:31,070 --> 00:00:33,400 Therefore, to separate objects will emerge. 7 00:00:33,770 --> 00:00:37,950 Red Square, a little square red rectangle and blue rectangle. 8 00:00:38,660 --> 00:00:44,450 You can post this video and think about the possible revitalization of this structure, which will make 9 00:00:44,450 --> 00:00:47,810 the whole program easier to read and with less lines of code. 10 00:00:48,740 --> 00:00:51,330 This is how the refectory ization looks like under the bridge. 11 00:00:51,370 --> 00:00:55,820 Back then, you have one color interface between two red and blue. 12 00:00:56,570 --> 00:01:01,790 The abstract shape class will remain alongside the two implementations, four square and rectangle. 13 00:01:02,360 --> 00:01:07,340 However, to build those two objects, you'll need to supply a color inside the constructor of each 14 00:01:07,340 --> 00:01:07,820 class. 15 00:01:08,990 --> 00:01:15,830 The key to remember when to use this method is when you have a complex structure of classes with numerous 16 00:01:15,830 --> 00:01:23,180 similar implementations, when you want to have the same implementation shared across multiple objects. 17 00:01:24,420 --> 00:01:30,120 When you have an orthogonal class hierarchies and you want to provide a map between them. 18 00:01:31,640 --> 00:01:34,700 Let me give you an example with real world applicability. 19 00:01:35,450 --> 00:01:41,000 Think about having a program that is used by stores to organize merchandise such as bags and purses. 20 00:01:41,970 --> 00:01:47,070 If within your program there is a structure similar to the one displayed on the screen, it's very easy 21 00:01:47,070 --> 00:01:52,050 to reorganize everything as we've seen for the sheep hierarchy using the breach. 22 00:01:52,050 --> 00:01:54,390 But as you can see right now on the screen. 23 00:01:56,190 --> 00:01:59,380 Let's have a look to see how exactly this works in the cold.