• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
NDC 2011 - The FLUID Principles
 

NDC 2011 - The FLUID Principles

on

  • 3,941 views

The slides from Kevlin Henney and Anders Norås introduction of the FLUID principles at The Norwegian Developer's Conference June 8th 2011.

The slides from Kevlin Henney and Anders Norås introduction of the FLUID principles at The Norwegian Developer's Conference June 8th 2011.

Statistics

Views

Total Views
3,941
Views on SlideShare
3,898
Embed Views
43

Actions

Likes
4
Downloads
32
Comments
0

3 Embeds 43

https://twitter.com 41
http://us-w1.rockmelt.com 1
http://www.slashdocs.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    NDC 2011 - The FLUID Principles NDC 2011 - The FLUID Principles Presentation Transcript

    • ndc 2011
    • TheFLUID Principles Kevlin Henney Anders Norås
    • FLUIDcontrasts with SOLID
    • SOLID
    • S ingle Responsibility PrincipleO pen / Closed PrincipleL iskov’s Substitution PrincipleI nterface Segregation PrincipleD ependency Inversion Principle
    • “ALL THE NEWS THAT’S FIT TO DEPLOY” LATE EDITION The Software Dev Times VOL XI...NO 12,345 OSLO, WEDNESDAY, JUNE 8, 2011 FREE AS IN BEER SHOCK-SOLID! MYSTERIOUS SOFTWARE CRAFTSMAN COINED THE SOLID ACRONYM! Bob might not be your uncle By A. NORÅS & K. HENNEYUt enim ad minim veniam, quis nostrud exerc.Irure dolor in reprehend incididunt ut labore etdolore magna aliqua. Ut enim ad minimveniam, quis nostrud exercitation ullamcolaboris nisi ut aliquip ex ea commodoconsequat. Duis aute irure dolor inreprehenderit in voluptate velit esse molestaie Etiam sit amet estcillum. Tia non ob ea soluad incommod quaeegen ium improb fugiend. Officia deseruntmollit anim id est laborum Et harumd dereud.Neque pecun modut nequeConsectetuer arcu ipsum ornare pellentesquevehicula, in vehicula diam, ornare magna eratfelis wisi a risus. Justo fermentum id. Malesuadaeleifend, tortor molestie, a fusce a vel et. Mauris NO COMMENT. The software craftsman claimed to have discovered that a set ofat suspendisse, neque aliquam faucibus principles could be abbreviated “SOLID”, declined to comment on the matter.adipiscing, vivamus in. Wisi mattis leo suscipitnec amet, nisl fermentum tempor ac a, augue in Sociosqu netus semper aenean Ut enim ad minim veniam, quis nostrudeleifend in venenatis, cras sit id in vestibulum suspendisse dictum, arcu enim conubia exerc. Irure dolor in reprehendfelis. Molestie ornare amet vel id fusce, rem leo nulla ac nibh, purus hendrerit ut incididunt ut labore et dolore magnavolutpat platea. Magnis vel, lacinia nisl, vel mattis nec maecenas, quo ac, vivamus aliqua. Ut enim ad minim veniam, quisnostra nunc eleifend arcu leo, in dignissim praesent metus eget viverra ante. nostrud exercitation ullamco laboris nisilorem vivamus laoreet. Natoque placerat sed sit hendrerit, ut aliquip ex ea commodo consequat. dapibus eleifend velit molestiae leo a, ut Duis aute irure dolor in reprehenderit inDonec arcu risus diam amet sit. Congue tortor lorem sit et lacus aliquam. Sodales nulla voluptate velit esse molestaie cillum. Tiacursus risus vestibulum commodo nisl, luctus erat et luctus faucibus aperiam sapien. non ob ea soluad incommod quae egenaugue amet quis aenean odio etiammaecenas sit, Leo inceptos augue nec pulvinar rutrum ium improb fugiend. Officia deseruntdonec velit iusto, morbi felis elit et nibh. aliquam mauris, wisi hasellus fames ac, mollit anim id est laborum Et harumdVestibulum volutpat dui lacus consectetuer ut, commodo eligendi dictumst, dapibus dereud.mauris at etiam suspendisse, eu wisi rhoncus morbi auctor.eget nibh velit, eget posuere sem in a sit.
    • e BristolDictionary of Concise English
    • prin·ci·ple /ˈprinsəpəl/ Noun 4. a natural law forming1. a fundamental truth the basis for theor prop osit ion t hat construction or workingserves as the foundation of a machine.for a system of belief orbehaviour or for a chainof reasoning. para·skevi·de·katri·a·ph o·bia /ˈpærəskevidekaˈtriəˈfōbēə/ Adjective, Noun2. morally correctbehaviour and attitudes. 1. fear of Friday the 13th.3. a general scienti c Etymology: e wordtheorem or law that hasnumerous special was devised by Dr.applications across a Donald Dossey who toldwide eld. his patients that "when you learn to pronounce it, youre cured.
    • TheFLUID Principles Kevlin Henney Anders Norås
    • TheFLUID Guidelines Kevlin Henney Anders Norås
    • What are theF L U I D Guidelines?
    • FLUID
    • FLUID
    • Functional
    • Javapublic class HeatingSystem { public void turnOn() ... public void turnOff() ... ...}public class Timer { public Timer(TimeOfDay toExpire, Runnable toDo) ... public void run() ... public void cancel() ... ...}
    • Javapublic class TurnOn implements Runnable { private HeatingSystem toTurnOn; public TurnOn(HeatingSystem toRun) { toTurnOn = toRun; } public void run() { toTurnOn.turnOn(); }}public class TurnOff implements Runnable { private HeatingSystem toTurnOff; public TurnOff(HeatingSystem toRun) { toTurnOff = toRun; } public void run() { toTurnOff.turnOff(); }}
    • JavaTimer turningOn = new Timer(timeOn, new TurnOn(heatingSystem));Timer turningOff = new Timer(timeOff, new TurnOff(heatingSystem));
    • JavaTimer turningOn = new Timer( timeToTurnOn, new Runnable() { public void run() { heatingSystem.turnOn(); } });Timer turningOff = new Timer( timeToTurnOff, new Runnable() { public void run() { heatingSystem.turnOff(); } });
    • C++void turnOn(void * toTurnOn){ static_cast<HeatingSystem *>(toTurnOn)->turnOn();}void turnOff(void * toTurnOff){ static_cast<HeatingSystem *>(toTurnOff)->turnOff();}
    • C++Timer turningOn(timeOn, &heatingSystem, turnOn);Timer turningOff(timeOff, &heatingSystem, turnOff);
    • C++class Timer{ Timer(TimeOfDay toExpire, function<void()> toDo); void run(); void cancel(); ...};
    • C++Timer turningOn( timeOn, bind( &HeatingSystem::turnOn, &heatingSystem));Timer turningOff( timeOff, bind( &HeatingSystem::turnOff, &heatingSystem));
    • C#public class Timer{ public Timer( TimeOfDay toExpire, Action toDo) ... public void Run() ... public void Cancel() ... ...}
    • C#Timer turningOn = new Timer( timeOn, () => heatingSystem.TurnOn() );Timer turningOff = new Timer( timeOff, () => heatingSystem.TurnOff() );
    • C#Timer turningOn = new Timer( timeOn, heatingSystem.TurnOn );Timer turningOff = new Timer( timeOff, heatingSystem.TurnOff );
    • F unctionalLUID
    • F unctionalLUID
    • Loose
    • “ OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. It can be done in Smalltalk and in LISP. There are possibly other systems in which this is possible, but Im not aware of them. •Allan Kay
    • C#include <windows.h>#include <stdio.h>typedef int (__cdecl *MYPROC)(LPWSTR);VOID main(VOID){ HINSTANCE hinstLib; MYPROC ProcAdd; BOOL fFreeResult, fRunTimeLinkSuccess = FALSE; hinstLib = LoadLibrary(TEXT("echo.dll")); if (hinstLib != NULL) { ProcAdd = (MYPROC) GetProcAddress(hinstLib, "echo"); if (NULL != ProcAdd) { fRunTimeLinkSuccess = TRUE; (ProcAdd) (L"Hello my world!n"); } fFreeResult = FreeLibrary(hinstLib); } if (!fRunTimeLinkSuccess) printf("Hello everybodys world!n");}
    • Groovyclass HeatingSystem { def turnOn() { ... } def turnOff() { ... }}def heater = new HeatingSystem()def timer = new Timer()def action = "turnOn"timer.runAfter(1000) { heater."$action"()}
    • PHPclass DiyStore{ private $_bucket; public function getPaintBucket() { if ($this->_bucket === null) { $this->_bucket = $this->fillPaintBucket(); } return $this->_bucket; } private function fillPaintBucket() { // ... }}
    • RubyNullObject.new().say().hello().to().any().method_call().you().like()
    • TheFLUID Principles Kevlin Henney Anders Norås
    • TheFLUID Suggestions Kevlin Henney Anders Norås
    • F unctionalL ooseUID
    • F unctionalL ooseUID
    • Unit Testable
    • PowerShellfunction GetNextFriday13th($from) { [DateTime[]] $friday13ths = &{ foreach($i in 1..500) { $from = $from.AddDays(1) $from } } | ?{ $_.DayOfWeek -eq [DayOfWeek]::Friday -and $_.Day -eq 13 } return $friday13ths[0]}
    • PowerShell[DateTime[][]] $inputsWithExpectations = ("2011-01-01", "2011-05-13"), ("2011-05-13", "2012-01-13"), ("2007-04-01", "2007-04-13"), ("2007-04-12", "2007-04-13"), ("2007-04-13", "2007-07-13"), ("2012-01-01", "2012-01-13"), ("2012-01-13", "2012-04-13"), ("2012-04-13", "2012-07-13"), ("2001-07-13", "2002-09-13")
    • PowerShell$inputsWithExpectations | ?{ [String] $actual = GetNextFriday13th($_[0]) [String] $expected = $_[1] $actual -ne $expected}
    • F unctionalL ooseU nit TestableID
    • F unctionalL ooseU nit TestableID
    • Introspective
    • Scheme(define (eval exp env) (cond ((self-evaluating? exp) exp) ((variable? exp) (lookup-variable-value exp env)) ((quoted? exp) (text-of-quotation exp)) ((assignment? exp) (eval-assignment exp env)) ((definition? exp) (eval-definition exp env)) ((if? exp) (eval-if exp env)) ((lambda? exp)) (make-procedure (lambda-parameters exp) (lambda-body exp) env)) ((begin? exp) (eval-sequence (begin-actions exp) env)) ((cond? exp) (eval (cond->if exp) env)) ((application? exp) (apply (eval (operator exp) env) (list-of-values (operands exp) env))) (else (error "Unknown expression type -EVAL" exp))))
    • JavaScriptfunction Shoebox() { var things = ["Nike 42", "Adidas 41", "Adidas 43", "Paul Smith 41"]; def(this, "find", function(brand) { var result = []; for (var i=0; i<things.length; i++) { if (things[i].indexOf(brand) !== -1) result.push(things[i]); } return result; }); def(this, "find", function(brand,size) { var result = []; for (var i=0; i<things.length; i++) { if (things[i].indexOf(brand) !== -1 || parseInt(things[i].match(/d+/),10) === size) result.push(things[i]); } return result; });}function def(obj, name, fn) { var implFn = obj[name]; obj[name]=function() { if (fn.length === arguments.length) return fn.apply(this,arguments); else if (typeof implFn === "function") return implFn.apply(this,arguments); };};
    • Visual BasicPublic Class Book <Key> _ Public Property ISBN() As String ... End Property <StringLength(256)> _ Public Property Title() As String ... End Property Public Property AuthorSSN() As String ... End Property <RelatedTo(RelatedProperty := Books, Key := AuthorSSN, RelatedKey := SSN)> _ Public Property Author() As Person ... End PropertyEnd Class
    • F unctionalL ooseU nit TestableI ntrospectiveD
    • F unctionalL ooseU nit TestableI ntrospectiveD
    • ‘Dempotent
    • “ Asking a question should not change the answer. •Betrand Meyer
    • “ Asking a question should not change the answer. •Betrand Meyer
    • Scala(1 to 10).foldLeft(0)(_ + _)
    • F unctionalL ooseU nit TestableI ntrospective‘D dempotent
    • e venerable master Qc Na was walking with his student, Anton. Hoping to prompt the master into a discussion, Anton said "Master, I have heard that objects are a very good thing — is this true?"Qc Na looked pityingly at his student and replied, "Foolish pupil — objectsare merely a poor mans closures." Chastised, Anton took his leave from his master and returned to his cell,intent on studying closures. He carefully read the entire "Lambda: eUltimate..." series of papers and its cousins, and implemented a smallScheme interpreter with a closure-based object system. He learned much,and looked forward to informing his master of his progress. On his next walk with Qc Na, Anton attempted to impress his master bysaying "Master, I have diligently studied the matter, and now understandthat objects are truly a poor mans closures."Qc Na responded by hitting Anton with his stick, saying "When will youlearn? Closures are a poor mans object." At that moment, Anton becameenlightened. http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/msg03277.html
    • @kevlinhenney @anoras