Created
October 22, 2016 07:55
-
-
Save soxjke/c2f3052d28320de95e38df0b1ee3ec2d to your computer and use it in GitHub Desktop.
Breaking KISS principle for the win
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
//: Playground - noun: a place where people can play | |
import UIKit | |
typealias ๐ป = String | |
typealias ๐ฑ = String | |
typealias ๐ถ = String | |
typealias ๐ = String | |
enum Decision{ | |
case DontGiveAFuck(๐ป) | |
case Panic(๐ฑ) | |
case KeepItSimple(๐ถ) | |
case Fuckup(๐) | |
} | |
enum Result { | |
case Win | |
case Fuckup | |
} | |
enum EngineeringPrinciples { | |
case SOLID | |
case YAGNI | |
case KISS | |
} | |
enum TestTarget { | |
case Device | |
case Simulator | |
} | |
var decision : Decision = .DontGiveAFuck("") | |
switch (decision) { | |
case .Fuckup(let ๐): | |
// ... | |
break | |
default: | |
break | |
} | |
class Developer { | |
} | |
class Engineer : Developer { | |
func workWith(smth: String) -> Result { | |
if (smth == "UIWebView-based browser") { | |
return .Fuckup | |
} | |
else { | |
return .Win | |
} | |
} | |
func useMagic() -> Result { | |
if !self.understandsMagic() { | |
return .Fuckup | |
} | |
else { | |
return .Win | |
} | |
} | |
func breakTheRules(principle: EngineeringPrinciples) -> Result { | |
switch principle { | |
case .SOLID: return rand() % 2 == 0 ? .Win : .Fuckup | |
case .YAGNI: return rand() % 2 == 0 ? .Win : .Fuckup | |
case .KISS : return .Fuckup | |
} | |
} | |
func RTFM(m: String) -> Result { | |
if m.containsString("ARM Instruction set") { | |
return .Fuckup | |
} | |
else { | |
return .Win | |
} | |
} | |
func useGoogle(use : Bool) -> Result { | |
return use ? .Win : .Fuckup | |
} | |
func testOn(target: TestTarget) -> Result { | |
return target == .Device ? .Win : .Fuckup | |
} | |
func tryWithoutDebugger(without: Bool) -> Result { | |
return without ? .Win : .Fuckup | |
} | |
private func understandsMagic() -> Bool { | |
return false | |
} | |
} | |
var you : Developer = Engineer() | |
// case study | |
(you as! Engineer).workWith("UIWebView-based browser") == .Fuckup | |
(you as! Engineer).useMagic() == .Fuckup | |
(you as! Engineer).breakTheRules(.KISS) == .Fuckup | |
(you as! Engineer).RTFM("ARM Instruction set") == .Fuckup | |
(you as! Engineer).useGoogle(false) == .Fuckup | |
(you as! Engineer).testOn(.Simulator) == .Fuckup | |
(you as! Engineer).tryWithoutDebugger(false) == .Fuckup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment