Successfully reported this slideshow.

Writing Frameworks for Fun and Profit

489 views

Published on

This was a presentation given at Droidcon India 2012. It was by request of the organizers as a masterclass in writing frameworks and toolkits.

It turned out to be quite a reflective talk on software design and its philosophy as discovered by the author.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Writing Frameworks for Fun and Profit

  1. 1. Writing aframework for fun @jhugman – James Hugman
  2. 2. Not him again • Software Engineer in industry for 10y+ • Written: • Compilers, Reasoning Engines, ETL systems, evolutionary algorithms, cross-platform mobile frameworks@jhugman
  3. 3. Contents • Why should I care • Words shape thought • Rules for enablers • Developers are users too@jhugman
  4. 4. Anti-Contents • A specific technology • The importance of encapsulation • An exhaustive list of anything@jhugman
  5. 5. Why should I care? Why would I want to write a framework?@jhugman
  6. 6. Your role changes • Tool user • Tool maker@jhugman
  7. 7. @jhugman Status
  8. 8. Architect@jhugman Status
  9. 9. What happens at@jhugman work…
  10. 10. What happens at@jhugman work…
  11. 11. @jhugman It feels like…
  12. 12. @jhugman It feels like…
  13. 13. Words Shape Thought Identifiers, Little Languages and Patterns@jhugman
  14. 14. Words shape thought • Find language that describe the concepts • Break concepts into smaller nouns & verbs@jhugman
  15. 15. Words shape thought • Make your code out of this language e.g. identifiers • Build your code bottom up@jhugman
  16. 16. Words shape thought • Over-generalizing is double-plus- ungood • process() • apply() • execute()@jhugman
  17. 17. Words shape thought • Wrong words require double-think@jhugman
  18. 18. Why Language Matters • Thought-to-code gap • More readable code • Better intra-team communication • Bugs are harder to write@jhugman
  19. 19. Other People’s DSLs • Integrate existing little languages with your framework • e.g. SQL, XPath, Javascript • Design patterns provide a vocabulary@jhugman
  20. 20. Definitional Interlude • Framework vs Toolkit (Hollywood Principle)@jhugman
  21. 21. Extendable systems Architect like you have a plugin mechanism@jhugman
  22. 22. Plugin systems • Modularity above the package level • Assume you have a plugin system, even if you don’t@jhugman
  23. 23. Rules for Enablers • Invitation Rule – Whenever possible, let others contribute to your contributions • Fair Play Rule – All clients play by the same rules, even me. • Explicit Extension Rule – Declare explicitly where a platform can be extended. • Diversity Rule – Extension points accept multiple extensions.@jhugman
  24. 24. Rules for Enablers • Explicit API Rule - separate the API from internals. • Defensive API Rule - Reveal only the API in which you are confident, but be prepared to reveal more API as clients ask for it.@jhugman
  25. 25. Architect for Participation • Requirements change, new features added • Multiple uncoordinated teams can work concurrently • Plugins limit negative impact of change • Containment of unpredictability@jhugman
  26. 26. Example Architecting for growth@jhugman
  27. 27. House Numbers • Physical world example • A street, where houses will be • How should we number the houses@jhugman
  28. 28. House numbers •Sequential •Row at a time •Simple at 1 2 3 4 build time road •Not 5 6 7 8 extendable •Not very navigable@jhugman
  29. 29. House numbers •Sequential •Odds/Evens •Extendable in 1 3 5 7 one direction road •Assumes no 2 4 6 8 space between houses@jhugman
  30. 30. House numbers •Distance from one end •Large scale 10300 17010 •Navigable road 15705 •No fixed 19010 construction order@jhugman
  31. 31. Developer UX Developers are users too@jhugman
  32. 32. Developer pain kills • Everything should be obvious • A good mental model@jhugman
  33. 33. API Usability • Design APIs upfront (almost BDD for APIs) • Seek feedback from real developers • Prototype, review, iterate@jhugman
  34. 34. Related • Paper prototyping • README driven development • Commit-log driven development@jhugman
  35. 35. Summary • Words shape thought • Build in extensibility, early • Think hard about developer experience@jhugman
  36. 36. Further Study • Graduates/Juniors: • Effective Java Josh Bloch • Huston Design Patterns (a website with GoF patterns) • Programming Pearls Jon Bentley • Pragmatic Programmer Andrew Hunt & Dave Thomas •@jhugman
  37. 37. Further Study • Principles of Newspeak George Orwell • Growing a Language Guy Steele • The Art Of War Sun Tzu • Unwritten Rules Of Engineering Skakoon & King • Developer UX@jhugman
  38. 38. Podcasts • Java Posse • this developer’s life • Hacker News Pod • Software Engineering Radio@jhugman
  39. 39. Thanks @jhugman – James Hugman@jhugman
  40. 40. Discuss AMA@jhugman
  41. 41. @jhugman

×