Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
The Language of
Abstraction
Sam Goldman
@nontrivialzeros
Tuesday, July 23, 13
Software is Big
• 400 page book: ~20,000 LOC
• MSVista: ~120,000,000 LOC (6,000 books)
• MS Apps: ~140,000,000 LOC (7,000 ...
Layers of Abstraction
Electronic Switches
Logic Gates
Binary
Machine Language
High-Level Language
Your Application
Tuesday...
Switches to Gates
Primitives Combination Abstraction
Tuesday, July 23, 13
Gates to Binary
Primitives Combination Abstraction
1 1 1 1 1 (carried digits)
0 1 1 0 1
+ 1 0 1 1 1
-------------
= 1 0 0 ...
Primitive Obsession
• Using a primitive from the wrong layer of
abstraction
• Particularly primitives provided by your
pro...
Framework Obsession
• We use frameworks that provide lots of
functionality: routing, ORM, templating
• Express your applic...
Linguistic Abstraction
• Simpler mental models of software
• Self-documenting code
• Complexity where it matters
Tuesday, ...
TCP/IP
Tuesday, July 23, 13
Tell, Don’t Ask
• Depending on collaborators’ states breaks
encapsulation
• Depend on behaviors, not state
• Law of Demete...
AskingQuestionnaire = Struct.new(:questions) do
def render(html)
html.form
questions.each do |question|
html.fieldset {
ca...
Telling
Questionnaire = Struct.new(:questions) do
def render(html)
html.form do
questions.each do |question|
html.fieldset...
Telling
ShortAnswerQuestion = Struct.new(:id, :prompt) do
def render(html)
html.label(:for => id) { html.text prompt }
htm...
Encapsulation
• Limits the number of components affected
by change
• Allows for extension
Tuesday, July 23, 13
Virtual Memory
Tuesday, July 23, 13
Services
• Fulfill needs determined though wishful
thinking
• Hide concrete implementation details
Tuesday, July 23, 13
Thank you
@smartlogic
facebook.com/smartlogic
github.com/smartlogic
Tuesday, July 23, 13
Upcoming SlideShare
Loading in …5
×

The Language of Abstraction in Software Development

666 views

Published on

A short view into the language of abstraction in software development.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

The Language of Abstraction in Software Development

  1. 1. The Language of Abstraction Sam Goldman @nontrivialzeros Tuesday, July 23, 13
  2. 2. Software is Big • 400 page book: ~20,000 LOC • MSVista: ~120,000,000 LOC (6,000 books) • MS Apps: ~140,000,000 LOC (7,000 books) Kay,Alan.“Programming and Scaling.” HPI Colloquium. Hasso-Plattner-Institut Postdam. 2011. http://www.tele-task.de/archive/video/flash/14029/ Tuesday, July 23, 13
  3. 3. Layers of Abstraction Electronic Switches Logic Gates Binary Machine Language High-Level Language Your Application Tuesday, July 23, 13
  4. 4. Switches to Gates Primitives Combination Abstraction Tuesday, July 23, 13
  5. 5. Gates to Binary Primitives Combination Abstraction 1 1 1 1 1 (carried digits) 0 1 1 0 1 + 1 0 1 1 1 ------------- = 1 0 0 1 0 0 = 36 Tuesday, July 23, 13
  6. 6. Primitive Obsession • Using a primitive from the wrong layer of abstraction • Particularly primitives provided by your programming language, e.g., dictionaries • Create useful primitives in a new language • Provide a means of combination and a means of abstraction Tuesday, July 23, 13
  7. 7. Framework Obsession • We use frameworks that provide lots of functionality: routing, ORM, templating • Express your application in the language of the domain, not the language of the framework. Tuesday, July 23, 13
  8. 8. Linguistic Abstraction • Simpler mental models of software • Self-documenting code • Complexity where it matters Tuesday, July 23, 13
  9. 9. TCP/IP Tuesday, July 23, 13
  10. 10. Tell, Don’t Ask • Depending on collaborators’ states breaks encapsulation • Depend on behaviors, not state • Law of Demeter Tuesday, July 23, 13
  11. 11. AskingQuestionnaire = Struct.new(:questions) do def render(html) html.form questions.each do |question| html.fieldset { case question when ShortAnswerQuestion html.label(:for => question.id) { html.text question.prompt } html.input(:type => "text", :id => question.id, :name => question.id) when MultipleChoiceQuestion html.label { html.text question.prompt } html.ul { question.choices.each do |choice| html.li { html.label(:for => choice.id) { html.text choice.title } html.input(:type => "radio", :id => choice.id, :name => choice.id) } end } end } end end end end Tuesday, July 23, 13
  12. 12. Telling Questionnaire = Struct.new(:questions) do def render(html) html.form do questions.each do |question| html.fieldset { question.render(html) } end end end end Tuesday, July 23, 13
  13. 13. Telling ShortAnswerQuestion = Struct.new(:id, :prompt) do def render(html) html.label(:for => id) { html.text prompt } html.input(:type => "text", :id => id, :name => id) end end MultipleChoiceQuestion = Struct.new(:id, :prompt, :choices) do def render(html) html.label { html.text prompt } html.ul { choices.each do |choice| html.li { choice.render(html) } end } end end Choice = Struct.new(:id, :title) do def render(html) html.label(:for => id) { html.text title } html.input(:type => "radio", :id => id, :name => id) end end Tuesday, July 23, 13
  14. 14. Encapsulation • Limits the number of components affected by change • Allows for extension Tuesday, July 23, 13
  15. 15. Virtual Memory Tuesday, July 23, 13
  16. 16. Services • Fulfill needs determined though wishful thinking • Hide concrete implementation details Tuesday, July 23, 13
  17. 17. Thank you @smartlogic facebook.com/smartlogic github.com/smartlogic Tuesday, July 23, 13

×