17
The Language of Abstraction Sam Goldman @nontrivialzeros Tuesday, July 23, 13

The Language of Abstraction in Software Development

Embed Size (px)

DESCRIPTION

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

Citation preview

Page 1: The Language of Abstraction in Software Development

The Language of Abstraction

Sam Goldman@nontrivialzeros

Tuesday, July 23, 13

Page 2: The Language of Abstraction in Software Development

Software is Big

• 400 page book: ~20,000 LOC

• MS Vista: ~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

Page 3: The Language of Abstraction in Software Development

Layers of Abstraction

Electronic Switches

Logic Gates

Binary

Machine Language

High-Level Language

Your Application

Tuesday, July 23, 13

Page 4: The Language of Abstraction in Software Development

Switches to Gates

Primitives Combination Abstraction

Tuesday, July 23, 13

Page 5: The Language of Abstraction in Software Development

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

Page 6: The Language of Abstraction in Software Development

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

Page 7: The Language of Abstraction in Software Development

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

Page 8: The Language of Abstraction in Software Development

Linguistic Abstraction

• Simpler mental models of software

• Self-documenting code

• Complexity where it matters

Tuesday, July 23, 13

Page 9: The Language of Abstraction in Software Development

TCP/IP

Tuesday, July 23, 13

Page 10: The Language of Abstraction in Software Development

Tell, Don’t Ask

• Depending on collaborators’ states breaks encapsulation

• Depend on behaviors, not state

• Law of Demeter

Tuesday, July 23, 13

Page 11: The Language of Abstraction in Software Development

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 endend

Tuesday, July 23, 13

Page 12: The Language of Abstraction in Software Development

Telling

Questionnaire = Struct.new(:questions) do def render(html) html.form do questions.each do |question| html.fieldset { question.render(html) } end end endend

Tuesday, July 23, 13

Page 13: The Language of Abstraction in Software Development

TellingShortAnswerQuestion = Struct.new(:id, :prompt) do def render(html) html.label(:for => id) { html.text prompt } html.input(:type => "text", :id => id, :name => id) endend

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 } endend

Choice = Struct.new(:id, :title) do def render(html) html.label(:for => id) { html.text title } html.input(:type => "radio", :id => id, :name => id) endend

Tuesday, July 23, 13

Page 14: The Language of Abstraction in Software Development

Encapsulation

• Limits the number of components affected by change

• Allows for extension

Tuesday, July 23, 13

Page 15: The Language of Abstraction in Software Development

Virtual Memory

Tuesday, July 23, 13

Page 16: The Language of Abstraction in Software Development

Services

• Fulfill needs determined though wishful thinking

• Hide concrete implementation details

Tuesday, July 23, 13

Page 17: The Language of Abstraction in Software Development

Thank you

@smartlogic

facebook.com/smartlogic

github.com/smartlogic

Tuesday, July 23, 13