Skip to content

Instantly share code, notes, and snippets.

@iamcrypticcoder
Created March 30, 2018 19:20
Show Gist options
  • Save iamcrypticcoder/6f84aa0fe501d4af19b47cdca0ce913a to your computer and use it in GitHub Desktop.
Save iamcrypticcoder/6f84aa0fe501d4af19b47cdca0ce913a to your computer and use it in GitHub Desktop.
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