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

Architecting is Difficult: Breaking Borders, April 2014

Architecting is Difficult: Breaking Borders, April 2014

Jack Franklin

April 15, 2014
Tweet

More Decks by Jack Franklin

Other Decks in Technology

Transcript

  1. @Jack_Franklin — Student (for one more month) at University of

    Bath — (Soon to be a) developer for @GoCardless — Blogger at javascriptplayground.com, tilvim.com — Google Developer Expert on the Chrome team — Does a pretty epic Gangnam Style with @benmacgowan
  2. Any fool can write code that a computer can understand.

    Good programmers write code that humans can understand. -- Martin Fowler.
  3. Defer concrete decisions as late as possible - you'll never

    again know less about the problem than you do right now and the correct abstraction will become clearer over time. -- Andy Appleton
  4. There are only two hard things in Computer Science: cache

    invalidation and naming things. -- Phil Karlton
  5. There are only two hard things in Computer Science: cache

    invalidation, naming things and off by one errors. -- ??
  6. Ye know too much class EmailSender def initialize(csv) def parse_csv_for_emails

    Parser.new(csv).emails def send_email end class Parser def initialize(csv) def emails end
  7. Ignorance is bliss class EmailSender def initialize(emails) def send_email end

    class Parser def initialize(csv) def emails end emails = Parser.new(csv).emails EmailSender.new(emails).send_email
  8. don't be afraid to create classes / objects It's easier

    to merge two small things than split one large thing
  9. You don't fix code smells. You look at them and

    see if they indicate a problem you can fix. -- Joe Ferris
  10. var googleMapPin = function(x, y) {...}; var getLatLong = function(x,

    y) {...}; var user = { coordinates: [x, y]; };
  11. var googleMapPin = function(coords) {...}; var getLatLong = function(coords) {...};

    var user = { coordinates: coords }; var coords = { x: 1, y: 2 };
  12. Implicit Knowledge The relationship of x and y was implicit.

    By extracting the coords object, we make it explicit.
  13. Implicit Knowledge Seek to remove all implicit knowledge in a

    system. If I was handing it over to you, what would I need to explain?
  14. var drawGraph = function(graphWidth, graphHeight) { var width = 165

    + graphWidth; var height = 170.5 + graphHeight; };
  15. var drawGraph = function(graphWidth, graphHeight) { var extra_graph_width_padding = 165;

    var extra_graph_height_padding = 170.5; var width = extra_graph_width_padding + graphWidth; var height = extra_graph_height_padding + graphHeight; };
  16. <% if user != nil %> <h2><%= user.welcome_message %></h2> <%

    else %> <h2>Please Sign In</h2> <% end %>
  17. class GuestUser def welcome_message "Please Sign In" end user =

    current_user || GuestUser.new View: <h2><%= user.welcome_message %></h2>
  18. Ye know too much (again) The carousel knows that when

    it starts, it needs the accordion to close. That seems a bit odd?
  19. Pub Sub! var carousel = function() { start: function() {

    event.publish('carousel_start'); } }; var accordion = { init: function() { event.subscribe('carousel_start', function() { this.close(); }); } }
  20. Fix one var carousel = function(options) { var width =

    options.width; var height = options.height; ... }
  21. Don't leave comments #TODO: this entire class is screwed, fix

    it #todo REMOVE BEFORE PRODUCTION... SERIOUSLY!
  22. Changing code 1. Refactor to make the change easy. 2.

    Make the change Each change should be easy to introduce. If it's not, refactor.