TDD et Erlang. Nicolas Charpentier - Dominic Williams. 30 Mars 2009. charpi.net - dominicwilliams.net



Similar documents
Liste d'adresses URL

Introduction. GEAL Bibliothèque Java pour écrire des algorithmes évolutionnaires. Objectifs. Simplicité Evolution et coévolution Parallélisme

Introduction au BIM. ESEB Seyssinet-Pariset Economie de la construction contact@eseb.fr

Les Broadcast Receivers...

Calcul parallèle avec R

Langages Orientés Objet Java

BUSINESS PROCESS OPTIMIZATION. OPTIMIZATION DES PROCESSUS D ENTERPRISE Comment d aborder la qualité en améliorant le processus

TP1 : Correction. Rappels : Stream, Thread et Socket TCP

Fondation Rennes 1. Atelier de l innovation. Fondation Rennes 1. Fondation Rennes 1 MANAGEMENT AGILE. Fondation Rennes 1 ET INNOVATION

The Need For Speed. leads to PostgreSQL. Dimitri Fontaine 28 Mars 2013

System Requirements Orion

POB-JAVA Documentation

Stockage distribué sous Linux

Introduction Les failles les plus courantes Les injections SQL. Failles Web. Maxime Arthaud. net7. Jeudi 03 avril 2014.

BILL C-665 PROJET DE LOI C-665 C-665 C-665 HOUSE OF COMMONS OF CANADA CHAMBRE DES COMMUNES DU CANADA

site et appel d'offres

Thursday, February 7, DOM via PHP

MapReduce Détails Optimisation de la phase Reduce avec le Combiner

Thursday, June 12 th, Food Security Network of Newfoundland and Labrador

«Object-Oriented Multi-Methods in Cecil» Craig Chambers (Cours IFT6310, H08)

Modifier le texte d'un élément d'un feuillet, en le spécifiant par son numéro d'index:

General Certificate of Education Advanced Level Examination June 2012

sept-2002 Computer architecture and software cells for broadband networks Va avec

Upgrading the Solaris PC NetLink Software

Sun Management Center Change Manager Release Notes

First-half 2012 Results. August 29 th, Jean-Paul AGON. Chairman and CEO

1. CANADA DAY 2012 PARKING LOT PARTIES IN THE BYWARD MARKET FÊTE DU CANADA 2012 CÉLÉBRATIONS TENUES DANS LE PARC DE STATIONNEMENT DU MARCHÉ BY

Account Manager H/F - CDI - France

Short Form Description / Sommaire: Carrying on a prescribed activity without or contrary to a licence

Keep in touch FINANCIAL COMMUNICATIONS. Thierry Prévot Group General Manager, Financial Communications & Strategic Prospective Analysis

Sun StorEdge A5000 Installation Guide

Sun Cluster 2.2 7/00 Data Services Update: Apache Web Server

State of Maryland Health Insurance Exchange

Memory Eye SSTIC Yoann Guillot. Sogeti / ESEC R&D yoann.guillot(at)sogeti.com

Audit de sécurité avec Backtrack 5

Strategic Workforce Planning and Competency Management at Schneider Electric

Survey on Conference Services provided by the United Nations Office at Geneva

Setting up a monitoring and remote control tool

Archived Content. Contenu archivé

Technical Service Bulletin

Vincent Rullier Technology specialist Microsoft Suisse Romande

Optimizing Solaris Resources Through Load Balancing

The power of co-creation. Jean Marc Devanne CEO CoManaging

USER Guide. ECONOMIX Solution. New Module - Purchases online. Purchases Online. User Guide ECONOMIX SYSTÈME INC. Tous droits réservés.

ExempleRMI.java. // Fichier de defintion des droits et proprietes // System.setProperty("java.security.policy","../server.java.

Archived Content. Contenu archivé

Archived Content. Contenu archivé

How To Set Up Vsftpd On A Pc Or Mac Or Mac (For Mac) On A Mac Or Ipa (For Pc Or Ipad) On Pc Or Pc Or Pb (For Ipa) On An Ipa Or Mac

Monitoring Open Source pour Java avec JmxTrans, Graphite et Nagios

Toolkit in OPen-source for Critical Applications & SystEms Development

Cours de Java. Sciences-U Lyon. Java - Introduction Java - Fondamentaux Java Avancé.

Le Cloud Computing selon IBM : stratégie et offres, zoom sur WebSphere CloudBurst

In-Home Caregivers Teleconference with Canadian Bar Association September 17, 2015

Archived Content. Contenu archivé

Archived Content. Contenu archivé

RAPPORT FINANCIER ANNUEL PORTANT SUR LES COMPTES 2014

Sun StorEdge RAID Manager Release Notes

Managing the Knowledge Exchange between the Partners of the Supply Chain

Sun TM SNMP Management Agent Release Notes, Version 1.6

Archived Content. Contenu archivé

AgroMarketDay. Research Application Summary pp: Abstract

Request for Proposals and Electronic Communities

Remote Method Invocation

Newsletter. Le process Lila - The Lila process 5 PARTNERS 2 OBSERVERS. October Product. Objectif du projet / Project objective

"Internationalization vs. Localization: The Translation of Videogame Advertising"

Sun StorEdge Availability Suite Software Point-in-Time Copy Software Maximizing Backup Performance

Installation troubleshooting guide

ESMA REGISTERS OJ/26/06/2012-PROC/2012/004. Questions/ Answers

Personnalisez votre intérieur avec les revêtements imprimés ALYOS design

VIREMENTS BANCAIRES INTERNATIONAUX

Sun Enterprise Optional Power Sequencer Installation Guide

CSS : petits compléments

Power Distribution System. Additional Information on page 2 See Page 2 Page 6. Eaton. See Page 2. Additional Information on page 2

REVOCABILITY. Contact: Lars MEINHARDT, Telephone:(32-2) ,

You can choose to install the plugin through Magento Connect or by directly using the archive files.

Sun Management Center 3.6 Version 5 Add-On Software Release Notes

Direct AC Wiring Option Installation Guide

Archived Content. Contenu archivé

Measuring Policing Complexity: A Research Based Agenda

Introduction Présentation de scapy. Scapy. Easy Packet Handling. Etienne Maynier. Capitole du Libre 24 Novembre 2012

Cliquez sur le résultat que vous avez obtenu au test de classement linguistique Click on the result you obtained following the language test

Reconstruction d un modèle géométrique à partir d un maillage 3D issu d un scanner surfacique

Qu est-ce que le Cloud? Quels sont ses points forts? Pourquoi l'adopter? Hugues De Pra Data Center Lead Cisco Belgium & Luxemburg

Les fragments. Programmation Mobile Android Master CCI. Une application avec deux fragments. Premier layout : le formulaire

Asset management in urban drainage

Chapter 6, page 1 of 12 Letter Carrier Route Measurement System Manual. Chapter 6 Householder Time Allowance (form )

Commutative Replicated Data Types for the Semantic Web. Pascal Molli Kickoff Kolflow Feb 2011

Licence Informatique Année Exceptions

N1 Grid Service Provisioning System 5.0 User s Guide for the Linux Plug-In

Enterprise Informa/on Modeling: An Integrated Way to Track and Measure Asset Performance

Web - Travaux Pratiques 1

STAT SHEET PROFESSIONAL INSTITUTE OF THE PUBLIC SERVICE OF CANADA

Jimmy Hébergement Cloud - TechDay

IPv6 Workshop: Location Date Security Trainer Name

Altiris Patch Management Solution for Windows 7.6 from Symantec Third-Party Legal Notices

SunFDDI 6.0 on the Sun Enterprise Server

Sun SNMP Management Agent Release Notes, Version 1.5.5

Comparing JavaServer Pages Technology and Microsoft Active Server Pages

Solaris 10 Documentation README

Linux A multi-purpose executive support for civil avionics applications?

Transcription:

TDD et Erlang Nicolas Charpentier - Dominic Williams charpi.net - dominicwilliams.net 30 Mars 2009 c N.Charpentier - D.Williams TDD et Erlang 1/23

Pourquoi certaines startups s interessent elles à Erlang Google, Amazon, Apache, EngineYard,... c N.Charpentier - D.Williams TDD et Erlang 2/23

Pensez différement, pensez Erlang c N.Charpentier - D.Williams TDD et Erlang 3/23

Besoin de scalabilité? Envie de simplicité? Pensez Erlang c N.Charpentier - D.Williams TDD et Erlang 4/23

Well, there are agile languages and agile methods. When you put the two together you get agile squared. Ward Cunningham c N.Charpentier - D.Williams TDD et Erlang 5/23

Le problème des objets Programmation fonctionnelle Tests canoniques assertequals ( Hello, s u b s t r i n g ( 5, Hello world ) ) ; assertequals ( o r l d, s u b s t r i n g ( 4, Hello world ) ) ; assertequals (, s u b s t r i n g ( 0, Hello world ) ) ; assertequals (, s u b s t r i n g ( 5, ) ) ; assertequals (, s u b s t r i n g ( 5, NULL ) ) ; c N.Charpentier - D.Williams TDD et Erlang 6/23

Le problème des objets Programmation fonctionnelle Initialisation des objets public void testselftestdircanbeset ( ) { f i n a l RemoteControlConfiguration c o n f i g u r a t i o n ; f i n a l F i l e a D i r e c t o r y ; } c o n f i g u r a t i o n = new RemoteControlConfiguration ( ) ; a D i r e c t o r y = new F i l e ( \ A D i r e c t o r y Name\ ) ; c o n f i g u r a t i o n. s e t S e l f T e s t D i r ( a D i r e c t o r y ) ; assertequals ( adirectory, c o n f i g u r a t i o n. g e t S e l f T e s t D i r ( ) ) ; OpenQA - Selenium server c N.Charpentier - D.Williams TDD et Erlang 7/23

Le problème des objets Programmation fonctionnelle Des objets comme valeur de retour public void testbrowserstartcommandmatchwhenbrowserstringisthebrowsername ( ) { f i n a l BrowserStringParser. Result r e s u l t ; r e s u l t = new BrowserStringParser ( ). parsebrowserstartcommand ( f i r e f o x, f i r e f o x ) ; asserttrue ( r e s u l t. match ( ) ) ; a s s e r t N u l l ( r e s u l t. customlauncher ( ) ) ; } OpenQA - Selenium server c N.Charpentier - D.Williams TDD et Erlang 8/23

Le problème des objets Programmation fonctionnelle Propagation public void testmatch ( ) throws Exception { RowFixture f i x t u r e = new TestRowFixture ( ) ; TypeAdapter arrayadapter = TypeAdapter. on ( fixture, BusinessObject. class. getmethod ( getstrings, new Class [ 0 ] ) ) ; f i x t u r e. columnbindings = new TypeAdapter [ ] { arrayadapter }; LinkedList computed = new LinkedList ( ) ; computed. add (new BusinessObject (new S t r i n g [ ] { 1 } ) ) ; LinkedList expected = new LinkedList ( ) ; expected. add (new Parse ( t r,,new Parse ( td, 1, null, n u l l ), n u l l ) ) ; f i x t u r e. match ( expected, computed, 0 ) ; assertequals ( r i g h t, 1, f i x t u r e. counts. r i g h t ) ; assertequals ( exceptions, 0, f i x t u r e. counts. exceptions ) ; assertequals ( missing, 0, f i x t u r e. missing. size ( ) ) ; assertequals ( surplus, 0, f i x t u r e. surplus. size ( ) ) ; } Cunningham & Cunningham, Inc. - Fit c N.Charpentier - D.Williams TDD et Erlang 9/23

Le problème des objets Programmation fonctionnelle Héritage, interfaces c N.Charpentier - D.Williams TDD et Erlang 10/23

Le problème des objets Programmation fonctionnelle Structure de données dynamique t e s t s e l f d i r c a n b e s e t ( ) > Name = c o n f i g u r a t i o n : get ( s e l f d i r, [ { s e l f d i r, Name } ] ). c N.Charpentier - D.Williams TDD et Erlang 11/23

Le problème des objets Programmation fonctionnelle Filtrage (Pattern Matching) Author = Knuth, Knuth = Author, Author = D i j k s t r a, %% e x i t : badmatch... Book = { 123, Author, The A r t of Programming }, { 123, Knuth, The A r t of Programming } = Book, { Id,, T i t l e } = Book, 123 = Id, The A r t of Programming = T i t l e. c N.Charpentier - D.Williams TDD et Erlang 12/23

Le problème des objets Programmation fonctionnelle Programmation déclarative Le test module ( xpday test ). export ( [ run /0 ] ). run ( [ ] ) > [ ] = xpday : odd ( [ ] ), [ 3 ] = xpday : odd ( [ 3 ] ), [ 3,5,7,9 ] = xpday : odd ( [ 3,2,4,5,6,7,8,9 ] ). c N.Charpentier - D.Williams TDD et Erlang 13/23

Le problème des objets Programmation fonctionnelle Programmation déclarative Le code module ( xpday ). export ( [ odd /1 ] ). odd ( [ ] ) > [ ] ; odd ( [ Value Values ] ) when Value rem 2 == 1 > [ Value odd ( Values ) ] ; odd ( [ Values ] ) > odd ( Values ). c N.Charpentier - D.Williams TDD et Erlang 13/23

Le problème des objets Programmation fonctionnelle Lambda, the ultimate mock Le test module ( xpday2 test ). export ( [ run /0 ] ). run ( [ ] ) > [ ] = xpday2 : f i l t e r ( [ ], fun ( ) > true end ), [ 3 ] = xpday2 : f i l t e r ( [ 3 ], fun ( 3 ) > true end ), Datas = [ 3,2,4,5,6,7,8,9 ], Is odd = fun (X) when X rem 2 == 1 > true ; ( ) > false end, [ 3,5,7,9 ] = xpday2 : f i l t e r ( Datas, Is odd ). c N.Charpentier - D.Williams TDD et Erlang 14/23

Le problème des objets Programmation fonctionnelle Lambda, the ultimate mock Le code module ( xpday2 ). export ( [ f i l t e r /2 ] ). f i l t e r ( [ ], ) > [ ] ; f i l t e r ( [ Value Values ], P r e d i c a t ) > F i l t e r = case P r e d i c a t ( Value ) of true > Value ; > [ ] end, [ F i l t e r f i l t e r ( Values, P r e d i c a t ) ]. c N.Charpentier - D.Williams TDD et Erlang 14/23

Mémoire partagée Messages Pourquoi la concurrence Interactivité des IHM Améliorer les performances Multi-coeur c N.Charpentier - D.Williams TDD et Erlang 15/23

Mémoire partagée Messages Threads à mémoire partagée Modèle dominant Processus légers Ressources partagées, notamment mémoire Non-déterminisme: situations de compétition (race) interblocages (deadlocks) c N.Charpentier - D.Williams TDD et Erlang 16/23

Mémoire partagée Messages Tests de threads Vérifier que c est parallèle seulement possible si le thread à tester peut être ralenti nécessite de créer des threads dans le test Vérifier que c est ré-entrant. C est le plus dur: le non-déterminisme est causé par le reste du programme on ne peut pas contrôler l ordonnanceur Tests illisibles et sans valeur documentaire c N.Charpentier - D.Williams TDD et Erlang 17/23

Mémoire partagée Messages Acteurs, ou processus communicants par messages Depuis 1978 et CSP (Hoare): processus légers isolés envoi de messages Parfaitement déterministe Simple et compréhensible c N.Charpentier - D.Williams TDD et Erlang 18/23

Mémoire partagée Messages Acteurs en Erlang Trois primitives spawn! (envoi de messages) receive (réception de messages et synchronisation) Identique pour process locaux ou distribués L écriture de tests devient simplissime c N.Charpentier - D.Williams TDD et Erlang 19/23

Mémoire partagée Messages TDD de process Erlang: le test run ( ) > Counter = spawn ( counter, count, [ 1 ] ), Counter! { s e l f ( ), next }, 1 = next ( Counter ), Counter! { s e l f ( ), next }, 2 = next ( Counter ), pass. next ( Counter ) > receive { Counter, Next} > Next a f t e r 100 > timeout end. c N.Charpentier - D.Williams TDD et Erlang 20/23

Mémoire partagée Messages TDD de process Erlang: le code module ( counter ). export ( [ count /1 ] ). count ( Number ) > receive {From, next } > From! { s e l f ( ), Number}, count ( Number + 1) end. c N.Charpentier - D.Williams TDD et Erlang 21/23

Mémoire partagée Messages I m sorry that I long ago coined the term objects for this topic because it gets many people to focus on the lesser idea. The big idea is messaging. Alan Kay c N.Charpentier - D.Williams TDD et Erlang 22/23

Retrouvez plus d information sur http://dominicwilliams.net http://charpi.net c N.Charpentier - D.Williams TDD et Erlang 23/23