Created
March 30, 2018 19:20
-
-
Save iamcrypticcoder/6f84aa0fe501d4af19b47cdca0ce913a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
// Bridge pattern is good for run time binding of implementation | |
var openGLApi: OpenGLAPI = OpenGLAPI() | |
var directXApi: DirectXAPI = DirectXAPI() | |
var circle: Circle = Circle(10, 10, 10, openGLApi) | |
circle.draw() | |
circle = Circle(10, 5, 4, directXApi) | |
circle.draw() | |
var rect: Rectangle = Rectangle(10, 10, 10, 10, openGLApi) | |
rect.draw() | |
rect = Rectangle(10, 10, 10, 10, directXApi) | |
rect.draw() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment