SlideShare ist ein Scribd-Unternehmen logo
1 von 89
Downloaden Sie, um offline zu lesen
ndc 2011
The

FLUID Principles
          Kevlin Henney
          Anders Norås
FLUID
contrasts with

  SOLID
S
O
L
I
D
S   ingle Responsibility Principle


O   pen / Closed Principle

L   iskov’s Substitution Principle


I   nterface Segregation Principle


D   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. 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        Etiam sit amet est
cillum. Tia non ob ea soluad incommod quae
egen ium improb fugiend. Officia deserunt
mollit anim id est laborum Et harumd dereud.

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   NO COMMENT. The software craftsman claimed to have discovered that a set of
at suspendisse, neque aliquam faucibus                principles could be abbreviated “SOLID”, declined to comment on the matter.
adipiscing, vivamus in. Wisi mattis leo suscipit
nec amet, nisl fermentum tempor ac a, augue in
                                                       Sociosqu netus semper aenean                 Ut enim ad minim veniam, quis nostrud
eleifend in venenatis, cras sit id in vestibulum
                                                       suspendisse dictum, arcu enim conubia        exerc. Irure dolor in reprehend
felis. Molestie ornare amet vel id fusce, rem
                                                       leo nulla ac nibh, purus hendrerit ut        incididunt ut labore et dolore magna
volutpat platea. Magnis vel, lacinia nisl, vel
                                                       mattis nec maecenas, quo ac, vivamus         aliqua. Ut enim ad minim veniam, quis
nostra nunc eleifend arcu leo, in dignissim
                                                       praesent metus eget viverra ante.            nostrud exercitation ullamco laboris nisi
lorem 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 in
Donec arcu risus diam amet sit. Congue tortor
                                                       lorem sit et lacus aliquam. Sodales nulla    voluptate velit esse molestaie cillum. Tia
cursus risus vestibulum commodo nisl, luctus
                                                       erat et luctus faucibus aperiam sapien.      non ob ea soluad incommod quae egen
augue amet quis aenean odio etiammaecenas sit,
                                                       Leo inceptos augue nec pulvinar rutrum       ium improb fugiend. Officia deserunt
donec velit iusto, morbi felis elit et nibh.
                                                       aliquam mauris, wisi hasellus fames ac,      mollit anim id est laborum Et harumd
Vestibulum 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
 Bristol
Dictionary
     of
 Concise
 English
prin·ci·ple /ˈprinsəpəl/
                 Noun       4. a natural law forming
1. a fundamental truth      the basis for the
or prop osit ion t hat      construction or working
serves as the foundation    of a machine.
for a system of belief or
behaviour or for a chain
of reasoning.               para·skevi·de·katri·a·ph
                            o·bia /ˈpærəskevidekaˈtriəˈfōbēə/
                                                     Adjective, Noun

2. morally correct
behaviour and attitudes.    1. fear of Friday the
                            13th.
3. a general scienti c          Etymology: e word
theorem or law that has
numerous special            was devised by Dr.
applications across a       Donald Dossey who told
wide eld.                   his patients that "when
                            you learn to pronounce
                            it, you're cured.
The

FLUID Principles
          Kevlin Henney
          Anders Norås
The

FLUID Guidelines
          Kevlin Henney
          Anders Norås
What are the
F L U I D
  Guidelines?
F
L
U
I
D
F
L
U
I
D
Functional
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() ...
  ...
}
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();
  }
}
Java
Timer turningOn =
  new Timer(timeOn, new TurnOn(heatingSystem));
Timer turningOff =
  new Timer(timeOff, new TurnOff(heatingSystem));
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();
        }
    });
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   unctional


L
U
I
D
F   unctional


L
U
I
D
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 I'm 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 everybody's world!n");
}
Groovy

class HeatingSystem {
  def turnOn() { ... }
  def turnOff() { ... }
}
def heater = new HeatingSystem()
def timer = new Timer()
def action = "turnOn"
timer.runAfter(1000) {
  heater."$action"()
}
PHP
class DiyStore
{
   private $_bucket;
   public function getPaintBucket()
   {
      if ($this->_bucket === null) {
          $this->_bucket = $this->fillPaintBucket();

      }
      return $this->_bucket;
    }
    private function fillPaintBucket() {
       // ...
    }
}
Ruby

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

FLUID Principles
          Kevlin Henney
          Anders Norås
The

FLUID Suggestions
            Kevlin Henney
            Anders Norås
F   unctional


L   oose


U
I
D
F   unctional


L   oose


U
I
D
Unit Testable
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]
}
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   unctional


L   oose


U   nit Testable


I
D
F   unctional


L   oose


U   nit Testable


I
D
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))))
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);
    };
};
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

   <RelatedTo(RelatedProperty := Books, Key := AuthorSSN, RelatedKey := SSN)> _
   Public Property Author() As Person
      ' ...
   End Property
End Class
F   unctional


L   oose


U   nit Testable


I   ntrospective


D
F   unctional


L   oose


U   nit Testable


I   ntrospective


D
‘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    unctional


L    oose


U    nit Testable


I    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 — objects
are merely a poor man's closures."
   Chastised, Anton took his leave from his master and returned to his cell,
intent on studying closures. He carefully read the entire "Lambda: e
Ultimate..." series of papers and its cousins, and implemented a small
Scheme 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 by
saying "Master, I have diligently studied the matter, and now understand
that objects are truly a poor man's closures."
Qc Na responded by hitting Anton with his stick, saying "When will you
learn? Closures are a poor man's object." At that moment, Anton became
enlightened.

                              http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/msg03277.html
@kevlinhenney
  @anoras

Weitere ähnliche Inhalte

Ähnlich wie NDC 2011 - The FLUID Principles

Questioning the status quo
Questioning the status quoQuestioning the status quo
Questioning the status quoIvano Pagano
 
PhoneGap Day US 2013 - Simon MacDonald: Speech Recognition
PhoneGap Day US 2013 - Simon MacDonald: Speech RecognitionPhoneGap Day US 2013 - Simon MacDonald: Speech Recognition
PhoneGap Day US 2013 - Simon MacDonald: Speech RecognitionPhoneGap
 
Welcome to the Flink Community!
Welcome to the Flink Community!Welcome to the Flink Community!
Welcome to the Flink Community!Flink Forward
 
You shouldneverdo
You shouldneverdoYou shouldneverdo
You shouldneverdodaniil3
 
Docker Inside/Out: The 'Real' Real- World World of Stacking Containers in pro...
Docker Inside/Out: The 'Real' Real- World World of Stacking Containers in pro...Docker Inside/Out: The 'Real' Real- World World of Stacking Containers in pro...
Docker Inside/Out: The 'Real' Real- World World of Stacking Containers in pro...Sonatype
 
DevDay.lk - Bare Knuckle Web Development
DevDay.lk - Bare Knuckle Web DevelopmentDevDay.lk - Bare Knuckle Web Development
DevDay.lk - Bare Knuckle Web DevelopmentJohannes Brodwall
 
Design and Evolution of cyber-dojo
Design and Evolution of cyber-dojoDesign and Evolution of cyber-dojo
Design and Evolution of cyber-dojoJon Jagger
 
Seven Ineffective Coding Habits of Many Programmers
Seven Ineffective Coding Habits of Many ProgrammersSeven Ineffective Coding Habits of Many Programmers
Seven Ineffective Coding Habits of Many ProgrammersKevlin Henney
 
Causal inference-for-profit | Dan McKinley | DN18
Causal inference-for-profit | Dan McKinley | DN18Causal inference-for-profit | Dan McKinley | DN18
Causal inference-for-profit | Dan McKinley | DN18DataconomyGmbH
 
DN18 | A/B Testing: Lessons Learned | Dan McKinley | Mailchimp
DN18 | A/B Testing: Lessons Learned | Dan McKinley | MailchimpDN18 | A/B Testing: Lessons Learned | Dan McKinley | Mailchimp
DN18 | A/B Testing: Lessons Learned | Dan McKinley | MailchimpDataconomy Media
 
Dear compiler please don't be my nanny v2
Dear compiler  please don't be my nanny v2Dear compiler  please don't be my nanny v2
Dear compiler please don't be my nanny v2Dino Dini
 
Microservices 5 things i wish i'd known java with the best 2018
Microservices 5 things i wish i'd known   java with the best 2018Microservices 5 things i wish i'd known   java with the best 2018
Microservices 5 things i wish i'd known java with the best 2018Vincent Kok
 
Microservices 5 Things I Wish I'd Known - JFall 2017
Microservices 5 Things I Wish I'd Known - JFall 2017Microservices 5 Things I Wish I'd Known - JFall 2017
Microservices 5 Things I Wish I'd Known - JFall 2017Vincent Kok
 
streamparse and pystorm: simple reliable parallel processing with storm
streamparse and pystorm: simple reliable parallel processing with stormstreamparse and pystorm: simple reliable parallel processing with storm
streamparse and pystorm: simple reliable parallel processing with stormDaniel Blanchard
 
Seven Ineffective Coding Habits of Many Programmers
Seven Ineffective Coding Habits of Many ProgrammersSeven Ineffective Coding Habits of Many Programmers
Seven Ineffective Coding Habits of Many ProgrammersKevlin Henney
 
Your Library Sucks, and why you should use it.
Your Library Sucks, and why you should use it.Your Library Sucks, and why you should use it.
Your Library Sucks, and why you should use it.Peter Higgins
 
The hunt of the unicorn, to capture productivity
The hunt of the unicorn, to capture productivityThe hunt of the unicorn, to capture productivity
The hunt of the unicorn, to capture productivityBrainhub
 
Codeception Testing Framework -- English #phpkansai
Codeception Testing Framework -- English #phpkansaiCodeception Testing Framework -- English #phpkansai
Codeception Testing Framework -- English #phpkansaiFlorent Batard
 

Ähnlich wie NDC 2011 - The FLUID Principles (20)

Questioning the status quo
Questioning the status quoQuestioning the status quo
Questioning the status quo
 
PhoneGap Day US 2013 - Simon MacDonald: Speech Recognition
PhoneGap Day US 2013 - Simon MacDonald: Speech RecognitionPhoneGap Day US 2013 - Simon MacDonald: Speech Recognition
PhoneGap Day US 2013 - Simon MacDonald: Speech Recognition
 
Welcome to the Flink Community!
Welcome to the Flink Community!Welcome to the Flink Community!
Welcome to the Flink Community!
 
You shouldneverdo
You shouldneverdoYou shouldneverdo
You shouldneverdo
 
Docker Inside/Out: The 'Real' Real- World World of Stacking Containers in pro...
Docker Inside/Out: The 'Real' Real- World World of Stacking Containers in pro...Docker Inside/Out: The 'Real' Real- World World of Stacking Containers in pro...
Docker Inside/Out: The 'Real' Real- World World of Stacking Containers in pro...
 
DevDay.lk - Bare Knuckle Web Development
DevDay.lk - Bare Knuckle Web DevelopmentDevDay.lk - Bare Knuckle Web Development
DevDay.lk - Bare Knuckle Web Development
 
Design and Evolution of cyber-dojo
Design and Evolution of cyber-dojoDesign and Evolution of cyber-dojo
Design and Evolution of cyber-dojo
 
Seven Ineffective Coding Habits of Many Programmers
Seven Ineffective Coding Habits of Many ProgrammersSeven Ineffective Coding Habits of Many Programmers
Seven Ineffective Coding Habits of Many Programmers
 
Causal inference-for-profit | Dan McKinley | DN18
Causal inference-for-profit | Dan McKinley | DN18Causal inference-for-profit | Dan McKinley | DN18
Causal inference-for-profit | Dan McKinley | DN18
 
DN18 | A/B Testing: Lessons Learned | Dan McKinley | Mailchimp
DN18 | A/B Testing: Lessons Learned | Dan McKinley | MailchimpDN18 | A/B Testing: Lessons Learned | Dan McKinley | Mailchimp
DN18 | A/B Testing: Lessons Learned | Dan McKinley | Mailchimp
 
Dear compiler please don't be my nanny v2
Dear compiler  please don't be my nanny v2Dear compiler  please don't be my nanny v2
Dear compiler please don't be my nanny v2
 
Microservices 5 things i wish i'd known java with the best 2018
Microservices 5 things i wish i'd known   java with the best 2018Microservices 5 things i wish i'd known   java with the best 2018
Microservices 5 things i wish i'd known java with the best 2018
 
Microservices 5 Things I Wish I'd Known - JFall 2017
Microservices 5 Things I Wish I'd Known - JFall 2017Microservices 5 Things I Wish I'd Known - JFall 2017
Microservices 5 Things I Wish I'd Known - JFall 2017
 
streamparse and pystorm: simple reliable parallel processing with storm
streamparse and pystorm: simple reliable parallel processing with stormstreamparse and pystorm: simple reliable parallel processing with storm
streamparse and pystorm: simple reliable parallel processing with storm
 
Seven Ineffective Coding Habits of Many Programmers
Seven Ineffective Coding Habits of Many ProgrammersSeven Ineffective Coding Habits of Many Programmers
Seven Ineffective Coding Habits of Many Programmers
 
Killer Bugs From Outer Space
Killer Bugs From Outer SpaceKiller Bugs From Outer Space
Killer Bugs From Outer Space
 
Your Library Sucks, and why you should use it.
Your Library Sucks, and why you should use it.Your Library Sucks, and why you should use it.
Your Library Sucks, and why you should use it.
 
The hunt of the unicorn, to capture productivity
The hunt of the unicorn, to capture productivityThe hunt of the unicorn, to capture productivity
The hunt of the unicorn, to capture productivity
 
Codeception Testing Framework -- English #phpkansai
Codeception Testing Framework -- English #phpkansaiCodeception Testing Framework -- English #phpkansai
Codeception Testing Framework -- English #phpkansai
 
Progressing and enhancing
Progressing and enhancingProgressing and enhancing
Progressing and enhancing
 

Kürzlich hochgeladen

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 

Kürzlich hochgeladen (20)

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

NDC 2011 - The FLUID Principles

  • 2.
  • 3. The FLUID Principles Kevlin Henney Anders Norås
  • 5.
  • 7. S ingle Responsibility Principle O pen / Closed Principle L iskov’s Substitution Principle I nterface Segregation Principle D ependency Inversion Principle
  • 8. “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. 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 Etiam sit amet est cillum. Tia non ob ea soluad incommod quae egen ium improb fugiend. Officia deserunt mollit anim id est laborum Et harumd dereud. 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 NO COMMENT. The software craftsman claimed to have discovered that a set of at suspendisse, neque aliquam faucibus principles could be abbreviated “SOLID”, declined to comment on the matter. adipiscing, vivamus in. Wisi mattis leo suscipit nec amet, nisl fermentum tempor ac a, augue in Sociosqu netus semper aenean Ut enim ad minim veniam, quis nostrud eleifend in venenatis, cras sit id in vestibulum suspendisse dictum, arcu enim conubia exerc. Irure dolor in reprehend felis. Molestie ornare amet vel id fusce, rem leo nulla ac nibh, purus hendrerit ut incididunt ut labore et dolore magna volutpat platea. Magnis vel, lacinia nisl, vel mattis nec maecenas, quo ac, vivamus aliqua. Ut enim ad minim veniam, quis nostra nunc eleifend arcu leo, in dignissim praesent metus eget viverra ante. nostrud exercitation ullamco laboris nisi lorem 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 in Donec arcu risus diam amet sit. Congue tortor lorem sit et lacus aliquam. Sodales nulla voluptate velit esse molestaie cillum. Tia cursus risus vestibulum commodo nisl, luctus erat et luctus faucibus aperiam sapien. non ob ea soluad incommod quae egen augue amet quis aenean odio etiammaecenas sit, Leo inceptos augue nec pulvinar rutrum ium improb fugiend. Officia deserunt donec velit iusto, morbi felis elit et nibh. aliquam mauris, wisi hasellus fames ac, mollit anim id est laborum Et harumd Vestibulum 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.
  • 9.
  • 10.
  • 11. e Bristol Dictionary of Concise English
  • 12. prin·ci·ple /ˈprinsəpəl/ Noun 4. a natural law forming 1. a fundamental truth the basis for the or prop osit ion t hat construction or working serves as the foundation of a machine. for a system of belief or behaviour or for a chain of reasoning. para·skevi·de·katri·a·ph o·bia /ˈpærəskevidekaˈtriəˈfōbēə/ Adjective, Noun 2. morally correct behaviour and attitudes. 1. fear of Friday the 13th. 3. a general scienti c Etymology: e word theorem or law that has numerous special was devised by Dr. applications across a Donald Dossey who told wide eld. his patients that "when you learn to pronounce it, you're cured.
  • 13.
  • 14. The FLUID Principles Kevlin Henney Anders Norås
  • 15. The FLUID Guidelines Kevlin Henney Anders Norås
  • 16.
  • 17. What are the F L U I D Guidelines?
  • 20.
  • 21.
  • 23. 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() ... ... }
  • 24. 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(); } }
  • 25. Java Timer turningOn = new Timer(timeOn, new TurnOn(heatingSystem)); Timer turningOff = new Timer(timeOff, new TurnOff(heatingSystem));
  • 26. 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(); } });
  • 27. C++ void turnOn(void * toTurnOn) { static_cast<HeatingSystem *>(toTurnOn)->turnOn(); } void turnOff(void * toTurnOff) { static_cast<HeatingSystem *>(toTurnOff)->turnOff(); }
  • 28. C++ Timer turningOn(timeOn, &heatingSystem, turnOn); Timer turningOff(timeOff, &heatingSystem, turnOff);
  • 29. C++ class Timer { Timer(TimeOfDay toExpire, function<void()> toDo); void run(); void cancel(); ... };
  • 30. C++ Timer turningOn( timeOn, bind( &HeatingSystem::turnOn, &heatingSystem)); Timer turningOff( timeOff, bind( &HeatingSystem::turnOff, &heatingSystem));
  • 31. C# public class Timer { public Timer( TimeOfDay toExpire, Action toDo) ... public void Run() ... public void Cancel() ... ... }
  • 32. C# Timer turningOn = new Timer( timeOn, () => heatingSystem.TurnOn() ); Timer turningOff = new Timer( timeOff, () => heatingSystem.TurnOff() );
  • 33. C# Timer turningOn = new Timer( timeOn, heatingSystem.TurnOn ); Timer turningOff = new Timer( timeOff, heatingSystem.TurnOff );
  • 34.
  • 35.
  • 36.
  • 37. F unctional L U I D
  • 38. F unctional L U I D
  • 39.
  • 40.
  • 41. Loose
  • 42.
  • 43. 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
  • 44. 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"); }
  • 45. Groovy class HeatingSystem { def turnOn() { ... } def turnOff() { ... } } def heater = new HeatingSystem() def timer = new Timer() def action = "turnOn" timer.runAfter(1000) { heater."$action"() }
  • 46. PHP class DiyStore { private $_bucket; public function getPaintBucket() { if ($this->_bucket === null) { $this->_bucket = $this->fillPaintBucket(); } return $this->_bucket; } private function fillPaintBucket() { // ... } }
  • 47.
  • 49. The FLUID Principles Kevlin Henney Anders Norås
  • 50. The FLUID Suggestions Kevlin Henney Anders Norås
  • 51.
  • 52. F unctional L oose U I D
  • 53. F unctional L oose U I D
  • 54.
  • 56.
  • 57. 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] }
  • 58. 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")
  • 59. PowerShell $inputsWithExpectations | ?{ [String] $actual = GetNextFriday13th($_[0]) [String] $expected = $_[1] $actual -ne $expected }
  • 60.
  • 61. F unctional L oose U nit Testable I D
  • 62. F unctional L oose U nit Testable I D
  • 63.
  • 64.
  • 66.
  • 67. 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))))
  • 68. 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); }; };
  • 69. 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 <RelatedTo(RelatedProperty := Books, Key := AuthorSSN, RelatedKey := SSN)> _ Public Property Author() As Person ' ... End Property End Class
  • 70.
  • 71. F unctional L oose U nit Testable I ntrospective D
  • 72. F unctional L oose U nit Testable I ntrospective D
  • 73.
  • 74.
  • 76.
  • 77.
  • 78. Asking a question should not change the answer. •Betrand Meyer
  • 79. Asking a question should not change the answer. •Betrand Meyer
  • 81.
  • 82. F unctional L oose U nit Testable I ntrospective ‘D dempotent
  • 83.
  • 84.
  • 85.
  • 86.
  • 87.
  • 88. 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 — objects are merely a poor man's closures." Chastised, Anton took his leave from his master and returned to his cell, intent on studying closures. He carefully read the entire "Lambda: e Ultimate..." series of papers and its cousins, and implemented a small Scheme 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 by saying "Master, I have diligently studied the matter, and now understand that objects are truly a poor man's closures." Qc Na responded by hitting Anton with his stick, saying "When will you learn? Closures are a poor man's object." At that moment, Anton became enlightened. http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/msg03277.html