*-Oriented Programming

1fa9cb8c7997c8c4d3d251fb5e41f749?s=47 Realm
December 01, 2015

*-Oriented Programming

Presented by Graham Lee at #Pragma 2015

1fa9cb8c7997c8c4d3d251fb5e41f749?s=128

Realm

December 01, 2015
Tweet

Transcript

  1. Outline Introduction Function–oriented Objects Object–oriented Functions Conclusions *–Oriented Programming Graham

    Lee December 1, 2015 Graham Lee *–Oriented Programming
  2. Outline Introduction Function–oriented Objects Object–oriented Functions Conclusions Introduction Function–oriented Objects

    Object–oriented Functions Conclusions Graham Lee *–Oriented Programming
  3. Outline Introduction Function–oriented Objects Object–oriented Functions Conclusions How can we

    Orient Programming? What is Object–Orientation? What is Functional Programming? What’s a programming paradigm, and where can I buy one? Graham Lee *–Oriented Programming
  4. Outline Introduction Function–oriented Objects Object–oriented Functions Conclusions Paradigmatic Programming How

    does the way we think about our problems define the solutions? Do programming tools have much bearing on this? Graham Lee *–Oriented Programming
  5. Outline Introduction Function–oriented Objects Object–oriented Functions Conclusions Paradigmatic Thinking Tools

    can support that thinking but don’t shape it This is all about how we attack our problems Graham Lee *–Oriented Programming
  6. Outline Introduction Function–oriented Objects Object–oriented Functions Conclusions Functional points Given

    a Cartesian representation of a point x, y, find its distance from the origin and angle from the x–axis. Graham Lee *–Oriented Programming
  7. Outline Introduction Function–oriented Objects Object–oriented Functions Conclusions Functional points—attempt 1

    Point radius :: float, float → float Point radius(x, y) = x2 + y2 Point angle :: float, float → float Point angle(x, y) = arctan(x/y) Graham Lee *–Oriented Programming
  8. Outline Introduction Function–oriented Objects Object–oriented Functions Conclusions Functional points—attempt 2

    Point :: float, float, operation → float Point(x, y, Radius) = x2 + y2 Point(x, y, Angle) = arctan(x/y) Graham Lee *–Oriented Programming
  9. Outline Introduction Function–oriented Objects Object–oriented Functions Conclusions Functional points—attempt 3

    Point :: float, float, operation → Function Point(x, y, Radius) = Point radius Point(x, y, Angle) = Point angle Graham Lee *–Oriented Programming
  10. Outline Introduction Function–oriented Objects Object–oriented Functions Conclusions Functional points—tidying up

    Point :: float, float → operation → Function Point(x, y) is a Constructor for an object, p p(operation) is a Message, which takes a Selector and returns a Method. Point (r, θ) could also be a Constructor. . . Graham Lee *–Oriented Programming
  11. Outline Introduction Function–oriented Objects Object–oriented Functions Conclusions Object–oriented compiler Write

    a compiler that takes source code in some language and creates an executable. If it encounters malformed source code, it should report an error and should not produce an executable. Graham Lee *–Oriented Programming
  12. Outline Introduction Function–oriented Objects Object–oriented Functions Conclusions Object–oriented compiler—attempt 1

    Compiler +compile(source:String): Optional<Executable> +getErrors(): Array<CompilerError> Graham Lee *–Oriented Programming
  13. Outline Introduction Function–oriented Objects Object–oriented Functions Conclusions Object–oriented compiler—attempt 2

    Compiler +compile(source:String,errorReporter:ErrorReporter): Optional<Executable> ErrorReporter +reportError(error:CompilerError): void Graham Lee *–Oriented Programming
  14. Outline Introduction Function–oriented Objects Object–oriented Functions Conclusions Object–oriented compiler—attempt 3

    Tokeniser +tokenise(source:String,errorReporter:ErrorReporter): Optional<TokenisedSource> ErrorReporter +reportError(error:CompilerError): void Compiler +compile(source:TokenisedSource,errorReporter:ErrorReporter): Optional<AssemblyProgram> Assembler +assemble(program:AssemblyProgram,errorReporter:ErrorReporter): Optional<BinaryObject> Linker +link(objects:Array<BinaryObject>,errorReporter:ErrorReporter): Optional<Executable> Graham Lee *–Oriented Programming
  15. Outline Introduction Function–oriented Objects Object–oriented Functions Conclusions So what just

    happened? We took functions describing points, and applied the principles of functional programming until what we had were objects. We took an object describing a compiler, and applied the principles of object–oriented programming until what we had were functions. Graham Lee *–Oriented Programming
  16. Outline Introduction Function–oriented Objects Object–oriented Functions Conclusions Conclusions *–oriented programming

    describes your thought process The tools can constrain you, they can’t lead your thought. You’re going to have to bring your own thinking. Graham Lee *–Oriented Programming