slide1 n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Introducing the FLUID Principles PowerPoint Presentation
Download Presentation
Introducing the FLUID Principles

Loading in 2 Seconds...

play fullscreen
1 / 58

Introducing the FLUID Principles - PowerPoint PPT Presentation


  • 1209 Views
  • Uploaded on

Presented at NDC 2011 in Oslo (8th June 2011) with Anders Norås
Video available at http://www.everytalk.tv/talks/694-NDC--Introducing-The-FLUID-Principles

When it comes to object–­oriented software, the SOLID principles have become almost synonymous with good design practice. While every letter stands for a principle, some developers obsess over them as if there were no more to good code than these five principles. Since the introduction of SOLID many alternatives to traditional object–­oriented programming have risen in popularity, suggesting that other design principles may have a role to play. In this talk Kevlin Henney and Anders Norås introduce their FLUID principles for software design.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

Introducing the FLUID Principles


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
    Presentation Transcript
    1. ndc 2011

    2. The FLUID Principles Kevlin Henney Anders Norås

    3. FLUID contrasts with SOLID

    4. S O L I D ingle Responsibility Principle pen / Closed Principle iskov’s Substitution Principle nterface Segregation Principle ependency Inversion Principle

    5. “ALL THE NEWS THAT’S FIT TO DEPLOY” LATE EDITION The Software Dev Times SHOCK-SOLID! MYSTERIOUS SOFTWARE CRAFTSMAN COINED THE SOLID ACRONYM! VOL XI...NO 12,345 OSLO, WEDNESDAY, JUNE 8, 2011 FREE AS IN BEER Bob might not be your uncle By A. NORÅS & K. HENNEY Ut enim ad minim veniam, quis nostrud exerc. Irure dolor in reprehend incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse molestaie cillum. Tia non ob ea soluad incommod quae egen ium improb fugiend. Officia deserunt mollit anim id est laborum Et harumd dereud. Etiam sit amet est Neque pecun modut neque Consectetuer arcu ipsum ornare pellentesque vehicula, in vehicula diam, ornare magna erat felis wisi a risus. Justo fermentum id. Malesuada eleifend, tortor molestie, a fusce a vel et. Mauris at suspendisse, neque aliquam faucibus adipiscing, vivamus in. Wisi mattis leo suscipit nec amet, nisl fermentum tempor ac a, augue in eleifend in venenatis, cras sit id in vestibulum felis. Molestie ornare amet vel id fusce, rem volutpat platea. Magnis vel, lacinia nisl, vel nostra nunc eleifend arcu leo, in dignissim lorem vivamus laoreet. NO COMMENT.The software craftsman claimed to have discovered that a set of principles could be abbreviated “SOLID”, declined to comment on the matter. Sociosqu netus semper aenean suspendisse dictum, arcu enim conubia leo nulla ac nibh, purus hendrerit ut mattis nec maecenas, quo ac, vivamus praesent metus eget viverra ante. Natoque placerat sed sit hendrerit, dapibus eleifend velit molestiae leo a, ut lorem sit et lacus aliquam. Sodales nulla erat et luctus faucibus aperiam sapien. Leo inceptos augue nec pulvinar rutrum aliquam mauris, wisi hasellus fames ac, commodo eligendi dictumst, dapibus morbi auctor. Ut enim ad minim veniam, quis nostrud exerc. Irure dolor in reprehend incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse molestaie cillum. Tia non ob ea soluad incommod quae egen ium improb fugiend. Officia deserunt mollit anim id est laborum Et harumd dereud. Donec arcu risus diam amet sit. Congue tortor cursus risus vestibulum commodo nisl, luctus augue amet quis aenean odio etiammaecenas sit, donec velit iusto, morbi felis elit et nibh. Vestibulum volutpat dui lacus consectetuer ut, mauris at etiam suspendisse, eu wisi rhoncus eget nibh velit, eget posuere sem in a sit.

    6. e Bristol Dictionary of Concise English

    7. prin·ci·ple /ˈprinsəpəl/ Noun 1. a fundamental truth or proposition that serves as the foundation for a system of belief or behaviour or for a chain of reasoning. 2. morally correct behaviour and attitudes. 3. a general scientifc theorem or law that has numerous special applications across a wide feld. 4. a natural law forming the basis for the construction or working of a machine. para·skevi·de·katri·a·ph o·bia /ˈpærəskevidekaˈtriəˈfōbēə/Adjective, Noun 1. fear of Friday the 13th. Etymology: e word was devised Donald Dossey who told his patients that "when you learn to pronounce it, you're cured. by Dr.

    8. The FLUID Principles Guidelines Kevlin Henney Anders Norås

    9. What are the F U D L I Guidelines?

    10. F L U I D

    11. F L U I D

    12. Functional

    13. Java public class HeatingSystem { public void turnOn() ... public void turnOff() ... ... } public class Timer { public Timer(TimeOfDay toExpire, Runnable toDo) ... public void run() ... public void cancel() ... ... }

    14. Java public 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(); } }

    15. Java Timer turningOn = new Timer(timeOn, new TurnOn(heatingSystem)); Timer turningOff = new Timer(timeOff, new TurnOff(heatingSystem));

    16. Java Timer turningOn = new Timer( timeToTurnOn, new Runnable() { public void run() { heatingSystem.turnOn(); } }); Timer turningOff = new Timer( timeToTurnOff, new Runnable() { public void run() { heatingSystem.turnOff(); } });

    17. C++ void turnOn(void * toTurnOn) { static_cast<HeatingSystem *>(toTurnOn)->turnOn(); } void turnOff(void * toTurnOff) { static_cast<HeatingSystem *>(toTurnOff)->turnOff(); }

    18. C++ Timer turningOn(timeOn, &heatingSystem, turnOn); Timer turningOff(timeOff, &heatingSystem, turnOff);

    19. C++ class Timer { Timer(TimeOfDay toExpire, function<void()> toDo); void run(); void cancel(); ... };

    20. C++ Timer turningOn( timeOn, bind( &HeatingSystem::turnOn, &heatingSystem); Timer turningOff( timeOff, bind( &HeatingSystem::turnOff, &heatingSystem);

    21. C# public class Timer { public Timer( TimeOfDay toExpire, Action toDo) ... public void Run() ... public void Cancel() ... ... }

    22. C# Timer turningOn = new Timer( timeOn, () => heatingSystem.TurnOn() ); Timer turningOff = new Timer( timeOff, () => heatingSystem.TurnOff() );

    23. C# Timer turningOn = new Timer( timeOn, heatingSystem.TurnOn ); Timer turningOff = new Timer( timeOff, heatingSystem.TurnOff );

    24. F L U I D unctional

    25. F L U I D unctional

    26. Loose

    27. 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 I'm not aware of them. •Allan Kay

    28. 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 everybody's world!\n"); }

    29. Groovy class HeatingSystem { def turnOn() { ... } def turnOff() { ... } } def heater = new HeatingSystem() def timer = new Timer() def action = "turnOn" timer.runAfter(1000) { heater."$action"() }

    30. PHP class DiyStore { private $_bucket; public function getPaintBucket() { if ($this->_bucket === null) { $this->_bucket = $this->fillPaintBucket(); } return $this->_bucket; } private function fillPaintBucket() { // ... } }

    31. Ruby NullObject.new().say().hello().to(). any().method_call().you().like()

    32. The FLUID Principles Guidelines Suggestions Kevlin Henney Anders Norås

    33. F L unctional oose U I D

    34. F L unctional oose U I D

    35. Unit Testable

    36. PowerShell function 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] }

    37. 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")

    38. PowerShell $inputsWithExpectations | ?{ [String] $actual = GetNextFriday13th($_[0]) [String] $expected = $_[1] $actual -ne $expected }

    39. F L U I D unctional oose nit Testable

    40. F L U I D unctional oose nit Testable

    41. Introspective

    42. 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))))

    43. JavaScript function 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); }; };

    44. Visual Basic Public 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 End Class <RelatedTo(RelatedProperty := Books, Key := AuthorSSN, RelatedKey := SSN)> _ Public Property Author() As Person ' ... End Property

    45. F L U I D unctional oose nit Testable ntrospective

    46. F L U I D unctional oose nit Testable ntrospective

    47. ‘Dempotent