Skip to content

Instantly share code, notes, and snippets.

@sorin-ref
Last active December 5, 2018 18:48
Show Gist options
  • Save sorin-ref/3eba4eeacbe5600ea29c4487e3f4de05 to your computer and use it in GitHub Desktop.
Save sorin-ref/3eba4eeacbe5600ea29c4487e3f4de05 to your computer and use it in GitHub Desktop.
// 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