Last active
December 5, 2018 18:48
-
-
Save sorin-ref/3eba4eeacbe5600ea29c4487e3f4de05 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
// 1. Service with hardcoded input and output. Cleanest usage, but no client side extensibility (too much encapsulation). | |
public class Service1 { | |
public init() { } | |
func input() -> Bool { | |
return true | |
} | |
func output(text: String) { | |
print(type(of: self), text) | |
} | |
public func doSomething() { | |
if input() { | |
output(text: "done") | |
} | |
} | |
} | |
class Client1 { | |
var service1 = Service1() | |
func doSomething() { | |
service1.doSomething() | |
} | |
} | |
Client1().doSomething() // prints "Service1 done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment