Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Unreasonable Effectiveness of Declarative C...

The Unreasonable Effectiveness of Declarative Code and the Near Future of Programming

Writing code in a declarative style has significantly improved my effectiveness as a developer. This lightning talk will discuss how we can bring a declarative style to our Swift codebase.

Benjamin Encz

November 07, 2016
Tweet

More Decks by Benjamin Encz

Other Decks in Programming

Transcript

  1. The Unreasonable Effectiveness Of Declarative Code And The Near Future

    of Programming The Unreasonable Effectiveness Of Declarative Code | @benjaminencz | Swift Summit, November 2016 2
  2. Facts instead of Behavior usernameLabel.text <~ user.name ageLabel.text <~ user.age

    The Unreasonable Effectiveness Of Declarative Code | @benjaminencz | Swift Summit, November 2016 8
  3. Facts instead of Behavior usernameLabel.text <~ user.name ageLabel.text <~ user.age

    The Unreasonable Effectiveness Of Declarative Code | @benjaminencz | Swift Summit, November 2016 9
  4. Facts instead of Behavior usernameLabel.text <~ user.name ageLabel.text <~ user.age

    • Idempotent The Unreasonable Effectiveness Of Declarative Code | @benjaminencz | Swift Summit, November 2016 9
  5. Facts instead of Behavior usernameLabel.text <~ user.name ageLabel.text <~ user.age

    • Idempotent • Commutative The Unreasonable Effectiveness Of Declarative Code | @benjaminencz | Swift Summit, November 2016 9
  6. Facts instead of Behavior usernameLabel.text <~ user.name ageLabel.text <~ user.age

    • Idempotent • Commutative • Concurrent The Unreasonable Effectiveness Of Declarative Code | @benjaminencz | Swift Summit, November 2016 9
  7. Facts instead of Behavior usernameLabel.text <~ user.name ageLabel.text <~ user.age

    • Idempotent • Commutative • Concurrent • Reactive The Unreasonable Effectiveness Of Declarative Code | @benjaminencz | Swift Summit, November 2016 9
  8. public protocol DownloadSyncable { static func handleServerResponse( response: SyncResponse, request:

    SyncRequest, state: SyncRequestState? ) -> ( changes: [ModelChange], newState: SyncRequestState?, nextRequest: SyncRequest? ) } The Unreasonable Effectiveness Of Declarative Code | @benjaminencz | Swift Summit, November 2016 11
  9. • Fact instead of behavior -> Easier to reason about

    The Unreasonable Effectiveness Of Declarative Code | @benjaminencz | Swift Summit, November 2016 12
  10. • Fact instead of behavior -> Easier to reason about

    • Interface forms DSL -> Constrained, unified implementation The Unreasonable Effectiveness Of Declarative Code | @benjaminencz | Swift Summit, November 2016 12
  11. • Fact instead of behavior -> Easier to reason about

    • Interface forms DSL -> Constrained, unified implementation • Separation of concerns via indirection The Unreasonable Effectiveness Of Declarative Code | @benjaminencz | Swift Summit, November 2016 12
  12. • Fact instead of behavior -> Easier to reason about

    • Interface forms DSL -> Constrained, unified implementation • Separation of concerns via indirection • Testability The Unreasonable Effectiveness Of Declarative Code | @benjaminencz | Swift Summit, November 2016 12
  13. bit.ly/declarative-swift Further Reading: Declarative API Design in Swift (me) Defining

    Declarative (awelonblue) @benjaminencz The Unreasonable Effectiveness Of Declarative Code | @benjaminencz | Swift Summit, November 2016 14