SlideShare une entreprise Scribd logo
1  sur  30
Elm et les états impossibles
Mon Model sur-mesure
Nicolas Umiastowski
@n_umiastowski
Mercredi 10 novembre 2016
Approche initiale
Encoding the answered state of a question in the
constructor does mean that you can’t write code that
doesn’t check for whether a question is answered or
not
1
3
2
1
0
Update
Questions répondues
Est-ce que ce sont vraiment des
questions répondues ?
Je peux tester le message qui s’affiche si au moins une
question ne possède pas de answerId
Je veux pouvoir m’assurer que :
si une question est répondue, alors elle a un answerId
Question répondue qui n’a pas de answerId : Possible
Elm- test
Making impossible states impossible :
Le Model est défini de telle sorte que le
compilateur renvoie une erreur si un état
impossible peut se produire
1ère tentative de MISI
Etape 1 : définir le Model
Distinguer questions répondues et
questions non répondues.
Approche « Impossible state »
J’affiche une seule liste de questions
Je vérifie qu’il n y a aucune question
« restante »
1ère tentative de MISI
Etape 2 : vérifier le Model
Je peux avoir des questions
« répondues » sans réponse
Ou une même question dans les 2
listes !!
2 questions avec le même Id mais
intitulés différents
Nombre de questions répondues > Total de questions
Impossible
On peut valider qu’une question existante possède un
answerId ou pas, mais on ne peut checker qu’elle a un
état “répondu” ou “non répondu”.
Elm-test
2ème tentative de MISI
Modifier une réponse
Donner une réponse
S’il n’y a que des questions
répondues…
Alors on affiche le message
correspondant
Nombre de questions répondues > Total de questions
Impossible
Toutes les questions existantes sont soit répondues soit
non répondues, avec un état correct
Elm-test
MISI
1/ Type
2/ Debug
3/ TU
Test unitaire
Elm-Test
Conclusion
Toujours refactoriser
Appliquer les bons patterns permet de progresser
On apprend en faisant
Au début, on prend plus de temps
Mais ensuite on est beaucoup plus rapide, et on évite les
bugs !
Questions ?

Contenu connexe

En vedette

4.16세월호참사 특별조사위원회 제3차 청문회 자료집 3차 청문회 자료집(최종) 2
4.16세월호참사 특별조사위원회 제3차 청문회 자료집 3차 청문회 자료집(최종) 24.16세월호참사 특별조사위원회 제3차 청문회 자료집 3차 청문회 자료집(최종) 2
4.16세월호참사 특별조사위원회 제3차 청문회 자료집 3차 청문회 자료집(최종) 2봉조 김
 
Convert Your Legacy OpenGL Code to Modern OpenGL with Qt
Convert Your Legacy OpenGL Code to Modern OpenGL with QtConvert Your Legacy OpenGL Code to Modern OpenGL with Qt
Convert Your Legacy OpenGL Code to Modern OpenGL with QtICS
 
Dealing with Changed Data in Hadoop
Dealing with Changed Data in HadoopDealing with Changed Data in Hadoop
Dealing with Changed Data in HadoopDataWorks Summit
 
Tema 4 los climas de españa
Tema 4 los climas de españaTema 4 los climas de españa
Tema 4 los climas de españanerea calonge
 
Julie Stevens CV HR Generalist 2016
Julie Stevens CV HR Generalist 2016Julie Stevens CV HR Generalist 2016
Julie Stevens CV HR Generalist 2016Julie Stevens
 
2016 kcd 세미나 발표자료. 구글포토로 바라본 인공지능과 머신러닝
2016 kcd 세미나 발표자료. 구글포토로 바라본 인공지능과 머신러닝2016 kcd 세미나 발표자료. 구글포토로 바라본 인공지능과 머신러닝
2016 kcd 세미나 발표자료. 구글포토로 바라본 인공지능과 머신러닝JungGeun Lee
 

En vedette (7)

Course International Strategy
Course International StrategyCourse International Strategy
Course International Strategy
 
4.16세월호참사 특별조사위원회 제3차 청문회 자료집 3차 청문회 자료집(최종) 2
4.16세월호참사 특별조사위원회 제3차 청문회 자료집 3차 청문회 자료집(최종) 24.16세월호참사 특별조사위원회 제3차 청문회 자료집 3차 청문회 자료집(최종) 2
4.16세월호참사 특별조사위원회 제3차 청문회 자료집 3차 청문회 자료집(최종) 2
 
Convert Your Legacy OpenGL Code to Modern OpenGL with Qt
Convert Your Legacy OpenGL Code to Modern OpenGL with QtConvert Your Legacy OpenGL Code to Modern OpenGL with Qt
Convert Your Legacy OpenGL Code to Modern OpenGL with Qt
 
Dealing with Changed Data in Hadoop
Dealing with Changed Data in HadoopDealing with Changed Data in Hadoop
Dealing with Changed Data in Hadoop
 
Tema 4 los climas de españa
Tema 4 los climas de españaTema 4 los climas de españa
Tema 4 los climas de españa
 
Julie Stevens CV HR Generalist 2016
Julie Stevens CV HR Generalist 2016Julie Stevens CV HR Generalist 2016
Julie Stevens CV HR Generalist 2016
 
2016 kcd 세미나 발표자료. 구글포토로 바라본 인공지능과 머신러닝
2016 kcd 세미나 발표자료. 구글포토로 바라본 인공지능과 머신러닝2016 kcd 세미나 발표자료. 구글포토로 바라본 인공지능과 머신러닝
2016 kcd 세미나 발표자료. 구글포토로 바라본 인공지능과 머신러닝
 

Plus de Nicolas Umiastowski

Training from the Back of the Room Agile Tour Lille 2018
Training from the Back of the Room Agile Tour Lille 2018Training from the Back of the Room Agile Tour Lille 2018
Training from the Back of the Room Agile Tour Lille 2018Nicolas Umiastowski
 
Meetup Aubay : Training from the Back of the Room
Meetup Aubay : Training from the Back of the RoomMeetup Aubay : Training from the Back of the Room
Meetup Aubay : Training from the Back of the RoomNicolas Umiastowski
 
Training Aubay : Training from the Back of the Room - 25 avril 2018
Training Aubay : Training from the Back of the Room - 25 avril 2018Training Aubay : Training from the Back of the Room - 25 avril 2018
Training Aubay : Training from the Back of the Room - 25 avril 2018Nicolas Umiastowski
 
Mob Programming et #NoEstimates : contre-intuitif et efficace
Mob Programming et #NoEstimates : contre-intuitif et efficaceMob Programming et #NoEstimates : contre-intuitif et efficace
Mob Programming et #NoEstimates : contre-intuitif et efficaceNicolas Umiastowski
 

Plus de Nicolas Umiastowski (7)

At nantes-niu
At nantes-niuAt nantes-niu
At nantes-niu
 
Training from the Back of the Room Agile Tour Lille 2018
Training from the Back of the Room Agile Tour Lille 2018Training from the Back of the Room Agile Tour Lille 2018
Training from the Back of the Room Agile Tour Lille 2018
 
Meetup Aubay : Training from the Back of the Room
Meetup Aubay : Training from the Back of the RoomMeetup Aubay : Training from the Back of the Room
Meetup Aubay : Training from the Back of the Room
 
Training Aubay : Training from the Back of the Room - 25 avril 2018
Training Aubay : Training from the Back of the Room - 25 avril 2018Training Aubay : Training from the Back of the Room - 25 avril 2018
Training Aubay : Training from the Back of the Room - 25 avril 2018
 
TDD with Elm
TDD with ElmTDD with Elm
TDD with Elm
 
Unrepresentable states in Elm
Unrepresentable states in ElmUnrepresentable states in Elm
Unrepresentable states in Elm
 
Mob Programming et #NoEstimates : contre-intuitif et efficace
Mob Programming et #NoEstimates : contre-intuitif et efficaceMob Programming et #NoEstimates : contre-intuitif et efficace
Mob Programming et #NoEstimates : contre-intuitif et efficace
 

Elm : Making impossible states impossible

Notes de l'éditeur

  1. Question non répondue pourrait avoir un answerId
  2. Question non répondue pourrait avoir un answerId
  3. Question non répondue pourrait avoir un answerId
  4. Question non répondue pourrait avoir un answerId