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

The TImeless Way of Building - RevConf 2017

The TImeless Way of Building - RevConf 2017

"Design patterns" is a common phrase that is often spoken in the course of design and development of web applications. But it's genesis is not from programming, but Architecture. Through a lack of understanding, they are misused and abused. We're going to rectify that misunderstanding.

John Athayde

June 01, 2017
Tweet

More Decks by John Athayde

Other Decks in Programming

Transcript

  1. A design pattern systematically names, motivates, and explains a general

    design that addresses a recurring design problem in object-oriented systems. It describes the problem, the solution, when to apply the solution, and its consequences. It also gives implementation hints and examples. The solution is a general arrangement of objects and classes that solve the problem. The solution is customized and implemented to solve the problem in a particular context.
  2. “Design patterns help you identify less-obvious abstractions and the objects

    than can capture them. For example, objects that represent a process or algorithm don’t occur in nature, yet they are a crucial part of flexible designs.”
  3. “How can you distribute responsibility for design through all levels

    of a large hierarchy, while still maintaining consistency and harmony of overall design?” — M. J. Dominus 2002 ALEXANDER’S QUEST:
  4. DRY

  5. “…[Architecture and Software patterns] give us a vocabulary to talk

    about how things are constructed. It is much more convenient to say, ‘this object has listeners for its properties,’ than ‘this object lets you hook callback functions that are called when properties change.’” — Federico Mena Quintero
 “Software that has the Quality Without a Name”
  6. “Engineers frequently have to make decisions of great practical consequence

    in the face of incomplete and uncertain knowledge.” — Walter Vincenti ON ENGINEERS:
  7. “…the mere list of elements which are typical in a

    given town tells us the way of life of people there.” — Alexander, TTWoB, pp71
  8. “To many software-patterns folk the quality without a name doesn’t

    apply to things like software anyhow. I agree that most software— at least the software I see—doesn’t have such a quality, but does that mean it couldn’t? I find it odd, though, to take so much inspiration from the simple, mechanical parts of a person’s work —the form of the pattern language and terms like forces—but to ignore the heart of it. I’m not so sure the quality without a name is irrelevant.” — Richard P. Gabriel Patterns of Software, pp 71
  9. Nature = 15 Properties in common All patterns come from

    these properties Each property can also transform Only good design = transformation,
 one property at a time.
  10. D

  11. 2

  12. D

  13. class Customer < ActiveRecord::Base has_one :address has_one :account ... def

    state address.state end ... end @account.customer.state 2
  14. http://callbackhell.com D fs.readdir(source, function (err, files) { if (err) {

    console.log('Error finding files: ' + err) } else { files.forEach(function (filename, fileIndex) { console.log(filename) gm(source + filename).size(function (err, values) { if (err) { console.log('Error identifying file size: ' + err) } else { console.log(filename + ' : ' + values) aspect = (values.width / values.height) widths.forEach(function (width, widthIndex) { height = Math.round(width / aspect) console.log('resizing ' + filename + 'to ' + height + 'x' + height) this.resize(width, height).write(dest + 'w' + width + '_' + filename, function(err) { if (err) console.log('Error writing file: ' + err) }) }.bind(this)) } }) }) } }) CALLBACKS
  15. class RemoteProcess < ActiveRecord::Base scope :running, where(:state => ‘Running’) scope

    :system, where(:owner => [‘root’, ‘mysql’]) scope :sorted, order(“percent_cpy desc”) scope :top, lamda {|1| limit(1)} end RemoteProcess.running.sorted.top(10) RemoteProcess.running.system.sorted.top(5) sample from Rails Antipatterns pp 37 2
  16. def text_field_tag(name, value = nil, options = {}) tag :input,

    { :type => "text", :name => name, :id => sanitize_to_id(name), :value => value }.update( end def text_field_tag(name, value = nil, options = {}) tag :input, { :type => "text", :name => name, :id => sanitize_to_id(name), :value => value }.update(options.stringify_keys) end 2 D
  17. “The best way to learn to write simple code is

    to write simple code! Patterns, like all forms of complexity, should be avoided until they are absolutely necessary. That’s the first thing beginners need to learn. Not the last thing. ” — Jeff Atwood c. 2005
  18. “ You cannot say that you are correctly applying a

    design pattern unless you are confronting the problem that the pattern is supposed to solve – R U S S O L S E N ”
  19. “...mediocre developers never even ask why. They just arrive at

    the first solution that works and keep plowing ahead.” — Jeff Atwood, c.2005
  20. “To many software-patterns folk the quality without a name doesn’t

    apply to things like software anyhow. I agree that most software— at least the software I see—doesn’t have such a quality, but does that mean it couldn’t? I find it odd, though, to take so much inspiration from the simple, mechanical parts of a person’s work —the form of the pattern language and terms like forces—but to ignore the heart of it. I’m not so sure the quality without a name is irrelevant.” — Richard P. Gabriel Patterns of Software, pp 71
  21. “Indeed this ageless character has nothing, in the end, to

    do with languages. The language, and the processes which stem from it, merely release the fundamental order which is native to us.” — The Timeless Way of Building, Chapter 27
  22. “They do not teach us, they only remind us of

    what we know already, and of what we shall discover time and time again, when we give up our opinions, and do exactly what emerges from ourselves.” — The Timeless Way of Building, Chapter 27
  23. “To make a building egoless, the builder must let go

    of all his willful images, and start with 
 a void. You are able to do this only when you no longer fear that nothing will happen, and you can therefore afford to let go of your images.” — The Timeless Way of Building, Chapter 27
  24. “Yet , at the very moment when you first relax,

    and let the language generate the buildings in your mind, you will begin to see how limited your language is. One place can have good patterns in it and be dead. Another place can be without the patterns which apply to it, and yet still be alive. ” — The Timeless Way of Building, Chapter 27
  25. “The pattern ALCOVE–which first functioned as an intellectual crutch–is no

    longer necessary to you. You see reality directly, like an animal. You make the alcove as an animal might make an alcove–not because of the concept–but directly, simply because it is appropriate.” — The Timeless Way of Building, Chapter 27