[{"data":1,"prerenderedAt":28963},["ShallowReactive",2],{"search-api":-1,"listing-page-4":3},[4,1477,3978,10106,13468,16300,20282,24405,26529],{"_path":5,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":9,"description":10,"id":11,"date":12,"listed":13,"nocomments":7,"hidden":7,"categories":14,"tags":15,"cover":18,"readingTime":19,"body":24,"_type":1471,"_id":1472,"_source":1473,"_file":1474,"_stem":1475,"_extension":1476},"/fr/dette-technique/yagni-ecrire-code-qualite-sans-fonctionnalites-inutiles","dette-technique",false,"","Principe YAGNI, Comment écrire du code de qualité en évitant les fonctionnalités inutiles","Découvrez le principe YAGNI en software craftsmanship et apprenez à simplifier votre code en évitant d'anticiper des besoins futurs. Exemples concrets en Java inclus.",41,"2024-06-18",true,[6],[16,17],"Clean code","Software craftsmanship","covers/articles/principe-yagni.jpg",{"text":20,"minutes":21,"time":22,"words":23},"8 min read",7.79,467400,1558,{"type":25,"children":26,"toc":1460},"root",[27,36,43,49,77,82,86,92,97,111,116,119,132,138,143,163,168,175,180,589,602,605,611,616,627,647,655,836,855,866,871,879,1133,1145,1255,1266,1278,1289,1294,1297,1303,1308,1313,1325,1337,1340,1346,1368,1381,1394,1414,1417,1423,1442,1454],{"type":28,"tag":29,"props":30,"children":32},"element","h2",{"id":31},"yagni-comment-écrire-du-code-de-qualité-en-évitant-les-fonctionnalités-inutiles",[33],{"type":34,"value":35},"text","YAGNI : Comment écrire du code de qualité en évitant les fonctionnalités inutiles",{"type":28,"tag":37,"props":38,"children":40},"h3",{"id":39},"introduction-quest-ce-que-yagni",[41],{"type":34,"value":42},"Introduction : Qu’est-ce que YAGNI ?",{"type":28,"tag":44,"props":45,"children":46},"p",{},[47],{"type":34,"value":48},"Audit d’une plateforme bancaire l’an dernier. Trois jours pour cartographier le code mort : près de 30 % de la base ne répondait à aucun besoin actif. Des modules de conversion multi-devises ajoutés \"au cas où\" cinq ans plus tôt, jamais activés. Une couche d’abstraction sur la persistence prête à supporter trois bases différentes (une seule en production). Chaque livraison ralentie par ce poids mort, chaque onboarding rallongé d’une semaine pour expliquer à quoi servaient des classes que personne n’avait touchées depuis 2019.",{"type":28,"tag":44,"props":50,"children":51},{},[52,54,60,62,68,70,75],{"type":34,"value":53},"Ce gaspillage a un nom et un antidote : YAGNI (You Aren’t Gonna Need It). Formulé par Kent Beck dans le cadre de l’Extreme Programming, c’est l’un des piliers du ",{"type":28,"tag":55,"props":56,"children":57},"strong",{},[58],{"type":34,"value":59},"software craftsmanship",{"type":34,"value":61},". La règle tient en une ligne : n’écrivez pas le code dont vous ",{"type":28,"tag":63,"props":64,"children":65},"em",{},[66],{"type":34,"value":67},"pensez",{"type":34,"value":69}," avoir besoin demain, écrivez celui dont vous ",{"type":28,"tag":63,"props":71,"children":72},{},[73],{"type":34,"value":74},"avez",{"type":34,"value":76}," besoin aujourd’hui.",{"type":28,"tag":44,"props":78,"children":79},{},[80],{"type":34,"value":81},"Cet article montre comment l’appliquer concrètement en Java, où repérer les ajouts superflus, et comment résister à la tentation d’anticiper.",{"type":28,"tag":83,"props":84,"children":85},"hr",{},[],{"type":28,"tag":37,"props":87,"children":89},{"id":88},"ce-que-yagni-vous-évite-vraiment",[90],{"type":34,"value":91},"Ce que YAGNI vous évite vraiment",{"type":28,"tag":44,"props":93,"children":94},{},[95],{"type":34,"value":96},"Trois conséquences directes, observées sur le terrain.",{"type":28,"tag":44,"props":98,"children":99},{},[100,102,109],{"type":34,"value":101},"Chaque fonctionnalité prématurée alourdit la base : plus de classes à lire, plus de chemins à tester, plus de surfaces où loger des bugs. Multipliez par cinq ans d’accumulation et vous obtenez la situation décrite plus haut : 30 % de code qui ne sert à rien mais que tout le monde doit comprendre. C’est de la ",{"type":28,"tag":103,"props":104,"children":106},"a",{"href":105},"/fr/dette-technique/legacy-code-evaluer-risque",[107],{"type":34,"value":108},"dette technique",{"type":34,"value":110}," pure, contractée pour rembourser un emprunt qui n’a jamais été demandé.",{"type":28,"tag":44,"props":112,"children":113},{},[114],{"type":34,"value":115},"Inversement, moins de code écrit, c’est moins de tests à maintenir, moins de revues à instruire, moins de couplage à gérer le jour où le vrai besoin émerge. Un module minimal s’adapte. Un module sur-conçu pour un futur fantasmé doit d’abord être démêlé avant d’être modifié, et personne n’ose y toucher.",{"type":28,"tag":83,"props":117,"children":118},{},[],{"type":28,"tag":120,"props":121,"children":126},"cta",{"cta":122,"href":123,"title":124,"type":125},"Coder comme un senior →","https://app.kamanga.fr/forms/mentoring","Vous voulez savoir, avant d'écrire une ligne, si elle est vraiment nécessaire ?","call",[127],{"type":28,"tag":44,"props":128,"children":129},{},[130],{"type":34,"value":131},"Résister à l'envie d'anticiper un besoin, ça ne se décrète pas en lisant un article : ça se travaille sur votre propre code. En mentoring 1:1, je relis vos PR avec vous et on traque ensemble chaque abstraction prématurée, chaque paramètre \"au cas où\". Vous développez le réflexe d'écrire juste ce qu'il faut, et rien de plus.",{"type":28,"tag":37,"props":133,"children":135},{"id":134},"comment-repérer-une-fonctionnalité-superflue",[136],{"type":34,"value":137},"Comment repérer une fonctionnalité superflue",{"type":28,"tag":44,"props":139,"children":140},{},[141],{"type":34,"value":142},"Trois questions suffisent en général. Si vous répondez \"non\" à la première et \"oui\" aux deux autres, vous tenez un candidat à supprimer ou à ne pas écrire.",{"type":28,"tag":144,"props":145,"children":146},"ul",{},[147,153,158],{"type":28,"tag":148,"props":149,"children":150},"li",{},[151],{"type":34,"value":152},"Existe-t-il aujourd’hui un cas d’usage concret, validé, qui exige cette fonctionnalité ? Pas un cas hypothétique évoqué en réunion il y a six mois, mais un besoin actif, daté, avec un utilisateur ou un client identifié.",{"type":28,"tag":148,"props":154,"children":155},{},[156],{"type":34,"value":157},"L’application fonctionnerait-elle correctement sans cette fonctionnalité ? Si oui, c’est qu’elle n’en a pas besoin maintenant.",{"type":28,"tag":148,"props":159,"children":160},{},[161],{"type":34,"value":162},"Cet ajout complique-t-il la lecture, les tests ou la maintenance du code existant ? Une option supplémentaire, un paramètre \"au cas où\", une couche d’abstraction préventive : chacun de ces choix a un coût immédiat pour un bénéfice incertain.",{"type":28,"tag":44,"props":164,"children":165},{},[166],{"type":34,"value":167},"Quand la pression vient d’un client ou d’un manager qui demande une fonctionnalité \"pour plus tard\", la conversation à avoir est simple : qui en a besoin, à quelle date, et que coûte-t-il d’attendre que ce besoin soit confirmé ? Dans neuf cas sur dix, la demande s’évapore.",{"type":28,"tag":169,"props":170,"children":172},"h4",{"id":171},"exemples-concrets-en-java",[173],{"type":34,"value":174},"Exemples concrets en Java",{"type":28,"tag":44,"props":176,"children":177},{},[178],{"type":34,"value":179},"Prenons un exemple simple en Java où vous pourriez être tenté d’ajouter une fonctionnalité inutile :",{"type":28,"tag":181,"props":182,"children":186},"pre",{"className":183,"code":184,"language":185,"meta":8,"style":8},"language-java shiki shiki-themes catppuccin-frappe github-dark","// Exemple où une fonctionnalité inutile est ajoutée\npublic class User {\n    private String name;\n    private int age;\n    private String address; // Cette information n'est pas encore utilisée\n\n    public User(String name, int age) {\n        this.name = name;\n        this.age = age;\n        // On pourrait être tenté d'ajouter l'adresse dès maintenant, mais YAGNI !\n    }\n\n    public String getName() {\n        return name;\n    }\n\n    public int getAge() {\n        return age;\n    }\n    \n    // On pourrait ajouter un getter pour l'adresse ici, mais ça serait prématuré.\n}\n","java",[187],{"type":28,"tag":188,"props":189,"children":190},"code",{"__ignoreMap":8},[191,203,230,256,278,305,314,365,399,428,437,446,454,480,497,505,513,538,554,562,571,580],{"type":28,"tag":192,"props":193,"children":196},"span",{"class":194,"line":195},"line",1,[197],{"type":28,"tag":192,"props":198,"children":200},{"style":199},"--shiki-default:#737994;--shiki-default-font-style:italic;--shiki-dark:#6A737D;--shiki-dark-font-style:inherit",[201],{"type":34,"value":202},"// Exemple où une fonctionnalité inutile est ajoutée\n",{"type":28,"tag":192,"props":204,"children":206},{"class":194,"line":205},2,[207,213,218,224],{"type":28,"tag":192,"props":208,"children":210},{"style":209},"--shiki-default:#CA9EE6;--shiki-dark:#F97583",[211],{"type":34,"value":212},"public",{"type":28,"tag":192,"props":214,"children":215},{"style":209},[216],{"type":34,"value":217}," class",{"type":28,"tag":192,"props":219,"children":221},{"style":220},"--shiki-default:#E5C890;--shiki-default-font-style:italic;--shiki-dark:#B392F0;--shiki-dark-font-style:inherit",[222],{"type":34,"value":223}," User",{"type":28,"tag":192,"props":225,"children":227},{"style":226},"--shiki-default:#949CBB;--shiki-dark:#E1E4E8",[228],{"type":34,"value":229}," {\n",{"type":28,"tag":192,"props":231,"children":233},{"class":194,"line":232},3,[234,239,245,251],{"type":28,"tag":192,"props":235,"children":236},{"style":209},[237],{"type":34,"value":238},"    private",{"type":28,"tag":192,"props":240,"children":242},{"style":241},"--shiki-default:#CA9EE6;--shiki-dark:#E1E4E8",[243],{"type":34,"value":244}," String",{"type":28,"tag":192,"props":246,"children":248},{"style":247},"--shiki-default:#C6D0F5;--shiki-dark:#E1E4E8",[249],{"type":34,"value":250}," name",{"type":28,"tag":192,"props":252,"children":253},{"style":226},[254],{"type":34,"value":255},";\n",{"type":28,"tag":192,"props":257,"children":259},{"class":194,"line":258},4,[260,264,269,274],{"type":28,"tag":192,"props":261,"children":262},{"style":209},[263],{"type":34,"value":238},{"type":28,"tag":192,"props":265,"children":266},{"style":209},[267],{"type":34,"value":268}," int",{"type":28,"tag":192,"props":270,"children":271},{"style":247},[272],{"type":34,"value":273}," age",{"type":28,"tag":192,"props":275,"children":276},{"style":226},[277],{"type":34,"value":255},{"type":28,"tag":192,"props":279,"children":281},{"class":194,"line":280},5,[282,286,290,295,300],{"type":28,"tag":192,"props":283,"children":284},{"style":209},[285],{"type":34,"value":238},{"type":28,"tag":192,"props":287,"children":288},{"style":241},[289],{"type":34,"value":244},{"type":28,"tag":192,"props":291,"children":292},{"style":247},[293],{"type":34,"value":294}," address",{"type":28,"tag":192,"props":296,"children":297},{"style":226},[298],{"type":34,"value":299},";",{"type":28,"tag":192,"props":301,"children":302},{"style":199},[303],{"type":34,"value":304}," // Cette information n'est pas encore utilisée\n",{"type":28,"tag":192,"props":306,"children":308},{"class":194,"line":307},6,[309],{"type":28,"tag":192,"props":310,"children":311},{"emptyLinePlaceholder":13},[312],{"type":34,"value":313},"\n",{"type":28,"tag":192,"props":315,"children":317},{"class":194,"line":316},7,[318,323,328,333,338,343,348,352,356,361],{"type":28,"tag":192,"props":319,"children":320},{"style":209},[321],{"type":34,"value":322},"    public",{"type":28,"tag":192,"props":324,"children":326},{"style":325},"--shiki-default:#8CAAEE;--shiki-default-font-style:italic;--shiki-dark:#B392F0;--shiki-dark-font-style:inherit",[327],{"type":34,"value":223},{"type":28,"tag":192,"props":329,"children":330},{"style":226},[331],{"type":34,"value":332},"(",{"type":28,"tag":192,"props":334,"children":335},{"style":241},[336],{"type":34,"value":337},"String",{"type":28,"tag":192,"props":339,"children":341},{"style":340},"--shiki-default:#EA999C;--shiki-default-font-style:italic;--shiki-dark:#FFAB70;--shiki-dark-font-style:inherit",[342],{"type":34,"value":250},{"type":28,"tag":192,"props":344,"children":345},{"style":226},[346],{"type":34,"value":347},",",{"type":28,"tag":192,"props":349,"children":350},{"style":209},[351],{"type":34,"value":268},{"type":28,"tag":192,"props":353,"children":354},{"style":340},[355],{"type":34,"value":273},{"type":28,"tag":192,"props":357,"children":358},{"style":226},[359],{"type":34,"value":360},")",{"type":28,"tag":192,"props":362,"children":363},{"style":226},[364],{"type":34,"value":229},{"type":28,"tag":192,"props":366,"children":368},{"class":194,"line":367},8,[369,375,380,385,391,395],{"type":28,"tag":192,"props":370,"children":372},{"style":371},"--shiki-default:#E78284;--shiki-dark:#79B8FF",[373],{"type":34,"value":374},"        this",{"type":28,"tag":192,"props":376,"children":377},{"style":226},[378],{"type":34,"value":379},".",{"type":28,"tag":192,"props":381,"children":382},{"style":247},[383],{"type":34,"value":384},"name ",{"type":28,"tag":192,"props":386,"children":388},{"style":387},"--shiki-default:#81C8BE;--shiki-dark:#F97583",[389],{"type":34,"value":390},"=",{"type":28,"tag":192,"props":392,"children":393},{"style":247},[394],{"type":34,"value":250},{"type":28,"tag":192,"props":396,"children":397},{"style":226},[398],{"type":34,"value":255},{"type":28,"tag":192,"props":400,"children":402},{"class":194,"line":401},9,[403,407,411,416,420,424],{"type":28,"tag":192,"props":404,"children":405},{"style":371},[406],{"type":34,"value":374},{"type":28,"tag":192,"props":408,"children":409},{"style":226},[410],{"type":34,"value":379},{"type":28,"tag":192,"props":412,"children":413},{"style":247},[414],{"type":34,"value":415},"age ",{"type":28,"tag":192,"props":417,"children":418},{"style":387},[419],{"type":34,"value":390},{"type":28,"tag":192,"props":421,"children":422},{"style":247},[423],{"type":34,"value":273},{"type":28,"tag":192,"props":425,"children":426},{"style":226},[427],{"type":34,"value":255},{"type":28,"tag":192,"props":429,"children":431},{"class":194,"line":430},10,[432],{"type":28,"tag":192,"props":433,"children":434},{"style":199},[435],{"type":34,"value":436},"        // On pourrait être tenté d'ajouter l'adresse dès maintenant, mais YAGNI !\n",{"type":28,"tag":192,"props":438,"children":440},{"class":194,"line":439},11,[441],{"type":28,"tag":192,"props":442,"children":443},{"style":226},[444],{"type":34,"value":445},"    }\n",{"type":28,"tag":192,"props":447,"children":449},{"class":194,"line":448},12,[450],{"type":28,"tag":192,"props":451,"children":452},{"emptyLinePlaceholder":13},[453],{"type":34,"value":313},{"type":28,"tag":192,"props":455,"children":457},{"class":194,"line":456},13,[458,462,466,471,476],{"type":28,"tag":192,"props":459,"children":460},{"style":209},[461],{"type":34,"value":322},{"type":28,"tag":192,"props":463,"children":464},{"style":241},[465],{"type":34,"value":244},{"type":28,"tag":192,"props":467,"children":468},{"style":325},[469],{"type":34,"value":470}," getName",{"type":28,"tag":192,"props":472,"children":473},{"style":226},[474],{"type":34,"value":475},"()",{"type":28,"tag":192,"props":477,"children":478},{"style":226},[479],{"type":34,"value":229},{"type":28,"tag":192,"props":481,"children":483},{"class":194,"line":482},14,[484,489,493],{"type":28,"tag":192,"props":485,"children":486},{"style":209},[487],{"type":34,"value":488},"        return",{"type":28,"tag":192,"props":490,"children":491},{"style":247},[492],{"type":34,"value":250},{"type":28,"tag":192,"props":494,"children":495},{"style":226},[496],{"type":34,"value":255},{"type":28,"tag":192,"props":498,"children":500},{"class":194,"line":499},15,[501],{"type":28,"tag":192,"props":502,"children":503},{"style":226},[504],{"type":34,"value":445},{"type":28,"tag":192,"props":506,"children":508},{"class":194,"line":507},16,[509],{"type":28,"tag":192,"props":510,"children":511},{"emptyLinePlaceholder":13},[512],{"type":34,"value":313},{"type":28,"tag":192,"props":514,"children":516},{"class":194,"line":515},17,[517,521,525,530,534],{"type":28,"tag":192,"props":518,"children":519},{"style":209},[520],{"type":34,"value":322},{"type":28,"tag":192,"props":522,"children":523},{"style":209},[524],{"type":34,"value":268},{"type":28,"tag":192,"props":526,"children":527},{"style":325},[528],{"type":34,"value":529}," getAge",{"type":28,"tag":192,"props":531,"children":532},{"style":226},[533],{"type":34,"value":475},{"type":28,"tag":192,"props":535,"children":536},{"style":226},[537],{"type":34,"value":229},{"type":28,"tag":192,"props":539,"children":541},{"class":194,"line":540},18,[542,546,550],{"type":28,"tag":192,"props":543,"children":544},{"style":209},[545],{"type":34,"value":488},{"type":28,"tag":192,"props":547,"children":548},{"style":247},[549],{"type":34,"value":273},{"type":28,"tag":192,"props":551,"children":552},{"style":226},[553],{"type":34,"value":255},{"type":28,"tag":192,"props":555,"children":557},{"class":194,"line":556},19,[558],{"type":28,"tag":192,"props":559,"children":560},{"style":226},[561],{"type":34,"value":445},{"type":28,"tag":192,"props":563,"children":565},{"class":194,"line":564},20,[566],{"type":28,"tag":192,"props":567,"children":568},{"style":247},[569],{"type":34,"value":570},"    \n",{"type":28,"tag":192,"props":572,"children":574},{"class":194,"line":573},21,[575],{"type":28,"tag":192,"props":576,"children":577},{"style":199},[578],{"type":34,"value":579},"    // On pourrait ajouter un getter pour l'adresse ici, mais ça serait prématuré.\n",{"type":28,"tag":192,"props":581,"children":583},{"class":194,"line":582},22,[584],{"type":28,"tag":192,"props":585,"children":586},{"style":226},[587],{"type":34,"value":588},"}\n",{"type":28,"tag":44,"props":590,"children":591},{},[592,594,600],{"type":34,"value":593},"Dans cet exemple, l’attribut ",{"type":28,"tag":188,"props":595,"children":597},{"className":596},[],[598],{"type":34,"value":599},"address",{"type":34,"value":601}," est inutile tant que le programme n’en a pas besoin. Selon YAGNI, ne l’ajoutez pas avant d’avoir une demande précise pour cette fonctionnalité.",{"type":28,"tag":83,"props":603,"children":604},{},[],{"type":28,"tag":37,"props":606,"children":608},{"id":607},"mettre-yagni-en-pratique-au-quotidien",[609],{"type":34,"value":610},"Mettre YAGNI en pratique au quotidien",{"type":28,"tag":44,"props":612,"children":613},{},[614],{"type":34,"value":615},"Appliquer YAGNI demande de la discipline et un cadre. Voici les leviers qui fonctionnent dans les équipes que j’accompagne.",{"type":28,"tag":169,"props":617,"children":619},{"id":618},"_1-laisser-les-tests-piloter-le-code",[620,622],{"type":34,"value":621},"1. ",{"type":28,"tag":55,"props":623,"children":624},{},[625],{"type":34,"value":626},"Laisser les tests piloter le code",{"type":28,"tag":44,"props":628,"children":629},{},[630,632,637,639,645],{"type":34,"value":631},"L’approche la plus efficace pour ne pas écrire de code spéculatif reste le ",{"type":28,"tag":55,"props":633,"children":634},{},[635],{"type":34,"value":636},"Test-Driven Development (TDD)",{"type":34,"value":638},". Un ",{"type":28,"tag":103,"props":640,"children":642},{"href":641},"/fr/dette-technique/decouvrir-frameworks-tests-java",[643],{"type":34,"value":644},"test",{"type":34,"value":646}," d’abord, puis juste assez de code pour le faire passer. Le mécanisme oblige à rester sur le besoin réel : si aucun test ne le justifie, le code n’existe pas.",{"type":28,"tag":44,"props":648,"children":649},{},[650],{"type":28,"tag":55,"props":651,"children":652},{},[653],{"type":34,"value":654},"Exemple en Java :",{"type":28,"tag":181,"props":656,"children":658},{"className":183,"code":657,"language":185,"meta":8,"style":8},"@Test\npublic void testAddUser() {\n    User user = new User(\"Alice\", 30);\n    assertEquals(\"Alice\", user.getName());\n    assertEquals(30, user.getAge());\n}\n",[659],{"type":28,"tag":188,"props":660,"children":661},{"__ignoreMap":8},[662,677,702,753,792,829],{"type":28,"tag":192,"props":663,"children":664},{"class":194,"line":195},[665,671],{"type":28,"tag":192,"props":666,"children":668},{"style":667},"--shiki-default:#EF9F76;--shiki-dark:#E1E4E8",[669],{"type":34,"value":670},"@",{"type":28,"tag":192,"props":672,"children":674},{"style":673},"--shiki-default:#EF9F76;--shiki-dark:#F97583",[675],{"type":34,"value":676},"Test\n",{"type":28,"tag":192,"props":678,"children":679},{"class":194,"line":205},[680,684,689,694,698],{"type":28,"tag":192,"props":681,"children":682},{"style":209},[683],{"type":34,"value":212},{"type":28,"tag":192,"props":685,"children":686},{"style":209},[687],{"type":34,"value":688}," void",{"type":28,"tag":192,"props":690,"children":691},{"style":325},[692],{"type":34,"value":693}," testAddUser",{"type":28,"tag":192,"props":695,"children":696},{"style":226},[697],{"type":34,"value":475},{"type":28,"tag":192,"props":699,"children":700},{"style":226},[701],{"type":34,"value":229},{"type":28,"tag":192,"props":703,"children":704},{"class":194,"line":232},[705,710,715,719,724,728,732,738,742,748],{"type":28,"tag":192,"props":706,"children":707},{"style":241},[708],{"type":34,"value":709},"    User",{"type":28,"tag":192,"props":711,"children":712},{"style":247},[713],{"type":34,"value":714}," user ",{"type":28,"tag":192,"props":716,"children":717},{"style":387},[718],{"type":34,"value":390},{"type":28,"tag":192,"props":720,"children":721},{"style":209},[722],{"type":34,"value":723}," new",{"type":28,"tag":192,"props":725,"children":726},{"style":325},[727],{"type":34,"value":223},{"type":28,"tag":192,"props":729,"children":730},{"style":226},[731],{"type":34,"value":332},{"type":28,"tag":192,"props":733,"children":735},{"style":734},"--shiki-default:#A6D189;--shiki-dark:#9ECBFF",[736],{"type":34,"value":737},"\"Alice\"",{"type":28,"tag":192,"props":739,"children":740},{"style":226},[741],{"type":34,"value":347},{"type":28,"tag":192,"props":743,"children":745},{"style":744},"--shiki-default:#EF9F76;--shiki-dark:#79B8FF",[746],{"type":34,"value":747}," 30",{"type":28,"tag":192,"props":749,"children":750},{"style":226},[751],{"type":34,"value":752},");\n",{"type":28,"tag":192,"props":754,"children":755},{"class":194,"line":258},[756,761,765,769,773,778,782,787],{"type":28,"tag":192,"props":757,"children":758},{"style":325},[759],{"type":34,"value":760},"    assertEquals",{"type":28,"tag":192,"props":762,"children":763},{"style":226},[764],{"type":34,"value":332},{"type":28,"tag":192,"props":766,"children":767},{"style":734},[768],{"type":34,"value":737},{"type":28,"tag":192,"props":770,"children":771},{"style":226},[772],{"type":34,"value":347},{"type":28,"tag":192,"props":774,"children":775},{"style":247},[776],{"type":34,"value":777}," user",{"type":28,"tag":192,"props":779,"children":780},{"style":226},[781],{"type":34,"value":379},{"type":28,"tag":192,"props":783,"children":784},{"style":325},[785],{"type":34,"value":786},"getName",{"type":28,"tag":192,"props":788,"children":789},{"style":226},[790],{"type":34,"value":791},"());\n",{"type":28,"tag":192,"props":793,"children":794},{"class":194,"line":280},[795,799,803,808,812,816,820,825],{"type":28,"tag":192,"props":796,"children":797},{"style":325},[798],{"type":34,"value":760},{"type":28,"tag":192,"props":800,"children":801},{"style":226},[802],{"type":34,"value":332},{"type":28,"tag":192,"props":804,"children":805},{"style":744},[806],{"type":34,"value":807},"30",{"type":28,"tag":192,"props":809,"children":810},{"style":226},[811],{"type":34,"value":347},{"type":28,"tag":192,"props":813,"children":814},{"style":247},[815],{"type":34,"value":777},{"type":28,"tag":192,"props":817,"children":818},{"style":226},[819],{"type":34,"value":379},{"type":28,"tag":192,"props":821,"children":822},{"style":325},[823],{"type":34,"value":824},"getAge",{"type":28,"tag":192,"props":826,"children":827},{"style":226},[828],{"type":34,"value":791},{"type":28,"tag":192,"props":830,"children":831},{"class":194,"line":307},[832],{"type":28,"tag":192,"props":833,"children":834},{"style":226},[835],{"type":34,"value":588},{"type":28,"tag":44,"props":837,"children":838},{},[839,841,846,848,854],{"type":34,"value":840},"Avec ce test, vous vous concentrez uniquement sur l’ajout de l’utilisateur avec un nom et un âge. Tant qu’il n’existe pas de test nécessitant l’adresse, n’ajoutez pas d’attribut ",{"type":28,"tag":188,"props":842,"children":844},{"className":843},[],[845],{"type":34,"value":599},{"type":34,"value":847}," à la classe ",{"type":28,"tag":188,"props":849,"children":851},{"className":850},[],[852],{"type":34,"value":853},"User",{"type":34,"value":379},{"type":28,"tag":169,"props":856,"children":858},{"id":857},"_2-évitez-de-généraliser-trop-tôt",[859,861],{"type":34,"value":860},"2. ",{"type":28,"tag":55,"props":862,"children":863},{},[864],{"type":34,"value":865},"Évitez de généraliser trop tôt",{"type":28,"tag":44,"props":867,"children":868},{},[869],{"type":34,"value":870},"Un autre piège commun est de vouloir tout de suite rendre votre code trop générique ou flexible. Par exemple, vous pourriez penser qu’une méthode pourrait être réutilisée plus tard et vouloir la rendre paramétrable. Mais en réalité, si cette flexibilité n’est pas nécessaire maintenant, elle pourrait ne jamais l’être.",{"type":28,"tag":44,"props":872,"children":873},{},[874],{"type":28,"tag":55,"props":875,"children":876},{},[877],{"type":34,"value":878},"Exemple à éviter :",{"type":28,"tag":181,"props":880,"children":882},{"className":183,"code":881,"language":185,"meta":8,"style":8},"public class MathOperations {\n    // On pourrait être tenté de rendre cette méthode très générique\n    public int multiply(int a, int b, boolean absoluteValues) {\n        if (absoluteValues) {\n            return Math.abs(a) * Math.abs(b);\n        } else {\n            return a * b;\n        }\n    }\n}\n",[883],{"type":28,"tag":188,"props":884,"children":885},{"__ignoreMap":8},[886,906,914,979,1005,1069,1086,1111,1119,1126],{"type":28,"tag":192,"props":887,"children":888},{"class":194,"line":195},[889,893,897,902],{"type":28,"tag":192,"props":890,"children":891},{"style":209},[892],{"type":34,"value":212},{"type":28,"tag":192,"props":894,"children":895},{"style":209},[896],{"type":34,"value":217},{"type":28,"tag":192,"props":898,"children":899},{"style":220},[900],{"type":34,"value":901}," MathOperations",{"type":28,"tag":192,"props":903,"children":904},{"style":226},[905],{"type":34,"value":229},{"type":28,"tag":192,"props":907,"children":908},{"class":194,"line":205},[909],{"type":28,"tag":192,"props":910,"children":911},{"style":199},[912],{"type":34,"value":913},"    // On pourrait être tenté de rendre cette méthode très générique\n",{"type":28,"tag":192,"props":915,"children":916},{"class":194,"line":232},[917,921,925,930,934,939,944,948,952,957,961,966,971,975],{"type":28,"tag":192,"props":918,"children":919},{"style":209},[920],{"type":34,"value":322},{"type":28,"tag":192,"props":922,"children":923},{"style":209},[924],{"type":34,"value":268},{"type":28,"tag":192,"props":926,"children":927},{"style":325},[928],{"type":34,"value":929}," multiply",{"type":28,"tag":192,"props":931,"children":932},{"style":226},[933],{"type":34,"value":332},{"type":28,"tag":192,"props":935,"children":936},{"style":209},[937],{"type":34,"value":938},"int",{"type":28,"tag":192,"props":940,"children":941},{"style":340},[942],{"type":34,"value":943}," a",{"type":28,"tag":192,"props":945,"children":946},{"style":226},[947],{"type":34,"value":347},{"type":28,"tag":192,"props":949,"children":950},{"style":209},[951],{"type":34,"value":268},{"type":28,"tag":192,"props":953,"children":954},{"style":340},[955],{"type":34,"value":956}," b",{"type":28,"tag":192,"props":958,"children":959},{"style":226},[960],{"type":34,"value":347},{"type":28,"tag":192,"props":962,"children":963},{"style":209},[964],{"type":34,"value":965}," boolean",{"type":28,"tag":192,"props":967,"children":968},{"style":340},[969],{"type":34,"value":970}," absoluteValues",{"type":28,"tag":192,"props":972,"children":973},{"style":226},[974],{"type":34,"value":360},{"type":28,"tag":192,"props":976,"children":977},{"style":226},[978],{"type":34,"value":229},{"type":28,"tag":192,"props":980,"children":981},{"class":194,"line":258},[982,987,992,997,1001],{"type":28,"tag":192,"props":983,"children":984},{"style":209},[985],{"type":34,"value":986},"        if",{"type":28,"tag":192,"props":988,"children":989},{"style":226},[990],{"type":34,"value":991}," (",{"type":28,"tag":192,"props":993,"children":994},{"style":247},[995],{"type":34,"value":996},"absoluteValues",{"type":28,"tag":192,"props":998,"children":999},{"style":226},[1000],{"type":34,"value":360},{"type":28,"tag":192,"props":1002,"children":1003},{"style":226},[1004],{"type":34,"value":229},{"type":28,"tag":192,"props":1006,"children":1007},{"class":194,"line":280},[1008,1013,1018,1022,1027,1031,1035,1039,1044,1048,1052,1056,1060,1065],{"type":28,"tag":192,"props":1009,"children":1010},{"style":209},[1011],{"type":34,"value":1012},"            return",{"type":28,"tag":192,"props":1014,"children":1015},{"style":247},[1016],{"type":34,"value":1017}," Math",{"type":28,"tag":192,"props":1019,"children":1020},{"style":226},[1021],{"type":34,"value":379},{"type":28,"tag":192,"props":1023,"children":1024},{"style":325},[1025],{"type":34,"value":1026},"abs",{"type":28,"tag":192,"props":1028,"children":1029},{"style":226},[1030],{"type":34,"value":332},{"type":28,"tag":192,"props":1032,"children":1033},{"style":247},[1034],{"type":34,"value":103},{"type":28,"tag":192,"props":1036,"children":1037},{"style":226},[1038],{"type":34,"value":360},{"type":28,"tag":192,"props":1040,"children":1041},{"style":387},[1042],{"type":34,"value":1043}," *",{"type":28,"tag":192,"props":1045,"children":1046},{"style":247},[1047],{"type":34,"value":1017},{"type":28,"tag":192,"props":1049,"children":1050},{"style":226},[1051],{"type":34,"value":379},{"type":28,"tag":192,"props":1053,"children":1054},{"style":325},[1055],{"type":34,"value":1026},{"type":28,"tag":192,"props":1057,"children":1058},{"style":226},[1059],{"type":34,"value":332},{"type":28,"tag":192,"props":1061,"children":1062},{"style":247},[1063],{"type":34,"value":1064},"b",{"type":28,"tag":192,"props":1066,"children":1067},{"style":226},[1068],{"type":34,"value":752},{"type":28,"tag":192,"props":1070,"children":1071},{"class":194,"line":307},[1072,1077,1082],{"type":28,"tag":192,"props":1073,"children":1074},{"style":226},[1075],{"type":34,"value":1076},"        }",{"type":28,"tag":192,"props":1078,"children":1079},{"style":209},[1080],{"type":34,"value":1081}," else",{"type":28,"tag":192,"props":1083,"children":1084},{"style":226},[1085],{"type":34,"value":229},{"type":28,"tag":192,"props":1087,"children":1088},{"class":194,"line":316},[1089,1093,1098,1103,1107],{"type":28,"tag":192,"props":1090,"children":1091},{"style":209},[1092],{"type":34,"value":1012},{"type":28,"tag":192,"props":1094,"children":1095},{"style":247},[1096],{"type":34,"value":1097}," a ",{"type":28,"tag":192,"props":1099,"children":1100},{"style":387},[1101],{"type":34,"value":1102},"*",{"type":28,"tag":192,"props":1104,"children":1105},{"style":247},[1106],{"type":34,"value":956},{"type":28,"tag":192,"props":1108,"children":1109},{"style":226},[1110],{"type":34,"value":255},{"type":28,"tag":192,"props":1112,"children":1113},{"class":194,"line":367},[1114],{"type":28,"tag":192,"props":1115,"children":1116},{"style":226},[1117],{"type":34,"value":1118},"        }\n",{"type":28,"tag":192,"props":1120,"children":1121},{"class":194,"line":401},[1122],{"type":28,"tag":192,"props":1123,"children":1124},{"style":226},[1125],{"type":34,"value":445},{"type":28,"tag":192,"props":1127,"children":1128},{"class":194,"line":430},[1129],{"type":28,"tag":192,"props":1130,"children":1131},{"style":226},[1132],{"type":34,"value":588},{"type":28,"tag":44,"props":1134,"children":1135},{},[1136,1138,1143],{"type":34,"value":1137},"Cette méthode introduit de la complexité inutile (avec le paramètre ",{"type":28,"tag":188,"props":1139,"children":1141},{"className":1140},[],[1142],{"type":34,"value":996},{"type":34,"value":1144},") si votre programme n'a besoin que de multiplier des nombres sans se préoccuper de leur signe. La solution YAGNI serait de garder la méthode simple :",{"type":28,"tag":181,"props":1146,"children":1148},{"className":183,"code":1147,"language":185,"meta":8,"style":8},"public class MathOperations {\n    public int multiply(int a, int b) {\n        return a * b;\n    }\n}\n",[1149],{"type":28,"tag":188,"props":1150,"children":1151},{"__ignoreMap":8},[1152,1171,1218,1241,1248],{"type":28,"tag":192,"props":1153,"children":1154},{"class":194,"line":195},[1155,1159,1163,1167],{"type":28,"tag":192,"props":1156,"children":1157},{"style":209},[1158],{"type":34,"value":212},{"type":28,"tag":192,"props":1160,"children":1161},{"style":209},[1162],{"type":34,"value":217},{"type":28,"tag":192,"props":1164,"children":1165},{"style":220},[1166],{"type":34,"value":901},{"type":28,"tag":192,"props":1168,"children":1169},{"style":226},[1170],{"type":34,"value":229},{"type":28,"tag":192,"props":1172,"children":1173},{"class":194,"line":205},[1174,1178,1182,1186,1190,1194,1198,1202,1206,1210,1214],{"type":28,"tag":192,"props":1175,"children":1176},{"style":209},[1177],{"type":34,"value":322},{"type":28,"tag":192,"props":1179,"children":1180},{"style":209},[1181],{"type":34,"value":268},{"type":28,"tag":192,"props":1183,"children":1184},{"style":325},[1185],{"type":34,"value":929},{"type":28,"tag":192,"props":1187,"children":1188},{"style":226},[1189],{"type":34,"value":332},{"type":28,"tag":192,"props":1191,"children":1192},{"style":209},[1193],{"type":34,"value":938},{"type":28,"tag":192,"props":1195,"children":1196},{"style":340},[1197],{"type":34,"value":943},{"type":28,"tag":192,"props":1199,"children":1200},{"style":226},[1201],{"type":34,"value":347},{"type":28,"tag":192,"props":1203,"children":1204},{"style":209},[1205],{"type":34,"value":268},{"type":28,"tag":192,"props":1207,"children":1208},{"style":340},[1209],{"type":34,"value":956},{"type":28,"tag":192,"props":1211,"children":1212},{"style":226},[1213],{"type":34,"value":360},{"type":28,"tag":192,"props":1215,"children":1216},{"style":226},[1217],{"type":34,"value":229},{"type":28,"tag":192,"props":1219,"children":1220},{"class":194,"line":232},[1221,1225,1229,1233,1237],{"type":28,"tag":192,"props":1222,"children":1223},{"style":209},[1224],{"type":34,"value":488},{"type":28,"tag":192,"props":1226,"children":1227},{"style":247},[1228],{"type":34,"value":1097},{"type":28,"tag":192,"props":1230,"children":1231},{"style":387},[1232],{"type":34,"value":1102},{"type":28,"tag":192,"props":1234,"children":1235},{"style":247},[1236],{"type":34,"value":956},{"type":28,"tag":192,"props":1238,"children":1239},{"style":226},[1240],{"type":34,"value":255},{"type":28,"tag":192,"props":1242,"children":1243},{"class":194,"line":258},[1244],{"type":28,"tag":192,"props":1245,"children":1246},{"style":226},[1247],{"type":34,"value":445},{"type":28,"tag":192,"props":1249,"children":1250},{"class":194,"line":280},[1251],{"type":28,"tag":192,"props":1252,"children":1253},{"style":226},[1254],{"type":34,"value":588},{"type":28,"tag":169,"props":1256,"children":1258},{"id":1257},"_3-refactoriser-pour-supprimer-pas-seulement-pour-ajouter",[1259,1261],{"type":34,"value":1260},"3. ",{"type":28,"tag":55,"props":1262,"children":1263},{},[1264],{"type":34,"value":1265},"Refactoriser pour supprimer, pas seulement pour ajouter",{"type":28,"tag":44,"props":1267,"children":1268},{},[1269,1271,1276],{"type":34,"value":1270},"Le refactoring sert aussi à ",{"type":28,"tag":63,"props":1272,"children":1273},{},[1274],{"type":34,"value":1275},"retirer",{"type":34,"value":1277}," ce qui n’a jamais servi. Un projet évolue, certaines parties ajoutées dans l’anticipation ne sont jamais activées. Une revue trimestrielle suffit pour identifier les classes orphelines, les méthodes jamais appelées, les options jamais cochées, et les supprimer sans cérémonie.",{"type":28,"tag":169,"props":1279,"children":1281},{"id":1280},"_4-trancher-en-équipe-sur-le-besoin-réel",[1282,1284],{"type":34,"value":1283},"4. ",{"type":28,"tag":55,"props":1285,"children":1286},{},[1287],{"type":34,"value":1288},"Trancher en équipe sur le besoin réel",{"type":28,"tag":44,"props":1290,"children":1291},{},[1292],{"type":34,"value":1293},"Quand une nouvelle fonctionnalité est proposée, une seule question à poser en stand-up : qui en a besoin maintenant ? Si la réponse est \"personne, mais ça pourrait servir\", la fonctionnalité retourne dans le backlog. Pas de débat, pas de compromis. Le backlog est fait pour ça.",{"type":28,"tag":83,"props":1295,"children":1296},{},[],{"type":28,"tag":37,"props":1298,"children":1300},{"id":1299},"les-deux-pièges-classiques",[1301],{"type":34,"value":1302},"Les deux pièges classiques",{"type":28,"tag":44,"props":1304,"children":1305},{},[1306],{"type":34,"value":1307},"Sur le terrain, deux dérives reviennent constamment.",{"type":28,"tag":44,"props":1309,"children":1310},{},[1311],{"type":34,"value":1312},"La première est le \"juste au cas où\" déguisé en bonne pratique. Un développeur ajoute une couche de gestion multi-devises dans une application qui ne traite que des euros, parce qu’\"on ne sait jamais\". Trois ans plus tard, l’app traite toujours des euros, mais chaque modification du module de paiement doit composer avec une abstraction qui n’a jamais servi. La majorité des scénarios anticipés ne se présentent pas, et ceux qui se présentent ressemblent rarement à ce qu’on avait imaginé.",{"type":28,"tag":44,"props":1314,"children":1315},{},[1316,1318,1323],{"type":34,"value":1317},"La deuxième dérive est l’inverse : confondre YAGNI avec un refus d’anticiper. YAGNI n’interdit pas d’adapter le code quand un besoin réel émerge. Si un client demande une fonctionnalité confirmée et planifiée, on l’implémente. La discipline porte sur les besoins ",{"type":28,"tag":63,"props":1319,"children":1320},{},[1321],{"type":34,"value":1322},"spéculatifs",{"type":34,"value":1324},", pas sur l’évolution légitime du produit. Le critère est simple : un besoin formulé, daté, attribué à un utilisateur identifié, pas un \"ce serait bien si\" entendu en couloir.",{"type":28,"tag":120,"props":1326,"children":1331},{"cta":1327,"href":1328,"title":1329,"type":1330},"Les 100 pratiques que l'IA n'enseigne pas →","https://kamanga.fr/referentiel-craft","YAGNI n'est qu'une pratique parmi les 100 qui font un code propre","product",[1332],{"type":28,"tag":44,"props":1333,"children":1334},{},[1335],{"type":34,"value":1336},"Cet article décortique une discipline : ne pas écrire le code dont vous n'avez pas besoin aujourd'hui. Le Craft Bundle réunit les 100 pratiques que j'applique au quotidien pour coder propre, savoir quand simplifier, quand refactoriser, quand s'arrêter. Ce sont celles que l'IA ne vous apprendra jamais, parce qu'elle ne les a jamais vues tenir sur cinq ans de production.",{"type":28,"tag":83,"props":1338,"children":1339},{},[],{"type":28,"tag":37,"props":1341,"children":1343},{"id":1342},"questions-fréquentes-sur-yagni",[1344],{"type":34,"value":1345},"Questions fréquentes sur YAGNI",{"type":28,"tag":1347,"props":1348,"children":1349},"details",{},[1350,1356],{"type":28,"tag":1351,"props":1352,"children":1353},"summary",{},[1354],{"type":34,"value":1355},"YAGNI veut-il dire \"ne jamais anticiper\" ?",{"type":28,"tag":44,"props":1357,"children":1358},{},[1359,1361,1366],{"type":34,"value":1360},"Non. YAGNI cible le code écrit pour des besoins ",{"type":28,"tag":63,"props":1362,"children":1363},{},[1364],{"type":34,"value":1365},"non confirmés",{"type":34,"value":1367},". Si vous savez avec certitude qu’une fonctionnalité sera livrée dans deux semaines parce qu’elle est validée et planifiée, l’ignorer serait absurde. La règle s’applique aux \"au cas où\", pas aux engagements pris.",{"type":28,"tag":1347,"props":1369,"children":1370},{},[1371,1376],{"type":28,"tag":1351,"props":1372,"children":1373},{},[1374],{"type":34,"value":1375},"Comment l’expliquer à un client qui demande des fonctionnalités \"pour plus tard\" ?",{"type":28,"tag":44,"props":1377,"children":1378},{},[1379],{"type":34,"value":1380},"Sortez les chiffres. Une fonctionnalité ajoutée prématurément coûte trois fois : à l’écriture, à la maintenance, et au moment où il faudra la retirer ou la modifier parce que le besoin réel ne correspond pas à ce qui a été imaginé. Proposez plutôt de garder le besoin dans le backlog et de l’implémenter quand il sera confirmé, avec une meilleure compréhension du contexte réel.",{"type":28,"tag":1347,"props":1382,"children":1383},{},[1384,1389],{"type":28,"tag":1351,"props":1385,"children":1386},{},[1387],{"type":34,"value":1388},"\"Si je ne l’ajoute pas maintenant, je devrai tout refaire plus tard\", vraiment ?",{"type":28,"tag":44,"props":1390,"children":1391},{},[1392],{"type":34,"value":1393},"Cette peur est compréhensible mais le terrain la dément. Un code minimal est plus facile à étendre qu’un code sur-conçu. Quand le besoin réel arrive, il diffère presque toujours de ce qui avait été anticipé : l’abstraction préventive devient un obstacle, pas un raccourci.",{"type":28,"tag":1347,"props":1395,"children":1396},{},[1397,1402],{"type":28,"tag":1351,"props":1398,"children":1399},{},[1400],{"type":34,"value":1401},"YAGNI et architectures évolutives : compatibles ?",{"type":28,"tag":44,"props":1403,"children":1404},{},[1405,1407,1412],{"type":34,"value":1406},"Oui. YAGNI ne s’oppose pas à la qualité ni au design : il s’oppose à la spéculation. Vous pouvez parfaitement appliquer SOLID, écrire des interfaces propres et concevoir des modules cohérents ",{"type":28,"tag":63,"props":1408,"children":1409},{},[1410],{"type":34,"value":1411},"sur le code que vous avez besoin d’écrire aujourd’hui",{"type":34,"value":1413},". La différence est qu’on n’invente pas de points d’extension pour des extensions qui n’existent pas encore.",{"type":28,"tag":83,"props":1415,"children":1416},{},[],{"type":28,"tag":37,"props":1418,"children":1420},{"id":1419},"conclusion",[1421],{"type":34,"value":1422},"Conclusion",{"type":28,"tag":44,"props":1424,"children":1425},{},[1426,1428,1433,1435,1440],{"type":34,"value":1427},"YAGNI ne rend pas votre code meilleur : il vous évite simplement de l’aggraver avec des fonctionnalités que personne n’a demandées. La discipline est moins intuitive qu’il n’y paraît, parce qu’elle suppose d’accepter une forme d’inconfort : ne pas écrire le code qu’on aurait ",{"type":28,"tag":63,"props":1429,"children":1430},{},[1431],{"type":34,"value":1432},"envie",{"type":34,"value":1434}," d’écrire, ne pas anticiper ce qu’on ",{"type":28,"tag":63,"props":1436,"children":1437},{},[1438],{"type":34,"value":1439},"imagine",{"type":34,"value":1441}," utile, faire confiance au backlog pour rattraper le besoin quand il sera réel. C’est cette retenue qui distingue les bases de code qui vieillissent bien des autres.",{"type":28,"tag":120,"props":1443,"children":1448},{"cta":1444,"href":1445,"title":1446,"type":1447},"Accéder à l'assessment gratuit →","/mes-ressources","Ressource gratuite : Votre équipe livre-t-elle aussi vite qu'elle le pourrait ?","resource",[1449],{"type":28,"tag":44,"props":1450,"children":1451},{},[1452],{"type":34,"value":1453},"30 questions, 5 dimensions, score sur 100. Mesurez la maturité engineering de votre équipe avec le benchmark utilisé dans des DSI de 50 à 800+ développeurs, et identifiez vos 3 chantiers prioritaires.",{"type":28,"tag":1455,"props":1456,"children":1457},"style",{},[1458],{"type":34,"value":1459},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":8,"searchDepth":205,"depth":205,"links":1461},[1462],{"id":31,"depth":205,"text":35,"children":1463},[1464,1465,1466,1467,1468,1469,1470],{"id":39,"depth":232,"text":42},{"id":88,"depth":232,"text":91},{"id":134,"depth":232,"text":137},{"id":607,"depth":232,"text":610},{"id":1299,"depth":232,"text":1302},{"id":1342,"depth":232,"text":1345},{"id":1419,"depth":232,"text":1422},"markdown","content:fr:dette-technique:yagni-ecrire-code-qualite-sans-fonctionnalites-inutiles.md","content","fr/dette-technique/yagni-ecrire-code-qualite-sans-fonctionnalites-inutiles.md","fr/dette-technique/yagni-ecrire-code-qualite-sans-fonctionnalites-inutiles","md",{"_path":1478,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":1479,"description":1480,"id":1481,"date":1482,"listed":13,"nocomments":7,"hidden":7,"categories":1483,"tags":1485,"cover":1488,"readingTime":1489,"body":1494,"_type":1471,"_id":3975,"_source":1473,"_file":3976,"_stem":3977,"_extension":1476},"/fr/dette-technique/software-craftsmanship-principes-exemples-java","Software Craftsmanship, Principes, Exemples Java et Astuces pour un Code Propre","Découvrez le Software Craftsmanship et comment appliquer ses principes à travers des exemples concrets en Java, des outils recommandés et des astuces pour améliorer votre code.",46,"2024-05-25",[1484],"Principes du software craftsmanship",[1486,1487],"principe","qualité","covers/articles/software-craftsmanship.jpg",{"text":1490,"minutes":1491,"time":1492,"words":1493},"9 min read",8.885,533100,1777,{"type":25,"children":1495,"toc":3964},[1496,1502,1508,1513,1525,1528,1534,1552,1558,1570,1576,1595,1614,1617,1626,1632,1643,1657,1665,1840,1874,1894,1902,2111,2124,2132,2305,2313,2431,2444,2447,2453,2464,2470,2475,2498,2506,2727,2735,3078,3083,3086,3092,3097,3105,3241,3246,3249,3255,3268,3273,3280,3386,3393,3503,3508,3511,3517,3543,3546,3552,3557,3563,3586,3592,3615,3800,3806,3829,3832,3838,3848,3858,3861,3867,3872,3881,3884,3890,3915,3928,3941,3944,3948,3953,3960],{"type":28,"tag":37,"props":1497,"children":1499},{"id":1498},"software-craftsmanship-guide-complet-pour-un-code-propre-et-maintenable",[1500],{"type":34,"value":1501},"Software Craftsmanship : Guide Complet pour un Code Propre et Maintenable",{"type":28,"tag":169,"props":1503,"children":1505},{"id":1504},"introduction-quest-ce-que-le-software-craftsmanship",[1506],{"type":34,"value":1507},"Introduction : Qu'est-ce que le Software Craftsmanship ?",{"type":28,"tag":44,"props":1509,"children":1510},{},[1511],{"type":34,"value":1512},"Mission chez Agirc-Arrco, équipe d’une douzaine de développeurs sur une plateforme métier critique. Le code tournait, les sprints se bouclaient, et pourtant chaque modification prenait deux fois plus de temps que prévu. Diagnostic : pas de tests sur les modules anciens, des classes de mille lignes héritées sans documentation, un refactoring que personne n’osait engager. Même topo chez ING Bank quelques mois plus tard sur un projet de paiements : la livraison fonctionnait, mais la dette technique mangeait 40 % de la capacité de l’équipe.",{"type":28,"tag":44,"props":1514,"children":1515},{},[1516,1518,1523],{"type":34,"value":1517},"Dans les deux cas, le redressement est passé par la même chose : adopter une posture d’artisan logiciel. Pas un label marketing, mais un ensemble de pratiques exigeantes : tests d’abord, refactoring continu, revues sérieuses, code que ses auteurs n’ont pas honte de montrer. Le ",{"type":28,"tag":55,"props":1519,"children":1520},{},[1521],{"type":34,"value":1522},"Software Craftsmanship",{"type":34,"value":1524}," porte un nom à cette discipline et la formalise depuis 2009. Cet article en pose les principes et montre, exemples Java à l’appui, comment les appliquer sans transformer chaque sprint en débat philosophique.",{"type":28,"tag":83,"props":1526,"children":1527},{},[],{"type":28,"tag":37,"props":1529,"children":1531},{"id":1530},"les-origines-du-software-craftsmanship",[1532],{"type":34,"value":1533},"Les origines du Software Craftsmanship",{"type":28,"tag":44,"props":1535,"children":1536},{},[1537,1539,1543,1545,1550],{"type":34,"value":1538},"Le mouvement ",{"type":28,"tag":55,"props":1540,"children":1541},{},[1542],{"type":34,"value":1522},{"type":34,"value":1544}," trouve ses racines dans la volonté d’améliorer la qualité du code produit dans l'industrie du logiciel. Il s'agit d'une réponse directe aux pratiques de développement qui privilégient la vitesse au détriment de la qualité, souvent encouragées par des approches ",{"type":28,"tag":55,"props":1546,"children":1547},{},[1548],{"type":34,"value":1549},"agiles",{"type":34,"value":1551}," mal interprétées.",{"type":28,"tag":169,"props":1553,"children":1555},{"id":1554},"_1-le-manifeste-agile-2001",[1556],{"type":34,"value":1557},"1. Le Manifeste Agile (2001)",{"type":28,"tag":44,"props":1559,"children":1560},{},[1561,1563,1568],{"type":34,"value":1562},"Tout commence en 2001 avec le ",{"type":28,"tag":55,"props":1564,"children":1565},{},[1566],{"type":34,"value":1567},"Manifeste Agile",{"type":34,"value":1569}," qui prône l'adaptation et la flexibilité dans le développement logiciel. Cependant, au fil des années, certains développeurs ont constaté que la méthodologie agile était parfois utilisée pour justifier un travail rapide et bâclé.",{"type":28,"tag":169,"props":1571,"children":1573},{"id":1572},"_2-le-manifeste-du-software-craftsmanship-2009",[1574],{"type":34,"value":1575},"2. Le Manifeste du Software Craftsmanship (2009)",{"type":28,"tag":44,"props":1577,"children":1578},{},[1579,1581,1586,1588,1593],{"type":34,"value":1580},"En 2009, un groupe de développeurs autour de ",{"type":28,"tag":55,"props":1582,"children":1583},{},[1584],{"type":34,"value":1585},"Robert C. Martin",{"type":34,"value":1587}," (Uncle Bob) publie le ",{"type":28,"tag":55,"props":1589,"children":1590},{},[1591],{"type":34,"value":1592},"Manifeste du Software Craftsmanship",{"type":34,"value":1594},". Le texte ajoute quatre engagements à ceux du Manifeste Agile : du logiciel bien conçu, pas seulement fonctionnel ; de la valeur ajoutée en continu, pas seulement de la réactivité ; une communauté de professionnels qui partagent leurs pratiques ; une collaboration productive avec le client, pas seulement de la collaboration.",{"type":28,"tag":44,"props":1596,"children":1597},{},[1598,1600,1605,1607,1612],{"type":34,"value":1599},"L’extension est naturelle : l’agilité dit ",{"type":28,"tag":63,"props":1601,"children":1602},{},[1603],{"type":34,"value":1604},"comment",{"type":34,"value":1606}," livrer, le craftsmanship dit ",{"type":28,"tag":63,"props":1608,"children":1609},{},[1610],{"type":34,"value":1611},"à quelle qualité",{"type":34,"value":1613},". Sans cette deuxième conversation, les sprints rapides finissent en sprints rapides vers le mur.",{"type":28,"tag":83,"props":1615,"children":1616},{},[],{"type":28,"tag":120,"props":1618,"children":1620},{"cta":122,"href":123,"title":1619,"type":125},"Vous voulez écrire un code dont vous n'avez plus honte en revue ?",[1621],{"type":28,"tag":44,"props":1622,"children":1623},{},[1624],{"type":34,"value":1625},"Le clean code, le TDD et le refactoring sans casse ne s'attrapent pas en lisant un article : ça se travaille sur votre propre code. En mentoring 1:1, je relis vos classes avec vous, je vous montre où extraire, où tester d'abord, où simplifier. Vous prenez le réflexe de l'artisan au lieu de juste connaître les principes.",{"type":28,"tag":37,"props":1627,"children":1629},{"id":1628},"les-principes-fondamentaux-du-software-craftsmanship",[1630],{"type":34,"value":1631},"Les principes fondamentaux du Software Craftsmanship",{"type":28,"tag":44,"props":1633,"children":1634},{},[1635,1637,1641],{"type":34,"value":1636},"Le ",{"type":28,"tag":55,"props":1638,"children":1639},{},[1640],{"type":34,"value":1522},{"type":34,"value":1642}," repose sur plusieurs principes clés qui vont bien au-delà du simple fait d'écrire du code qui fonctionne. C'est une approche qui valorise la qualité du code et la collaboration au sein de la communauté des développeurs. Voici les principes fondamentaux :",{"type":28,"tag":1644,"props":1645,"children":1646},"ol",{},[1647],{"type":28,"tag":148,"props":1648,"children":1649},{},[1650,1655],{"type":28,"tag":55,"props":1651,"children":1652},{},[1653],{"type":34,"value":1654},"Code propre (Clean Code)",{"type":34,"value":1656},"\nLisible, maintenable, testé. Un autre développeur (ou vous dans six mois) doit comprendre le code sans archéologie. Cela passe par des noms explicites, des fonctions courtes, une responsabilité claire par classe.",{"type":28,"tag":44,"props":1658,"children":1659},{},[1660],{"type":28,"tag":63,"props":1661,"children":1662},{},[1663],{"type":34,"value":1664},"Exemple Java :",{"type":28,"tag":181,"props":1666,"children":1668},{"className":183,"code":1667,"language":185,"meta":8,"style":8},"public class Calculateur {\n    public double calculerMoyenne(List\u003CInteger> nombres) {\n        return nombres.stream().mapToInt(Integer::intValue).average().orElse(0);\n    }\n}\n",[1669],{"type":28,"tag":188,"props":1670,"children":1671},{"__ignoreMap":8},[1672,1692,1746,1826,1833],{"type":28,"tag":192,"props":1673,"children":1674},{"class":194,"line":195},[1675,1679,1683,1688],{"type":28,"tag":192,"props":1676,"children":1677},{"style":209},[1678],{"type":34,"value":212},{"type":28,"tag":192,"props":1680,"children":1681},{"style":209},[1682],{"type":34,"value":217},{"type":28,"tag":192,"props":1684,"children":1685},{"style":220},[1686],{"type":34,"value":1687}," Calculateur",{"type":28,"tag":192,"props":1689,"children":1690},{"style":226},[1691],{"type":34,"value":229},{"type":28,"tag":192,"props":1693,"children":1694},{"class":194,"line":205},[1695,1699,1704,1709,1713,1718,1723,1728,1733,1738,1742],{"type":28,"tag":192,"props":1696,"children":1697},{"style":209},[1698],{"type":34,"value":322},{"type":28,"tag":192,"props":1700,"children":1701},{"style":209},[1702],{"type":34,"value":1703}," double",{"type":28,"tag":192,"props":1705,"children":1706},{"style":325},[1707],{"type":34,"value":1708}," calculerMoyenne",{"type":28,"tag":192,"props":1710,"children":1711},{"style":226},[1712],{"type":34,"value":332},{"type":28,"tag":192,"props":1714,"children":1715},{"style":241},[1716],{"type":34,"value":1717},"List",{"type":28,"tag":192,"props":1719,"children":1720},{"style":226},[1721],{"type":34,"value":1722},"\u003C",{"type":28,"tag":192,"props":1724,"children":1725},{"style":209},[1726],{"type":34,"value":1727},"Integer",{"type":28,"tag":192,"props":1729,"children":1730},{"style":226},[1731],{"type":34,"value":1732},">",{"type":28,"tag":192,"props":1734,"children":1735},{"style":340},[1736],{"type":34,"value":1737}," nombres",{"type":28,"tag":192,"props":1739,"children":1740},{"style":226},[1741],{"type":34,"value":360},{"type":28,"tag":192,"props":1743,"children":1744},{"style":226},[1745],{"type":34,"value":229},{"type":28,"tag":192,"props":1747,"children":1748},{"class":194,"line":232},[1749,1753,1757,1761,1766,1771,1776,1780,1784,1789,1794,1799,1804,1808,1813,1817,1822],{"type":28,"tag":192,"props":1750,"children":1751},{"style":209},[1752],{"type":34,"value":488},{"type":28,"tag":192,"props":1754,"children":1755},{"style":247},[1756],{"type":34,"value":1737},{"type":28,"tag":192,"props":1758,"children":1759},{"style":226},[1760],{"type":34,"value":379},{"type":28,"tag":192,"props":1762,"children":1763},{"style":325},[1764],{"type":34,"value":1765},"stream",{"type":28,"tag":192,"props":1767,"children":1768},{"style":226},[1769],{"type":34,"value":1770},"().",{"type":28,"tag":192,"props":1772,"children":1773},{"style":325},[1774],{"type":34,"value":1775},"mapToInt",{"type":28,"tag":192,"props":1777,"children":1778},{"style":226},[1779],{"type":34,"value":332},{"type":28,"tag":192,"props":1781,"children":1782},{"style":247},[1783],{"type":34,"value":1727},{"type":28,"tag":192,"props":1785,"children":1786},{"style":209},[1787],{"type":34,"value":1788},"::",{"type":28,"tag":192,"props":1790,"children":1791},{"style":247},[1792],{"type":34,"value":1793},"intValue",{"type":28,"tag":192,"props":1795,"children":1796},{"style":226},[1797],{"type":34,"value":1798},").",{"type":28,"tag":192,"props":1800,"children":1801},{"style":325},[1802],{"type":34,"value":1803},"average",{"type":28,"tag":192,"props":1805,"children":1806},{"style":226},[1807],{"type":34,"value":1770},{"type":28,"tag":192,"props":1809,"children":1810},{"style":325},[1811],{"type":34,"value":1812},"orElse",{"type":28,"tag":192,"props":1814,"children":1815},{"style":226},[1816],{"type":34,"value":332},{"type":28,"tag":192,"props":1818,"children":1819},{"style":744},[1820],{"type":34,"value":1821},"0",{"type":28,"tag":192,"props":1823,"children":1824},{"style":226},[1825],{"type":34,"value":752},{"type":28,"tag":192,"props":1827,"children":1828},{"class":194,"line":258},[1829],{"type":28,"tag":192,"props":1830,"children":1831},{"style":226},[1832],{"type":34,"value":445},{"type":28,"tag":192,"props":1834,"children":1835},{"class":194,"line":280},[1836],{"type":28,"tag":192,"props":1837,"children":1838},{"style":226},[1839],{"type":34,"value":588},{"type":28,"tag":1841,"props":1842,"children":1844},"alert",{"type":1843},"TIP",[1845],{"type":28,"tag":44,"props":1846,"children":1847},{},[1848,1850,1856,1858,1864,1866,1872],{"type":34,"value":1849},"Le nom d’une méthode doit décrire son intention sans ambiguïté. ",{"type":28,"tag":188,"props":1851,"children":1853},{"className":1852},[],[1854],{"type":34,"value":1855},"calculerMoyenne",{"type":34,"value":1857}," parle, ",{"type":28,"tag":188,"props":1859,"children":1861},{"className":1860},[],[1862],{"type":34,"value":1863},"calc",{"type":34,"value":1865}," ou ",{"type":28,"tag":188,"props":1867,"children":1869},{"className":1868},[],[1870],{"type":34,"value":1871},"moy",{"type":34,"value":1873}," obligent à ouvrir l’implémentation pour deviner.",{"type":28,"tag":1644,"props":1875,"children":1876},{"start":205},[1877],{"type":28,"tag":148,"props":1878,"children":1879},{},[1880,1885,1887,1892],{"type":28,"tag":55,"props":1881,"children":1882},{},[1883],{"type":34,"value":1884},"Tests automatisés",{"type":34,"value":1886},"\nLe développement piloté par les tests (",{"type":28,"tag":55,"props":1888,"children":1889},{},[1890],{"type":34,"value":1891},"TDD",{"type":34,"value":1893},") reste l’ossature du craftsmanship. Test d’abord, code ensuite, juste assez pour passer au vert. Le bénéfice n’est pas qu’une question de bugs évités : c’est aussi le filet qui rend le refactoring possible.",{"type":28,"tag":44,"props":1895,"children":1896},{},[1897],{"type":28,"tag":63,"props":1898,"children":1899},{},[1900],{"type":34,"value":1901},"Exemple Java avec JUnit :",{"type":28,"tag":181,"props":1903,"children":1905},{"className":183,"code":1904,"language":185,"meta":8,"style":8},"@Test\npublic void testCalculerMoyenne() {\n    Calculateur calc = new Calculateur();\n    List\u003CInteger> nombres = Arrays.asList(2, 4, 6);\n    assertEquals(4.0, calc.calculerMoyenne(nombres), 0.01);\n}\n",[1906],{"type":28,"tag":188,"props":1907,"children":1908},{"__ignoreMap":8},[1909,1920,1944,1974,2048,2104],{"type":28,"tag":192,"props":1910,"children":1911},{"class":194,"line":195},[1912,1916],{"type":28,"tag":192,"props":1913,"children":1914},{"style":667},[1915],{"type":34,"value":670},{"type":28,"tag":192,"props":1917,"children":1918},{"style":673},[1919],{"type":34,"value":676},{"type":28,"tag":192,"props":1921,"children":1922},{"class":194,"line":205},[1923,1927,1931,1936,1940],{"type":28,"tag":192,"props":1924,"children":1925},{"style":209},[1926],{"type":34,"value":212},{"type":28,"tag":192,"props":1928,"children":1929},{"style":209},[1930],{"type":34,"value":688},{"type":28,"tag":192,"props":1932,"children":1933},{"style":325},[1934],{"type":34,"value":1935}," testCalculerMoyenne",{"type":28,"tag":192,"props":1937,"children":1938},{"style":226},[1939],{"type":34,"value":475},{"type":28,"tag":192,"props":1941,"children":1942},{"style":226},[1943],{"type":34,"value":229},{"type":28,"tag":192,"props":1945,"children":1946},{"class":194,"line":232},[1947,1952,1957,1961,1965,1969],{"type":28,"tag":192,"props":1948,"children":1949},{"style":241},[1950],{"type":34,"value":1951},"    Calculateur",{"type":28,"tag":192,"props":1953,"children":1954},{"style":247},[1955],{"type":34,"value":1956}," calc ",{"type":28,"tag":192,"props":1958,"children":1959},{"style":387},[1960],{"type":34,"value":390},{"type":28,"tag":192,"props":1962,"children":1963},{"style":209},[1964],{"type":34,"value":723},{"type":28,"tag":192,"props":1966,"children":1967},{"style":325},[1968],{"type":34,"value":1687},{"type":28,"tag":192,"props":1970,"children":1971},{"style":226},[1972],{"type":34,"value":1973},"();\n",{"type":28,"tag":192,"props":1975,"children":1976},{"class":194,"line":258},[1977,1982,1986,1990,1994,1999,2003,2008,2012,2017,2021,2026,2030,2035,2039,2044],{"type":28,"tag":192,"props":1978,"children":1979},{"style":241},[1980],{"type":34,"value":1981},"    List",{"type":28,"tag":192,"props":1983,"children":1984},{"style":226},[1985],{"type":34,"value":1722},{"type":28,"tag":192,"props":1987,"children":1988},{"style":209},[1989],{"type":34,"value":1727},{"type":28,"tag":192,"props":1991,"children":1992},{"style":226},[1993],{"type":34,"value":1732},{"type":28,"tag":192,"props":1995,"children":1996},{"style":247},[1997],{"type":34,"value":1998}," nombres ",{"type":28,"tag":192,"props":2000,"children":2001},{"style":387},[2002],{"type":34,"value":390},{"type":28,"tag":192,"props":2004,"children":2005},{"style":247},[2006],{"type":34,"value":2007}," Arrays",{"type":28,"tag":192,"props":2009,"children":2010},{"style":226},[2011],{"type":34,"value":379},{"type":28,"tag":192,"props":2013,"children":2014},{"style":325},[2015],{"type":34,"value":2016},"asList",{"type":28,"tag":192,"props":2018,"children":2019},{"style":226},[2020],{"type":34,"value":332},{"type":28,"tag":192,"props":2022,"children":2023},{"style":744},[2024],{"type":34,"value":2025},"2",{"type":28,"tag":192,"props":2027,"children":2028},{"style":226},[2029],{"type":34,"value":347},{"type":28,"tag":192,"props":2031,"children":2032},{"style":744},[2033],{"type":34,"value":2034}," 4",{"type":28,"tag":192,"props":2036,"children":2037},{"style":226},[2038],{"type":34,"value":347},{"type":28,"tag":192,"props":2040,"children":2041},{"style":744},[2042],{"type":34,"value":2043}," 6",{"type":28,"tag":192,"props":2045,"children":2046},{"style":226},[2047],{"type":34,"value":752},{"type":28,"tag":192,"props":2049,"children":2050},{"class":194,"line":280},[2051,2055,2059,2064,2068,2073,2077,2081,2085,2090,2095,2100],{"type":28,"tag":192,"props":2052,"children":2053},{"style":325},[2054],{"type":34,"value":760},{"type":28,"tag":192,"props":2056,"children":2057},{"style":226},[2058],{"type":34,"value":332},{"type":28,"tag":192,"props":2060,"children":2061},{"style":744},[2062],{"type":34,"value":2063},"4.0",{"type":28,"tag":192,"props":2065,"children":2066},{"style":226},[2067],{"type":34,"value":347},{"type":28,"tag":192,"props":2069,"children":2070},{"style":247},[2071],{"type":34,"value":2072}," calc",{"type":28,"tag":192,"props":2074,"children":2075},{"style":226},[2076],{"type":34,"value":379},{"type":28,"tag":192,"props":2078,"children":2079},{"style":325},[2080],{"type":34,"value":1855},{"type":28,"tag":192,"props":2082,"children":2083},{"style":226},[2084],{"type":34,"value":332},{"type":28,"tag":192,"props":2086,"children":2087},{"style":247},[2088],{"type":34,"value":2089},"nombres",{"type":28,"tag":192,"props":2091,"children":2092},{"style":226},[2093],{"type":34,"value":2094},"),",{"type":28,"tag":192,"props":2096,"children":2097},{"style":744},[2098],{"type":34,"value":2099}," 0.01",{"type":28,"tag":192,"props":2101,"children":2102},{"style":226},[2103],{"type":34,"value":752},{"type":28,"tag":192,"props":2105,"children":2106},{"class":194,"line":307},[2107],{"type":28,"tag":192,"props":2108,"children":2109},{"style":226},[2110],{"type":34,"value":588},{"type":28,"tag":1644,"props":2112,"children":2113},{"start":232},[2114],{"type":28,"tag":148,"props":2115,"children":2116},{},[2117,2122],{"type":28,"tag":55,"props":2118,"children":2119},{},[2120],{"type":34,"value":2121},"Refactoring constant",{"type":34,"value":2123},"\nAméliorer la structure du code sans changer son comportement. Cette pratique garde la base saine à mesure que le projet grossit, et n’a de sens qu’adossée à une couverture de tests sérieuse.",{"type":28,"tag":44,"props":2125,"children":2126},{},[2127],{"type":28,"tag":63,"props":2128,"children":2129},{},[2130],{"type":34,"value":2131},"Avant :",{"type":28,"tag":181,"props":2133,"children":2135},{"className":183,"code":2134,"language":185,"meta":8,"style":8},"public double calculerTotal(List\u003CInteger> prix) {\n    double total = 0;\n    for (int prixUnitaire : prix) {\n        total += prixUnitaire;\n    }\n    return total;\n}\n",[2136],{"type":28,"tag":188,"props":2137,"children":2138},{"__ignoreMap":8},[2139,2188,2214,2252,2274,2281,2298],{"type":28,"tag":192,"props":2140,"children":2141},{"class":194,"line":195},[2142,2146,2150,2155,2159,2163,2167,2171,2175,2180,2184],{"type":28,"tag":192,"props":2143,"children":2144},{"style":209},[2145],{"type":34,"value":212},{"type":28,"tag":192,"props":2147,"children":2148},{"style":209},[2149],{"type":34,"value":1703},{"type":28,"tag":192,"props":2151,"children":2152},{"style":325},[2153],{"type":34,"value":2154}," calculerTotal",{"type":28,"tag":192,"props":2156,"children":2157},{"style":226},[2158],{"type":34,"value":332},{"type":28,"tag":192,"props":2160,"children":2161},{"style":241},[2162],{"type":34,"value":1717},{"type":28,"tag":192,"props":2164,"children":2165},{"style":387},[2166],{"type":34,"value":1722},{"type":28,"tag":192,"props":2168,"children":2169},{"style":247},[2170],{"type":34,"value":1727},{"type":28,"tag":192,"props":2172,"children":2173},{"style":387},[2174],{"type":34,"value":1732},{"type":28,"tag":192,"props":2176,"children":2177},{"style":247},[2178],{"type":34,"value":2179}," prix",{"type":28,"tag":192,"props":2181,"children":2182},{"style":226},[2183],{"type":34,"value":360},{"type":28,"tag":192,"props":2185,"children":2186},{"style":226},[2187],{"type":34,"value":229},{"type":28,"tag":192,"props":2189,"children":2190},{"class":194,"line":205},[2191,2196,2201,2205,2210],{"type":28,"tag":192,"props":2192,"children":2193},{"style":209},[2194],{"type":34,"value":2195},"    double",{"type":28,"tag":192,"props":2197,"children":2198},{"style":247},[2199],{"type":34,"value":2200}," total ",{"type":28,"tag":192,"props":2202,"children":2203},{"style":387},[2204],{"type":34,"value":390},{"type":28,"tag":192,"props":2206,"children":2207},{"style":744},[2208],{"type":34,"value":2209}," 0",{"type":28,"tag":192,"props":2211,"children":2212},{"style":226},[2213],{"type":34,"value":255},{"type":28,"tag":192,"props":2215,"children":2216},{"class":194,"line":232},[2217,2222,2226,2230,2235,2240,2244,2248],{"type":28,"tag":192,"props":2218,"children":2219},{"style":209},[2220],{"type":34,"value":2221},"    for",{"type":28,"tag":192,"props":2223,"children":2224},{"style":226},[2225],{"type":34,"value":991},{"type":28,"tag":192,"props":2227,"children":2228},{"style":209},[2229],{"type":34,"value":938},{"type":28,"tag":192,"props":2231,"children":2232},{"style":247},[2233],{"type":34,"value":2234}," prixUnitaire ",{"type":28,"tag":192,"props":2236,"children":2237},{"style":209},[2238],{"type":34,"value":2239},":",{"type":28,"tag":192,"props":2241,"children":2242},{"style":247},[2243],{"type":34,"value":2179},{"type":28,"tag":192,"props":2245,"children":2246},{"style":226},[2247],{"type":34,"value":360},{"type":28,"tag":192,"props":2249,"children":2250},{"style":226},[2251],{"type":34,"value":229},{"type":28,"tag":192,"props":2253,"children":2254},{"class":194,"line":258},[2255,2260,2265,2270],{"type":28,"tag":192,"props":2256,"children":2257},{"style":247},[2258],{"type":34,"value":2259},"        total ",{"type":28,"tag":192,"props":2261,"children":2262},{"style":387},[2263],{"type":34,"value":2264},"+=",{"type":28,"tag":192,"props":2266,"children":2267},{"style":247},[2268],{"type":34,"value":2269}," prixUnitaire",{"type":28,"tag":192,"props":2271,"children":2272},{"style":226},[2273],{"type":34,"value":255},{"type":28,"tag":192,"props":2275,"children":2276},{"class":194,"line":280},[2277],{"type":28,"tag":192,"props":2278,"children":2279},{"style":226},[2280],{"type":34,"value":445},{"type":28,"tag":192,"props":2282,"children":2283},{"class":194,"line":307},[2284,2289,2294],{"type":28,"tag":192,"props":2285,"children":2286},{"style":209},[2287],{"type":34,"value":2288},"    return",{"type":28,"tag":192,"props":2290,"children":2291},{"style":247},[2292],{"type":34,"value":2293}," total",{"type":28,"tag":192,"props":2295,"children":2296},{"style":226},[2297],{"type":34,"value":255},{"type":28,"tag":192,"props":2299,"children":2300},{"class":194,"line":316},[2301],{"type":28,"tag":192,"props":2302,"children":2303},{"style":226},[2304],{"type":34,"value":588},{"type":28,"tag":44,"props":2306,"children":2307},{},[2308],{"type":28,"tag":63,"props":2309,"children":2310},{},[2311],{"type":34,"value":2312},"Après :",{"type":28,"tag":181,"props":2314,"children":2316},{"className":183,"code":2315,"language":185,"meta":8,"style":8},"public double calculerTotal(List\u003CInteger> prix) {\n    return prix.stream().mapToDouble(Integer::intValue).sum();\n}\n",[2317],{"type":28,"tag":188,"props":2318,"children":2319},{"__ignoreMap":8},[2320,2367,2424],{"type":28,"tag":192,"props":2321,"children":2322},{"class":194,"line":195},[2323,2327,2331,2335,2339,2343,2347,2351,2355,2359,2363],{"type":28,"tag":192,"props":2324,"children":2325},{"style":209},[2326],{"type":34,"value":212},{"type":28,"tag":192,"props":2328,"children":2329},{"style":209},[2330],{"type":34,"value":1703},{"type":28,"tag":192,"props":2332,"children":2333},{"style":325},[2334],{"type":34,"value":2154},{"type":28,"tag":192,"props":2336,"children":2337},{"style":226},[2338],{"type":34,"value":332},{"type":28,"tag":192,"props":2340,"children":2341},{"style":241},[2342],{"type":34,"value":1717},{"type":28,"tag":192,"props":2344,"children":2345},{"style":387},[2346],{"type":34,"value":1722},{"type":28,"tag":192,"props":2348,"children":2349},{"style":247},[2350],{"type":34,"value":1727},{"type":28,"tag":192,"props":2352,"children":2353},{"style":387},[2354],{"type":34,"value":1732},{"type":28,"tag":192,"props":2356,"children":2357},{"style":247},[2358],{"type":34,"value":2179},{"type":28,"tag":192,"props":2360,"children":2361},{"style":226},[2362],{"type":34,"value":360},{"type":28,"tag":192,"props":2364,"children":2365},{"style":226},[2366],{"type":34,"value":229},{"type":28,"tag":192,"props":2368,"children":2369},{"class":194,"line":205},[2370,2374,2378,2382,2386,2390,2395,2399,2403,2407,2411,2415,2420],{"type":28,"tag":192,"props":2371,"children":2372},{"style":209},[2373],{"type":34,"value":2288},{"type":28,"tag":192,"props":2375,"children":2376},{"style":247},[2377],{"type":34,"value":2179},{"type":28,"tag":192,"props":2379,"children":2380},{"style":226},[2381],{"type":34,"value":379},{"type":28,"tag":192,"props":2383,"children":2384},{"style":325},[2385],{"type":34,"value":1765},{"type":28,"tag":192,"props":2387,"children":2388},{"style":226},[2389],{"type":34,"value":1770},{"type":28,"tag":192,"props":2391,"children":2392},{"style":325},[2393],{"type":34,"value":2394},"mapToDouble",{"type":28,"tag":192,"props":2396,"children":2397},{"style":226},[2398],{"type":34,"value":332},{"type":28,"tag":192,"props":2400,"children":2401},{"style":247},[2402],{"type":34,"value":1727},{"type":28,"tag":192,"props":2404,"children":2405},{"style":209},[2406],{"type":34,"value":1788},{"type":28,"tag":192,"props":2408,"children":2409},{"style":247},[2410],{"type":34,"value":1793},{"type":28,"tag":192,"props":2412,"children":2413},{"style":226},[2414],{"type":34,"value":1798},{"type":28,"tag":192,"props":2416,"children":2417},{"style":325},[2418],{"type":34,"value":2419},"sum",{"type":28,"tag":192,"props":2421,"children":2422},{"style":226},[2423],{"type":34,"value":1973},{"type":28,"tag":192,"props":2425,"children":2426},{"class":194,"line":232},[2427],{"type":28,"tag":192,"props":2428,"children":2429},{"style":226},[2430],{"type":34,"value":588},{"type":28,"tag":1644,"props":2432,"children":2433},{"start":258},[2434],{"type":28,"tag":148,"props":2435,"children":2436},{},[2437,2442],{"type":28,"tag":55,"props":2438,"children":2439},{},[2440],{"type":34,"value":2441},"Apprendre et transmettre",{"type":34,"value":2443},"\nLe métier évolue vite. Lectures régulières, participation aux revues, mentorat ascendant ou descendant : un artisan logiciel investit dans sa pratique et celle des autres. Une équipe qui ne partage pas ses pratiques régresse, même si chaque individu progresse.",{"type":28,"tag":83,"props":2445,"children":2446},{},[],{"type":28,"tag":37,"props":2448,"children":2450},{"id":2449},"comment-appliquer-ces-principes-dans-votre-code-au-quotidien-avec-exemples-java",[2451],{"type":34,"value":2452},"Comment appliquer ces principes dans votre code au quotidien (avec exemples Java)",{"type":28,"tag":44,"props":2454,"children":2455},{},[2456,2458,2462],{"type":34,"value":2457},"Voyons ",{"type":28,"tag":55,"props":2459,"children":2460},{},[2461],{"type":34,"value":1604},{"type":34,"value":2463}," appliquer de manière concrète ces principes dans votre développement quotidien.",{"type":28,"tag":169,"props":2465,"children":2467},{"id":2466},"_1-code-propre-structure-et-lisibilité",[2468],{"type":34,"value":2469},"1. Code propre : Structure et lisibilité",{"type":28,"tag":44,"props":2471,"children":2472},{},[2473],{"type":34,"value":2474},"Quand je parle de code propre, cela signifie que chaque partie de votre code doit être facilement compréhensible et maintenable. Voici quelques règles simples pour y parvenir :",{"type":28,"tag":144,"props":2476,"children":2477},{},[2478,2488],{"type":28,"tag":148,"props":2479,"children":2480},{},[2481,2486],{"type":28,"tag":55,"props":2482,"children":2483},{},[2484],{"type":34,"value":2485},"Utilisez des noms de variables explicites.",{"type":34,"value":2487}," Les noms doivent décrire clairement leur rôle.",{"type":28,"tag":148,"props":2489,"children":2490},{},[2491,2496],{"type":28,"tag":55,"props":2492,"children":2493},{},[2494],{"type":34,"value":2495},"Découpez votre code en petites fonctions",{"type":34,"value":2497},". Chacune doit accomplir une seule tâche.",{"type":28,"tag":44,"props":2499,"children":2500},{},[2501],{"type":28,"tag":55,"props":2502,"children":2503},{},[2504],{"type":34,"value":2505},"Exemple de mauvaise pratique :",{"type":28,"tag":181,"props":2507,"children":2509},{"className":183,"code":2508,"language":185,"meta":8,"style":8},"public void traiterDonnées(List\u003CString> données) {\n    for (String d : données) {\n        if (d != null && !d.isEmpty()) {\n            System.out.println(\"Donnée : \" + d);\n        }\n    }\n}\n",[2510],{"type":28,"tag":188,"props":2511,"children":2512},{"__ignoreMap":8},[2513,2562,2598,2657,2706,2713,2720],{"type":28,"tag":192,"props":2514,"children":2515},{"class":194,"line":195},[2516,2520,2524,2529,2533,2537,2541,2545,2549,2554,2558],{"type":28,"tag":192,"props":2517,"children":2518},{"style":209},[2519],{"type":34,"value":212},{"type":28,"tag":192,"props":2521,"children":2522},{"style":209},[2523],{"type":34,"value":688},{"type":28,"tag":192,"props":2525,"children":2526},{"style":325},[2527],{"type":34,"value":2528}," traiterDonnées",{"type":28,"tag":192,"props":2530,"children":2531},{"style":226},[2532],{"type":34,"value":332},{"type":28,"tag":192,"props":2534,"children":2535},{"style":241},[2536],{"type":34,"value":1717},{"type":28,"tag":192,"props":2538,"children":2539},{"style":387},[2540],{"type":34,"value":1722},{"type":28,"tag":192,"props":2542,"children":2543},{"style":247},[2544],{"type":34,"value":337},{"type":28,"tag":192,"props":2546,"children":2547},{"style":387},[2548],{"type":34,"value":1732},{"type":28,"tag":192,"props":2550,"children":2551},{"style":247},[2552],{"type":34,"value":2553}," données",{"type":28,"tag":192,"props":2555,"children":2556},{"style":226},[2557],{"type":34,"value":360},{"type":28,"tag":192,"props":2559,"children":2560},{"style":226},[2561],{"type":34,"value":229},{"type":28,"tag":192,"props":2563,"children":2564},{"class":194,"line":205},[2565,2569,2573,2577,2582,2586,2590,2594],{"type":28,"tag":192,"props":2566,"children":2567},{"style":209},[2568],{"type":34,"value":2221},{"type":28,"tag":192,"props":2570,"children":2571},{"style":226},[2572],{"type":34,"value":991},{"type":28,"tag":192,"props":2574,"children":2575},{"style":241},[2576],{"type":34,"value":337},{"type":28,"tag":192,"props":2578,"children":2579},{"style":247},[2580],{"type":34,"value":2581}," d ",{"type":28,"tag":192,"props":2583,"children":2584},{"style":209},[2585],{"type":34,"value":2239},{"type":28,"tag":192,"props":2587,"children":2588},{"style":247},[2589],{"type":34,"value":2553},{"type":28,"tag":192,"props":2591,"children":2592},{"style":226},[2593],{"type":34,"value":360},{"type":28,"tag":192,"props":2595,"children":2596},{"style":226},[2597],{"type":34,"value":229},{"type":28,"tag":192,"props":2599,"children":2600},{"class":194,"line":232},[2601,2605,2609,2614,2619,2624,2629,2634,2639,2643,2648,2653],{"type":28,"tag":192,"props":2602,"children":2603},{"style":209},[2604],{"type":34,"value":986},{"type":28,"tag":192,"props":2606,"children":2607},{"style":226},[2608],{"type":34,"value":991},{"type":28,"tag":192,"props":2610,"children":2611},{"style":247},[2612],{"type":34,"value":2613},"d ",{"type":28,"tag":192,"props":2615,"children":2616},{"style":387},[2617],{"type":34,"value":2618},"!=",{"type":28,"tag":192,"props":2620,"children":2621},{"style":371},[2622],{"type":34,"value":2623}," null",{"type":28,"tag":192,"props":2625,"children":2626},{"style":387},[2627],{"type":34,"value":2628}," &&",{"type":28,"tag":192,"props":2630,"children":2631},{"style":387},[2632],{"type":34,"value":2633}," !",{"type":28,"tag":192,"props":2635,"children":2636},{"style":247},[2637],{"type":34,"value":2638},"d",{"type":28,"tag":192,"props":2640,"children":2641},{"style":226},[2642],{"type":34,"value":379},{"type":28,"tag":192,"props":2644,"children":2645},{"style":325},[2646],{"type":34,"value":2647},"isEmpty",{"type":28,"tag":192,"props":2649,"children":2650},{"style":226},[2651],{"type":34,"value":2652},"())",{"type":28,"tag":192,"props":2654,"children":2655},{"style":226},[2656],{"type":34,"value":229},{"type":28,"tag":192,"props":2658,"children":2659},{"class":194,"line":258},[2660,2665,2669,2674,2678,2683,2687,2692,2697,2702],{"type":28,"tag":192,"props":2661,"children":2662},{"style":247},[2663],{"type":34,"value":2664},"            System",{"type":28,"tag":192,"props":2666,"children":2667},{"style":226},[2668],{"type":34,"value":379},{"type":28,"tag":192,"props":2670,"children":2671},{"style":247},[2672],{"type":34,"value":2673},"out",{"type":28,"tag":192,"props":2675,"children":2676},{"style":226},[2677],{"type":34,"value":379},{"type":28,"tag":192,"props":2679,"children":2680},{"style":325},[2681],{"type":34,"value":2682},"println",{"type":28,"tag":192,"props":2684,"children":2685},{"style":226},[2686],{"type":34,"value":332},{"type":28,"tag":192,"props":2688,"children":2689},{"style":734},[2690],{"type":34,"value":2691},"\"Donnée : \"",{"type":28,"tag":192,"props":2693,"children":2694},{"style":387},[2695],{"type":34,"value":2696}," +",{"type":28,"tag":192,"props":2698,"children":2699},{"style":247},[2700],{"type":34,"value":2701}," d",{"type":28,"tag":192,"props":2703,"children":2704},{"style":226},[2705],{"type":34,"value":752},{"type":28,"tag":192,"props":2707,"children":2708},{"class":194,"line":280},[2709],{"type":28,"tag":192,"props":2710,"children":2711},{"style":226},[2712],{"type":34,"value":1118},{"type":28,"tag":192,"props":2714,"children":2715},{"class":194,"line":307},[2716],{"type":28,"tag":192,"props":2717,"children":2718},{"style":226},[2719],{"type":34,"value":445},{"type":28,"tag":192,"props":2721,"children":2722},{"class":194,"line":316},[2723],{"type":28,"tag":192,"props":2724,"children":2725},{"style":226},[2726],{"type":34,"value":588},{"type":28,"tag":44,"props":2728,"children":2729},{},[2730],{"type":28,"tag":55,"props":2731,"children":2732},{},[2733],{"type":34,"value":2734},"Exemple amélioré :",{"type":28,"tag":181,"props":2736,"children":2738},{"className":183,"code":2737,"language":185,"meta":8,"style":8},"public void afficherDonnéesNonNulles(List\u003CString> données) {\n    données.stream()\n           .filter(this::estValide)\n           .forEach(this::afficherDonnée);\n}\n\nprivate boolean estValide(String donnée) {\n    return donnée != null && !donnée.isEmpty();\n}\n\nprivate void afficherDonnée(String donnée) {\n    System.out.println(\"Donnée : \" + donnée);\n}\n",[2739],{"type":28,"tag":188,"props":2740,"children":2741},{"__ignoreMap":8},[2742,2790,2811,2847,2880,2887,2894,2932,2977,2984,2991,3027,3071],{"type":28,"tag":192,"props":2743,"children":2744},{"class":194,"line":195},[2745,2749,2753,2758,2762,2766,2770,2774,2778,2782,2786],{"type":28,"tag":192,"props":2746,"children":2747},{"style":209},[2748],{"type":34,"value":212},{"type":28,"tag":192,"props":2750,"children":2751},{"style":209},[2752],{"type":34,"value":688},{"type":28,"tag":192,"props":2754,"children":2755},{"style":325},[2756],{"type":34,"value":2757}," afficherDonnéesNonNulles",{"type":28,"tag":192,"props":2759,"children":2760},{"style":226},[2761],{"type":34,"value":332},{"type":28,"tag":192,"props":2763,"children":2764},{"style":241},[2765],{"type":34,"value":1717},{"type":28,"tag":192,"props":2767,"children":2768},{"style":387},[2769],{"type":34,"value":1722},{"type":28,"tag":192,"props":2771,"children":2772},{"style":247},[2773],{"type":34,"value":337},{"type":28,"tag":192,"props":2775,"children":2776},{"style":387},[2777],{"type":34,"value":1732},{"type":28,"tag":192,"props":2779,"children":2780},{"style":247},[2781],{"type":34,"value":2553},{"type":28,"tag":192,"props":2783,"children":2784},{"style":226},[2785],{"type":34,"value":360},{"type":28,"tag":192,"props":2787,"children":2788},{"style":226},[2789],{"type":34,"value":229},{"type":28,"tag":192,"props":2791,"children":2792},{"class":194,"line":205},[2793,2798,2802,2806],{"type":28,"tag":192,"props":2794,"children":2795},{"style":247},[2796],{"type":34,"value":2797},"    données",{"type":28,"tag":192,"props":2799,"children":2800},{"style":226},[2801],{"type":34,"value":379},{"type":28,"tag":192,"props":2803,"children":2804},{"style":325},[2805],{"type":34,"value":1765},{"type":28,"tag":192,"props":2807,"children":2808},{"style":226},[2809],{"type":34,"value":2810},"()\n",{"type":28,"tag":192,"props":2812,"children":2813},{"class":194,"line":232},[2814,2819,2824,2828,2833,2837,2842],{"type":28,"tag":192,"props":2815,"children":2816},{"style":226},[2817],{"type":34,"value":2818},"           .",{"type":28,"tag":192,"props":2820,"children":2821},{"style":325},[2822],{"type":34,"value":2823},"filter",{"type":28,"tag":192,"props":2825,"children":2826},{"style":226},[2827],{"type":34,"value":332},{"type":28,"tag":192,"props":2829,"children":2830},{"style":371},[2831],{"type":34,"value":2832},"this",{"type":28,"tag":192,"props":2834,"children":2835},{"style":209},[2836],{"type":34,"value":1788},{"type":28,"tag":192,"props":2838,"children":2839},{"style":247},[2840],{"type":34,"value":2841},"estValide",{"type":28,"tag":192,"props":2843,"children":2844},{"style":226},[2845],{"type":34,"value":2846},")\n",{"type":28,"tag":192,"props":2848,"children":2849},{"class":194,"line":258},[2850,2854,2859,2863,2867,2871,2876],{"type":28,"tag":192,"props":2851,"children":2852},{"style":226},[2853],{"type":34,"value":2818},{"type":28,"tag":192,"props":2855,"children":2856},{"style":325},[2857],{"type":34,"value":2858},"forEach",{"type":28,"tag":192,"props":2860,"children":2861},{"style":226},[2862],{"type":34,"value":332},{"type":28,"tag":192,"props":2864,"children":2865},{"style":371},[2866],{"type":34,"value":2832},{"type":28,"tag":192,"props":2868,"children":2869},{"style":209},[2870],{"type":34,"value":1788},{"type":28,"tag":192,"props":2872,"children":2873},{"style":247},[2874],{"type":34,"value":2875},"afficherDonnée",{"type":28,"tag":192,"props":2877,"children":2878},{"style":226},[2879],{"type":34,"value":752},{"type":28,"tag":192,"props":2881,"children":2882},{"class":194,"line":280},[2883],{"type":28,"tag":192,"props":2884,"children":2885},{"style":226},[2886],{"type":34,"value":588},{"type":28,"tag":192,"props":2888,"children":2889},{"class":194,"line":307},[2890],{"type":28,"tag":192,"props":2891,"children":2892},{"emptyLinePlaceholder":13},[2893],{"type":34,"value":313},{"type":28,"tag":192,"props":2895,"children":2896},{"class":194,"line":316},[2897,2902,2906,2911,2915,2919,2924,2928],{"type":28,"tag":192,"props":2898,"children":2899},{"style":209},[2900],{"type":34,"value":2901},"private",{"type":28,"tag":192,"props":2903,"children":2904},{"style":209},[2905],{"type":34,"value":965},{"type":28,"tag":192,"props":2907,"children":2908},{"style":325},[2909],{"type":34,"value":2910}," estValide",{"type":28,"tag":192,"props":2912,"children":2913},{"style":226},[2914],{"type":34,"value":332},{"type":28,"tag":192,"props":2916,"children":2917},{"style":241},[2918],{"type":34,"value":337},{"type":28,"tag":192,"props":2920,"children":2921},{"style":247},[2922],{"type":34,"value":2923}," donnée",{"type":28,"tag":192,"props":2925,"children":2926},{"style":226},[2927],{"type":34,"value":360},{"type":28,"tag":192,"props":2929,"children":2930},{"style":226},[2931],{"type":34,"value":229},{"type":28,"tag":192,"props":2933,"children":2934},{"class":194,"line":367},[2935,2939,2944,2948,2952,2956,2960,2965,2969,2973],{"type":28,"tag":192,"props":2936,"children":2937},{"style":209},[2938],{"type":34,"value":2288},{"type":28,"tag":192,"props":2940,"children":2941},{"style":247},[2942],{"type":34,"value":2943}," donnée ",{"type":28,"tag":192,"props":2945,"children":2946},{"style":387},[2947],{"type":34,"value":2618},{"type":28,"tag":192,"props":2949,"children":2950},{"style":371},[2951],{"type":34,"value":2623},{"type":28,"tag":192,"props":2953,"children":2954},{"style":387},[2955],{"type":34,"value":2628},{"type":28,"tag":192,"props":2957,"children":2958},{"style":387},[2959],{"type":34,"value":2633},{"type":28,"tag":192,"props":2961,"children":2962},{"style":247},[2963],{"type":34,"value":2964},"donnée",{"type":28,"tag":192,"props":2966,"children":2967},{"style":226},[2968],{"type":34,"value":379},{"type":28,"tag":192,"props":2970,"children":2971},{"style":325},[2972],{"type":34,"value":2647},{"type":28,"tag":192,"props":2974,"children":2975},{"style":226},[2976],{"type":34,"value":1973},{"type":28,"tag":192,"props":2978,"children":2979},{"class":194,"line":401},[2980],{"type":28,"tag":192,"props":2981,"children":2982},{"style":226},[2983],{"type":34,"value":588},{"type":28,"tag":192,"props":2985,"children":2986},{"class":194,"line":430},[2987],{"type":28,"tag":192,"props":2988,"children":2989},{"emptyLinePlaceholder":13},[2990],{"type":34,"value":313},{"type":28,"tag":192,"props":2992,"children":2993},{"class":194,"line":439},[2994,2998,3002,3007,3011,3015,3019,3023],{"type":28,"tag":192,"props":2995,"children":2996},{"style":209},[2997],{"type":34,"value":2901},{"type":28,"tag":192,"props":2999,"children":3000},{"style":209},[3001],{"type":34,"value":688},{"type":28,"tag":192,"props":3003,"children":3004},{"style":325},[3005],{"type":34,"value":3006}," afficherDonnée",{"type":28,"tag":192,"props":3008,"children":3009},{"style":226},[3010],{"type":34,"value":332},{"type":28,"tag":192,"props":3012,"children":3013},{"style":241},[3014],{"type":34,"value":337},{"type":28,"tag":192,"props":3016,"children":3017},{"style":247},[3018],{"type":34,"value":2923},{"type":28,"tag":192,"props":3020,"children":3021},{"style":226},[3022],{"type":34,"value":360},{"type":28,"tag":192,"props":3024,"children":3025},{"style":226},[3026],{"type":34,"value":229},{"type":28,"tag":192,"props":3028,"children":3029},{"class":194,"line":448},[3030,3035,3039,3043,3047,3051,3055,3059,3063,3067],{"type":28,"tag":192,"props":3031,"children":3032},{"style":247},[3033],{"type":34,"value":3034},"    System",{"type":28,"tag":192,"props":3036,"children":3037},{"style":226},[3038],{"type":34,"value":379},{"type":28,"tag":192,"props":3040,"children":3041},{"style":247},[3042],{"type":34,"value":2673},{"type":28,"tag":192,"props":3044,"children":3045},{"style":226},[3046],{"type":34,"value":379},{"type":28,"tag":192,"props":3048,"children":3049},{"style":325},[3050],{"type":34,"value":2682},{"type":28,"tag":192,"props":3052,"children":3053},{"style":226},[3054],{"type":34,"value":332},{"type":28,"tag":192,"props":3056,"children":3057},{"style":734},[3058],{"type":34,"value":2691},{"type":28,"tag":192,"props":3060,"children":3061},{"style":387},[3062],{"type":34,"value":2696},{"type":28,"tag":192,"props":3064,"children":3065},{"style":247},[3066],{"type":34,"value":2923},{"type":28,"tag":192,"props":3068,"children":3069},{"style":226},[3070],{"type":34,"value":752},{"type":28,"tag":192,"props":3072,"children":3073},{"class":194,"line":456},[3074],{"type":28,"tag":192,"props":3075,"children":3076},{"style":226},[3077],{"type":34,"value":588},{"type":28,"tag":44,"props":3079,"children":3080},{},[3081],{"type":34,"value":3082},"Les méthodes privées extraites portent la complexité par petits morceaux nommés, là où une boucle imbriquée la cachait.",{"type":28,"tag":83,"props":3084,"children":3085},{},[],{"type":28,"tag":169,"props":3087,"children":3089},{"id":3088},"_2-tests-automatisés-assurer-la-qualité-de-votre-code-dès-le-départ",[3090],{"type":34,"value":3091},"2. Tests automatisés : Assurer la qualité de votre code dès le départ",{"type":28,"tag":44,"props":3093,"children":3094},{},[3095],{"type":34,"value":3096},"Les tests garantissent que votre code fonctionne comme prévu à chaque étape, et surtout, ils rendent le refactoring possible sans crainte.",{"type":28,"tag":44,"props":3098,"children":3099},{},[3100],{"type":28,"tag":55,"props":3101,"children":3102},{},[3103],{"type":34,"value":3104},"Exemple avec JUnit :",{"type":28,"tag":181,"props":3106,"children":3108},{"className":183,"code":3107,"language":185,"meta":8,"style":8},"@Test\npublic void testEstValide() {\n    assertTrue(estValide(\"ValidData\"));\n    assertFalse(estValide(\"\"));\n    assertFalse(estValide(null));\n}\n",[3109],{"type":28,"tag":188,"props":3110,"children":3111},{"__ignoreMap":8},[3112,3123,3147,3177,3206,3234],{"type":28,"tag":192,"props":3113,"children":3114},{"class":194,"line":195},[3115,3119],{"type":28,"tag":192,"props":3116,"children":3117},{"style":667},[3118],{"type":34,"value":670},{"type":28,"tag":192,"props":3120,"children":3121},{"style":673},[3122],{"type":34,"value":676},{"type":28,"tag":192,"props":3124,"children":3125},{"class":194,"line":205},[3126,3130,3134,3139,3143],{"type":28,"tag":192,"props":3127,"children":3128},{"style":209},[3129],{"type":34,"value":212},{"type":28,"tag":192,"props":3131,"children":3132},{"style":209},[3133],{"type":34,"value":688},{"type":28,"tag":192,"props":3135,"children":3136},{"style":325},[3137],{"type":34,"value":3138}," testEstValide",{"type":28,"tag":192,"props":3140,"children":3141},{"style":226},[3142],{"type":34,"value":475},{"type":28,"tag":192,"props":3144,"children":3145},{"style":226},[3146],{"type":34,"value":229},{"type":28,"tag":192,"props":3148,"children":3149},{"class":194,"line":232},[3150,3155,3159,3163,3167,3172],{"type":28,"tag":192,"props":3151,"children":3152},{"style":325},[3153],{"type":34,"value":3154},"    assertTrue",{"type":28,"tag":192,"props":3156,"children":3157},{"style":226},[3158],{"type":34,"value":332},{"type":28,"tag":192,"props":3160,"children":3161},{"style":325},[3162],{"type":34,"value":2841},{"type":28,"tag":192,"props":3164,"children":3165},{"style":226},[3166],{"type":34,"value":332},{"type":28,"tag":192,"props":3168,"children":3169},{"style":734},[3170],{"type":34,"value":3171},"\"ValidData\"",{"type":28,"tag":192,"props":3173,"children":3174},{"style":226},[3175],{"type":34,"value":3176},"));\n",{"type":28,"tag":192,"props":3178,"children":3179},{"class":194,"line":258},[3180,3185,3189,3193,3197,3202],{"type":28,"tag":192,"props":3181,"children":3182},{"style":325},[3183],{"type":34,"value":3184},"    assertFalse",{"type":28,"tag":192,"props":3186,"children":3187},{"style":226},[3188],{"type":34,"value":332},{"type":28,"tag":192,"props":3190,"children":3191},{"style":325},[3192],{"type":34,"value":2841},{"type":28,"tag":192,"props":3194,"children":3195},{"style":226},[3196],{"type":34,"value":332},{"type":28,"tag":192,"props":3198,"children":3199},{"style":734},[3200],{"type":34,"value":3201},"\"\"",{"type":28,"tag":192,"props":3203,"children":3204},{"style":226},[3205],{"type":34,"value":3176},{"type":28,"tag":192,"props":3207,"children":3208},{"class":194,"line":280},[3209,3213,3217,3221,3225,3230],{"type":28,"tag":192,"props":3210,"children":3211},{"style":325},[3212],{"type":34,"value":3184},{"type":28,"tag":192,"props":3214,"children":3215},{"style":226},[3216],{"type":34,"value":332},{"type":28,"tag":192,"props":3218,"children":3219},{"style":325},[3220],{"type":34,"value":2841},{"type":28,"tag":192,"props":3222,"children":3223},{"style":226},[3224],{"type":34,"value":332},{"type":28,"tag":192,"props":3226,"children":3227},{"style":371},[3228],{"type":34,"value":3229},"null",{"type":28,"tag":192,"props":3231,"children":3232},{"style":226},[3233],{"type":34,"value":3176},{"type":28,"tag":192,"props":3235,"children":3236},{"class":194,"line":307},[3237],{"type":28,"tag":192,"props":3238,"children":3239},{"style":226},[3240],{"type":34,"value":588},{"type":28,"tag":44,"props":3242,"children":3243},{},[3244],{"type":34,"value":3245},"Cette approche valide la logique à chaque modification, sans dépendre d’un test manuel oublié. À coupler systématiquement avec un pipeline CI/CD qui rejoue la suite à chaque commit. Sinon les tests existent sans vraiment exister.",{"type":28,"tag":83,"props":3247,"children":3248},{},[],{"type":28,"tag":169,"props":3250,"children":3252},{"id":3251},"_3-refactoring-améliorer-sans-casser",[3253],{"type":34,"value":3254},"3. Refactoring : Améliorer sans casser",{"type":28,"tag":44,"props":3256,"children":3257},{},[3258,3260,3266],{"type":34,"value":3259},"Refactorer, c’est nettoyer sans modifier le comportement observable. Une boucle remplacée par un stream, une concaténation transformée en ",{"type":28,"tag":188,"props":3261,"children":3263},{"className":3262},[],[3264],{"type":34,"value":3265},"String.format",{"type":34,"value":3267},", une méthode extraite pour clarifier une intention. Petits gestes, effet cumulé considérable sur la durée de vie de la base.",{"type":28,"tag":44,"props":3269,"children":3270},{},[3271],{"type":34,"value":3272},"Exemple typique :",{"type":28,"tag":44,"props":3274,"children":3275},{},[3276],{"type":28,"tag":55,"props":3277,"children":3278},{},[3279],{"type":34,"value":2131},{"type":28,"tag":181,"props":3281,"children":3283},{"className":183,"code":3282,"language":185,"meta":8,"style":8},"public String construireMessage(String nom, int age) {\n    return \"Nom: \" + nom + \", Age: \" + age;\n}\n",[3284],{"type":28,"tag":188,"props":3285,"children":3286},{"__ignoreMap":8},[3287,3336,3379],{"type":28,"tag":192,"props":3288,"children":3289},{"class":194,"line":195},[3290,3294,3298,3303,3307,3311,3316,3320,3324,3328,3332],{"type":28,"tag":192,"props":3291,"children":3292},{"style":209},[3293],{"type":34,"value":212},{"type":28,"tag":192,"props":3295,"children":3296},{"style":241},[3297],{"type":34,"value":244},{"type":28,"tag":192,"props":3299,"children":3300},{"style":325},[3301],{"type":34,"value":3302}," construireMessage",{"type":28,"tag":192,"props":3304,"children":3305},{"style":226},[3306],{"type":34,"value":332},{"type":28,"tag":192,"props":3308,"children":3309},{"style":241},[3310],{"type":34,"value":337},{"type":28,"tag":192,"props":3312,"children":3313},{"style":247},[3314],{"type":34,"value":3315}," nom",{"type":28,"tag":192,"props":3317,"children":3318},{"style":226},[3319],{"type":34,"value":347},{"type":28,"tag":192,"props":3321,"children":3322},{"style":209},[3323],{"type":34,"value":268},{"type":28,"tag":192,"props":3325,"children":3326},{"style":247},[3327],{"type":34,"value":273},{"type":28,"tag":192,"props":3329,"children":3330},{"style":226},[3331],{"type":34,"value":360},{"type":28,"tag":192,"props":3333,"children":3334},{"style":226},[3335],{"type":34,"value":229},{"type":28,"tag":192,"props":3337,"children":3338},{"class":194,"line":205},[3339,3343,3348,3352,3357,3362,3367,3371,3375],{"type":28,"tag":192,"props":3340,"children":3341},{"style":209},[3342],{"type":34,"value":2288},{"type":28,"tag":192,"props":3344,"children":3345},{"style":734},[3346],{"type":34,"value":3347}," \"Nom: \"",{"type":28,"tag":192,"props":3349,"children":3350},{"style":387},[3351],{"type":34,"value":2696},{"type":28,"tag":192,"props":3353,"children":3354},{"style":247},[3355],{"type":34,"value":3356}," nom ",{"type":28,"tag":192,"props":3358,"children":3359},{"style":387},[3360],{"type":34,"value":3361},"+",{"type":28,"tag":192,"props":3363,"children":3364},{"style":734},[3365],{"type":34,"value":3366}," \", Age: \"",{"type":28,"tag":192,"props":3368,"children":3369},{"style":387},[3370],{"type":34,"value":2696},{"type":28,"tag":192,"props":3372,"children":3373},{"style":247},[3374],{"type":34,"value":273},{"type":28,"tag":192,"props":3376,"children":3377},{"style":226},[3378],{"type":34,"value":255},{"type":28,"tag":192,"props":3380,"children":3381},{"class":194,"line":232},[3382],{"type":28,"tag":192,"props":3383,"children":3384},{"style":226},[3385],{"type":34,"value":588},{"type":28,"tag":44,"props":3387,"children":3388},{},[3389],{"type":28,"tag":55,"props":3390,"children":3391},{},[3392],{"type":34,"value":2312},{"type":28,"tag":181,"props":3394,"children":3396},{"className":183,"code":3395,"language":185,"meta":8,"style":8},"public String construireMessage(String nom, int age) {\n    return String.format(\"Nom: %s, Age: %d\", nom, age);\n}\n",[3397],{"type":28,"tag":188,"props":3398,"children":3399},{"__ignoreMap":8},[3400,3447,3496],{"type":28,"tag":192,"props":3401,"children":3402},{"class":194,"line":195},[3403,3407,3411,3415,3419,3423,3427,3431,3435,3439,3443],{"type":28,"tag":192,"props":3404,"children":3405},{"style":209},[3406],{"type":34,"value":212},{"type":28,"tag":192,"props":3408,"children":3409},{"style":241},[3410],{"type":34,"value":244},{"type":28,"tag":192,"props":3412,"children":3413},{"style":325},[3414],{"type":34,"value":3302},{"type":28,"tag":192,"props":3416,"children":3417},{"style":226},[3418],{"type":34,"value":332},{"type":28,"tag":192,"props":3420,"children":3421},{"style":241},[3422],{"type":34,"value":337},{"type":28,"tag":192,"props":3424,"children":3425},{"style":247},[3426],{"type":34,"value":3315},{"type":28,"tag":192,"props":3428,"children":3429},{"style":226},[3430],{"type":34,"value":347},{"type":28,"tag":192,"props":3432,"children":3433},{"style":209},[3434],{"type":34,"value":268},{"type":28,"tag":192,"props":3436,"children":3437},{"style":247},[3438],{"type":34,"value":273},{"type":28,"tag":192,"props":3440,"children":3441},{"style":226},[3442],{"type":34,"value":360},{"type":28,"tag":192,"props":3444,"children":3445},{"style":226},[3446],{"type":34,"value":229},{"type":28,"tag":192,"props":3448,"children":3449},{"class":194,"line":205},[3450,3454,3458,3462,3467,3471,3476,3480,3484,3488,3492],{"type":28,"tag":192,"props":3451,"children":3452},{"style":209},[3453],{"type":34,"value":2288},{"type":28,"tag":192,"props":3455,"children":3456},{"style":247},[3457],{"type":34,"value":244},{"type":28,"tag":192,"props":3459,"children":3460},{"style":226},[3461],{"type":34,"value":379},{"type":28,"tag":192,"props":3463,"children":3464},{"style":325},[3465],{"type":34,"value":3466},"format",{"type":28,"tag":192,"props":3468,"children":3469},{"style":226},[3470],{"type":34,"value":332},{"type":28,"tag":192,"props":3472,"children":3473},{"style":734},[3474],{"type":34,"value":3475},"\"Nom: %s, Age: %d\"",{"type":28,"tag":192,"props":3477,"children":3478},{"style":226},[3479],{"type":34,"value":347},{"type":28,"tag":192,"props":3481,"children":3482},{"style":247},[3483],{"type":34,"value":3315},{"type":28,"tag":192,"props":3485,"children":3486},{"style":226},[3487],{"type":34,"value":347},{"type":28,"tag":192,"props":3489,"children":3490},{"style":247},[3491],{"type":34,"value":273},{"type":28,"tag":192,"props":3493,"children":3494},{"style":226},[3495],{"type":34,"value":752},{"type":28,"tag":192,"props":3497,"children":3498},{"class":194,"line":232},[3499],{"type":28,"tag":192,"props":3500,"children":3501},{"style":226},[3502],{"type":34,"value":588},{"type":28,"tag":44,"props":3504,"children":3505},{},[3506],{"type":34,"value":3507},"Plus concis, plus robuste face aux cas limites de formatage. Règle non négociable : pas de refactoring sans filet de tests. Modifier du code sans garantie de comportement, c’est introduire des bugs sous couvert d’améliorer la qualité.",{"type":28,"tag":83,"props":3509,"children":3510},{},[],{"type":28,"tag":169,"props":3512,"children":3514},{"id":3513},"_4-apprentissage-continu-et-pair-programming",[3515],{"type":34,"value":3516},"4. Apprentissage continu et Pair Programming",{"type":28,"tag":44,"props":3518,"children":3519},{},[3520,3521,3530,3532,3541],{"type":34,"value":1636},{"type":28,"tag":55,"props":3522,"children":3523},{},[3524],{"type":28,"tag":103,"props":3525,"children":3527},{"href":3526},"/fr/dette-technique/pair-programming-roi-conditions",[3528],{"type":34,"value":3529},"pair programming",{"type":34,"value":3531}," et la ",{"type":28,"tag":55,"props":3533,"children":3534},{},[3535],{"type":28,"tag":103,"props":3536,"children":3538},{"href":3537},"/fr/intelligence-artificielle/ia-code-review-retour-experience",[3539],{"type":34,"value":3540},"revue de code",{"type":34,"value":3542}," restent les deux accélérateurs d'apprentissage les plus efficaces : on y découvre des patterns, on y débat des choix de design, on y prend l'habitude de justifier ses décisions.",{"type":28,"tag":83,"props":3544,"children":3545},{},[],{"type":28,"tag":37,"props":3547,"children":3549},{"id":3548},"outils-et-pratiques-recommandés",[3550],{"type":34,"value":3551},"Outils et pratiques recommandés",{"type":28,"tag":44,"props":3553,"children":3554},{},[3555],{"type":34,"value":3556},"L’outillage ne fait pas l’artisan, mais sans outillage l’artisan perd un temps précieux. Voici l’équipement de base à mettre en place sur un projet Java sérieux.",{"type":28,"tag":169,"props":3558,"children":3560},{"id":3559},"code-propre",[3561],{"type":34,"value":3562},"Code propre",{"type":28,"tag":144,"props":3564,"children":3565},{},[3566,3576],{"type":28,"tag":148,"props":3567,"children":3568},{},[3569,3574],{"type":28,"tag":55,"props":3570,"children":3571},{},[3572],{"type":34,"value":3573},"SonarLint",{"type":34,"value":3575}," : analyse statique en temps réel dans l’IDE. Détecte duplications, code mort, bugs probables. Indispensable.",{"type":28,"tag":148,"props":3577,"children":3578},{},[3579,3584],{"type":28,"tag":55,"props":3580,"children":3581},{},[3582],{"type":34,"value":3583},"Checkstyle",{"type":34,"value":3585}," : vérification des conventions de style. À configurer selon les standards de l’équipe, pas selon les règles par défaut, qui sont rarement adaptées.",{"type":28,"tag":169,"props":3587,"children":3589},{"id":3588},"tests",[3590],{"type":34,"value":3591},"Tests",{"type":28,"tag":144,"props":3593,"children":3594},{},[3595,3605],{"type":28,"tag":148,"props":3596,"children":3597},{},[3598,3603],{"type":28,"tag":55,"props":3599,"children":3600},{},[3601],{"type":34,"value":3602},"JUnit",{"type":34,"value":3604}," : bibliothèque de tests unitaires standard de l’écosystème Java.",{"type":28,"tag":148,"props":3606,"children":3607},{},[3608,3613],{"type":28,"tag":55,"props":3609,"children":3610},{},[3611],{"type":34,"value":3612},"Mockito",{"type":34,"value":3614}," : simulation de dépendances externes (bases, services web) pour isoler le composant testé.",{"type":28,"tag":181,"props":3616,"children":3618},{"className":183,"code":3617,"language":185,"meta":8,"style":8},"@Test\npublic void testAvecMock() {\n    MyService service = mock(MyService.class);\n    when(service.calculer()).thenReturn(42);\n\n    assertEquals(42, service.calculer());\n}\n",[3619],{"type":28,"tag":188,"props":3620,"children":3621},{"__ignoreMap":8},[3622,3633,3657,3701,3750,3757,3793],{"type":28,"tag":192,"props":3623,"children":3624},{"class":194,"line":195},[3625,3629],{"type":28,"tag":192,"props":3626,"children":3627},{"style":667},[3628],{"type":34,"value":670},{"type":28,"tag":192,"props":3630,"children":3631},{"style":673},[3632],{"type":34,"value":676},{"type":28,"tag":192,"props":3634,"children":3635},{"class":194,"line":205},[3636,3640,3644,3649,3653],{"type":28,"tag":192,"props":3637,"children":3638},{"style":209},[3639],{"type":34,"value":212},{"type":28,"tag":192,"props":3641,"children":3642},{"style":209},[3643],{"type":34,"value":688},{"type":28,"tag":192,"props":3645,"children":3646},{"style":325},[3647],{"type":34,"value":3648}," testAvecMock",{"type":28,"tag":192,"props":3650,"children":3651},{"style":226},[3652],{"type":34,"value":475},{"type":28,"tag":192,"props":3654,"children":3655},{"style":226},[3656],{"type":34,"value":229},{"type":28,"tag":192,"props":3658,"children":3659},{"class":194,"line":232},[3660,3665,3670,3674,3679,3683,3688,3692,3697],{"type":28,"tag":192,"props":3661,"children":3662},{"style":241},[3663],{"type":34,"value":3664},"    MyService",{"type":28,"tag":192,"props":3666,"children":3667},{"style":247},[3668],{"type":34,"value":3669}," service ",{"type":28,"tag":192,"props":3671,"children":3672},{"style":387},[3673],{"type":34,"value":390},{"type":28,"tag":192,"props":3675,"children":3676},{"style":325},[3677],{"type":34,"value":3678}," mock",{"type":28,"tag":192,"props":3680,"children":3681},{"style":226},[3682],{"type":34,"value":332},{"type":28,"tag":192,"props":3684,"children":3685},{"style":247},[3686],{"type":34,"value":3687},"MyService",{"type":28,"tag":192,"props":3689,"children":3690},{"style":226},[3691],{"type":34,"value":379},{"type":28,"tag":192,"props":3693,"children":3694},{"style":247},[3695],{"type":34,"value":3696},"class",{"type":28,"tag":192,"props":3698,"children":3699},{"style":226},[3700],{"type":34,"value":752},{"type":28,"tag":192,"props":3702,"children":3703},{"class":194,"line":258},[3704,3709,3713,3718,3722,3727,3732,3737,3741,3746],{"type":28,"tag":192,"props":3705,"children":3706},{"style":325},[3707],{"type":34,"value":3708},"    when",{"type":28,"tag":192,"props":3710,"children":3711},{"style":226},[3712],{"type":34,"value":332},{"type":28,"tag":192,"props":3714,"children":3715},{"style":247},[3716],{"type":34,"value":3717},"service",{"type":28,"tag":192,"props":3719,"children":3720},{"style":226},[3721],{"type":34,"value":379},{"type":28,"tag":192,"props":3723,"children":3724},{"style":325},[3725],{"type":34,"value":3726},"calculer",{"type":28,"tag":192,"props":3728,"children":3729},{"style":226},[3730],{"type":34,"value":3731},"()).",{"type":28,"tag":192,"props":3733,"children":3734},{"style":325},[3735],{"type":34,"value":3736},"thenReturn",{"type":28,"tag":192,"props":3738,"children":3739},{"style":226},[3740],{"type":34,"value":332},{"type":28,"tag":192,"props":3742,"children":3743},{"style":744},[3744],{"type":34,"value":3745},"42",{"type":28,"tag":192,"props":3747,"children":3748},{"style":226},[3749],{"type":34,"value":752},{"type":28,"tag":192,"props":3751,"children":3752},{"class":194,"line":280},[3753],{"type":28,"tag":192,"props":3754,"children":3755},{"emptyLinePlaceholder":13},[3756],{"type":34,"value":313},{"type":28,"tag":192,"props":3758,"children":3759},{"class":194,"line":307},[3760,3764,3768,3772,3776,3781,3785,3789],{"type":28,"tag":192,"props":3761,"children":3762},{"style":325},[3763],{"type":34,"value":760},{"type":28,"tag":192,"props":3765,"children":3766},{"style":226},[3767],{"type":34,"value":332},{"type":28,"tag":192,"props":3769,"children":3770},{"style":744},[3771],{"type":34,"value":3745},{"type":28,"tag":192,"props":3773,"children":3774},{"style":226},[3775],{"type":34,"value":347},{"type":28,"tag":192,"props":3777,"children":3778},{"style":247},[3779],{"type":34,"value":3780}," service",{"type":28,"tag":192,"props":3782,"children":3783},{"style":226},[3784],{"type":34,"value":379},{"type":28,"tag":192,"props":3786,"children":3787},{"style":325},[3788],{"type":34,"value":3726},{"type":28,"tag":192,"props":3790,"children":3791},{"style":226},[3792],{"type":34,"value":791},{"type":28,"tag":192,"props":3794,"children":3795},{"class":194,"line":316},[3796],{"type":28,"tag":192,"props":3797,"children":3798},{"style":226},[3799],{"type":34,"value":588},{"type":28,"tag":169,"props":3801,"children":3803},{"id":3802},"refactoring",[3804],{"type":34,"value":3805},"Refactoring",{"type":28,"tag":144,"props":3807,"children":3808},{},[3809,3819],{"type":28,"tag":148,"props":3810,"children":3811},{},[3812,3817],{"type":28,"tag":55,"props":3813,"children":3814},{},[3815],{"type":34,"value":3816},"IntelliJ IDEA",{"type":34,"value":3818}," : refactorings intégrés (rename, extract method, inline, move). Apprendre les raccourcis change le quotidien.",{"type":28,"tag":148,"props":3820,"children":3821},{},[3822,3827],{"type":28,"tag":55,"props":3823,"children":3824},{},[3825],{"type":34,"value":3826},"PMD",{"type":34,"value":3828}," : analyse statique complémentaire à SonarLint, particulièrement utile pour repérer les zones candidates au refactoring.",{"type":28,"tag":83,"props":3830,"children":3831},{},[],{"type":28,"tag":37,"props":3833,"children":3835},{"id":3834},"deux-histoires-qui-finissent-mal",[3836],{"type":34,"value":3837},"Deux histoires qui finissent mal",{"type":28,"tag":44,"props":3839,"children":3840},{},[3841,3846],{"type":28,"tag":55,"props":3842,"children":3843},{},[3844],{"type":34,"value":3845},"Refactoring sans tests, équipe assurance, 2019.",{"type":34,"value":3847}," Un développeur senior décide de \"nettoyer\" un module de calcul de cotisations vieillissant. Pas de tests dessus, mais il connaît le code. Trois semaines plus tard, un client signale des écarts de quelques centimes sur des milliers de contrats. Coût total du correctif et des régularisations : un mois-homme et beaucoup de mails désagréables. Le refactoring sans filet n’est pas un raccourci, c’est une dette à crédit.",{"type":28,"tag":44,"props":3849,"children":3850},{},[3851,3856],{"type":28,"tag":55,"props":3852,"children":3853},{},[3854],{"type":34,"value":3855},"Tests \"à faire plus tard\", scale-up média, 2021.",{"type":34,"value":3857}," Sprint après sprint, les tests sont repoussés au refactoring suivant. Au bout d’un an, la base atteint 80 000 lignes avec 12 % de couverture. La moindre évolution déclenche des régressions imprévisibles, les développeurs ralentissent par peur. Il aura fallu six mois de remontée patient pour atteindre une couverture viable : six mois pendant lesquels presque aucune fonctionnalité n’a pu être livrée. Le \"test d’abord\" n’est pas un slogan, c’est une assurance qui se paie en temps réel.",{"type":28,"tag":83,"props":3859,"children":3860},{},[],{"type":28,"tag":37,"props":3862,"children":3864},{"id":3863},"quelques-repères-pour-progresser",[3865],{"type":34,"value":3866},"Quelques repères pour progresser",{"type":28,"tag":44,"props":3868,"children":3869},{},[3870],{"type":34,"value":3871},"Un test simple pour évaluer votre code : seriez-vous à l’aise de l’expliquer ligne par ligne en revue ? Si la réponse est non, c’est que la simplification est encore possible. Le refactoring n’est pas une étape ponctuelle déclenchée par une crise : c’est un geste continu, intégré au cycle normal de développement. Et le meilleur accélérateur d’apprentissage reste la revue de code par des pairs exigeants : aucun blog, aucune conférence ne remplace le regard d’un collègue qui pointe une faiblesse dans votre design.",{"type":28,"tag":120,"props":3873,"children":3875},{"cta":1327,"href":1328,"title":3874,"type":1330},"Le clean code n'est qu'une pratique parmi 100",[3876],{"type":28,"tag":44,"props":3877,"children":3878},{},[3879],{"type":34,"value":3880},"Cet article détaille une poignée de gestes : noms explicites, fonctions courtes, test d'abord, refactoring sous filet. Le Craft Bundle réunit les 100 pratiques que j'applique au quotidien pour coder propre, celles que j'ai vues tenir en production sur des projets critiques. Ce sont exactement celles que l'IA ne vous apprendra jamais, parce qu'elle ne les a jamais vues tourner.",{"type":28,"tag":83,"props":3882,"children":3883},{},[],{"type":28,"tag":37,"props":3885,"children":3887},{"id":3886},"questions-fréquentes",[3888],{"type":34,"value":3889},"Questions fréquentes",{"type":28,"tag":1347,"props":3891,"children":3892},{},[3893,3898],{"type":28,"tag":1351,"props":3894,"children":3895},{},[3896],{"type":34,"value":3897},"Craftsmanship et agilité : opposition ou complémentarité ?",{"type":28,"tag":44,"props":3899,"children":3900},{},[3901,3903,3907,3909,3913],{"type":34,"value":3902},"Complémentarité. L’agilité organise ",{"type":28,"tag":63,"props":3904,"children":3905},{},[3906],{"type":34,"value":1604},{"type":34,"value":3908}," on livre, le craftsmanship définit ",{"type":28,"tag":63,"props":3910,"children":3911},{},[3912],{"type":34,"value":1611},{"type":34,"value":3914},". Une équipe agile sans craftsmanship livre vite et accumule de la dette ; une équipe craftsmanship sans agilité produit du beau code mais loupe la livraison. Les deux ensemble forment un cycle viable.",{"type":28,"tag":1347,"props":3916,"children":3917},{},[3918,3923],{"type":28,"tag":1351,"props":3919,"children":3920},{},[3921],{"type":34,"value":3922},"TDD ralentit-il vraiment le développement ?",{"type":28,"tag":44,"props":3924,"children":3925},{},[3926],{"type":34,"value":3927},"Sur les deux premières semaines, oui, le temps d’installer le réflexe. Au-delà, le bilan s’inverse : moins de régressions, refactoring serein, intégration continue qui fonctionne. Les équipes que j’ai accompagnées atteignent le seuil de rentabilité entre la troisième et la sixième semaine.",{"type":28,"tag":1347,"props":3929,"children":3930},{},[3931,3936],{"type":28,"tag":1351,"props":3932,"children":3933},{},[3934],{"type":34,"value":3935},"Faut-il tout tester ?",{"type":28,"tag":44,"props":3937,"children":3938},{},[3939],{"type":34,"value":3940},"Non. Cibler les composants critiques, la logique métier, les zones à fort taux de modification. Les getters/setters triviaux et le code de glue ne méritent pas une suite dédiée. Une couverture de 70-80 % sur les bons modules vaut mieux que 95 % réparti partout.",{"type":28,"tag":83,"props":3942,"children":3943},{},[],{"type":28,"tag":37,"props":3945,"children":3946},{"id":1419},[3947],{"type":34,"value":1422},{"type":28,"tag":44,"props":3949,"children":3950},{},[3951],{"type":34,"value":3952},"Le craftsmanship ne se décrète pas le matin et ne s’installe pas par un changement de process. C’est une discipline qui se construit au fil des sprints : un test écrit avant le code, un refactoring engagé plutôt que reporté, une revue qui pose les vraies questions plutôt que les questions polies. Ces petits gestes répétés font la différence entre une base qui vieillit bien et une base qui devient ingérable au bout de trois ans.",{"type":28,"tag":120,"props":3954,"children":3955},{"cta":1444,"href":1445,"title":1446,"type":1447},[3956],{"type":28,"tag":44,"props":3957,"children":3958},{},[3959],{"type":34,"value":1453},{"type":28,"tag":1455,"props":3961,"children":3962},{},[3963],{"type":34,"value":1459},{"title":8,"searchDepth":205,"depth":205,"links":3965},[3966,3967,3968,3969,3970,3971,3972,3973,3974],{"id":1498,"depth":232,"text":1501},{"id":1530,"depth":232,"text":1533},{"id":1628,"depth":232,"text":1631},{"id":2449,"depth":232,"text":2452},{"id":3548,"depth":232,"text":3551},{"id":3834,"depth":232,"text":3837},{"id":3863,"depth":232,"text":3866},{"id":3886,"depth":232,"text":3889},{"id":1419,"depth":232,"text":1422},"content:fr:dette-technique:software-craftsmanship-principes-exemples-java.md","fr/dette-technique/software-craftsmanship-principes-exemples-java.md","fr/dette-technique/software-craftsmanship-principes-exemples-java",{"_path":3979,"_dir":3980,"_draft":7,"_partial":7,"_locale":8,"title":3981,"description":3982,"id":3983,"date":3984,"listed":13,"nocomments":7,"hidden":7,"categories":3985,"tags":3986,"cover":3987,"readingTime":3988,"body":3993,"_type":1471,"_id":10103,"_source":1473,"_file":10104,"_stem":10105,"_extension":1476},"/fr/architecture-craft/principes-solid-java-exemples","architecture-craft","Principes SOLID en Java, Comprendre et Appliquer pour un Code plus Propre","Découvrez comment appliquer les principes SOLID en Java pour améliorer la structure, la maintenabilité et la modularité de votre code. Avec des exemples...",48,"2024-05-22",[1484],[1486,1487],"covers/articles/solid-principles.jpg",{"text":3989,"minutes":3990,"time":3991,"words":3992},"16 min read",15.03,901800,3006,{"type":25,"children":3994,"toc":10077},[3995,4001,4006,4018,4023,4028,4086,4092,4097,4100,4106,4118,4124,4129,4135,4155,4161,4482,4494,4500,4505,4857,4860,4873,4882,4888,4907,4912,4917,4922,4927,4933,4946,5211,5238,5244,5249,5674,5686,5813,5824,6156,6159,6172,6178,6183,6188,6193,6198,6219,6225,6243,6828,6862,6868,6873,7364,7367,7380,7386,7391,7396,7401,7406,7419,7425,7430,7512,7541,7546,7805,7824,7830,7842,8013,8018,8453,8456,8469,8475,8480,8485,8490,8495,8507,8513,8525,8846,8872,8878,8891,9476,9517,9825,9828,9841,9847,9992,10001,10004,10010,10023,10036,10049,10062,10065,10073],{"type":28,"tag":29,"props":3996,"children":3998},{"id":3997},"principes-solid-les-fondements-de-la-programmation-orientée-objet",[3999],{"type":34,"value":4000},"Principes SOLID : Les fondements de la programmation orientée objet",{"type":28,"tag":44,"props":4002,"children":4003},{},[4004],{"type":34,"value":4005},"La plupart des bases de code que j'ai auditées en 25 ans ne souffrent pas d'un manque de tests ou d'un mauvais framework. Elles souffrent d'un couplage que personne n'ose plus toucher. Chaque nouvelle fonctionnalité casse une fonctionnalité voisine, chaque refactoring devient un projet de trois mois.",{"type":28,"tag":44,"props":4007,"children":4008},{},[4009,4011,4016],{"type":34,"value":4010},"Les cinq principes SOLID, formalisés par Robert C. Martin dans ",{"type":28,"tag":63,"props":4012,"children":4013},{},[4014],{"type":34,"value":4015},"Agile Software Development: Principles, Patterns, and Practices",{"type":34,"value":4017},", ciblent exactement ce problème. Ils ne sont pas une théorie scolaire. Ce sont des leviers concrets pour décider où couper, où abstraire, et où s'arrêter. Quand j'ai commencé à les appliquer systématiquement, mon code est devenu plus propre et j'ai pu livrer plus vite sans craindre de casser l'existant.",{"type":28,"tag":44,"props":4019,"children":4020},{},[4021],{"type":34,"value":4022},"Cet article couvre ce que sont ces principes, pourquoi ils structurent une architecture saine, et comment les appliquer concrètement en Java.",{"type":28,"tag":44,"props":4024,"children":4025},{},[4026],{"type":34,"value":4027},"Les principes SOLID sont les suivants :",{"type":28,"tag":1644,"props":4029,"children":4030},{},[4031,4042,4053,4064,4075],{"type":28,"tag":148,"props":4032,"children":4033},{},[4034,4040],{"type":28,"tag":103,"props":4035,"children":4037},{"href":4036},"/fr/architecture-craft/principe-srp-software-craftsmanship-exemples-java",[4038],{"type":34,"value":4039},"Le principe de responsabilité unique (SRP)",{"type":34,"value":4041}," : une classe ne doit avoir qu'une seule raison de changer. Une classe, une responsabilité : pas un fourre-tout fonctionnel.",{"type":28,"tag":148,"props":4043,"children":4044},{},[4045,4051],{"type":28,"tag":103,"props":4046,"children":4048},{"href":4047},"/fr/architecture-craft/principe-ocp-software-craftsmanship-exemples-java",[4049],{"type":34,"value":4050},"Le principe d'ouverture/fermeture (OCP)",{"type":34,"value":4052}," : les entités logicielles (classes, modules, fonctions, etc.) doivent être ouvertes à l'extension mais fermées à la modification. On ajoute du comportement sans toucher au code existant.",{"type":28,"tag":148,"props":4054,"children":4055},{},[4056,4062],{"type":28,"tag":103,"props":4057,"children":4059},{"href":4058},"/fr/architecture-craft/principe-substitution-liskov-lsp-java",[4060],{"type":34,"value":4061},"Le principe de substitution de Liskov (LSP)",{"type":34,"value":4063}," : les objets d'une classe dérivée doivent pouvoir être utilisés en remplacement des objets de la classe de base sans altérer la cohérence du programme.",{"type":28,"tag":148,"props":4065,"children":4066},{},[4067,4073],{"type":28,"tag":103,"props":4068,"children":4070},{"href":4069},"/fr/architecture-craft/principe-isp-software-craftsmanship-exemples-java",[4071],{"type":34,"value":4072},"Le principe de ségrégation des interfaces (ISP)",{"type":34,"value":4074}," : les interfaces doivent être spécifiques aux besoins des clients. Plusieurs interfaces ciblées valent mieux qu'une interface fourre-tout.",{"type":28,"tag":148,"props":4076,"children":4077},{},[4078,4084],{"type":28,"tag":103,"props":4079,"children":4081},{"href":4080},"/fr/architecture-craft/principe-inversion-dependances-dip-java-guide-complet",[4082],{"type":34,"value":4083},"Le principe d'inversion de dépendance (DIP)",{"type":34,"value":4085}," : les modules de haut niveau ne doivent pas dépendre des modules de bas niveau. Les deux doivent dépendre d'abstractions, ce qui ouvre la voie à la modularité et à des tests réellement faisables.",{"type":28,"tag":29,"props":4087,"children":4089},{"id":4088},"comprendre-et-appliquer-les-principes-solid-en-java",[4090],{"type":34,"value":4091},"Comprendre et appliquer les principes SOLID en Java",{"type":28,"tag":44,"props":4093,"children":4094},{},[4095],{"type":34,"value":4096},"Les cinq principes qui suivent répondent à un seul problème : un code qui devient impossible à modifier sans tout casser. Chaque section illustre un principe avec un cas Java concret : d'abord le code qui pose problème, ensuite la version refactorisée.",{"type":28,"tag":83,"props":4098,"children":4099},{},[],{"type":28,"tag":29,"props":4101,"children":4103},{"id":4102},"_1-principe-de-responsabilité-unique-single-responsibility-principle-srp",[4104],{"type":34,"value":4105},"1. Principe de Responsabilité Unique (Single Responsibility Principle - SRP)",{"type":28,"tag":44,"props":4107,"children":4108},{},[4109,4111,4116],{"type":34,"value":4110},"Le principe de responsabilité unique, ou SRP, est probablement l’un des plus simples à comprendre, mais aussi l’un des plus importants. L'idée est qu'une classe ne devrait avoir ",{"type":28,"tag":55,"props":4112,"children":4113},{},[4114],{"type":34,"value":4115},"qu'une seule raison de changer",{"type":34,"value":4117},". En d'autres termes, chaque classe doit se concentrer sur une seule tâche ou responsabilité.",{"type":28,"tag":37,"props":4119,"children":4121},{"id":4120},"pourquoi-cest-important",[4122],{"type":34,"value":4123},"Pourquoi c'est important ?",{"type":28,"tag":44,"props":4125,"children":4126},{},[4127],{"type":34,"value":4128},"Quand une classe porte plusieurs responsabilités, modifier une partie casse souvent les autres, qui n'ont pourtant rien à voir avec le changement. Le code devient difficile à maintenir et les bugs s'accumulent. Respecter le SRP réduit le couplage et clarifie où intervenir.",{"type":28,"tag":37,"props":4130,"children":4132},{"id":4131},"exemple-concret-en-java",[4133],{"type":34,"value":4134},"Exemple concret en Java",{"type":28,"tag":44,"props":4136,"children":4137},{},[4138,4140,4146,4148,4153],{"type":34,"value":4139},"Imaginons un système qui gère des rapports. Nous avons une classe ",{"type":28,"tag":188,"props":4141,"children":4143},{"className":4142},[],[4144],{"type":34,"value":4145},"Report",{"type":34,"value":4147}," qui s'occupe à la fois de la génération du rapport et de son enregistrement au format PDF. À première vue, cela peut sembler correct. Cependant, cette classe enfreint le principe de responsabilité unique, car elle fait deux choses différentes : générer un rapport ",{"type":28,"tag":55,"props":4149,"children":4150},{},[4151],{"type":34,"value":4152},"et",{"type":34,"value":4154}," le sauvegarder en PDF.",{"type":28,"tag":169,"props":4156,"children":4158},{"id":4157},"exemple-sans-srp",[4159],{"type":34,"value":4160},"Exemple sans SRP :",{"type":28,"tag":181,"props":4162,"children":4164},{"className":183,"code":4163,"language":185,"meta":8,"style":8},"public class Report {\n    private String content;\n\n    public Report(String content) {\n        this.content = content;\n    }\n\n    public void generateReport() {\n        // Logique de génération de rapport\n        System.out.println(\"Génération du rapport : \" + content);\n    }\n\n    public void saveToPDF(String filename) {\n        // Logique d'enregistrement en PDF\n        System.out.println(\"Enregistrement du rapport en PDF sous : \" + filename);\n    }\n}\n",[4165],{"type":28,"tag":188,"props":4166,"children":4167},{"__ignoreMap":8},[4168,4188,4208,4215,4246,4274,4281,4288,4312,4320,4365,4372,4379,4416,4424,4468,4475],{"type":28,"tag":192,"props":4169,"children":4170},{"class":194,"line":195},[4171,4175,4179,4184],{"type":28,"tag":192,"props":4172,"children":4173},{"style":209},[4174],{"type":34,"value":212},{"type":28,"tag":192,"props":4176,"children":4177},{"style":209},[4178],{"type":34,"value":217},{"type":28,"tag":192,"props":4180,"children":4181},{"style":220},[4182],{"type":34,"value":4183}," Report",{"type":28,"tag":192,"props":4185,"children":4186},{"style":226},[4187],{"type":34,"value":229},{"type":28,"tag":192,"props":4189,"children":4190},{"class":194,"line":205},[4191,4195,4199,4204],{"type":28,"tag":192,"props":4192,"children":4193},{"style":209},[4194],{"type":34,"value":238},{"type":28,"tag":192,"props":4196,"children":4197},{"style":241},[4198],{"type":34,"value":244},{"type":28,"tag":192,"props":4200,"children":4201},{"style":247},[4202],{"type":34,"value":4203}," content",{"type":28,"tag":192,"props":4205,"children":4206},{"style":226},[4207],{"type":34,"value":255},{"type":28,"tag":192,"props":4209,"children":4210},{"class":194,"line":232},[4211],{"type":28,"tag":192,"props":4212,"children":4213},{"emptyLinePlaceholder":13},[4214],{"type":34,"value":313},{"type":28,"tag":192,"props":4216,"children":4217},{"class":194,"line":258},[4218,4222,4226,4230,4234,4238,4242],{"type":28,"tag":192,"props":4219,"children":4220},{"style":209},[4221],{"type":34,"value":322},{"type":28,"tag":192,"props":4223,"children":4224},{"style":325},[4225],{"type":34,"value":4183},{"type":28,"tag":192,"props":4227,"children":4228},{"style":226},[4229],{"type":34,"value":332},{"type":28,"tag":192,"props":4231,"children":4232},{"style":241},[4233],{"type":34,"value":337},{"type":28,"tag":192,"props":4235,"children":4236},{"style":340},[4237],{"type":34,"value":4203},{"type":28,"tag":192,"props":4239,"children":4240},{"style":226},[4241],{"type":34,"value":360},{"type":28,"tag":192,"props":4243,"children":4244},{"style":226},[4245],{"type":34,"value":229},{"type":28,"tag":192,"props":4247,"children":4248},{"class":194,"line":280},[4249,4253,4257,4262,4266,4270],{"type":28,"tag":192,"props":4250,"children":4251},{"style":371},[4252],{"type":34,"value":374},{"type":28,"tag":192,"props":4254,"children":4255},{"style":226},[4256],{"type":34,"value":379},{"type":28,"tag":192,"props":4258,"children":4259},{"style":247},[4260],{"type":34,"value":4261},"content ",{"type":28,"tag":192,"props":4263,"children":4264},{"style":387},[4265],{"type":34,"value":390},{"type":28,"tag":192,"props":4267,"children":4268},{"style":247},[4269],{"type":34,"value":4203},{"type":28,"tag":192,"props":4271,"children":4272},{"style":226},[4273],{"type":34,"value":255},{"type":28,"tag":192,"props":4275,"children":4276},{"class":194,"line":307},[4277],{"type":28,"tag":192,"props":4278,"children":4279},{"style":226},[4280],{"type":34,"value":445},{"type":28,"tag":192,"props":4282,"children":4283},{"class":194,"line":316},[4284],{"type":28,"tag":192,"props":4285,"children":4286},{"emptyLinePlaceholder":13},[4287],{"type":34,"value":313},{"type":28,"tag":192,"props":4289,"children":4290},{"class":194,"line":367},[4291,4295,4299,4304,4308],{"type":28,"tag":192,"props":4292,"children":4293},{"style":209},[4294],{"type":34,"value":322},{"type":28,"tag":192,"props":4296,"children":4297},{"style":209},[4298],{"type":34,"value":688},{"type":28,"tag":192,"props":4300,"children":4301},{"style":325},[4302],{"type":34,"value":4303}," generateReport",{"type":28,"tag":192,"props":4305,"children":4306},{"style":226},[4307],{"type":34,"value":475},{"type":28,"tag":192,"props":4309,"children":4310},{"style":226},[4311],{"type":34,"value":229},{"type":28,"tag":192,"props":4313,"children":4314},{"class":194,"line":401},[4315],{"type":28,"tag":192,"props":4316,"children":4317},{"style":199},[4318],{"type":34,"value":4319},"        // Logique de génération de rapport\n",{"type":28,"tag":192,"props":4321,"children":4322},{"class":194,"line":430},[4323,4328,4332,4336,4340,4344,4348,4353,4357,4361],{"type":28,"tag":192,"props":4324,"children":4325},{"style":247},[4326],{"type":34,"value":4327},"        System",{"type":28,"tag":192,"props":4329,"children":4330},{"style":226},[4331],{"type":34,"value":379},{"type":28,"tag":192,"props":4333,"children":4334},{"style":247},[4335],{"type":34,"value":2673},{"type":28,"tag":192,"props":4337,"children":4338},{"style":226},[4339],{"type":34,"value":379},{"type":28,"tag":192,"props":4341,"children":4342},{"style":325},[4343],{"type":34,"value":2682},{"type":28,"tag":192,"props":4345,"children":4346},{"style":226},[4347],{"type":34,"value":332},{"type":28,"tag":192,"props":4349,"children":4350},{"style":734},[4351],{"type":34,"value":4352},"\"Génération du rapport : \"",{"type":28,"tag":192,"props":4354,"children":4355},{"style":387},[4356],{"type":34,"value":2696},{"type":28,"tag":192,"props":4358,"children":4359},{"style":247},[4360],{"type":34,"value":4203},{"type":28,"tag":192,"props":4362,"children":4363},{"style":226},[4364],{"type":34,"value":752},{"type":28,"tag":192,"props":4366,"children":4367},{"class":194,"line":439},[4368],{"type":28,"tag":192,"props":4369,"children":4370},{"style":226},[4371],{"type":34,"value":445},{"type":28,"tag":192,"props":4373,"children":4374},{"class":194,"line":448},[4375],{"type":28,"tag":192,"props":4376,"children":4377},{"emptyLinePlaceholder":13},[4378],{"type":34,"value":313},{"type":28,"tag":192,"props":4380,"children":4381},{"class":194,"line":456},[4382,4386,4390,4395,4399,4403,4408,4412],{"type":28,"tag":192,"props":4383,"children":4384},{"style":209},[4385],{"type":34,"value":322},{"type":28,"tag":192,"props":4387,"children":4388},{"style":209},[4389],{"type":34,"value":688},{"type":28,"tag":192,"props":4391,"children":4392},{"style":325},[4393],{"type":34,"value":4394}," saveToPDF",{"type":28,"tag":192,"props":4396,"children":4397},{"style":226},[4398],{"type":34,"value":332},{"type":28,"tag":192,"props":4400,"children":4401},{"style":241},[4402],{"type":34,"value":337},{"type":28,"tag":192,"props":4404,"children":4405},{"style":340},[4406],{"type":34,"value":4407}," filename",{"type":28,"tag":192,"props":4409,"children":4410},{"style":226},[4411],{"type":34,"value":360},{"type":28,"tag":192,"props":4413,"children":4414},{"style":226},[4415],{"type":34,"value":229},{"type":28,"tag":192,"props":4417,"children":4418},{"class":194,"line":482},[4419],{"type":28,"tag":192,"props":4420,"children":4421},{"style":199},[4422],{"type":34,"value":4423},"        // Logique d'enregistrement en PDF\n",{"type":28,"tag":192,"props":4425,"children":4426},{"class":194,"line":499},[4427,4431,4435,4439,4443,4447,4451,4456,4460,4464],{"type":28,"tag":192,"props":4428,"children":4429},{"style":247},[4430],{"type":34,"value":4327},{"type":28,"tag":192,"props":4432,"children":4433},{"style":226},[4434],{"type":34,"value":379},{"type":28,"tag":192,"props":4436,"children":4437},{"style":247},[4438],{"type":34,"value":2673},{"type":28,"tag":192,"props":4440,"children":4441},{"style":226},[4442],{"type":34,"value":379},{"type":28,"tag":192,"props":4444,"children":4445},{"style":325},[4446],{"type":34,"value":2682},{"type":28,"tag":192,"props":4448,"children":4449},{"style":226},[4450],{"type":34,"value":332},{"type":28,"tag":192,"props":4452,"children":4453},{"style":734},[4454],{"type":34,"value":4455},"\"Enregistrement du rapport en PDF sous : \"",{"type":28,"tag":192,"props":4457,"children":4458},{"style":387},[4459],{"type":34,"value":2696},{"type":28,"tag":192,"props":4461,"children":4462},{"style":247},[4463],{"type":34,"value":4407},{"type":28,"tag":192,"props":4465,"children":4466},{"style":226},[4467],{"type":34,"value":752},{"type":28,"tag":192,"props":4469,"children":4470},{"class":194,"line":507},[4471],{"type":28,"tag":192,"props":4472,"children":4473},{"style":226},[4474],{"type":34,"value":445},{"type":28,"tag":192,"props":4476,"children":4477},{"class":194,"line":515},[4478],{"type":28,"tag":192,"props":4479,"children":4480},{"style":226},[4481],{"type":34,"value":588},{"type":28,"tag":44,"props":4483,"children":4484},{},[4485,4487,4492],{"type":34,"value":4486},"Dans cet exemple, la classe ",{"type":28,"tag":188,"props":4488,"children":4490},{"className":4489},[],[4491],{"type":34,"value":4145},{"type":34,"value":4493}," enfreint le SRP. Elle est responsable de deux tâches distinctes : générer un rapport et l'enregistrer sous forme de fichier PDF. Si un jour on décide de changer la méthode de génération des rapports ou d'enregistrer le fichier dans un autre format (par exemple, JSON), il faudra modifier cette classe, ce qui peut introduire des bugs ou rendre les modifications plus difficiles.",{"type":28,"tag":169,"props":4495,"children":4497},{"id":4496},"exemple-avec-srp-appliqué",[4498],{"type":34,"value":4499},"Exemple avec SRP appliqué :",{"type":28,"tag":44,"props":4501,"children":4502},{},[4503],{"type":34,"value":4504},"Pour corriger cela, on peut diviser les responsabilités en deux classes distinctes.",{"type":28,"tag":181,"props":4506,"children":4508},{"className":183,"code":4507,"language":185,"meta":8,"style":8},"// Classe qui se charge uniquement de la génération du rapport\npublic class Report {\n    private String content;\n\n    public Report(String content) {\n        this.content = content;\n    }\n\n    public void generateReport() {\n        System.out.println(\"Génération du rapport : \" + content);\n    }\n}\n\n// Classe qui se charge uniquement de l'enregistrement du rapport\npublic class ReportSaver {\n    public void saveToPDF(Report report, String filename) {\n        System.out.println(\"Enregistrement du rapport en PDF sous : \" + filename);\n    }\n}\n",[4509],{"type":28,"tag":188,"props":4510,"children":4511},{"__ignoreMap":8},[4512,4520,4539,4558,4565,4596,4623,4630,4637,4660,4703,4710,4717,4724,4732,4752,4800,4843,4850],{"type":28,"tag":192,"props":4513,"children":4514},{"class":194,"line":195},[4515],{"type":28,"tag":192,"props":4516,"children":4517},{"style":199},[4518],{"type":34,"value":4519},"// Classe qui se charge uniquement de la génération du rapport\n",{"type":28,"tag":192,"props":4521,"children":4522},{"class":194,"line":205},[4523,4527,4531,4535],{"type":28,"tag":192,"props":4524,"children":4525},{"style":209},[4526],{"type":34,"value":212},{"type":28,"tag":192,"props":4528,"children":4529},{"style":209},[4530],{"type":34,"value":217},{"type":28,"tag":192,"props":4532,"children":4533},{"style":220},[4534],{"type":34,"value":4183},{"type":28,"tag":192,"props":4536,"children":4537},{"style":226},[4538],{"type":34,"value":229},{"type":28,"tag":192,"props":4540,"children":4541},{"class":194,"line":232},[4542,4546,4550,4554],{"type":28,"tag":192,"props":4543,"children":4544},{"style":209},[4545],{"type":34,"value":238},{"type":28,"tag":192,"props":4547,"children":4548},{"style":241},[4549],{"type":34,"value":244},{"type":28,"tag":192,"props":4551,"children":4552},{"style":247},[4553],{"type":34,"value":4203},{"type":28,"tag":192,"props":4555,"children":4556},{"style":226},[4557],{"type":34,"value":255},{"type":28,"tag":192,"props":4559,"children":4560},{"class":194,"line":258},[4561],{"type":28,"tag":192,"props":4562,"children":4563},{"emptyLinePlaceholder":13},[4564],{"type":34,"value":313},{"type":28,"tag":192,"props":4566,"children":4567},{"class":194,"line":280},[4568,4572,4576,4580,4584,4588,4592],{"type":28,"tag":192,"props":4569,"children":4570},{"style":209},[4571],{"type":34,"value":322},{"type":28,"tag":192,"props":4573,"children":4574},{"style":325},[4575],{"type":34,"value":4183},{"type":28,"tag":192,"props":4577,"children":4578},{"style":226},[4579],{"type":34,"value":332},{"type":28,"tag":192,"props":4581,"children":4582},{"style":241},[4583],{"type":34,"value":337},{"type":28,"tag":192,"props":4585,"children":4586},{"style":340},[4587],{"type":34,"value":4203},{"type":28,"tag":192,"props":4589,"children":4590},{"style":226},[4591],{"type":34,"value":360},{"type":28,"tag":192,"props":4593,"children":4594},{"style":226},[4595],{"type":34,"value":229},{"type":28,"tag":192,"props":4597,"children":4598},{"class":194,"line":307},[4599,4603,4607,4611,4615,4619],{"type":28,"tag":192,"props":4600,"children":4601},{"style":371},[4602],{"type":34,"value":374},{"type":28,"tag":192,"props":4604,"children":4605},{"style":226},[4606],{"type":34,"value":379},{"type":28,"tag":192,"props":4608,"children":4609},{"style":247},[4610],{"type":34,"value":4261},{"type":28,"tag":192,"props":4612,"children":4613},{"style":387},[4614],{"type":34,"value":390},{"type":28,"tag":192,"props":4616,"children":4617},{"style":247},[4618],{"type":34,"value":4203},{"type":28,"tag":192,"props":4620,"children":4621},{"style":226},[4622],{"type":34,"value":255},{"type":28,"tag":192,"props":4624,"children":4625},{"class":194,"line":316},[4626],{"type":28,"tag":192,"props":4627,"children":4628},{"style":226},[4629],{"type":34,"value":445},{"type":28,"tag":192,"props":4631,"children":4632},{"class":194,"line":367},[4633],{"type":28,"tag":192,"props":4634,"children":4635},{"emptyLinePlaceholder":13},[4636],{"type":34,"value":313},{"type":28,"tag":192,"props":4638,"children":4639},{"class":194,"line":401},[4640,4644,4648,4652,4656],{"type":28,"tag":192,"props":4641,"children":4642},{"style":209},[4643],{"type":34,"value":322},{"type":28,"tag":192,"props":4645,"children":4646},{"style":209},[4647],{"type":34,"value":688},{"type":28,"tag":192,"props":4649,"children":4650},{"style":325},[4651],{"type":34,"value":4303},{"type":28,"tag":192,"props":4653,"children":4654},{"style":226},[4655],{"type":34,"value":475},{"type":28,"tag":192,"props":4657,"children":4658},{"style":226},[4659],{"type":34,"value":229},{"type":28,"tag":192,"props":4661,"children":4662},{"class":194,"line":430},[4663,4667,4671,4675,4679,4683,4687,4691,4695,4699],{"type":28,"tag":192,"props":4664,"children":4665},{"style":247},[4666],{"type":34,"value":4327},{"type":28,"tag":192,"props":4668,"children":4669},{"style":226},[4670],{"type":34,"value":379},{"type":28,"tag":192,"props":4672,"children":4673},{"style":247},[4674],{"type":34,"value":2673},{"type":28,"tag":192,"props":4676,"children":4677},{"style":226},[4678],{"type":34,"value":379},{"type":28,"tag":192,"props":4680,"children":4681},{"style":325},[4682],{"type":34,"value":2682},{"type":28,"tag":192,"props":4684,"children":4685},{"style":226},[4686],{"type":34,"value":332},{"type":28,"tag":192,"props":4688,"children":4689},{"style":734},[4690],{"type":34,"value":4352},{"type":28,"tag":192,"props":4692,"children":4693},{"style":387},[4694],{"type":34,"value":2696},{"type":28,"tag":192,"props":4696,"children":4697},{"style":247},[4698],{"type":34,"value":4203},{"type":28,"tag":192,"props":4700,"children":4701},{"style":226},[4702],{"type":34,"value":752},{"type":28,"tag":192,"props":4704,"children":4705},{"class":194,"line":439},[4706],{"type":28,"tag":192,"props":4707,"children":4708},{"style":226},[4709],{"type":34,"value":445},{"type":28,"tag":192,"props":4711,"children":4712},{"class":194,"line":448},[4713],{"type":28,"tag":192,"props":4714,"children":4715},{"style":226},[4716],{"type":34,"value":588},{"type":28,"tag":192,"props":4718,"children":4719},{"class":194,"line":456},[4720],{"type":28,"tag":192,"props":4721,"children":4722},{"emptyLinePlaceholder":13},[4723],{"type":34,"value":313},{"type":28,"tag":192,"props":4725,"children":4726},{"class":194,"line":482},[4727],{"type":28,"tag":192,"props":4728,"children":4729},{"style":199},[4730],{"type":34,"value":4731},"// Classe qui se charge uniquement de l'enregistrement du rapport\n",{"type":28,"tag":192,"props":4733,"children":4734},{"class":194,"line":499},[4735,4739,4743,4748],{"type":28,"tag":192,"props":4736,"children":4737},{"style":209},[4738],{"type":34,"value":212},{"type":28,"tag":192,"props":4740,"children":4741},{"style":209},[4742],{"type":34,"value":217},{"type":28,"tag":192,"props":4744,"children":4745},{"style":220},[4746],{"type":34,"value":4747}," ReportSaver",{"type":28,"tag":192,"props":4749,"children":4750},{"style":226},[4751],{"type":34,"value":229},{"type":28,"tag":192,"props":4753,"children":4754},{"class":194,"line":507},[4755,4759,4763,4767,4771,4775,4780,4784,4788,4792,4796],{"type":28,"tag":192,"props":4756,"children":4757},{"style":209},[4758],{"type":34,"value":322},{"type":28,"tag":192,"props":4760,"children":4761},{"style":209},[4762],{"type":34,"value":688},{"type":28,"tag":192,"props":4764,"children":4765},{"style":325},[4766],{"type":34,"value":4394},{"type":28,"tag":192,"props":4768,"children":4769},{"style":226},[4770],{"type":34,"value":332},{"type":28,"tag":192,"props":4772,"children":4773},{"style":241},[4774],{"type":34,"value":4145},{"type":28,"tag":192,"props":4776,"children":4777},{"style":340},[4778],{"type":34,"value":4779}," report",{"type":28,"tag":192,"props":4781,"children":4782},{"style":226},[4783],{"type":34,"value":347},{"type":28,"tag":192,"props":4785,"children":4786},{"style":241},[4787],{"type":34,"value":244},{"type":28,"tag":192,"props":4789,"children":4790},{"style":340},[4791],{"type":34,"value":4407},{"type":28,"tag":192,"props":4793,"children":4794},{"style":226},[4795],{"type":34,"value":360},{"type":28,"tag":192,"props":4797,"children":4798},{"style":226},[4799],{"type":34,"value":229},{"type":28,"tag":192,"props":4801,"children":4802},{"class":194,"line":515},[4803,4807,4811,4815,4819,4823,4827,4831,4835,4839],{"type":28,"tag":192,"props":4804,"children":4805},{"style":247},[4806],{"type":34,"value":4327},{"type":28,"tag":192,"props":4808,"children":4809},{"style":226},[4810],{"type":34,"value":379},{"type":28,"tag":192,"props":4812,"children":4813},{"style":247},[4814],{"type":34,"value":2673},{"type":28,"tag":192,"props":4816,"children":4817},{"style":226},[4818],{"type":34,"value":379},{"type":28,"tag":192,"props":4820,"children":4821},{"style":325},[4822],{"type":34,"value":2682},{"type":28,"tag":192,"props":4824,"children":4825},{"style":226},[4826],{"type":34,"value":332},{"type":28,"tag":192,"props":4828,"children":4829},{"style":734},[4830],{"type":34,"value":4455},{"type":28,"tag":192,"props":4832,"children":4833},{"style":387},[4834],{"type":34,"value":2696},{"type":28,"tag":192,"props":4836,"children":4837},{"style":247},[4838],{"type":34,"value":4407},{"type":28,"tag":192,"props":4840,"children":4841},{"style":226},[4842],{"type":34,"value":752},{"type":28,"tag":192,"props":4844,"children":4845},{"class":194,"line":540},[4846],{"type":28,"tag":192,"props":4847,"children":4848},{"style":226},[4849],{"type":34,"value":445},{"type":28,"tag":192,"props":4851,"children":4852},{"class":194,"line":556},[4853],{"type":28,"tag":192,"props":4854,"children":4855},{"style":226},[4856],{"type":34,"value":588},{"type":28,"tag":83,"props":4858,"children":4859},{},[],{"type":28,"tag":1841,"props":4861,"children":4862},{"type":1843},[4863],{"type":28,"tag":44,"props":4864,"children":4865},{},[4866,4871],{"type":28,"tag":55,"props":4867,"children":4868},{},[4869],{"type":34,"value":4870},"Gardez vos classes petites",{"type":34,"value":4872},". Si vous trouvez qu'une classe fait plusieurs choses non liées, envisagez de la diviser en plusieurs classes plus petites. Cela rendra le code plus lisible et plus facile à maintenir.",{"type":28,"tag":120,"props":4874,"children":4876},{"cta":122,"href":123,"title":4875,"type":125},"Vous voulez savoir, en regardant une classe, où SOLID doit s'appliquer et où il ne sert à rien ?",[4877],{"type":28,"tag":44,"props":4878,"children":4879},{},[4880],{"type":34,"value":4881},"Reconnaître une violation du SRP ou un héritage qui casse Liskov dans votre propre code, ça ne s'apprend pas en lisant un article : ça se travaille. En mentoring 1:1, je relis votre code Java avec vous, on refactorise ensemble les zones les plus couplées, et vous développez le réflexe de couper au bon endroit sans sur-abstraire.",{"type":28,"tag":29,"props":4883,"children":4885},{"id":4884},"_2-principe-ouvertfermé-openclosed-principle-ocp",[4886],{"type":34,"value":4887},"2. Principe Ouvert/Fermé (Open/Closed Principle - OCP)",{"type":28,"tag":44,"props":4889,"children":4890},{},[4891,4893,4898,4900,4905],{"type":34,"value":4892},"Le principe Ouvert/Fermé stipule qu’une entité (classe, module, fonction, etc.) doit être ",{"type":28,"tag":55,"props":4894,"children":4895},{},[4896],{"type":34,"value":4897},"ouverte à l’extension",{"type":34,"value":4899}," mais ",{"type":28,"tag":55,"props":4901,"children":4902},{},[4903],{"type":34,"value":4904},"fermée à la modification",{"type":34,"value":4906},". Cela signifie qu’il devrait être possible d’ajouter de nouvelles fonctionnalités sans avoir à modifier le code existant. En d’autres termes, je vous recommande de concevoir le code de manière à ce qu’il puisse évoluer par des extensions plutôt que par des modifications internes.",{"type":28,"tag":37,"props":4908,"children":4910},{"id":4909},"pourquoi-cest-important-1",[4911],{"type":34,"value":4123},{"type":28,"tag":44,"props":4913,"children":4914},{},[4915],{"type":34,"value":4916},"Respecter l'OCP évite de toucher au code stable et déjà testé, ce qui réduit le risque d'introduire des bugs. C'est aussi ce qui rend l'ajout de nouvelles fonctionnalités fluide sur le long terme : vous étendez plutôt que de patcher.",{"type":28,"tag":37,"props":4918,"children":4920},{"id":4919},"exemple-concret-en-java-1",[4921],{"type":34,"value":4134},{"type":28,"tag":44,"props":4923,"children":4924},{},[4925],{"type":34,"value":4926},"Imaginons que nous travaillions sur un système de paiement qui supporte plusieurs méthodes de paiement comme la carte bancaire et PayPal. Si l’on veut ajouter une nouvelle méthode de paiement, par exemple via un portefeuille électronique (e-wallet), on ne veut pas devoir modifier chaque partie du code. Cela enfreindrait le principe OCP.",{"type":28,"tag":169,"props":4928,"children":4930},{"id":4929},"exemple-sans-ocp",[4931],{"type":34,"value":4932},"Exemple sans OCP :",{"type":28,"tag":44,"props":4934,"children":4935},{},[4936,4938,4944],{"type":34,"value":4937},"Voici une implémentation où la classe ",{"type":28,"tag":188,"props":4939,"children":4941},{"className":4940},[],[4942],{"type":34,"value":4943},"PaymentProcessor",{"type":34,"value":4945}," gère directement les différentes méthodes de paiement :",{"type":28,"tag":181,"props":4947,"children":4949},{"className":183,"code":4948,"language":185,"meta":8,"style":8},"public class PaymentProcessor {\n    public void processPayment(String type) {\n        if (type.equals(\"creditCard\")) {\n            // Traitement paiement par carte bancaire\n            System.out.println(\"Paiement par carte bancaire\");\n        } else if (type.equals(\"paypal\")) {\n            // Traitement paiement PayPal\n            System.out.println(\"Paiement via PayPal\");\n        }\n    }\n}\n",[4950],{"type":28,"tag":188,"props":4951,"children":4952},{"__ignoreMap":8},[4953,4973,5010,5053,5061,5097,5146,5154,5190,5197,5204],{"type":28,"tag":192,"props":4954,"children":4955},{"class":194,"line":195},[4956,4960,4964,4969],{"type":28,"tag":192,"props":4957,"children":4958},{"style":209},[4959],{"type":34,"value":212},{"type":28,"tag":192,"props":4961,"children":4962},{"style":209},[4963],{"type":34,"value":217},{"type":28,"tag":192,"props":4965,"children":4966},{"style":220},[4967],{"type":34,"value":4968}," PaymentProcessor",{"type":28,"tag":192,"props":4970,"children":4971},{"style":226},[4972],{"type":34,"value":229},{"type":28,"tag":192,"props":4974,"children":4975},{"class":194,"line":205},[4976,4980,4984,4989,4993,4997,5002,5006],{"type":28,"tag":192,"props":4977,"children":4978},{"style":209},[4979],{"type":34,"value":322},{"type":28,"tag":192,"props":4981,"children":4982},{"style":209},[4983],{"type":34,"value":688},{"type":28,"tag":192,"props":4985,"children":4986},{"style":325},[4987],{"type":34,"value":4988}," processPayment",{"type":28,"tag":192,"props":4990,"children":4991},{"style":226},[4992],{"type":34,"value":332},{"type":28,"tag":192,"props":4994,"children":4995},{"style":241},[4996],{"type":34,"value":337},{"type":28,"tag":192,"props":4998,"children":4999},{"style":340},[5000],{"type":34,"value":5001}," type",{"type":28,"tag":192,"props":5003,"children":5004},{"style":226},[5005],{"type":34,"value":360},{"type":28,"tag":192,"props":5007,"children":5008},{"style":226},[5009],{"type":34,"value":229},{"type":28,"tag":192,"props":5011,"children":5012},{"class":194,"line":232},[5013,5017,5021,5026,5030,5035,5039,5044,5049],{"type":28,"tag":192,"props":5014,"children":5015},{"style":209},[5016],{"type":34,"value":986},{"type":28,"tag":192,"props":5018,"children":5019},{"style":226},[5020],{"type":34,"value":991},{"type":28,"tag":192,"props":5022,"children":5023},{"style":247},[5024],{"type":34,"value":5025},"type",{"type":28,"tag":192,"props":5027,"children":5028},{"style":226},[5029],{"type":34,"value":379},{"type":28,"tag":192,"props":5031,"children":5032},{"style":325},[5033],{"type":34,"value":5034},"equals",{"type":28,"tag":192,"props":5036,"children":5037},{"style":226},[5038],{"type":34,"value":332},{"type":28,"tag":192,"props":5040,"children":5041},{"style":734},[5042],{"type":34,"value":5043},"\"creditCard\"",{"type":28,"tag":192,"props":5045,"children":5046},{"style":226},[5047],{"type":34,"value":5048},"))",{"type":28,"tag":192,"props":5050,"children":5051},{"style":226},[5052],{"type":34,"value":229},{"type":28,"tag":192,"props":5054,"children":5055},{"class":194,"line":258},[5056],{"type":28,"tag":192,"props":5057,"children":5058},{"style":199},[5059],{"type":34,"value":5060},"            // Traitement paiement par carte bancaire\n",{"type":28,"tag":192,"props":5062,"children":5063},{"class":194,"line":280},[5064,5068,5072,5076,5080,5084,5088,5093],{"type":28,"tag":192,"props":5065,"children":5066},{"style":247},[5067],{"type":34,"value":2664},{"type":28,"tag":192,"props":5069,"children":5070},{"style":226},[5071],{"type":34,"value":379},{"type":28,"tag":192,"props":5073,"children":5074},{"style":247},[5075],{"type":34,"value":2673},{"type":28,"tag":192,"props":5077,"children":5078},{"style":226},[5079],{"type":34,"value":379},{"type":28,"tag":192,"props":5081,"children":5082},{"style":325},[5083],{"type":34,"value":2682},{"type":28,"tag":192,"props":5085,"children":5086},{"style":226},[5087],{"type":34,"value":332},{"type":28,"tag":192,"props":5089,"children":5090},{"style":734},[5091],{"type":34,"value":5092},"\"Paiement par carte bancaire\"",{"type":28,"tag":192,"props":5094,"children":5095},{"style":226},[5096],{"type":34,"value":752},{"type":28,"tag":192,"props":5098,"children":5099},{"class":194,"line":307},[5100,5104,5108,5113,5117,5121,5125,5129,5133,5138,5142],{"type":28,"tag":192,"props":5101,"children":5102},{"style":226},[5103],{"type":34,"value":1076},{"type":28,"tag":192,"props":5105,"children":5106},{"style":209},[5107],{"type":34,"value":1081},{"type":28,"tag":192,"props":5109,"children":5110},{"style":209},[5111],{"type":34,"value":5112}," if",{"type":28,"tag":192,"props":5114,"children":5115},{"style":226},[5116],{"type":34,"value":991},{"type":28,"tag":192,"props":5118,"children":5119},{"style":247},[5120],{"type":34,"value":5025},{"type":28,"tag":192,"props":5122,"children":5123},{"style":226},[5124],{"type":34,"value":379},{"type":28,"tag":192,"props":5126,"children":5127},{"style":325},[5128],{"type":34,"value":5034},{"type":28,"tag":192,"props":5130,"children":5131},{"style":226},[5132],{"type":34,"value":332},{"type":28,"tag":192,"props":5134,"children":5135},{"style":734},[5136],{"type":34,"value":5137},"\"paypal\"",{"type":28,"tag":192,"props":5139,"children":5140},{"style":226},[5141],{"type":34,"value":5048},{"type":28,"tag":192,"props":5143,"children":5144},{"style":226},[5145],{"type":34,"value":229},{"type":28,"tag":192,"props":5147,"children":5148},{"class":194,"line":316},[5149],{"type":28,"tag":192,"props":5150,"children":5151},{"style":199},[5152],{"type":34,"value":5153},"            // Traitement paiement PayPal\n",{"type":28,"tag":192,"props":5155,"children":5156},{"class":194,"line":367},[5157,5161,5165,5169,5173,5177,5181,5186],{"type":28,"tag":192,"props":5158,"children":5159},{"style":247},[5160],{"type":34,"value":2664},{"type":28,"tag":192,"props":5162,"children":5163},{"style":226},[5164],{"type":34,"value":379},{"type":28,"tag":192,"props":5166,"children":5167},{"style":247},[5168],{"type":34,"value":2673},{"type":28,"tag":192,"props":5170,"children":5171},{"style":226},[5172],{"type":34,"value":379},{"type":28,"tag":192,"props":5174,"children":5175},{"style":325},[5176],{"type":34,"value":2682},{"type":28,"tag":192,"props":5178,"children":5179},{"style":226},[5180],{"type":34,"value":332},{"type":28,"tag":192,"props":5182,"children":5183},{"style":734},[5184],{"type":34,"value":5185},"\"Paiement via PayPal\"",{"type":28,"tag":192,"props":5187,"children":5188},{"style":226},[5189],{"type":34,"value":752},{"type":28,"tag":192,"props":5191,"children":5192},{"class":194,"line":401},[5193],{"type":28,"tag":192,"props":5194,"children":5195},{"style":226},[5196],{"type":34,"value":1118},{"type":28,"tag":192,"props":5198,"children":5199},{"class":194,"line":430},[5200],{"type":28,"tag":192,"props":5201,"children":5202},{"style":226},[5203],{"type":34,"value":445},{"type":28,"tag":192,"props":5205,"children":5206},{"class":194,"line":439},[5207],{"type":28,"tag":192,"props":5208,"children":5209},{"style":226},[5210],{"type":34,"value":588},{"type":28,"tag":44,"props":5212,"children":5213},{},[5214,5216,5221,5223,5228,5230,5236],{"type":34,"value":5215},"Dans ce cas, si l'on veut ajouter un nouveau moyen de paiement, comme un portefeuille électronique, il faudrait ",{"type":28,"tag":55,"props":5217,"children":5218},{},[5219],{"type":34,"value":5220},"modifier la classe",{"type":34,"value":5222}," ",{"type":28,"tag":188,"props":5224,"children":5226},{"className":5225},[],[5227],{"type":34,"value":4943},{"type":34,"value":5229}," en ajoutant une nouvelle condition ",{"type":28,"tag":188,"props":5231,"children":5233},{"className":5232},[],[5234],{"type":34,"value":5235},"else if",{"type":34,"value":5237},". Cela enfreint le principe OCP, car on doit toucher au code existant pour ajouter une nouvelle fonctionnalité.",{"type":28,"tag":169,"props":5239,"children":5241},{"id":5240},"exemple-avec-ocp-appliqué",[5242],{"type":34,"value":5243},"Exemple avec OCP appliqué :",{"type":28,"tag":44,"props":5245,"children":5246},{},[5247],{"type":34,"value":5248},"Voyons maintenant une solution où la classe est ouverte à l'extension mais fermée à la modification en utilisant l’héritage et le polymorphisme.",{"type":28,"tag":181,"props":5250,"children":5252},{"className":183,"code":5251,"language":185,"meta":8,"style":8},"// Interface de stratégie de paiement\npublic interface PaymentMethod {\n    void processPayment();\n}\n\n// Implémentation pour la carte bancaire\npublic class CreditCardPayment implements PaymentMethod {\n    @Override\n    public void processPayment() {\n        System.out.println(\"Paiement par carte bancaire\");\n    }\n}\n\n// Implémentation pour PayPal\npublic class PayPalPayment implements PaymentMethod {\n    @Override\n    public void processPayment() {\n        System.out.println(\"Paiement via PayPal\");\n    }\n}\n\n// Classe de traitement des paiements qui respecte OCP\npublic class PaymentProcessor {\n    public void processPayment(PaymentMethod paymentMethod) {\n        paymentMethod.processPayment();\n    }\n}\n",[5253],{"type":28,"tag":188,"props":5254,"children":5255},{"__ignoreMap":8},[5256,5264,5285,5301,5308,5315,5323,5352,5365,5388,5423,5430,5437,5444,5452,5480,5491,5514,5549,5556,5563,5570,5578,5598,5636,5658,5666],{"type":28,"tag":192,"props":5257,"children":5258},{"class":194,"line":195},[5259],{"type":28,"tag":192,"props":5260,"children":5261},{"style":199},[5262],{"type":34,"value":5263},"// Interface de stratégie de paiement\n",{"type":28,"tag":192,"props":5265,"children":5266},{"class":194,"line":205},[5267,5271,5276,5281],{"type":28,"tag":192,"props":5268,"children":5269},{"style":209},[5270],{"type":34,"value":212},{"type":28,"tag":192,"props":5272,"children":5273},{"style":209},[5274],{"type":34,"value":5275}," interface",{"type":28,"tag":192,"props":5277,"children":5278},{"style":220},[5279],{"type":34,"value":5280}," PaymentMethod",{"type":28,"tag":192,"props":5282,"children":5283},{"style":226},[5284],{"type":34,"value":229},{"type":28,"tag":192,"props":5286,"children":5287},{"class":194,"line":232},[5288,5293,5297],{"type":28,"tag":192,"props":5289,"children":5290},{"style":209},[5291],{"type":34,"value":5292},"    void",{"type":28,"tag":192,"props":5294,"children":5295},{"style":325},[5296],{"type":34,"value":4988},{"type":28,"tag":192,"props":5298,"children":5299},{"style":226},[5300],{"type":34,"value":1973},{"type":28,"tag":192,"props":5302,"children":5303},{"class":194,"line":258},[5304],{"type":28,"tag":192,"props":5305,"children":5306},{"style":226},[5307],{"type":34,"value":588},{"type":28,"tag":192,"props":5309,"children":5310},{"class":194,"line":280},[5311],{"type":28,"tag":192,"props":5312,"children":5313},{"emptyLinePlaceholder":13},[5314],{"type":34,"value":313},{"type":28,"tag":192,"props":5316,"children":5317},{"class":194,"line":307},[5318],{"type":28,"tag":192,"props":5319,"children":5320},{"style":199},[5321],{"type":34,"value":5322},"// Implémentation pour la carte bancaire\n",{"type":28,"tag":192,"props":5324,"children":5325},{"class":194,"line":316},[5326,5330,5334,5339,5344,5348],{"type":28,"tag":192,"props":5327,"children":5328},{"style":209},[5329],{"type":34,"value":212},{"type":28,"tag":192,"props":5331,"children":5332},{"style":209},[5333],{"type":34,"value":217},{"type":28,"tag":192,"props":5335,"children":5336},{"style":220},[5337],{"type":34,"value":5338}," CreditCardPayment",{"type":28,"tag":192,"props":5340,"children":5341},{"style":209},[5342],{"type":34,"value":5343}," implements",{"type":28,"tag":192,"props":5345,"children":5346},{"style":220},[5347],{"type":34,"value":5280},{"type":28,"tag":192,"props":5349,"children":5350},{"style":226},[5351],{"type":34,"value":229},{"type":28,"tag":192,"props":5353,"children":5354},{"class":194,"line":367},[5355,5360],{"type":28,"tag":192,"props":5356,"children":5357},{"style":667},[5358],{"type":34,"value":5359},"    @",{"type":28,"tag":192,"props":5361,"children":5362},{"style":673},[5363],{"type":34,"value":5364},"Override\n",{"type":28,"tag":192,"props":5366,"children":5367},{"class":194,"line":401},[5368,5372,5376,5380,5384],{"type":28,"tag":192,"props":5369,"children":5370},{"style":209},[5371],{"type":34,"value":322},{"type":28,"tag":192,"props":5373,"children":5374},{"style":209},[5375],{"type":34,"value":688},{"type":28,"tag":192,"props":5377,"children":5378},{"style":325},[5379],{"type":34,"value":4988},{"type":28,"tag":192,"props":5381,"children":5382},{"style":226},[5383],{"type":34,"value":475},{"type":28,"tag":192,"props":5385,"children":5386},{"style":226},[5387],{"type":34,"value":229},{"type":28,"tag":192,"props":5389,"children":5390},{"class":194,"line":430},[5391,5395,5399,5403,5407,5411,5415,5419],{"type":28,"tag":192,"props":5392,"children":5393},{"style":247},[5394],{"type":34,"value":4327},{"type":28,"tag":192,"props":5396,"children":5397},{"style":226},[5398],{"type":34,"value":379},{"type":28,"tag":192,"props":5400,"children":5401},{"style":247},[5402],{"type":34,"value":2673},{"type":28,"tag":192,"props":5404,"children":5405},{"style":226},[5406],{"type":34,"value":379},{"type":28,"tag":192,"props":5408,"children":5409},{"style":325},[5410],{"type":34,"value":2682},{"type":28,"tag":192,"props":5412,"children":5413},{"style":226},[5414],{"type":34,"value":332},{"type":28,"tag":192,"props":5416,"children":5417},{"style":734},[5418],{"type":34,"value":5092},{"type":28,"tag":192,"props":5420,"children":5421},{"style":226},[5422],{"type":34,"value":752},{"type":28,"tag":192,"props":5424,"children":5425},{"class":194,"line":439},[5426],{"type":28,"tag":192,"props":5427,"children":5428},{"style":226},[5429],{"type":34,"value":445},{"type":28,"tag":192,"props":5431,"children":5432},{"class":194,"line":448},[5433],{"type":28,"tag":192,"props":5434,"children":5435},{"style":226},[5436],{"type":34,"value":588},{"type":28,"tag":192,"props":5438,"children":5439},{"class":194,"line":456},[5440],{"type":28,"tag":192,"props":5441,"children":5442},{"emptyLinePlaceholder":13},[5443],{"type":34,"value":313},{"type":28,"tag":192,"props":5445,"children":5446},{"class":194,"line":482},[5447],{"type":28,"tag":192,"props":5448,"children":5449},{"style":199},[5450],{"type":34,"value":5451},"// Implémentation pour PayPal\n",{"type":28,"tag":192,"props":5453,"children":5454},{"class":194,"line":499},[5455,5459,5463,5468,5472,5476],{"type":28,"tag":192,"props":5456,"children":5457},{"style":209},[5458],{"type":34,"value":212},{"type":28,"tag":192,"props":5460,"children":5461},{"style":209},[5462],{"type":34,"value":217},{"type":28,"tag":192,"props":5464,"children":5465},{"style":220},[5466],{"type":34,"value":5467}," PayPalPayment",{"type":28,"tag":192,"props":5469,"children":5470},{"style":209},[5471],{"type":34,"value":5343},{"type":28,"tag":192,"props":5473,"children":5474},{"style":220},[5475],{"type":34,"value":5280},{"type":28,"tag":192,"props":5477,"children":5478},{"style":226},[5479],{"type":34,"value":229},{"type":28,"tag":192,"props":5481,"children":5482},{"class":194,"line":507},[5483,5487],{"type":28,"tag":192,"props":5484,"children":5485},{"style":667},[5486],{"type":34,"value":5359},{"type":28,"tag":192,"props":5488,"children":5489},{"style":673},[5490],{"type":34,"value":5364},{"type":28,"tag":192,"props":5492,"children":5493},{"class":194,"line":515},[5494,5498,5502,5506,5510],{"type":28,"tag":192,"props":5495,"children":5496},{"style":209},[5497],{"type":34,"value":322},{"type":28,"tag":192,"props":5499,"children":5500},{"style":209},[5501],{"type":34,"value":688},{"type":28,"tag":192,"props":5503,"children":5504},{"style":325},[5505],{"type":34,"value":4988},{"type":28,"tag":192,"props":5507,"children":5508},{"style":226},[5509],{"type":34,"value":475},{"type":28,"tag":192,"props":5511,"children":5512},{"style":226},[5513],{"type":34,"value":229},{"type":28,"tag":192,"props":5515,"children":5516},{"class":194,"line":540},[5517,5521,5525,5529,5533,5537,5541,5545],{"type":28,"tag":192,"props":5518,"children":5519},{"style":247},[5520],{"type":34,"value":4327},{"type":28,"tag":192,"props":5522,"children":5523},{"style":226},[5524],{"type":34,"value":379},{"type":28,"tag":192,"props":5526,"children":5527},{"style":247},[5528],{"type":34,"value":2673},{"type":28,"tag":192,"props":5530,"children":5531},{"style":226},[5532],{"type":34,"value":379},{"type":28,"tag":192,"props":5534,"children":5535},{"style":325},[5536],{"type":34,"value":2682},{"type":28,"tag":192,"props":5538,"children":5539},{"style":226},[5540],{"type":34,"value":332},{"type":28,"tag":192,"props":5542,"children":5543},{"style":734},[5544],{"type":34,"value":5185},{"type":28,"tag":192,"props":5546,"children":5547},{"style":226},[5548],{"type":34,"value":752},{"type":28,"tag":192,"props":5550,"children":5551},{"class":194,"line":556},[5552],{"type":28,"tag":192,"props":5553,"children":5554},{"style":226},[5555],{"type":34,"value":445},{"type":28,"tag":192,"props":5557,"children":5558},{"class":194,"line":564},[5559],{"type":28,"tag":192,"props":5560,"children":5561},{"style":226},[5562],{"type":34,"value":588},{"type":28,"tag":192,"props":5564,"children":5565},{"class":194,"line":573},[5566],{"type":28,"tag":192,"props":5567,"children":5568},{"emptyLinePlaceholder":13},[5569],{"type":34,"value":313},{"type":28,"tag":192,"props":5571,"children":5572},{"class":194,"line":582},[5573],{"type":28,"tag":192,"props":5574,"children":5575},{"style":199},[5576],{"type":34,"value":5577},"// Classe de traitement des paiements qui respecte OCP\n",{"type":28,"tag":192,"props":5579,"children":5581},{"class":194,"line":5580},23,[5582,5586,5590,5594],{"type":28,"tag":192,"props":5583,"children":5584},{"style":209},[5585],{"type":34,"value":212},{"type":28,"tag":192,"props":5587,"children":5588},{"style":209},[5589],{"type":34,"value":217},{"type":28,"tag":192,"props":5591,"children":5592},{"style":220},[5593],{"type":34,"value":4968},{"type":28,"tag":192,"props":5595,"children":5596},{"style":226},[5597],{"type":34,"value":229},{"type":28,"tag":192,"props":5599,"children":5601},{"class":194,"line":5600},24,[5602,5606,5610,5614,5618,5623,5628,5632],{"type":28,"tag":192,"props":5603,"children":5604},{"style":209},[5605],{"type":34,"value":322},{"type":28,"tag":192,"props":5607,"children":5608},{"style":209},[5609],{"type":34,"value":688},{"type":28,"tag":192,"props":5611,"children":5612},{"style":325},[5613],{"type":34,"value":4988},{"type":28,"tag":192,"props":5615,"children":5616},{"style":226},[5617],{"type":34,"value":332},{"type":28,"tag":192,"props":5619,"children":5620},{"style":241},[5621],{"type":34,"value":5622},"PaymentMethod",{"type":28,"tag":192,"props":5624,"children":5625},{"style":340},[5626],{"type":34,"value":5627}," paymentMethod",{"type":28,"tag":192,"props":5629,"children":5630},{"style":226},[5631],{"type":34,"value":360},{"type":28,"tag":192,"props":5633,"children":5634},{"style":226},[5635],{"type":34,"value":229},{"type":28,"tag":192,"props":5637,"children":5639},{"class":194,"line":5638},25,[5640,5645,5649,5654],{"type":28,"tag":192,"props":5641,"children":5642},{"style":247},[5643],{"type":34,"value":5644},"        paymentMethod",{"type":28,"tag":192,"props":5646,"children":5647},{"style":226},[5648],{"type":34,"value":379},{"type":28,"tag":192,"props":5650,"children":5651},{"style":325},[5652],{"type":34,"value":5653},"processPayment",{"type":28,"tag":192,"props":5655,"children":5656},{"style":226},[5657],{"type":34,"value":1973},{"type":28,"tag":192,"props":5659,"children":5661},{"class":194,"line":5660},26,[5662],{"type":28,"tag":192,"props":5663,"children":5664},{"style":226},[5665],{"type":34,"value":445},{"type":28,"tag":192,"props":5667,"children":5669},{"class":194,"line":5668},27,[5670],{"type":28,"tag":192,"props":5671,"children":5672},{"style":226},[5673],{"type":34,"value":588},{"type":28,"tag":44,"props":5675,"children":5676},{},[5677,5679,5684],{"type":34,"value":5678},"Pour ajouter une nouvelle méthode de paiement, il suffit simplement de créer une nouvelle classe qui implémente l'interface ",{"type":28,"tag":188,"props":5680,"children":5682},{"className":5681},[],[5683],{"type":34,"value":5622},{"type":34,"value":5685}," :",{"type":28,"tag":181,"props":5687,"children":5689},{"className":183,"code":5688,"language":185,"meta":8,"style":8},"// Nouvelle implémentation pour portefeuille électronique (e-wallet)\npublic class EWalletPayment implements PaymentMethod {\n    @Override\n    public void processPayment() {\n        System.out.println(\"Paiement via portefeuille électronique\");\n    }\n}\n",[5690],{"type":28,"tag":188,"props":5691,"children":5692},{"__ignoreMap":8},[5693,5701,5729,5740,5763,5799,5806],{"type":28,"tag":192,"props":5694,"children":5695},{"class":194,"line":195},[5696],{"type":28,"tag":192,"props":5697,"children":5698},{"style":199},[5699],{"type":34,"value":5700},"// Nouvelle implémentation pour portefeuille électronique (e-wallet)\n",{"type":28,"tag":192,"props":5702,"children":5703},{"class":194,"line":205},[5704,5708,5712,5717,5721,5725],{"type":28,"tag":192,"props":5705,"children":5706},{"style":209},[5707],{"type":34,"value":212},{"type":28,"tag":192,"props":5709,"children":5710},{"style":209},[5711],{"type":34,"value":217},{"type":28,"tag":192,"props":5713,"children":5714},{"style":220},[5715],{"type":34,"value":5716}," EWalletPayment",{"type":28,"tag":192,"props":5718,"children":5719},{"style":209},[5720],{"type":34,"value":5343},{"type":28,"tag":192,"props":5722,"children":5723},{"style":220},[5724],{"type":34,"value":5280},{"type":28,"tag":192,"props":5726,"children":5727},{"style":226},[5728],{"type":34,"value":229},{"type":28,"tag":192,"props":5730,"children":5731},{"class":194,"line":232},[5732,5736],{"type":28,"tag":192,"props":5733,"children":5734},{"style":667},[5735],{"type":34,"value":5359},{"type":28,"tag":192,"props":5737,"children":5738},{"style":673},[5739],{"type":34,"value":5364},{"type":28,"tag":192,"props":5741,"children":5742},{"class":194,"line":258},[5743,5747,5751,5755,5759],{"type":28,"tag":192,"props":5744,"children":5745},{"style":209},[5746],{"type":34,"value":322},{"type":28,"tag":192,"props":5748,"children":5749},{"style":209},[5750],{"type":34,"value":688},{"type":28,"tag":192,"props":5752,"children":5753},{"style":325},[5754],{"type":34,"value":4988},{"type":28,"tag":192,"props":5756,"children":5757},{"style":226},[5758],{"type":34,"value":475},{"type":28,"tag":192,"props":5760,"children":5761},{"style":226},[5762],{"type":34,"value":229},{"type":28,"tag":192,"props":5764,"children":5765},{"class":194,"line":280},[5766,5770,5774,5778,5782,5786,5790,5795],{"type":28,"tag":192,"props":5767,"children":5768},{"style":247},[5769],{"type":34,"value":4327},{"type":28,"tag":192,"props":5771,"children":5772},{"style":226},[5773],{"type":34,"value":379},{"type":28,"tag":192,"props":5775,"children":5776},{"style":247},[5777],{"type":34,"value":2673},{"type":28,"tag":192,"props":5779,"children":5780},{"style":226},[5781],{"type":34,"value":379},{"type":28,"tag":192,"props":5783,"children":5784},{"style":325},[5785],{"type":34,"value":2682},{"type":28,"tag":192,"props":5787,"children":5788},{"style":226},[5789],{"type":34,"value":332},{"type":28,"tag":192,"props":5791,"children":5792},{"style":734},[5793],{"type":34,"value":5794},"\"Paiement via portefeuille électronique\"",{"type":28,"tag":192,"props":5796,"children":5797},{"style":226},[5798],{"type":34,"value":752},{"type":28,"tag":192,"props":5800,"children":5801},{"class":194,"line":307},[5802],{"type":28,"tag":192,"props":5803,"children":5804},{"style":226},[5805],{"type":34,"value":445},{"type":28,"tag":192,"props":5807,"children":5808},{"class":194,"line":316},[5809],{"type":28,"tag":192,"props":5810,"children":5811},{"style":226},[5812],{"type":34,"value":588},{"type":28,"tag":44,"props":5814,"children":5815},{},[5816,5818,5823],{"type":34,"value":5817},"On peut maintenant utiliser cette nouvelle méthode de paiement sans toucher à la classe ",{"type":28,"tag":188,"props":5819,"children":5821},{"className":5820},[],[5822],{"type":34,"value":4943},{"type":34,"value":5685},{"type":28,"tag":181,"props":5825,"children":5827},{"className":183,"code":5826,"language":185,"meta":8,"style":8},"public class Main {\n    public static void main(String[] args) {\n        PaymentProcessor processor = new PaymentProcessor();\n\n        // Utilisation de la carte bancaire\n        PaymentMethod creditCard = new CreditCardPayment();\n        processor.processPayment(creditCard);\n\n        // Utilisation de PayPal\n        PaymentMethod paypal = new PayPalPayment();\n        processor.processPayment(paypal);\n\n        // Utilisation d'un portefeuille électronique\n        PaymentMethod ewallet = new EWalletPayment();\n        processor.processPayment(ewallet);\n    }\n}\n",[5828],{"type":28,"tag":188,"props":5829,"children":5830},{"__ignoreMap":8},[5831,5851,5898,5927,5934,5942,5971,6000,6007,6015,6043,6071,6078,6086,6114,6142,6149],{"type":28,"tag":192,"props":5832,"children":5833},{"class":194,"line":195},[5834,5838,5842,5847],{"type":28,"tag":192,"props":5835,"children":5836},{"style":209},[5837],{"type":34,"value":212},{"type":28,"tag":192,"props":5839,"children":5840},{"style":209},[5841],{"type":34,"value":217},{"type":28,"tag":192,"props":5843,"children":5844},{"style":220},[5845],{"type":34,"value":5846}," Main",{"type":28,"tag":192,"props":5848,"children":5849},{"style":226},[5850],{"type":34,"value":229},{"type":28,"tag":192,"props":5852,"children":5853},{"class":194,"line":205},[5854,5858,5863,5867,5872,5876,5880,5885,5890,5894],{"type":28,"tag":192,"props":5855,"children":5856},{"style":209},[5857],{"type":34,"value":322},{"type":28,"tag":192,"props":5859,"children":5860},{"style":209},[5861],{"type":34,"value":5862}," static",{"type":28,"tag":192,"props":5864,"children":5865},{"style":209},[5866],{"type":34,"value":688},{"type":28,"tag":192,"props":5868,"children":5869},{"style":325},[5870],{"type":34,"value":5871}," main",{"type":28,"tag":192,"props":5873,"children":5874},{"style":226},[5875],{"type":34,"value":332},{"type":28,"tag":192,"props":5877,"children":5878},{"style":209},[5879],{"type":34,"value":337},{"type":28,"tag":192,"props":5881,"children":5882},{"style":226},[5883],{"type":34,"value":5884},"[]",{"type":28,"tag":192,"props":5886,"children":5887},{"style":340},[5888],{"type":34,"value":5889}," args",{"type":28,"tag":192,"props":5891,"children":5892},{"style":226},[5893],{"type":34,"value":360},{"type":28,"tag":192,"props":5895,"children":5896},{"style":226},[5897],{"type":34,"value":229},{"type":28,"tag":192,"props":5899,"children":5900},{"class":194,"line":232},[5901,5906,5911,5915,5919,5923],{"type":28,"tag":192,"props":5902,"children":5903},{"style":241},[5904],{"type":34,"value":5905},"        PaymentProcessor",{"type":28,"tag":192,"props":5907,"children":5908},{"style":247},[5909],{"type":34,"value":5910}," processor ",{"type":28,"tag":192,"props":5912,"children":5913},{"style":387},[5914],{"type":34,"value":390},{"type":28,"tag":192,"props":5916,"children":5917},{"style":209},[5918],{"type":34,"value":723},{"type":28,"tag":192,"props":5920,"children":5921},{"style":325},[5922],{"type":34,"value":4968},{"type":28,"tag":192,"props":5924,"children":5925},{"style":226},[5926],{"type":34,"value":1973},{"type":28,"tag":192,"props":5928,"children":5929},{"class":194,"line":258},[5930],{"type":28,"tag":192,"props":5931,"children":5932},{"emptyLinePlaceholder":13},[5933],{"type":34,"value":313},{"type":28,"tag":192,"props":5935,"children":5936},{"class":194,"line":280},[5937],{"type":28,"tag":192,"props":5938,"children":5939},{"style":199},[5940],{"type":34,"value":5941},"        // Utilisation de la carte bancaire\n",{"type":28,"tag":192,"props":5943,"children":5944},{"class":194,"line":307},[5945,5950,5955,5959,5963,5967],{"type":28,"tag":192,"props":5946,"children":5947},{"style":241},[5948],{"type":34,"value":5949},"        PaymentMethod",{"type":28,"tag":192,"props":5951,"children":5952},{"style":247},[5953],{"type":34,"value":5954}," creditCard ",{"type":28,"tag":192,"props":5956,"children":5957},{"style":387},[5958],{"type":34,"value":390},{"type":28,"tag":192,"props":5960,"children":5961},{"style":209},[5962],{"type":34,"value":723},{"type":28,"tag":192,"props":5964,"children":5965},{"style":325},[5966],{"type":34,"value":5338},{"type":28,"tag":192,"props":5968,"children":5969},{"style":226},[5970],{"type":34,"value":1973},{"type":28,"tag":192,"props":5972,"children":5973},{"class":194,"line":316},[5974,5979,5983,5987,5991,5996],{"type":28,"tag":192,"props":5975,"children":5976},{"style":247},[5977],{"type":34,"value":5978},"        processor",{"type":28,"tag":192,"props":5980,"children":5981},{"style":226},[5982],{"type":34,"value":379},{"type":28,"tag":192,"props":5984,"children":5985},{"style":325},[5986],{"type":34,"value":5653},{"type":28,"tag":192,"props":5988,"children":5989},{"style":226},[5990],{"type":34,"value":332},{"type":28,"tag":192,"props":5992,"children":5993},{"style":247},[5994],{"type":34,"value":5995},"creditCard",{"type":28,"tag":192,"props":5997,"children":5998},{"style":226},[5999],{"type":34,"value":752},{"type":28,"tag":192,"props":6001,"children":6002},{"class":194,"line":367},[6003],{"type":28,"tag":192,"props":6004,"children":6005},{"emptyLinePlaceholder":13},[6006],{"type":34,"value":313},{"type":28,"tag":192,"props":6008,"children":6009},{"class":194,"line":401},[6010],{"type":28,"tag":192,"props":6011,"children":6012},{"style":199},[6013],{"type":34,"value":6014},"        // Utilisation de PayPal\n",{"type":28,"tag":192,"props":6016,"children":6017},{"class":194,"line":430},[6018,6022,6027,6031,6035,6039],{"type":28,"tag":192,"props":6019,"children":6020},{"style":241},[6021],{"type":34,"value":5949},{"type":28,"tag":192,"props":6023,"children":6024},{"style":247},[6025],{"type":34,"value":6026}," paypal ",{"type":28,"tag":192,"props":6028,"children":6029},{"style":387},[6030],{"type":34,"value":390},{"type":28,"tag":192,"props":6032,"children":6033},{"style":209},[6034],{"type":34,"value":723},{"type":28,"tag":192,"props":6036,"children":6037},{"style":325},[6038],{"type":34,"value":5467},{"type":28,"tag":192,"props":6040,"children":6041},{"style":226},[6042],{"type":34,"value":1973},{"type":28,"tag":192,"props":6044,"children":6045},{"class":194,"line":439},[6046,6050,6054,6058,6062,6067],{"type":28,"tag":192,"props":6047,"children":6048},{"style":247},[6049],{"type":34,"value":5978},{"type":28,"tag":192,"props":6051,"children":6052},{"style":226},[6053],{"type":34,"value":379},{"type":28,"tag":192,"props":6055,"children":6056},{"style":325},[6057],{"type":34,"value":5653},{"type":28,"tag":192,"props":6059,"children":6060},{"style":226},[6061],{"type":34,"value":332},{"type":28,"tag":192,"props":6063,"children":6064},{"style":247},[6065],{"type":34,"value":6066},"paypal",{"type":28,"tag":192,"props":6068,"children":6069},{"style":226},[6070],{"type":34,"value":752},{"type":28,"tag":192,"props":6072,"children":6073},{"class":194,"line":448},[6074],{"type":28,"tag":192,"props":6075,"children":6076},{"emptyLinePlaceholder":13},[6077],{"type":34,"value":313},{"type":28,"tag":192,"props":6079,"children":6080},{"class":194,"line":456},[6081],{"type":28,"tag":192,"props":6082,"children":6083},{"style":199},[6084],{"type":34,"value":6085},"        // Utilisation d'un portefeuille électronique\n",{"type":28,"tag":192,"props":6087,"children":6088},{"class":194,"line":482},[6089,6093,6098,6102,6106,6110],{"type":28,"tag":192,"props":6090,"children":6091},{"style":241},[6092],{"type":34,"value":5949},{"type":28,"tag":192,"props":6094,"children":6095},{"style":247},[6096],{"type":34,"value":6097}," ewallet ",{"type":28,"tag":192,"props":6099,"children":6100},{"style":387},[6101],{"type":34,"value":390},{"type":28,"tag":192,"props":6103,"children":6104},{"style":209},[6105],{"type":34,"value":723},{"type":28,"tag":192,"props":6107,"children":6108},{"style":325},[6109],{"type":34,"value":5716},{"type":28,"tag":192,"props":6111,"children":6112},{"style":226},[6113],{"type":34,"value":1973},{"type":28,"tag":192,"props":6115,"children":6116},{"class":194,"line":499},[6117,6121,6125,6129,6133,6138],{"type":28,"tag":192,"props":6118,"children":6119},{"style":247},[6120],{"type":34,"value":5978},{"type":28,"tag":192,"props":6122,"children":6123},{"style":226},[6124],{"type":34,"value":379},{"type":28,"tag":192,"props":6126,"children":6127},{"style":325},[6128],{"type":34,"value":5653},{"type":28,"tag":192,"props":6130,"children":6131},{"style":226},[6132],{"type":34,"value":332},{"type":28,"tag":192,"props":6134,"children":6135},{"style":247},[6136],{"type":34,"value":6137},"ewallet",{"type":28,"tag":192,"props":6139,"children":6140},{"style":226},[6141],{"type":34,"value":752},{"type":28,"tag":192,"props":6143,"children":6144},{"class":194,"line":507},[6145],{"type":28,"tag":192,"props":6146,"children":6147},{"style":226},[6148],{"type":34,"value":445},{"type":28,"tag":192,"props":6150,"children":6151},{"class":194,"line":515},[6152],{"type":28,"tag":192,"props":6153,"children":6154},{"style":226},[6155],{"type":34,"value":588},{"type":28,"tag":83,"props":6157,"children":6158},{},[],{"type":28,"tag":1841,"props":6160,"children":6161},{"type":1843},[6162],{"type":28,"tag":44,"props":6163,"children":6164},{},[6165,6170],{"type":28,"tag":55,"props":6166,"children":6167},{},[6168],{"type":34,"value":6169},"Utilisez des interfaces ou des classes abstraites",{"type":34,"value":6171}," pour éviter de toucher au code déjà testé. C'est ce qui rend l'extension de l'application possible sans régression.",{"type":28,"tag":29,"props":6173,"children":6175},{"id":6174},"_3-principe-de-substitution-de-liskov-liskov-substitution-principle-lsp",[6176],{"type":34,"value":6177},"3. Principe de Substitution de Liskov (Liskov Substitution Principle - LSP)",{"type":28,"tag":44,"props":6179,"children":6180},{},[6181],{"type":34,"value":6182},"Le principe de substitution de Liskov (LSP) stipule que les sous-classes doivent pouvoir être substituées à leurs classes mères sans que cela ne perturbe le bon fonctionnement du programme. Autrement dit, une classe dérivée doit pouvoir remplacer la classe parente sans modifier le comportement attendu du système.",{"type":28,"tag":37,"props":6184,"children":6186},{"id":6185},"pourquoi-cest-important-2",[6187],{"type":34,"value":4123},{"type":28,"tag":44,"props":6189,"children":6190},{},[6191],{"type":34,"value":6192},"Si vous brisez ce principe, l'héritage peut causer des problèmes inattendus. Par exemple, certaines méthodes ou comportements pourraient ne pas fonctionner correctement, ce qui peut engendrer des bugs subtils et rendre le système imprévisible.",{"type":28,"tag":37,"props":6194,"children":6196},{"id":6195},"exemple-concret-en-java-2",[6197],{"type":34,"value":4134},{"type":28,"tag":44,"props":6199,"children":6200},{},[6201,6203,6209,6211,6217],{"type":34,"value":6202},"Imaginons que nous ayons une classe ",{"type":28,"tag":188,"props":6204,"children":6206},{"className":6205},[],[6207],{"type":34,"value":6208},"Rectangle",{"type":34,"value":6210}," et une sous-classe ",{"type":28,"tag":188,"props":6212,"children":6214},{"className":6213},[],[6215],{"type":34,"value":6216},"Square",{"type":34,"value":6218}," (carré), puisque, mathématiquement, un carré est un cas particulier de rectangle.",{"type":28,"tag":169,"props":6220,"children":6222},{"id":6221},"exemple-sans-lsp",[6223],{"type":34,"value":6224},"Exemple sans LSP :",{"type":28,"tag":44,"props":6226,"children":6227},{},[6228,6230,6235,6237,6242],{"type":34,"value":6229},"Voici une implémentation basique où ",{"type":28,"tag":188,"props":6231,"children":6233},{"className":6232},[],[6234],{"type":34,"value":6216},{"type":34,"value":6236}," hérite de ",{"type":28,"tag":188,"props":6238,"children":6240},{"className":6239},[],[6241],{"type":34,"value":6208},{"type":34,"value":5685},{"type":28,"tag":181,"props":6244,"children":6246},{"className":183,"code":6245,"language":185,"meta":8,"style":8},"public class Rectangle {\n    protected int width;\n    protected int height;\n\n    public void setWidth(int width) {\n        this.width = width;\n    }\n\n\n\n    public void setHeight(int height) {\n        this.height = height;\n    }\n\n    public int getArea() {\n        return width * height;\n    }\n}\n\npublic class Square extends Rectangle {\n    @Override\n    public void setWidth(int width) {\n        this.width = width;\n        this.height = width; // Contraintes du carré\n    }\n\n    @Override\n    public void setHeight(int height) {\n        this.height = height;\n        this.width = height; // Contraintes du carré\n    }\n}\n",[6247],{"type":28,"tag":188,"props":6248,"children":6249},{"__ignoreMap":8},[6250,6270,6291,6311,6318,6354,6382,6389,6396,6403,6410,6446,6474,6481,6488,6512,6536,6543,6550,6557,6586,6597,6632,6659,6691,6698,6705,6716,6752,6780,6812,6820],{"type":28,"tag":192,"props":6251,"children":6252},{"class":194,"line":195},[6253,6257,6261,6266],{"type":28,"tag":192,"props":6254,"children":6255},{"style":209},[6256],{"type":34,"value":212},{"type":28,"tag":192,"props":6258,"children":6259},{"style":209},[6260],{"type":34,"value":217},{"type":28,"tag":192,"props":6262,"children":6263},{"style":220},[6264],{"type":34,"value":6265}," Rectangle",{"type":28,"tag":192,"props":6267,"children":6268},{"style":226},[6269],{"type":34,"value":229},{"type":28,"tag":192,"props":6271,"children":6272},{"class":194,"line":205},[6273,6278,6282,6287],{"type":28,"tag":192,"props":6274,"children":6275},{"style":209},[6276],{"type":34,"value":6277},"    protected",{"type":28,"tag":192,"props":6279,"children":6280},{"style":209},[6281],{"type":34,"value":268},{"type":28,"tag":192,"props":6283,"children":6284},{"style":247},[6285],{"type":34,"value":6286}," width",{"type":28,"tag":192,"props":6288,"children":6289},{"style":226},[6290],{"type":34,"value":255},{"type":28,"tag":192,"props":6292,"children":6293},{"class":194,"line":232},[6294,6298,6302,6307],{"type":28,"tag":192,"props":6295,"children":6296},{"style":209},[6297],{"type":34,"value":6277},{"type":28,"tag":192,"props":6299,"children":6300},{"style":209},[6301],{"type":34,"value":268},{"type":28,"tag":192,"props":6303,"children":6304},{"style":247},[6305],{"type":34,"value":6306}," height",{"type":28,"tag":192,"props":6308,"children":6309},{"style":226},[6310],{"type":34,"value":255},{"type":28,"tag":192,"props":6312,"children":6313},{"class":194,"line":258},[6314],{"type":28,"tag":192,"props":6315,"children":6316},{"emptyLinePlaceholder":13},[6317],{"type":34,"value":313},{"type":28,"tag":192,"props":6319,"children":6320},{"class":194,"line":280},[6321,6325,6329,6334,6338,6342,6346,6350],{"type":28,"tag":192,"props":6322,"children":6323},{"style":209},[6324],{"type":34,"value":322},{"type":28,"tag":192,"props":6326,"children":6327},{"style":209},[6328],{"type":34,"value":688},{"type":28,"tag":192,"props":6330,"children":6331},{"style":325},[6332],{"type":34,"value":6333}," setWidth",{"type":28,"tag":192,"props":6335,"children":6336},{"style":226},[6337],{"type":34,"value":332},{"type":28,"tag":192,"props":6339,"children":6340},{"style":209},[6341],{"type":34,"value":938},{"type":28,"tag":192,"props":6343,"children":6344},{"style":340},[6345],{"type":34,"value":6286},{"type":28,"tag":192,"props":6347,"children":6348},{"style":226},[6349],{"type":34,"value":360},{"type":28,"tag":192,"props":6351,"children":6352},{"style":226},[6353],{"type":34,"value":229},{"type":28,"tag":192,"props":6355,"children":6356},{"class":194,"line":307},[6357,6361,6365,6370,6374,6378],{"type":28,"tag":192,"props":6358,"children":6359},{"style":371},[6360],{"type":34,"value":374},{"type":28,"tag":192,"props":6362,"children":6363},{"style":226},[6364],{"type":34,"value":379},{"type":28,"tag":192,"props":6366,"children":6367},{"style":247},[6368],{"type":34,"value":6369},"width ",{"type":28,"tag":192,"props":6371,"children":6372},{"style":387},[6373],{"type":34,"value":390},{"type":28,"tag":192,"props":6375,"children":6376},{"style":247},[6377],{"type":34,"value":6286},{"type":28,"tag":192,"props":6379,"children":6380},{"style":226},[6381],{"type":34,"value":255},{"type":28,"tag":192,"props":6383,"children":6384},{"class":194,"line":316},[6385],{"type":28,"tag":192,"props":6386,"children":6387},{"style":226},[6388],{"type":34,"value":445},{"type":28,"tag":192,"props":6390,"children":6391},{"class":194,"line":367},[6392],{"type":28,"tag":192,"props":6393,"children":6394},{"emptyLinePlaceholder":13},[6395],{"type":34,"value":313},{"type":28,"tag":192,"props":6397,"children":6398},{"class":194,"line":401},[6399],{"type":28,"tag":192,"props":6400,"children":6401},{"emptyLinePlaceholder":13},[6402],{"type":34,"value":313},{"type":28,"tag":192,"props":6404,"children":6405},{"class":194,"line":430},[6406],{"type":28,"tag":192,"props":6407,"children":6408},{"emptyLinePlaceholder":13},[6409],{"type":34,"value":313},{"type":28,"tag":192,"props":6411,"children":6412},{"class":194,"line":439},[6413,6417,6421,6426,6430,6434,6438,6442],{"type":28,"tag":192,"props":6414,"children":6415},{"style":209},[6416],{"type":34,"value":322},{"type":28,"tag":192,"props":6418,"children":6419},{"style":209},[6420],{"type":34,"value":688},{"type":28,"tag":192,"props":6422,"children":6423},{"style":325},[6424],{"type":34,"value":6425}," setHeight",{"type":28,"tag":192,"props":6427,"children":6428},{"style":226},[6429],{"type":34,"value":332},{"type":28,"tag":192,"props":6431,"children":6432},{"style":209},[6433],{"type":34,"value":938},{"type":28,"tag":192,"props":6435,"children":6436},{"style":340},[6437],{"type":34,"value":6306},{"type":28,"tag":192,"props":6439,"children":6440},{"style":226},[6441],{"type":34,"value":360},{"type":28,"tag":192,"props":6443,"children":6444},{"style":226},[6445],{"type":34,"value":229},{"type":28,"tag":192,"props":6447,"children":6448},{"class":194,"line":448},[6449,6453,6457,6462,6466,6470],{"type":28,"tag":192,"props":6450,"children":6451},{"style":371},[6452],{"type":34,"value":374},{"type":28,"tag":192,"props":6454,"children":6455},{"style":226},[6456],{"type":34,"value":379},{"type":28,"tag":192,"props":6458,"children":6459},{"style":247},[6460],{"type":34,"value":6461},"height ",{"type":28,"tag":192,"props":6463,"children":6464},{"style":387},[6465],{"type":34,"value":390},{"type":28,"tag":192,"props":6467,"children":6468},{"style":247},[6469],{"type":34,"value":6306},{"type":28,"tag":192,"props":6471,"children":6472},{"style":226},[6473],{"type":34,"value":255},{"type":28,"tag":192,"props":6475,"children":6476},{"class":194,"line":456},[6477],{"type":28,"tag":192,"props":6478,"children":6479},{"style":226},[6480],{"type":34,"value":445},{"type":28,"tag":192,"props":6482,"children":6483},{"class":194,"line":482},[6484],{"type":28,"tag":192,"props":6485,"children":6486},{"emptyLinePlaceholder":13},[6487],{"type":34,"value":313},{"type":28,"tag":192,"props":6489,"children":6490},{"class":194,"line":499},[6491,6495,6499,6504,6508],{"type":28,"tag":192,"props":6492,"children":6493},{"style":209},[6494],{"type":34,"value":322},{"type":28,"tag":192,"props":6496,"children":6497},{"style":209},[6498],{"type":34,"value":268},{"type":28,"tag":192,"props":6500,"children":6501},{"style":325},[6502],{"type":34,"value":6503}," getArea",{"type":28,"tag":192,"props":6505,"children":6506},{"style":226},[6507],{"type":34,"value":475},{"type":28,"tag":192,"props":6509,"children":6510},{"style":226},[6511],{"type":34,"value":229},{"type":28,"tag":192,"props":6513,"children":6514},{"class":194,"line":507},[6515,6519,6524,6528,6532],{"type":28,"tag":192,"props":6516,"children":6517},{"style":209},[6518],{"type":34,"value":488},{"type":28,"tag":192,"props":6520,"children":6521},{"style":247},[6522],{"type":34,"value":6523}," width ",{"type":28,"tag":192,"props":6525,"children":6526},{"style":387},[6527],{"type":34,"value":1102},{"type":28,"tag":192,"props":6529,"children":6530},{"style":247},[6531],{"type":34,"value":6306},{"type":28,"tag":192,"props":6533,"children":6534},{"style":226},[6535],{"type":34,"value":255},{"type":28,"tag":192,"props":6537,"children":6538},{"class":194,"line":515},[6539],{"type":28,"tag":192,"props":6540,"children":6541},{"style":226},[6542],{"type":34,"value":445},{"type":28,"tag":192,"props":6544,"children":6545},{"class":194,"line":540},[6546],{"type":28,"tag":192,"props":6547,"children":6548},{"style":226},[6549],{"type":34,"value":588},{"type":28,"tag":192,"props":6551,"children":6552},{"class":194,"line":556},[6553],{"type":28,"tag":192,"props":6554,"children":6555},{"emptyLinePlaceholder":13},[6556],{"type":34,"value":313},{"type":28,"tag":192,"props":6558,"children":6559},{"class":194,"line":564},[6560,6564,6568,6573,6578,6582],{"type":28,"tag":192,"props":6561,"children":6562},{"style":209},[6563],{"type":34,"value":212},{"type":28,"tag":192,"props":6565,"children":6566},{"style":209},[6567],{"type":34,"value":217},{"type":28,"tag":192,"props":6569,"children":6570},{"style":220},[6571],{"type":34,"value":6572}," Square",{"type":28,"tag":192,"props":6574,"children":6575},{"style":209},[6576],{"type":34,"value":6577}," extends",{"type":28,"tag":192,"props":6579,"children":6580},{"style":220},[6581],{"type":34,"value":6265},{"type":28,"tag":192,"props":6583,"children":6584},{"style":226},[6585],{"type":34,"value":229},{"type":28,"tag":192,"props":6587,"children":6588},{"class":194,"line":573},[6589,6593],{"type":28,"tag":192,"props":6590,"children":6591},{"style":667},[6592],{"type":34,"value":5359},{"type":28,"tag":192,"props":6594,"children":6595},{"style":673},[6596],{"type":34,"value":5364},{"type":28,"tag":192,"props":6598,"children":6599},{"class":194,"line":582},[6600,6604,6608,6612,6616,6620,6624,6628],{"type":28,"tag":192,"props":6601,"children":6602},{"style":209},[6603],{"type":34,"value":322},{"type":28,"tag":192,"props":6605,"children":6606},{"style":209},[6607],{"type":34,"value":688},{"type":28,"tag":192,"props":6609,"children":6610},{"style":325},[6611],{"type":34,"value":6333},{"type":28,"tag":192,"props":6613,"children":6614},{"style":226},[6615],{"type":34,"value":332},{"type":28,"tag":192,"props":6617,"children":6618},{"style":209},[6619],{"type":34,"value":938},{"type":28,"tag":192,"props":6621,"children":6622},{"style":340},[6623],{"type":34,"value":6286},{"type":28,"tag":192,"props":6625,"children":6626},{"style":226},[6627],{"type":34,"value":360},{"type":28,"tag":192,"props":6629,"children":6630},{"style":226},[6631],{"type":34,"value":229},{"type":28,"tag":192,"props":6633,"children":6634},{"class":194,"line":5580},[6635,6639,6643,6647,6651,6655],{"type":28,"tag":192,"props":6636,"children":6637},{"style":371},[6638],{"type":34,"value":374},{"type":28,"tag":192,"props":6640,"children":6641},{"style":226},[6642],{"type":34,"value":379},{"type":28,"tag":192,"props":6644,"children":6645},{"style":247},[6646],{"type":34,"value":6369},{"type":28,"tag":192,"props":6648,"children":6649},{"style":387},[6650],{"type":34,"value":390},{"type":28,"tag":192,"props":6652,"children":6653},{"style":247},[6654],{"type":34,"value":6286},{"type":28,"tag":192,"props":6656,"children":6657},{"style":226},[6658],{"type":34,"value":255},{"type":28,"tag":192,"props":6660,"children":6661},{"class":194,"line":5600},[6662,6666,6670,6674,6678,6682,6686],{"type":28,"tag":192,"props":6663,"children":6664},{"style":371},[6665],{"type":34,"value":374},{"type":28,"tag":192,"props":6667,"children":6668},{"style":226},[6669],{"type":34,"value":379},{"type":28,"tag":192,"props":6671,"children":6672},{"style":247},[6673],{"type":34,"value":6461},{"type":28,"tag":192,"props":6675,"children":6676},{"style":387},[6677],{"type":34,"value":390},{"type":28,"tag":192,"props":6679,"children":6680},{"style":247},[6681],{"type":34,"value":6286},{"type":28,"tag":192,"props":6683,"children":6684},{"style":226},[6685],{"type":34,"value":299},{"type":28,"tag":192,"props":6687,"children":6688},{"style":199},[6689],{"type":34,"value":6690}," // Contraintes du carré\n",{"type":28,"tag":192,"props":6692,"children":6693},{"class":194,"line":5638},[6694],{"type":28,"tag":192,"props":6695,"children":6696},{"style":226},[6697],{"type":34,"value":445},{"type":28,"tag":192,"props":6699,"children":6700},{"class":194,"line":5660},[6701],{"type":28,"tag":192,"props":6702,"children":6703},{"emptyLinePlaceholder":13},[6704],{"type":34,"value":313},{"type":28,"tag":192,"props":6706,"children":6707},{"class":194,"line":5668},[6708,6712],{"type":28,"tag":192,"props":6709,"children":6710},{"style":667},[6711],{"type":34,"value":5359},{"type":28,"tag":192,"props":6713,"children":6714},{"style":673},[6715],{"type":34,"value":5364},{"type":28,"tag":192,"props":6717,"children":6719},{"class":194,"line":6718},28,[6720,6724,6728,6732,6736,6740,6744,6748],{"type":28,"tag":192,"props":6721,"children":6722},{"style":209},[6723],{"type":34,"value":322},{"type":28,"tag":192,"props":6725,"children":6726},{"style":209},[6727],{"type":34,"value":688},{"type":28,"tag":192,"props":6729,"children":6730},{"style":325},[6731],{"type":34,"value":6425},{"type":28,"tag":192,"props":6733,"children":6734},{"style":226},[6735],{"type":34,"value":332},{"type":28,"tag":192,"props":6737,"children":6738},{"style":209},[6739],{"type":34,"value":938},{"type":28,"tag":192,"props":6741,"children":6742},{"style":340},[6743],{"type":34,"value":6306},{"type":28,"tag":192,"props":6745,"children":6746},{"style":226},[6747],{"type":34,"value":360},{"type":28,"tag":192,"props":6749,"children":6750},{"style":226},[6751],{"type":34,"value":229},{"type":28,"tag":192,"props":6753,"children":6755},{"class":194,"line":6754},29,[6756,6760,6764,6768,6772,6776],{"type":28,"tag":192,"props":6757,"children":6758},{"style":371},[6759],{"type":34,"value":374},{"type":28,"tag":192,"props":6761,"children":6762},{"style":226},[6763],{"type":34,"value":379},{"type":28,"tag":192,"props":6765,"children":6766},{"style":247},[6767],{"type":34,"value":6461},{"type":28,"tag":192,"props":6769,"children":6770},{"style":387},[6771],{"type":34,"value":390},{"type":28,"tag":192,"props":6773,"children":6774},{"style":247},[6775],{"type":34,"value":6306},{"type":28,"tag":192,"props":6777,"children":6778},{"style":226},[6779],{"type":34,"value":255},{"type":28,"tag":192,"props":6781,"children":6783},{"class":194,"line":6782},30,[6784,6788,6792,6796,6800,6804,6808],{"type":28,"tag":192,"props":6785,"children":6786},{"style":371},[6787],{"type":34,"value":374},{"type":28,"tag":192,"props":6789,"children":6790},{"style":226},[6791],{"type":34,"value":379},{"type":28,"tag":192,"props":6793,"children":6794},{"style":247},[6795],{"type":34,"value":6369},{"type":28,"tag":192,"props":6797,"children":6798},{"style":387},[6799],{"type":34,"value":390},{"type":28,"tag":192,"props":6801,"children":6802},{"style":247},[6803],{"type":34,"value":6306},{"type":28,"tag":192,"props":6805,"children":6806},{"style":226},[6807],{"type":34,"value":299},{"type":28,"tag":192,"props":6809,"children":6810},{"style":199},[6811],{"type":34,"value":6690},{"type":28,"tag":192,"props":6813,"children":6815},{"class":194,"line":6814},31,[6816],{"type":28,"tag":192,"props":6817,"children":6818},{"style":226},[6819],{"type":34,"value":445},{"type":28,"tag":192,"props":6821,"children":6823},{"class":194,"line":6822},32,[6824],{"type":28,"tag":192,"props":6825,"children":6826},{"style":226},[6827],{"type":34,"value":588},{"type":28,"tag":44,"props":6829,"children":6830},{},[6831,6833,6838,6840,6845,6847,6853,6854,6860],{"type":34,"value":6832},"À première vue, cela semble correct. Cependant, cette implémentation brise le principe de substitution de Liskov. Si l'on remplace un ",{"type":28,"tag":188,"props":6834,"children":6836},{"className":6835},[],[6837],{"type":34,"value":6208},{"type":34,"value":6839}," par un ",{"type":28,"tag":188,"props":6841,"children":6843},{"className":6842},[],[6844],{"type":34,"value":6216},{"type":34,"value":6846},", le comportement de la méthode ",{"type":28,"tag":188,"props":6848,"children":6850},{"className":6849},[],[6851],{"type":34,"value":6852},"setWidth()",{"type":34,"value":1865},{"type":28,"tag":188,"props":6855,"children":6857},{"className":6856},[],[6858],{"type":34,"value":6859},"setHeight()",{"type":34,"value":6861}," devient imprévisible. Un carré ne peut pas fonctionner exactement comme un rectangle, car modifier la largeur affecte également la hauteur (et vice versa). Cela peut causer des bugs, notamment si on essaye de modifier indépendamment la largeur et la hauteur d’un carré en tant que rectangle.",{"type":28,"tag":169,"props":6863,"children":6865},{"id":6864},"exemple-avec-lsp-appliqué",[6866],{"type":34,"value":6867},"Exemple avec LSP appliqué :",{"type":28,"tag":44,"props":6869,"children":6870},{},[6871],{"type":34,"value":6872},"Pour respecter le principe de substitution de Liskov, il est préférable d’éviter d’utiliser l’héritage ici, car un carré n'est pas un rectangle en termes de comportement. Nous devrions plutôt créer des classes distinctes qui n’essaient pas d’être substituées l'une à l'autre.",{"type":28,"tag":181,"props":6874,"children":6876},{"className":183,"code":6875,"language":185,"meta":8,"style":8},"// Classe Rectangle\npublic class Rectangle {\n    private int width;\n    private int height;\n\n    public void setWidth(int width) {\n        this.width = width;\n    }\n\n    public void setHeight(int height) {\n        this.height = height;\n    }\n\n    public int getArea() {\n        return width * height;\n    }\n}\n\n// Classe Square avec son propre comportement\npublic class Square {\n    private int side;\n\n    public void setSide(int side) {\n        this.side = side;\n    }\n\n    public int getArea() {\n        return side * side;\n    }\n}\n",[6877],{"type":28,"tag":188,"props":6878,"children":6879},{"__ignoreMap":8},[6880,6888,6907,6926,6945,6952,6987,7014,7021,7028,7063,7090,7097,7104,7127,7150,7157,7164,7171,7179,7198,7218,7225,7261,7289,7296,7303,7326,7350,7357],{"type":28,"tag":192,"props":6881,"children":6882},{"class":194,"line":195},[6883],{"type":28,"tag":192,"props":6884,"children":6885},{"style":199},[6886],{"type":34,"value":6887},"// Classe Rectangle\n",{"type":28,"tag":192,"props":6889,"children":6890},{"class":194,"line":205},[6891,6895,6899,6903],{"type":28,"tag":192,"props":6892,"children":6893},{"style":209},[6894],{"type":34,"value":212},{"type":28,"tag":192,"props":6896,"children":6897},{"style":209},[6898],{"type":34,"value":217},{"type":28,"tag":192,"props":6900,"children":6901},{"style":220},[6902],{"type":34,"value":6265},{"type":28,"tag":192,"props":6904,"children":6905},{"style":226},[6906],{"type":34,"value":229},{"type":28,"tag":192,"props":6908,"children":6909},{"class":194,"line":232},[6910,6914,6918,6922],{"type":28,"tag":192,"props":6911,"children":6912},{"style":209},[6913],{"type":34,"value":238},{"type":28,"tag":192,"props":6915,"children":6916},{"style":209},[6917],{"type":34,"value":268},{"type":28,"tag":192,"props":6919,"children":6920},{"style":247},[6921],{"type":34,"value":6286},{"type":28,"tag":192,"props":6923,"children":6924},{"style":226},[6925],{"type":34,"value":255},{"type":28,"tag":192,"props":6927,"children":6928},{"class":194,"line":258},[6929,6933,6937,6941],{"type":28,"tag":192,"props":6930,"children":6931},{"style":209},[6932],{"type":34,"value":238},{"type":28,"tag":192,"props":6934,"children":6935},{"style":209},[6936],{"type":34,"value":268},{"type":28,"tag":192,"props":6938,"children":6939},{"style":247},[6940],{"type":34,"value":6306},{"type":28,"tag":192,"props":6942,"children":6943},{"style":226},[6944],{"type":34,"value":255},{"type":28,"tag":192,"props":6946,"children":6947},{"class":194,"line":280},[6948],{"type":28,"tag":192,"props":6949,"children":6950},{"emptyLinePlaceholder":13},[6951],{"type":34,"value":313},{"type":28,"tag":192,"props":6953,"children":6954},{"class":194,"line":307},[6955,6959,6963,6967,6971,6975,6979,6983],{"type":28,"tag":192,"props":6956,"children":6957},{"style":209},[6958],{"type":34,"value":322},{"type":28,"tag":192,"props":6960,"children":6961},{"style":209},[6962],{"type":34,"value":688},{"type":28,"tag":192,"props":6964,"children":6965},{"style":325},[6966],{"type":34,"value":6333},{"type":28,"tag":192,"props":6968,"children":6969},{"style":226},[6970],{"type":34,"value":332},{"type":28,"tag":192,"props":6972,"children":6973},{"style":209},[6974],{"type":34,"value":938},{"type":28,"tag":192,"props":6976,"children":6977},{"style":340},[6978],{"type":34,"value":6286},{"type":28,"tag":192,"props":6980,"children":6981},{"style":226},[6982],{"type":34,"value":360},{"type":28,"tag":192,"props":6984,"children":6985},{"style":226},[6986],{"type":34,"value":229},{"type":28,"tag":192,"props":6988,"children":6989},{"class":194,"line":316},[6990,6994,6998,7002,7006,7010],{"type":28,"tag":192,"props":6991,"children":6992},{"style":371},[6993],{"type":34,"value":374},{"type":28,"tag":192,"props":6995,"children":6996},{"style":226},[6997],{"type":34,"value":379},{"type":28,"tag":192,"props":6999,"children":7000},{"style":247},[7001],{"type":34,"value":6369},{"type":28,"tag":192,"props":7003,"children":7004},{"style":387},[7005],{"type":34,"value":390},{"type":28,"tag":192,"props":7007,"children":7008},{"style":247},[7009],{"type":34,"value":6286},{"type":28,"tag":192,"props":7011,"children":7012},{"style":226},[7013],{"type":34,"value":255},{"type":28,"tag":192,"props":7015,"children":7016},{"class":194,"line":367},[7017],{"type":28,"tag":192,"props":7018,"children":7019},{"style":226},[7020],{"type":34,"value":445},{"type":28,"tag":192,"props":7022,"children":7023},{"class":194,"line":401},[7024],{"type":28,"tag":192,"props":7025,"children":7026},{"emptyLinePlaceholder":13},[7027],{"type":34,"value":313},{"type":28,"tag":192,"props":7029,"children":7030},{"class":194,"line":430},[7031,7035,7039,7043,7047,7051,7055,7059],{"type":28,"tag":192,"props":7032,"children":7033},{"style":209},[7034],{"type":34,"value":322},{"type":28,"tag":192,"props":7036,"children":7037},{"style":209},[7038],{"type":34,"value":688},{"type":28,"tag":192,"props":7040,"children":7041},{"style":325},[7042],{"type":34,"value":6425},{"type":28,"tag":192,"props":7044,"children":7045},{"style":226},[7046],{"type":34,"value":332},{"type":28,"tag":192,"props":7048,"children":7049},{"style":209},[7050],{"type":34,"value":938},{"type":28,"tag":192,"props":7052,"children":7053},{"style":340},[7054],{"type":34,"value":6306},{"type":28,"tag":192,"props":7056,"children":7057},{"style":226},[7058],{"type":34,"value":360},{"type":28,"tag":192,"props":7060,"children":7061},{"style":226},[7062],{"type":34,"value":229},{"type":28,"tag":192,"props":7064,"children":7065},{"class":194,"line":439},[7066,7070,7074,7078,7082,7086],{"type":28,"tag":192,"props":7067,"children":7068},{"style":371},[7069],{"type":34,"value":374},{"type":28,"tag":192,"props":7071,"children":7072},{"style":226},[7073],{"type":34,"value":379},{"type":28,"tag":192,"props":7075,"children":7076},{"style":247},[7077],{"type":34,"value":6461},{"type":28,"tag":192,"props":7079,"children":7080},{"style":387},[7081],{"type":34,"value":390},{"type":28,"tag":192,"props":7083,"children":7084},{"style":247},[7085],{"type":34,"value":6306},{"type":28,"tag":192,"props":7087,"children":7088},{"style":226},[7089],{"type":34,"value":255},{"type":28,"tag":192,"props":7091,"children":7092},{"class":194,"line":448},[7093],{"type":28,"tag":192,"props":7094,"children":7095},{"style":226},[7096],{"type":34,"value":445},{"type":28,"tag":192,"props":7098,"children":7099},{"class":194,"line":456},[7100],{"type":28,"tag":192,"props":7101,"children":7102},{"emptyLinePlaceholder":13},[7103],{"type":34,"value":313},{"type":28,"tag":192,"props":7105,"children":7106},{"class":194,"line":482},[7107,7111,7115,7119,7123],{"type":28,"tag":192,"props":7108,"children":7109},{"style":209},[7110],{"type":34,"value":322},{"type":28,"tag":192,"props":7112,"children":7113},{"style":209},[7114],{"type":34,"value":268},{"type":28,"tag":192,"props":7116,"children":7117},{"style":325},[7118],{"type":34,"value":6503},{"type":28,"tag":192,"props":7120,"children":7121},{"style":226},[7122],{"type":34,"value":475},{"type":28,"tag":192,"props":7124,"children":7125},{"style":226},[7126],{"type":34,"value":229},{"type":28,"tag":192,"props":7128,"children":7129},{"class":194,"line":499},[7130,7134,7138,7142,7146],{"type":28,"tag":192,"props":7131,"children":7132},{"style":209},[7133],{"type":34,"value":488},{"type":28,"tag":192,"props":7135,"children":7136},{"style":247},[7137],{"type":34,"value":6523},{"type":28,"tag":192,"props":7139,"children":7140},{"style":387},[7141],{"type":34,"value":1102},{"type":28,"tag":192,"props":7143,"children":7144},{"style":247},[7145],{"type":34,"value":6306},{"type":28,"tag":192,"props":7147,"children":7148},{"style":226},[7149],{"type":34,"value":255},{"type":28,"tag":192,"props":7151,"children":7152},{"class":194,"line":507},[7153],{"type":28,"tag":192,"props":7154,"children":7155},{"style":226},[7156],{"type":34,"value":445},{"type":28,"tag":192,"props":7158,"children":7159},{"class":194,"line":515},[7160],{"type":28,"tag":192,"props":7161,"children":7162},{"style":226},[7163],{"type":34,"value":588},{"type":28,"tag":192,"props":7165,"children":7166},{"class":194,"line":540},[7167],{"type":28,"tag":192,"props":7168,"children":7169},{"emptyLinePlaceholder":13},[7170],{"type":34,"value":313},{"type":28,"tag":192,"props":7172,"children":7173},{"class":194,"line":556},[7174],{"type":28,"tag":192,"props":7175,"children":7176},{"style":199},[7177],{"type":34,"value":7178},"// Classe Square avec son propre comportement\n",{"type":28,"tag":192,"props":7180,"children":7181},{"class":194,"line":564},[7182,7186,7190,7194],{"type":28,"tag":192,"props":7183,"children":7184},{"style":209},[7185],{"type":34,"value":212},{"type":28,"tag":192,"props":7187,"children":7188},{"style":209},[7189],{"type":34,"value":217},{"type":28,"tag":192,"props":7191,"children":7192},{"style":220},[7193],{"type":34,"value":6572},{"type":28,"tag":192,"props":7195,"children":7196},{"style":226},[7197],{"type":34,"value":229},{"type":28,"tag":192,"props":7199,"children":7200},{"class":194,"line":573},[7201,7205,7209,7214],{"type":28,"tag":192,"props":7202,"children":7203},{"style":209},[7204],{"type":34,"value":238},{"type":28,"tag":192,"props":7206,"children":7207},{"style":209},[7208],{"type":34,"value":268},{"type":28,"tag":192,"props":7210,"children":7211},{"style":247},[7212],{"type":34,"value":7213}," side",{"type":28,"tag":192,"props":7215,"children":7216},{"style":226},[7217],{"type":34,"value":255},{"type":28,"tag":192,"props":7219,"children":7220},{"class":194,"line":582},[7221],{"type":28,"tag":192,"props":7222,"children":7223},{"emptyLinePlaceholder":13},[7224],{"type":34,"value":313},{"type":28,"tag":192,"props":7226,"children":7227},{"class":194,"line":5580},[7228,7232,7236,7241,7245,7249,7253,7257],{"type":28,"tag":192,"props":7229,"children":7230},{"style":209},[7231],{"type":34,"value":322},{"type":28,"tag":192,"props":7233,"children":7234},{"style":209},[7235],{"type":34,"value":688},{"type":28,"tag":192,"props":7237,"children":7238},{"style":325},[7239],{"type":34,"value":7240}," setSide",{"type":28,"tag":192,"props":7242,"children":7243},{"style":226},[7244],{"type":34,"value":332},{"type":28,"tag":192,"props":7246,"children":7247},{"style":209},[7248],{"type":34,"value":938},{"type":28,"tag":192,"props":7250,"children":7251},{"style":340},[7252],{"type":34,"value":7213},{"type":28,"tag":192,"props":7254,"children":7255},{"style":226},[7256],{"type":34,"value":360},{"type":28,"tag":192,"props":7258,"children":7259},{"style":226},[7260],{"type":34,"value":229},{"type":28,"tag":192,"props":7262,"children":7263},{"class":194,"line":5600},[7264,7268,7272,7277,7281,7285],{"type":28,"tag":192,"props":7265,"children":7266},{"style":371},[7267],{"type":34,"value":374},{"type":28,"tag":192,"props":7269,"children":7270},{"style":226},[7271],{"type":34,"value":379},{"type":28,"tag":192,"props":7273,"children":7274},{"style":247},[7275],{"type":34,"value":7276},"side ",{"type":28,"tag":192,"props":7278,"children":7279},{"style":387},[7280],{"type":34,"value":390},{"type":28,"tag":192,"props":7282,"children":7283},{"style":247},[7284],{"type":34,"value":7213},{"type":28,"tag":192,"props":7286,"children":7287},{"style":226},[7288],{"type":34,"value":255},{"type":28,"tag":192,"props":7290,"children":7291},{"class":194,"line":5638},[7292],{"type":28,"tag":192,"props":7293,"children":7294},{"style":226},[7295],{"type":34,"value":445},{"type":28,"tag":192,"props":7297,"children":7298},{"class":194,"line":5660},[7299],{"type":28,"tag":192,"props":7300,"children":7301},{"emptyLinePlaceholder":13},[7302],{"type":34,"value":313},{"type":28,"tag":192,"props":7304,"children":7305},{"class":194,"line":5668},[7306,7310,7314,7318,7322],{"type":28,"tag":192,"props":7307,"children":7308},{"style":209},[7309],{"type":34,"value":322},{"type":28,"tag":192,"props":7311,"children":7312},{"style":209},[7313],{"type":34,"value":268},{"type":28,"tag":192,"props":7315,"children":7316},{"style":325},[7317],{"type":34,"value":6503},{"type":28,"tag":192,"props":7319,"children":7320},{"style":226},[7321],{"type":34,"value":475},{"type":28,"tag":192,"props":7323,"children":7324},{"style":226},[7325],{"type":34,"value":229},{"type":28,"tag":192,"props":7327,"children":7328},{"class":194,"line":6718},[7329,7333,7338,7342,7346],{"type":28,"tag":192,"props":7330,"children":7331},{"style":209},[7332],{"type":34,"value":488},{"type":28,"tag":192,"props":7334,"children":7335},{"style":247},[7336],{"type":34,"value":7337}," side ",{"type":28,"tag":192,"props":7339,"children":7340},{"style":387},[7341],{"type":34,"value":1102},{"type":28,"tag":192,"props":7343,"children":7344},{"style":247},[7345],{"type":34,"value":7213},{"type":28,"tag":192,"props":7347,"children":7348},{"style":226},[7349],{"type":34,"value":255},{"type":28,"tag":192,"props":7351,"children":7352},{"class":194,"line":6754},[7353],{"type":28,"tag":192,"props":7354,"children":7355},{"style":226},[7356],{"type":34,"value":445},{"type":28,"tag":192,"props":7358,"children":7359},{"class":194,"line":6782},[7360],{"type":28,"tag":192,"props":7361,"children":7362},{"style":226},[7363],{"type":34,"value":588},{"type":28,"tag":83,"props":7365,"children":7366},{},[],{"type":28,"tag":1841,"props":7368,"children":7369},{"type":1843},[7370],{"type":28,"tag":44,"props":7371,"children":7372},{},[7373,7378],{"type":28,"tag":55,"props":7374,"children":7375},{},[7376],{"type":34,"value":7377},"Évitez l'héritage si les comportements diffèrent",{"type":34,"value":7379}," trop entre la classe parente et la sous-classe. Utilisez des classes séparées ou le polymorphisme si nécessaire, pour éviter les surprises lors de l'exécution du programme.",{"type":28,"tag":29,"props":7381,"children":7383},{"id":7382},"_4-principe-de-ségrégation-des-interfaces-interface-segregation-principle-isp",[7384],{"type":34,"value":7385},"4. Principe de Ségrégation des Interfaces (Interface Segregation Principle - ISP)",{"type":28,"tag":44,"props":7387,"children":7388},{},[7389],{"type":34,"value":7390},"Le principe de ségrégation des interfaces stipule qu'un client ne doit pas être forcé d'implémenter des interfaces dont il n'a pas besoin. Cela signifie qu’il vaut mieux avoir plusieurs petites interfaces spécifiques à des besoins qu'une seule interface générale contenant des méthodes inutiles pour certains clients.",{"type":28,"tag":37,"props":7392,"children":7394},{"id":7393},"pourquoi-cest-important-3",[7395],{"type":34,"value":4123},{"type":28,"tag":44,"props":7397,"children":7398},{},[7399],{"type":34,"value":7400},"Une interface trop large oblige toutes les classes qui l'implémentent à porter des méthodes inutiles. Le couplage explose et le code devient pénible à maintenir. Diviser cette interface en plusieurs interfaces ciblées ramène chaque classe à ce qu'elle fait réellement, et le système redevient modulaire.",{"type":28,"tag":37,"props":7402,"children":7404},{"id":7403},"exemple-concret-en-java-3",[7405],{"type":34,"value":4134},{"type":28,"tag":44,"props":7407,"children":7408},{},[7409,7411,7417],{"type":34,"value":7410},"Imaginons que nous ayons un système qui gère différentes sortes d'oiseaux. Nous avons une interface ",{"type":28,"tag":188,"props":7412,"children":7414},{"className":7413},[],[7415],{"type":34,"value":7416},"Bird",{"type":34,"value":7418}," qui contient des méthodes communes pour les oiseaux.",{"type":28,"tag":169,"props":7420,"children":7422},{"id":7421},"exemple-sans-isp",[7423],{"type":34,"value":7424},"Exemple sans ISP :",{"type":28,"tag":44,"props":7426,"children":7427},{},[7428],{"type":34,"value":7429},"Voici une interface qui regroupe trop de responsabilités :",{"type":28,"tag":181,"props":7431,"children":7433},{"className":183,"code":7432,"language":185,"meta":8,"style":8},"public interface Bird {\n    void fly();\n    void swim();\n    void makeSound();\n}\n",[7434],{"type":28,"tag":188,"props":7435,"children":7436},{"__ignoreMap":8},[7437,7457,7473,7489,7505],{"type":28,"tag":192,"props":7438,"children":7439},{"class":194,"line":195},[7440,7444,7448,7453],{"type":28,"tag":192,"props":7441,"children":7442},{"style":209},[7443],{"type":34,"value":212},{"type":28,"tag":192,"props":7445,"children":7446},{"style":209},[7447],{"type":34,"value":5275},{"type":28,"tag":192,"props":7449,"children":7450},{"style":220},[7451],{"type":34,"value":7452}," Bird",{"type":28,"tag":192,"props":7454,"children":7455},{"style":226},[7456],{"type":34,"value":229},{"type":28,"tag":192,"props":7458,"children":7459},{"class":194,"line":205},[7460,7464,7469],{"type":28,"tag":192,"props":7461,"children":7462},{"style":209},[7463],{"type":34,"value":5292},{"type":28,"tag":192,"props":7465,"children":7466},{"style":325},[7467],{"type":34,"value":7468}," fly",{"type":28,"tag":192,"props":7470,"children":7471},{"style":226},[7472],{"type":34,"value":1973},{"type":28,"tag":192,"props":7474,"children":7475},{"class":194,"line":232},[7476,7480,7485],{"type":28,"tag":192,"props":7477,"children":7478},{"style":209},[7479],{"type":34,"value":5292},{"type":28,"tag":192,"props":7481,"children":7482},{"style":325},[7483],{"type":34,"value":7484}," swim",{"type":28,"tag":192,"props":7486,"children":7487},{"style":226},[7488],{"type":34,"value":1973},{"type":28,"tag":192,"props":7490,"children":7491},{"class":194,"line":258},[7492,7496,7501],{"type":28,"tag":192,"props":7493,"children":7494},{"style":209},[7495],{"type":34,"value":5292},{"type":28,"tag":192,"props":7497,"children":7498},{"style":325},[7499],{"type":34,"value":7500}," makeSound",{"type":28,"tag":192,"props":7502,"children":7503},{"style":226},[7504],{"type":34,"value":1973},{"type":28,"tag":192,"props":7506,"children":7507},{"class":194,"line":280},[7508],{"type":28,"tag":192,"props":7509,"children":7510},{"style":226},[7511],{"type":34,"value":588},{"type":28,"tag":44,"props":7513,"children":7514},{},[7515,7517,7523,7525,7531,7533,7539],{"type":34,"value":7516},"Toutes les classes qui implémentent cette interface devront fournir des implémentations pour ",{"type":28,"tag":188,"props":7518,"children":7520},{"className":7519},[],[7521],{"type":34,"value":7522},"fly()",{"type":34,"value":7524},", ",{"type":28,"tag":188,"props":7526,"children":7528},{"className":7527},[],[7529],{"type":34,"value":7530},"swim()",{"type":34,"value":7532},", et ",{"type":28,"tag":188,"props":7534,"children":7536},{"className":7535},[],[7537],{"type":34,"value":7538},"makeSound()",{"type":34,"value":7540},". Cela peut poser problème pour des oiseaux comme les pingouins, qui ne volent pas mais nagent, ou les autruches, qui ne nagent ni ne volent.",{"type":28,"tag":44,"props":7542,"children":7543},{},[7544],{"type":34,"value":7545},"Voici une implémentation pour un pingouin, qui enfreint clairement l'ISP :",{"type":28,"tag":181,"props":7547,"children":7549},{"className":183,"code":7548,"language":185,"meta":8,"style":8},"public class Penguin implements Bird {\n    @Override\n    public void fly() {\n        // Pingouin ne peut pas voler, on laisse la méthode vide\n    }\n\n    @Override\n    public void swim() {\n        System.out.println(\"Le pingouin nage.\");\n    }\n\n    @Override\n    public void makeSound() {\n        System.out.println(\"Le pingouin émet un son.\");\n    }\n}\n",[7550],{"type":28,"tag":188,"props":7551,"children":7552},{"__ignoreMap":8},[7553,7581,7592,7615,7623,7630,7637,7648,7671,7707,7714,7721,7732,7755,7791,7798],{"type":28,"tag":192,"props":7554,"children":7555},{"class":194,"line":195},[7556,7560,7564,7569,7573,7577],{"type":28,"tag":192,"props":7557,"children":7558},{"style":209},[7559],{"type":34,"value":212},{"type":28,"tag":192,"props":7561,"children":7562},{"style":209},[7563],{"type":34,"value":217},{"type":28,"tag":192,"props":7565,"children":7566},{"style":220},[7567],{"type":34,"value":7568}," Penguin",{"type":28,"tag":192,"props":7570,"children":7571},{"style":209},[7572],{"type":34,"value":5343},{"type":28,"tag":192,"props":7574,"children":7575},{"style":220},[7576],{"type":34,"value":7452},{"type":28,"tag":192,"props":7578,"children":7579},{"style":226},[7580],{"type":34,"value":229},{"type":28,"tag":192,"props":7582,"children":7583},{"class":194,"line":205},[7584,7588],{"type":28,"tag":192,"props":7585,"children":7586},{"style":667},[7587],{"type":34,"value":5359},{"type":28,"tag":192,"props":7589,"children":7590},{"style":673},[7591],{"type":34,"value":5364},{"type":28,"tag":192,"props":7593,"children":7594},{"class":194,"line":232},[7595,7599,7603,7607,7611],{"type":28,"tag":192,"props":7596,"children":7597},{"style":209},[7598],{"type":34,"value":322},{"type":28,"tag":192,"props":7600,"children":7601},{"style":209},[7602],{"type":34,"value":688},{"type":28,"tag":192,"props":7604,"children":7605},{"style":325},[7606],{"type":34,"value":7468},{"type":28,"tag":192,"props":7608,"children":7609},{"style":226},[7610],{"type":34,"value":475},{"type":28,"tag":192,"props":7612,"children":7613},{"style":226},[7614],{"type":34,"value":229},{"type":28,"tag":192,"props":7616,"children":7617},{"class":194,"line":258},[7618],{"type":28,"tag":192,"props":7619,"children":7620},{"style":199},[7621],{"type":34,"value":7622},"        // Pingouin ne peut pas voler, on laisse la méthode vide\n",{"type":28,"tag":192,"props":7624,"children":7625},{"class":194,"line":280},[7626],{"type":28,"tag":192,"props":7627,"children":7628},{"style":226},[7629],{"type":34,"value":445},{"type":28,"tag":192,"props":7631,"children":7632},{"class":194,"line":307},[7633],{"type":28,"tag":192,"props":7634,"children":7635},{"emptyLinePlaceholder":13},[7636],{"type":34,"value":313},{"type":28,"tag":192,"props":7638,"children":7639},{"class":194,"line":316},[7640,7644],{"type":28,"tag":192,"props":7641,"children":7642},{"style":667},[7643],{"type":34,"value":5359},{"type":28,"tag":192,"props":7645,"children":7646},{"style":673},[7647],{"type":34,"value":5364},{"type":28,"tag":192,"props":7649,"children":7650},{"class":194,"line":367},[7651,7655,7659,7663,7667],{"type":28,"tag":192,"props":7652,"children":7653},{"style":209},[7654],{"type":34,"value":322},{"type":28,"tag":192,"props":7656,"children":7657},{"style":209},[7658],{"type":34,"value":688},{"type":28,"tag":192,"props":7660,"children":7661},{"style":325},[7662],{"type":34,"value":7484},{"type":28,"tag":192,"props":7664,"children":7665},{"style":226},[7666],{"type":34,"value":475},{"type":28,"tag":192,"props":7668,"children":7669},{"style":226},[7670],{"type":34,"value":229},{"type":28,"tag":192,"props":7672,"children":7673},{"class":194,"line":401},[7674,7678,7682,7686,7690,7694,7698,7703],{"type":28,"tag":192,"props":7675,"children":7676},{"style":247},[7677],{"type":34,"value":4327},{"type":28,"tag":192,"props":7679,"children":7680},{"style":226},[7681],{"type":34,"value":379},{"type":28,"tag":192,"props":7683,"children":7684},{"style":247},[7685],{"type":34,"value":2673},{"type":28,"tag":192,"props":7687,"children":7688},{"style":226},[7689],{"type":34,"value":379},{"type":28,"tag":192,"props":7691,"children":7692},{"style":325},[7693],{"type":34,"value":2682},{"type":28,"tag":192,"props":7695,"children":7696},{"style":226},[7697],{"type":34,"value":332},{"type":28,"tag":192,"props":7699,"children":7700},{"style":734},[7701],{"type":34,"value":7702},"\"Le pingouin nage.\"",{"type":28,"tag":192,"props":7704,"children":7705},{"style":226},[7706],{"type":34,"value":752},{"type":28,"tag":192,"props":7708,"children":7709},{"class":194,"line":430},[7710],{"type":28,"tag":192,"props":7711,"children":7712},{"style":226},[7713],{"type":34,"value":445},{"type":28,"tag":192,"props":7715,"children":7716},{"class":194,"line":439},[7717],{"type":28,"tag":192,"props":7718,"children":7719},{"emptyLinePlaceholder":13},[7720],{"type":34,"value":313},{"type":28,"tag":192,"props":7722,"children":7723},{"class":194,"line":448},[7724,7728],{"type":28,"tag":192,"props":7725,"children":7726},{"style":667},[7727],{"type":34,"value":5359},{"type":28,"tag":192,"props":7729,"children":7730},{"style":673},[7731],{"type":34,"value":5364},{"type":28,"tag":192,"props":7733,"children":7734},{"class":194,"line":456},[7735,7739,7743,7747,7751],{"type":28,"tag":192,"props":7736,"children":7737},{"style":209},[7738],{"type":34,"value":322},{"type":28,"tag":192,"props":7740,"children":7741},{"style":209},[7742],{"type":34,"value":688},{"type":28,"tag":192,"props":7744,"children":7745},{"style":325},[7746],{"type":34,"value":7500},{"type":28,"tag":192,"props":7748,"children":7749},{"style":226},[7750],{"type":34,"value":475},{"type":28,"tag":192,"props":7752,"children":7753},{"style":226},[7754],{"type":34,"value":229},{"type":28,"tag":192,"props":7756,"children":7757},{"class":194,"line":482},[7758,7762,7766,7770,7774,7778,7782,7787],{"type":28,"tag":192,"props":7759,"children":7760},{"style":247},[7761],{"type":34,"value":4327},{"type":28,"tag":192,"props":7763,"children":7764},{"style":226},[7765],{"type":34,"value":379},{"type":28,"tag":192,"props":7767,"children":7768},{"style":247},[7769],{"type":34,"value":2673},{"type":28,"tag":192,"props":7771,"children":7772},{"style":226},[7773],{"type":34,"value":379},{"type":28,"tag":192,"props":7775,"children":7776},{"style":325},[7777],{"type":34,"value":2682},{"type":28,"tag":192,"props":7779,"children":7780},{"style":226},[7781],{"type":34,"value":332},{"type":28,"tag":192,"props":7783,"children":7784},{"style":734},[7785],{"type":34,"value":7786},"\"Le pingouin émet un son.\"",{"type":28,"tag":192,"props":7788,"children":7789},{"style":226},[7790],{"type":34,"value":752},{"type":28,"tag":192,"props":7792,"children":7793},{"class":194,"line":499},[7794],{"type":28,"tag":192,"props":7795,"children":7796},{"style":226},[7797],{"type":34,"value":445},{"type":28,"tag":192,"props":7799,"children":7800},{"class":194,"line":507},[7801],{"type":28,"tag":192,"props":7802,"children":7803},{"style":226},[7804],{"type":34,"value":588},{"type":28,"tag":44,"props":7806,"children":7807},{},[7808,7810,7815,7817,7822],{"type":34,"value":7809},"La méthode ",{"type":28,"tag":188,"props":7811,"children":7813},{"className":7812},[],[7814],{"type":34,"value":7522},{"type":34,"value":7816}," est ici inutile, mais nous devons quand même la définir parce que l'interface ",{"type":28,"tag":188,"props":7818,"children":7820},{"className":7819},[],[7821],{"type":34,"value":7416},{"type":34,"value":7823}," l'impose. Cela entraîne du code mort et une mauvaise conception.",{"type":28,"tag":169,"props":7825,"children":7827},{"id":7826},"exemple-avec-isp-appliqué",[7828],{"type":34,"value":7829},"Exemple avec ISP appliqué :",{"type":28,"tag":44,"props":7831,"children":7832},{},[7833,7835,7840],{"type":34,"value":7834},"Pour corriger cela, nous allons séparer l'interface ",{"type":28,"tag":188,"props":7836,"children":7838},{"className":7837},[],[7839],{"type":34,"value":7416},{"type":34,"value":7841}," en plusieurs petites interfaces spécifiques à des capacités d’oiseaux.",{"type":28,"tag":181,"props":7843,"children":7845},{"className":183,"code":7844,"language":185,"meta":8,"style":8},"// Interface pour les oiseaux qui volent\npublic interface FlyingBird {\n    void fly();\n}\n\n// Interface pour les oiseaux qui nagent\npublic interface SwimmingBird {\n    void swim();\n}\n\n// Interface pour les oiseaux qui émettent des sons\npublic interface SoundingBird {\n    void makeSound();\n}\n",[7846],{"type":28,"tag":188,"props":7847,"children":7848},{"__ignoreMap":8},[7849,7857,7877,7892,7899,7906,7914,7934,7949,7956,7963,7971,7991,8006],{"type":28,"tag":192,"props":7850,"children":7851},{"class":194,"line":195},[7852],{"type":28,"tag":192,"props":7853,"children":7854},{"style":199},[7855],{"type":34,"value":7856},"// Interface pour les oiseaux qui volent\n",{"type":28,"tag":192,"props":7858,"children":7859},{"class":194,"line":205},[7860,7864,7868,7873],{"type":28,"tag":192,"props":7861,"children":7862},{"style":209},[7863],{"type":34,"value":212},{"type":28,"tag":192,"props":7865,"children":7866},{"style":209},[7867],{"type":34,"value":5275},{"type":28,"tag":192,"props":7869,"children":7870},{"style":220},[7871],{"type":34,"value":7872}," FlyingBird",{"type":28,"tag":192,"props":7874,"children":7875},{"style":226},[7876],{"type":34,"value":229},{"type":28,"tag":192,"props":7878,"children":7879},{"class":194,"line":232},[7880,7884,7888],{"type":28,"tag":192,"props":7881,"children":7882},{"style":209},[7883],{"type":34,"value":5292},{"type":28,"tag":192,"props":7885,"children":7886},{"style":325},[7887],{"type":34,"value":7468},{"type":28,"tag":192,"props":7889,"children":7890},{"style":226},[7891],{"type":34,"value":1973},{"type":28,"tag":192,"props":7893,"children":7894},{"class":194,"line":258},[7895],{"type":28,"tag":192,"props":7896,"children":7897},{"style":226},[7898],{"type":34,"value":588},{"type":28,"tag":192,"props":7900,"children":7901},{"class":194,"line":280},[7902],{"type":28,"tag":192,"props":7903,"children":7904},{"emptyLinePlaceholder":13},[7905],{"type":34,"value":313},{"type":28,"tag":192,"props":7907,"children":7908},{"class":194,"line":307},[7909],{"type":28,"tag":192,"props":7910,"children":7911},{"style":199},[7912],{"type":34,"value":7913},"// Interface pour les oiseaux qui nagent\n",{"type":28,"tag":192,"props":7915,"children":7916},{"class":194,"line":316},[7917,7921,7925,7930],{"type":28,"tag":192,"props":7918,"children":7919},{"style":209},[7920],{"type":34,"value":212},{"type":28,"tag":192,"props":7922,"children":7923},{"style":209},[7924],{"type":34,"value":5275},{"type":28,"tag":192,"props":7926,"children":7927},{"style":220},[7928],{"type":34,"value":7929}," SwimmingBird",{"type":28,"tag":192,"props":7931,"children":7932},{"style":226},[7933],{"type":34,"value":229},{"type":28,"tag":192,"props":7935,"children":7936},{"class":194,"line":367},[7937,7941,7945],{"type":28,"tag":192,"props":7938,"children":7939},{"style":209},[7940],{"type":34,"value":5292},{"type":28,"tag":192,"props":7942,"children":7943},{"style":325},[7944],{"type":34,"value":7484},{"type":28,"tag":192,"props":7946,"children":7947},{"style":226},[7948],{"type":34,"value":1973},{"type":28,"tag":192,"props":7950,"children":7951},{"class":194,"line":401},[7952],{"type":28,"tag":192,"props":7953,"children":7954},{"style":226},[7955],{"type":34,"value":588},{"type":28,"tag":192,"props":7957,"children":7958},{"class":194,"line":430},[7959],{"type":28,"tag":192,"props":7960,"children":7961},{"emptyLinePlaceholder":13},[7962],{"type":34,"value":313},{"type":28,"tag":192,"props":7964,"children":7965},{"class":194,"line":439},[7966],{"type":28,"tag":192,"props":7967,"children":7968},{"style":199},[7969],{"type":34,"value":7970},"// Interface pour les oiseaux qui émettent des sons\n",{"type":28,"tag":192,"props":7972,"children":7973},{"class":194,"line":448},[7974,7978,7982,7987],{"type":28,"tag":192,"props":7975,"children":7976},{"style":209},[7977],{"type":34,"value":212},{"type":28,"tag":192,"props":7979,"children":7980},{"style":209},[7981],{"type":34,"value":5275},{"type":28,"tag":192,"props":7983,"children":7984},{"style":220},[7985],{"type":34,"value":7986}," SoundingBird",{"type":28,"tag":192,"props":7988,"children":7989},{"style":226},[7990],{"type":34,"value":229},{"type":28,"tag":192,"props":7992,"children":7993},{"class":194,"line":456},[7994,7998,8002],{"type":28,"tag":192,"props":7995,"children":7996},{"style":209},[7997],{"type":34,"value":5292},{"type":28,"tag":192,"props":7999,"children":8000},{"style":325},[8001],{"type":34,"value":7500},{"type":28,"tag":192,"props":8003,"children":8004},{"style":226},[8005],{"type":34,"value":1973},{"type":28,"tag":192,"props":8007,"children":8008},{"class":194,"line":482},[8009],{"type":28,"tag":192,"props":8010,"children":8011},{"style":226},[8012],{"type":34,"value":588},{"type":28,"tag":44,"props":8014,"children":8015},{},[8016],{"type":34,"value":8017},"Maintenant, nous pouvons créer des classes qui implémentent uniquement les interfaces dont elles ont besoin :",{"type":28,"tag":181,"props":8019,"children":8021},{"className":183,"code":8020,"language":185,"meta":8,"style":8},"// Le pingouin nage et émet des sons, mais ne vole pas\npublic class Penguin implements SwimmingBird, SoundingBird {\n    @Override\n    public void swim() {\n        System.out.println(\"Le pingouin nage.\");\n    }\n\n    @Override\n    public void makeSound() {\n        System.out.println(\"Le pingouin émet un son.\");\n    }\n}\n\n// L'aigle vole et émet des sons\npublic class Eagle implements FlyingBird, SoundingBird {\n    @Override\n    public void fly() {\n        System.out.println(\"L'aigle vole.\");\n    }\n\n    @Override\n    public void makeSound() {\n        System.out.println(\"L'aigle émet un son.\");\n    }\n}\n",[8022],{"type":28,"tag":188,"props":8023,"children":8024},{"__ignoreMap":8},[8025,8033,8068,8079,8102,8137,8144,8151,8162,8185,8220,8227,8234,8241,8249,8285,8296,8319,8355,8362,8369,8380,8403,8439,8446],{"type":28,"tag":192,"props":8026,"children":8027},{"class":194,"line":195},[8028],{"type":28,"tag":192,"props":8029,"children":8030},{"style":199},[8031],{"type":34,"value":8032},"// Le pingouin nage et émet des sons, mais ne vole pas\n",{"type":28,"tag":192,"props":8034,"children":8035},{"class":194,"line":205},[8036,8040,8044,8048,8052,8056,8060,8064],{"type":28,"tag":192,"props":8037,"children":8038},{"style":209},[8039],{"type":34,"value":212},{"type":28,"tag":192,"props":8041,"children":8042},{"style":209},[8043],{"type":34,"value":217},{"type":28,"tag":192,"props":8045,"children":8046},{"style":220},[8047],{"type":34,"value":7568},{"type":28,"tag":192,"props":8049,"children":8050},{"style":209},[8051],{"type":34,"value":5343},{"type":28,"tag":192,"props":8053,"children":8054},{"style":220},[8055],{"type":34,"value":7929},{"type":28,"tag":192,"props":8057,"children":8058},{"style":226},[8059],{"type":34,"value":347},{"type":28,"tag":192,"props":8061,"children":8062},{"style":220},[8063],{"type":34,"value":7986},{"type":28,"tag":192,"props":8065,"children":8066},{"style":226},[8067],{"type":34,"value":229},{"type":28,"tag":192,"props":8069,"children":8070},{"class":194,"line":232},[8071,8075],{"type":28,"tag":192,"props":8072,"children":8073},{"style":667},[8074],{"type":34,"value":5359},{"type":28,"tag":192,"props":8076,"children":8077},{"style":673},[8078],{"type":34,"value":5364},{"type":28,"tag":192,"props":8080,"children":8081},{"class":194,"line":258},[8082,8086,8090,8094,8098],{"type":28,"tag":192,"props":8083,"children":8084},{"style":209},[8085],{"type":34,"value":322},{"type":28,"tag":192,"props":8087,"children":8088},{"style":209},[8089],{"type":34,"value":688},{"type":28,"tag":192,"props":8091,"children":8092},{"style":325},[8093],{"type":34,"value":7484},{"type":28,"tag":192,"props":8095,"children":8096},{"style":226},[8097],{"type":34,"value":475},{"type":28,"tag":192,"props":8099,"children":8100},{"style":226},[8101],{"type":34,"value":229},{"type":28,"tag":192,"props":8103,"children":8104},{"class":194,"line":280},[8105,8109,8113,8117,8121,8125,8129,8133],{"type":28,"tag":192,"props":8106,"children":8107},{"style":247},[8108],{"type":34,"value":4327},{"type":28,"tag":192,"props":8110,"children":8111},{"style":226},[8112],{"type":34,"value":379},{"type":28,"tag":192,"props":8114,"children":8115},{"style":247},[8116],{"type":34,"value":2673},{"type":28,"tag":192,"props":8118,"children":8119},{"style":226},[8120],{"type":34,"value":379},{"type":28,"tag":192,"props":8122,"children":8123},{"style":325},[8124],{"type":34,"value":2682},{"type":28,"tag":192,"props":8126,"children":8127},{"style":226},[8128],{"type":34,"value":332},{"type":28,"tag":192,"props":8130,"children":8131},{"style":734},[8132],{"type":34,"value":7702},{"type":28,"tag":192,"props":8134,"children":8135},{"style":226},[8136],{"type":34,"value":752},{"type":28,"tag":192,"props":8138,"children":8139},{"class":194,"line":307},[8140],{"type":28,"tag":192,"props":8141,"children":8142},{"style":226},[8143],{"type":34,"value":445},{"type":28,"tag":192,"props":8145,"children":8146},{"class":194,"line":316},[8147],{"type":28,"tag":192,"props":8148,"children":8149},{"emptyLinePlaceholder":13},[8150],{"type":34,"value":313},{"type":28,"tag":192,"props":8152,"children":8153},{"class":194,"line":367},[8154,8158],{"type":28,"tag":192,"props":8155,"children":8156},{"style":667},[8157],{"type":34,"value":5359},{"type":28,"tag":192,"props":8159,"children":8160},{"style":673},[8161],{"type":34,"value":5364},{"type":28,"tag":192,"props":8163,"children":8164},{"class":194,"line":401},[8165,8169,8173,8177,8181],{"type":28,"tag":192,"props":8166,"children":8167},{"style":209},[8168],{"type":34,"value":322},{"type":28,"tag":192,"props":8170,"children":8171},{"style":209},[8172],{"type":34,"value":688},{"type":28,"tag":192,"props":8174,"children":8175},{"style":325},[8176],{"type":34,"value":7500},{"type":28,"tag":192,"props":8178,"children":8179},{"style":226},[8180],{"type":34,"value":475},{"type":28,"tag":192,"props":8182,"children":8183},{"style":226},[8184],{"type":34,"value":229},{"type":28,"tag":192,"props":8186,"children":8187},{"class":194,"line":430},[8188,8192,8196,8200,8204,8208,8212,8216],{"type":28,"tag":192,"props":8189,"children":8190},{"style":247},[8191],{"type":34,"value":4327},{"type":28,"tag":192,"props":8193,"children":8194},{"style":226},[8195],{"type":34,"value":379},{"type":28,"tag":192,"props":8197,"children":8198},{"style":247},[8199],{"type":34,"value":2673},{"type":28,"tag":192,"props":8201,"children":8202},{"style":226},[8203],{"type":34,"value":379},{"type":28,"tag":192,"props":8205,"children":8206},{"style":325},[8207],{"type":34,"value":2682},{"type":28,"tag":192,"props":8209,"children":8210},{"style":226},[8211],{"type":34,"value":332},{"type":28,"tag":192,"props":8213,"children":8214},{"style":734},[8215],{"type":34,"value":7786},{"type":28,"tag":192,"props":8217,"children":8218},{"style":226},[8219],{"type":34,"value":752},{"type":28,"tag":192,"props":8221,"children":8222},{"class":194,"line":439},[8223],{"type":28,"tag":192,"props":8224,"children":8225},{"style":226},[8226],{"type":34,"value":445},{"type":28,"tag":192,"props":8228,"children":8229},{"class":194,"line":448},[8230],{"type":28,"tag":192,"props":8231,"children":8232},{"style":226},[8233],{"type":34,"value":588},{"type":28,"tag":192,"props":8235,"children":8236},{"class":194,"line":456},[8237],{"type":28,"tag":192,"props":8238,"children":8239},{"emptyLinePlaceholder":13},[8240],{"type":34,"value":313},{"type":28,"tag":192,"props":8242,"children":8243},{"class":194,"line":482},[8244],{"type":28,"tag":192,"props":8245,"children":8246},{"style":199},[8247],{"type":34,"value":8248},"// L'aigle vole et émet des sons\n",{"type":28,"tag":192,"props":8250,"children":8251},{"class":194,"line":499},[8252,8256,8260,8265,8269,8273,8277,8281],{"type":28,"tag":192,"props":8253,"children":8254},{"style":209},[8255],{"type":34,"value":212},{"type":28,"tag":192,"props":8257,"children":8258},{"style":209},[8259],{"type":34,"value":217},{"type":28,"tag":192,"props":8261,"children":8262},{"style":220},[8263],{"type":34,"value":8264}," Eagle",{"type":28,"tag":192,"props":8266,"children":8267},{"style":209},[8268],{"type":34,"value":5343},{"type":28,"tag":192,"props":8270,"children":8271},{"style":220},[8272],{"type":34,"value":7872},{"type":28,"tag":192,"props":8274,"children":8275},{"style":226},[8276],{"type":34,"value":347},{"type":28,"tag":192,"props":8278,"children":8279},{"style":220},[8280],{"type":34,"value":7986},{"type":28,"tag":192,"props":8282,"children":8283},{"style":226},[8284],{"type":34,"value":229},{"type":28,"tag":192,"props":8286,"children":8287},{"class":194,"line":507},[8288,8292],{"type":28,"tag":192,"props":8289,"children":8290},{"style":667},[8291],{"type":34,"value":5359},{"type":28,"tag":192,"props":8293,"children":8294},{"style":673},[8295],{"type":34,"value":5364},{"type":28,"tag":192,"props":8297,"children":8298},{"class":194,"line":515},[8299,8303,8307,8311,8315],{"type":28,"tag":192,"props":8300,"children":8301},{"style":209},[8302],{"type":34,"value":322},{"type":28,"tag":192,"props":8304,"children":8305},{"style":209},[8306],{"type":34,"value":688},{"type":28,"tag":192,"props":8308,"children":8309},{"style":325},[8310],{"type":34,"value":7468},{"type":28,"tag":192,"props":8312,"children":8313},{"style":226},[8314],{"type":34,"value":475},{"type":28,"tag":192,"props":8316,"children":8317},{"style":226},[8318],{"type":34,"value":229},{"type":28,"tag":192,"props":8320,"children":8321},{"class":194,"line":540},[8322,8326,8330,8334,8338,8342,8346,8351],{"type":28,"tag":192,"props":8323,"children":8324},{"style":247},[8325],{"type":34,"value":4327},{"type":28,"tag":192,"props":8327,"children":8328},{"style":226},[8329],{"type":34,"value":379},{"type":28,"tag":192,"props":8331,"children":8332},{"style":247},[8333],{"type":34,"value":2673},{"type":28,"tag":192,"props":8335,"children":8336},{"style":226},[8337],{"type":34,"value":379},{"type":28,"tag":192,"props":8339,"children":8340},{"style":325},[8341],{"type":34,"value":2682},{"type":28,"tag":192,"props":8343,"children":8344},{"style":226},[8345],{"type":34,"value":332},{"type":28,"tag":192,"props":8347,"children":8348},{"style":734},[8349],{"type":34,"value":8350},"\"L'aigle vole.\"",{"type":28,"tag":192,"props":8352,"children":8353},{"style":226},[8354],{"type":34,"value":752},{"type":28,"tag":192,"props":8356,"children":8357},{"class":194,"line":556},[8358],{"type":28,"tag":192,"props":8359,"children":8360},{"style":226},[8361],{"type":34,"value":445},{"type":28,"tag":192,"props":8363,"children":8364},{"class":194,"line":564},[8365],{"type":28,"tag":192,"props":8366,"children":8367},{"emptyLinePlaceholder":13},[8368],{"type":34,"value":313},{"type":28,"tag":192,"props":8370,"children":8371},{"class":194,"line":573},[8372,8376],{"type":28,"tag":192,"props":8373,"children":8374},{"style":667},[8375],{"type":34,"value":5359},{"type":28,"tag":192,"props":8377,"children":8378},{"style":673},[8379],{"type":34,"value":5364},{"type":28,"tag":192,"props":8381,"children":8382},{"class":194,"line":582},[8383,8387,8391,8395,8399],{"type":28,"tag":192,"props":8384,"children":8385},{"style":209},[8386],{"type":34,"value":322},{"type":28,"tag":192,"props":8388,"children":8389},{"style":209},[8390],{"type":34,"value":688},{"type":28,"tag":192,"props":8392,"children":8393},{"style":325},[8394],{"type":34,"value":7500},{"type":28,"tag":192,"props":8396,"children":8397},{"style":226},[8398],{"type":34,"value":475},{"type":28,"tag":192,"props":8400,"children":8401},{"style":226},[8402],{"type":34,"value":229},{"type":28,"tag":192,"props":8404,"children":8405},{"class":194,"line":5580},[8406,8410,8414,8418,8422,8426,8430,8435],{"type":28,"tag":192,"props":8407,"children":8408},{"style":247},[8409],{"type":34,"value":4327},{"type":28,"tag":192,"props":8411,"children":8412},{"style":226},[8413],{"type":34,"value":379},{"type":28,"tag":192,"props":8415,"children":8416},{"style":247},[8417],{"type":34,"value":2673},{"type":28,"tag":192,"props":8419,"children":8420},{"style":226},[8421],{"type":34,"value":379},{"type":28,"tag":192,"props":8423,"children":8424},{"style":325},[8425],{"type":34,"value":2682},{"type":28,"tag":192,"props":8427,"children":8428},{"style":226},[8429],{"type":34,"value":332},{"type":28,"tag":192,"props":8431,"children":8432},{"style":734},[8433],{"type":34,"value":8434},"\"L'aigle émet un son.\"",{"type":28,"tag":192,"props":8436,"children":8437},{"style":226},[8438],{"type":34,"value":752},{"type":28,"tag":192,"props":8440,"children":8441},{"class":194,"line":5600},[8442],{"type":28,"tag":192,"props":8443,"children":8444},{"style":226},[8445],{"type":34,"value":445},{"type":28,"tag":192,"props":8447,"children":8448},{"class":194,"line":5638},[8449],{"type":28,"tag":192,"props":8450,"children":8451},{"style":226},[8452],{"type":34,"value":588},{"type":28,"tag":83,"props":8454,"children":8455},{},[],{"type":28,"tag":1841,"props":8457,"children":8458},{"type":1843},[8459],{"type":28,"tag":44,"props":8460,"children":8461},{},[8462,8467],{"type":28,"tag":55,"props":8463,"children":8464},{},[8465],{"type":34,"value":8466},"Divisez vos interfaces selon les besoins réels",{"type":34,"value":8468},". Ne regroupez pas des méthodes non liées dans une même interface. Cela rendra vos classes plus légères et plus faciles à tester.",{"type":28,"tag":29,"props":8470,"children":8472},{"id":8471},"_5-principe-dinversion-des-dépendances-dependency-inversion-principle-dip",[8473],{"type":34,"value":8474},"5. Principe d'Inversion des Dépendances (Dependency Inversion Principle - DIP)",{"type":28,"tag":44,"props":8476,"children":8477},{},[8478],{"type":34,"value":8479},"Le principe d'inversion des dépendances stipule que les modules de haut niveau ne doivent pas dépendre des modules de bas niveau. Tous deux doivent dépendre d'abstractions. En d'autres termes, plutôt que de lier directement des classes concrètes, il est préférable de dépendre d'interfaces ou de classes abstraites.",{"type":28,"tag":37,"props":8481,"children":8483},{"id":8482},"pourquoi-cest-important-4",[8484],{"type":34,"value":4123},{"type":28,"tag":44,"props":8486,"children":8487},{},[8488],{"type":34,"value":8489},"Quand un module de haut niveau dépend directement d'un module de bas niveau, le couplage devient rigide : impossible de modifier ou tester l'un sans l'autre. Introduire une abstraction entre les deux casse cette dépendance directe et ouvre la porte au remplacement des implémentations de bas niveau sans toucher au reste du système.",{"type":28,"tag":37,"props":8491,"children":8493},{"id":8492},"exemple-concret-en-java-4",[8494],{"type":34,"value":4134},{"type":28,"tag":44,"props":8496,"children":8497},{},[8498,8499,8505],{"type":34,"value":6202},{"type":28,"tag":188,"props":8500,"children":8502},{"className":8501},[],[8503],{"type":34,"value":8504},"NotificationService",{"type":34,"value":8506}," qui envoie des notifications par email. Si cette classe dépend directement d'une implémentation concrète d'email, nous brisons le DIP.",{"type":28,"tag":169,"props":8508,"children":8510},{"id":8509},"exemple-sans-dip",[8511],{"type":34,"value":8512},"Exemple sans DIP :",{"type":28,"tag":44,"props":8514,"children":8515},{},[8516,8518,8524],{"type":34,"value":8517},"Voici une implémentation où le service de notification dépend directement de la classe ",{"type":28,"tag":188,"props":8519,"children":8521},{"className":8520},[],[8522],{"type":34,"value":8523},"EmailService",{"type":34,"value":5685},{"type":28,"tag":181,"props":8526,"children":8528},{"className":183,"code":8527,"language":185,"meta":8,"style":8},"public class EmailService {\n    public void sendEmail(String message) {\n        System.out.println(\"Envoi de l'email : \" + message);\n    }\n}\n\npublic class NotificationService {\n    private EmailService emailService;\n\n    public NotificationService() {\n        this.emailService = new EmailService();\n    }\n\n    public void sendNotification(String message) {\n        emailService.sendEmail(message);\n    }\n}\n",[8529],{"type":28,"tag":188,"props":8530,"children":8531},{"__ignoreMap":8},[8532,8552,8589,8633,8640,8647,8654,8674,8694,8701,8720,8752,8759,8766,8802,8832,8839],{"type":28,"tag":192,"props":8533,"children":8534},{"class":194,"line":195},[8535,8539,8543,8548],{"type":28,"tag":192,"props":8536,"children":8537},{"style":209},[8538],{"type":34,"value":212},{"type":28,"tag":192,"props":8540,"children":8541},{"style":209},[8542],{"type":34,"value":217},{"type":28,"tag":192,"props":8544,"children":8545},{"style":220},[8546],{"type":34,"value":8547}," EmailService",{"type":28,"tag":192,"props":8549,"children":8550},{"style":226},[8551],{"type":34,"value":229},{"type":28,"tag":192,"props":8553,"children":8554},{"class":194,"line":205},[8555,8559,8563,8568,8572,8576,8581,8585],{"type":28,"tag":192,"props":8556,"children":8557},{"style":209},[8558],{"type":34,"value":322},{"type":28,"tag":192,"props":8560,"children":8561},{"style":209},[8562],{"type":34,"value":688},{"type":28,"tag":192,"props":8564,"children":8565},{"style":325},[8566],{"type":34,"value":8567}," sendEmail",{"type":28,"tag":192,"props":8569,"children":8570},{"style":226},[8571],{"type":34,"value":332},{"type":28,"tag":192,"props":8573,"children":8574},{"style":241},[8575],{"type":34,"value":337},{"type":28,"tag":192,"props":8577,"children":8578},{"style":340},[8579],{"type":34,"value":8580}," message",{"type":28,"tag":192,"props":8582,"children":8583},{"style":226},[8584],{"type":34,"value":360},{"type":28,"tag":192,"props":8586,"children":8587},{"style":226},[8588],{"type":34,"value":229},{"type":28,"tag":192,"props":8590,"children":8591},{"class":194,"line":232},[8592,8596,8600,8604,8608,8612,8616,8621,8625,8629],{"type":28,"tag":192,"props":8593,"children":8594},{"style":247},[8595],{"type":34,"value":4327},{"type":28,"tag":192,"props":8597,"children":8598},{"style":226},[8599],{"type":34,"value":379},{"type":28,"tag":192,"props":8601,"children":8602},{"style":247},[8603],{"type":34,"value":2673},{"type":28,"tag":192,"props":8605,"children":8606},{"style":226},[8607],{"type":34,"value":379},{"type":28,"tag":192,"props":8609,"children":8610},{"style":325},[8611],{"type":34,"value":2682},{"type":28,"tag":192,"props":8613,"children":8614},{"style":226},[8615],{"type":34,"value":332},{"type":28,"tag":192,"props":8617,"children":8618},{"style":734},[8619],{"type":34,"value":8620},"\"Envoi de l'email : \"",{"type":28,"tag":192,"props":8622,"children":8623},{"style":387},[8624],{"type":34,"value":2696},{"type":28,"tag":192,"props":8626,"children":8627},{"style":247},[8628],{"type":34,"value":8580},{"type":28,"tag":192,"props":8630,"children":8631},{"style":226},[8632],{"type":34,"value":752},{"type":28,"tag":192,"props":8634,"children":8635},{"class":194,"line":258},[8636],{"type":28,"tag":192,"props":8637,"children":8638},{"style":226},[8639],{"type":34,"value":445},{"type":28,"tag":192,"props":8641,"children":8642},{"class":194,"line":280},[8643],{"type":28,"tag":192,"props":8644,"children":8645},{"style":226},[8646],{"type":34,"value":588},{"type":28,"tag":192,"props":8648,"children":8649},{"class":194,"line":307},[8650],{"type":28,"tag":192,"props":8651,"children":8652},{"emptyLinePlaceholder":13},[8653],{"type":34,"value":313},{"type":28,"tag":192,"props":8655,"children":8656},{"class":194,"line":316},[8657,8661,8665,8670],{"type":28,"tag":192,"props":8658,"children":8659},{"style":209},[8660],{"type":34,"value":212},{"type":28,"tag":192,"props":8662,"children":8663},{"style":209},[8664],{"type":34,"value":217},{"type":28,"tag":192,"props":8666,"children":8667},{"style":220},[8668],{"type":34,"value":8669}," NotificationService",{"type":28,"tag":192,"props":8671,"children":8672},{"style":226},[8673],{"type":34,"value":229},{"type":28,"tag":192,"props":8675,"children":8676},{"class":194,"line":367},[8677,8681,8685,8690],{"type":28,"tag":192,"props":8678,"children":8679},{"style":209},[8680],{"type":34,"value":238},{"type":28,"tag":192,"props":8682,"children":8683},{"style":241},[8684],{"type":34,"value":8547},{"type":28,"tag":192,"props":8686,"children":8687},{"style":247},[8688],{"type":34,"value":8689}," emailService",{"type":28,"tag":192,"props":8691,"children":8692},{"style":226},[8693],{"type":34,"value":255},{"type":28,"tag":192,"props":8695,"children":8696},{"class":194,"line":401},[8697],{"type":28,"tag":192,"props":8698,"children":8699},{"emptyLinePlaceholder":13},[8700],{"type":34,"value":313},{"type":28,"tag":192,"props":8702,"children":8703},{"class":194,"line":430},[8704,8708,8712,8716],{"type":28,"tag":192,"props":8705,"children":8706},{"style":209},[8707],{"type":34,"value":322},{"type":28,"tag":192,"props":8709,"children":8710},{"style":325},[8711],{"type":34,"value":8669},{"type":28,"tag":192,"props":8713,"children":8714},{"style":226},[8715],{"type":34,"value":475},{"type":28,"tag":192,"props":8717,"children":8718},{"style":226},[8719],{"type":34,"value":229},{"type":28,"tag":192,"props":8721,"children":8722},{"class":194,"line":439},[8723,8727,8731,8736,8740,8744,8748],{"type":28,"tag":192,"props":8724,"children":8725},{"style":371},[8726],{"type":34,"value":374},{"type":28,"tag":192,"props":8728,"children":8729},{"style":226},[8730],{"type":34,"value":379},{"type":28,"tag":192,"props":8732,"children":8733},{"style":247},[8734],{"type":34,"value":8735},"emailService ",{"type":28,"tag":192,"props":8737,"children":8738},{"style":387},[8739],{"type":34,"value":390},{"type":28,"tag":192,"props":8741,"children":8742},{"style":209},[8743],{"type":34,"value":723},{"type":28,"tag":192,"props":8745,"children":8746},{"style":325},[8747],{"type":34,"value":8547},{"type":28,"tag":192,"props":8749,"children":8750},{"style":226},[8751],{"type":34,"value":1973},{"type":28,"tag":192,"props":8753,"children":8754},{"class":194,"line":448},[8755],{"type":28,"tag":192,"props":8756,"children":8757},{"style":226},[8758],{"type":34,"value":445},{"type":28,"tag":192,"props":8760,"children":8761},{"class":194,"line":456},[8762],{"type":28,"tag":192,"props":8763,"children":8764},{"emptyLinePlaceholder":13},[8765],{"type":34,"value":313},{"type":28,"tag":192,"props":8767,"children":8768},{"class":194,"line":482},[8769,8773,8777,8782,8786,8790,8794,8798],{"type":28,"tag":192,"props":8770,"children":8771},{"style":209},[8772],{"type":34,"value":322},{"type":28,"tag":192,"props":8774,"children":8775},{"style":209},[8776],{"type":34,"value":688},{"type":28,"tag":192,"props":8778,"children":8779},{"style":325},[8780],{"type":34,"value":8781}," sendNotification",{"type":28,"tag":192,"props":8783,"children":8784},{"style":226},[8785],{"type":34,"value":332},{"type":28,"tag":192,"props":8787,"children":8788},{"style":241},[8789],{"type":34,"value":337},{"type":28,"tag":192,"props":8791,"children":8792},{"style":340},[8793],{"type":34,"value":8580},{"type":28,"tag":192,"props":8795,"children":8796},{"style":226},[8797],{"type":34,"value":360},{"type":28,"tag":192,"props":8799,"children":8800},{"style":226},[8801],{"type":34,"value":229},{"type":28,"tag":192,"props":8803,"children":8804},{"class":194,"line":499},[8805,8810,8814,8819,8823,8828],{"type":28,"tag":192,"props":8806,"children":8807},{"style":247},[8808],{"type":34,"value":8809},"        emailService",{"type":28,"tag":192,"props":8811,"children":8812},{"style":226},[8813],{"type":34,"value":379},{"type":28,"tag":192,"props":8815,"children":8816},{"style":325},[8817],{"type":34,"value":8818},"sendEmail",{"type":28,"tag":192,"props":8820,"children":8821},{"style":226},[8822],{"type":34,"value":332},{"type":28,"tag":192,"props":8824,"children":8825},{"style":247},[8826],{"type":34,"value":8827},"message",{"type":28,"tag":192,"props":8829,"children":8830},{"style":226},[8831],{"type":34,"value":752},{"type":28,"tag":192,"props":8833,"children":8834},{"class":194,"line":507},[8835],{"type":28,"tag":192,"props":8836,"children":8837},{"style":226},[8838],{"type":34,"value":445},{"type":28,"tag":192,"props":8840,"children":8841},{"class":194,"line":515},[8842],{"type":28,"tag":192,"props":8843,"children":8844},{"style":226},[8845],{"type":34,"value":588},{"type":28,"tag":44,"props":8847,"children":8848},{},[8849,8851,8856,8858,8863,8865,8870],{"type":34,"value":8850},"Dans cet exemple, ",{"type":28,"tag":188,"props":8852,"children":8854},{"className":8853},[],[8855],{"type":34,"value":8504},{"type":34,"value":8857}," est étroitement couplé à ",{"type":28,"tag":188,"props":8859,"children":8861},{"className":8860},[],[8862],{"type":34,"value":8523},{"type":34,"value":8864},". Si nous voulions envoyer une notification par SMS au lieu d’un email, nous devrions modifier la classe ",{"type":28,"tag":188,"props":8866,"children":8868},{"className":8867},[],[8869],{"type":34,"value":8504},{"type":34,"value":8871},", ce qui va à l'encontre du principe DIP.",{"type":28,"tag":169,"props":8873,"children":8875},{"id":8874},"exemple-avec-dip-appliqué",[8876],{"type":34,"value":8877},"Exemple avec DIP appliqué :",{"type":28,"tag":44,"props":8879,"children":8880},{},[8881,8883,8889],{"type":34,"value":8882},"Pour respecter le principe d'inversion des dépendances, nous allons introduire une abstraction sous forme d'une interface ",{"type":28,"tag":188,"props":8884,"children":8886},{"className":8885},[],[8887],{"type":34,"value":8888},"NotificationSender",{"type":34,"value":8890}," que toutes les implémentations concrètes (Email, SMS, etc.) respecteront.",{"type":28,"tag":181,"props":8892,"children":8894},{"className":183,"code":8893,"language":185,"meta":8,"style":8},"// Interface pour les services d'envoi de notifications\npublic interface NotificationSender {\n    void send(String message);\n}\n\n// Implémentation pour l'email\npublic class EmailSender implements NotificationSender {\n    @Override\n    public void send(String message) {\n        System.out.println(\"Envoi de l'email : \" + message);\n    }\n}\n\n// Implémentation pour SMS\npublic class SMSSender implements NotificationSender {\n    @Override\n    public void send(String message) {\n        System.out.println(\"Envoi du SMS : \" + message);\n    }\n}\n\n// Service de notification utilisant l'interface NotificationSender\npublic class NotificationService {\n    private NotificationSender sender;\n\n    // Injection de dépendance via le constructeur\n    public NotificationService(NotificationSender sender) {\n        this.sender = sender;\n    }\n\n    public void sendNotification(String message) {\n        sender.send(message);\n    }\n}\n",[8895],{"type":28,"tag":188,"props":8896,"children":8897},{"__ignoreMap":8},[8898,8906,8926,8954,8961,8968,8976,9004,9015,9050,9093,9100,9107,9114,9122,9150,9161,9196,9240,9247,9254,9261,9269,9288,9308,9315,9323,9354,9382,9389,9396,9431,9460,9468],{"type":28,"tag":192,"props":8899,"children":8900},{"class":194,"line":195},[8901],{"type":28,"tag":192,"props":8902,"children":8903},{"style":199},[8904],{"type":34,"value":8905},"// Interface pour les services d'envoi de notifications\n",{"type":28,"tag":192,"props":8907,"children":8908},{"class":194,"line":205},[8909,8913,8917,8922],{"type":28,"tag":192,"props":8910,"children":8911},{"style":209},[8912],{"type":34,"value":212},{"type":28,"tag":192,"props":8914,"children":8915},{"style":209},[8916],{"type":34,"value":5275},{"type":28,"tag":192,"props":8918,"children":8919},{"style":220},[8920],{"type":34,"value":8921}," NotificationSender",{"type":28,"tag":192,"props":8923,"children":8924},{"style":226},[8925],{"type":34,"value":229},{"type":28,"tag":192,"props":8927,"children":8928},{"class":194,"line":232},[8929,8933,8938,8942,8946,8950],{"type":28,"tag":192,"props":8930,"children":8931},{"style":209},[8932],{"type":34,"value":5292},{"type":28,"tag":192,"props":8934,"children":8935},{"style":325},[8936],{"type":34,"value":8937}," send",{"type":28,"tag":192,"props":8939,"children":8940},{"style":226},[8941],{"type":34,"value":332},{"type":28,"tag":192,"props":8943,"children":8944},{"style":241},[8945],{"type":34,"value":337},{"type":28,"tag":192,"props":8947,"children":8948},{"style":340},[8949],{"type":34,"value":8580},{"type":28,"tag":192,"props":8951,"children":8952},{"style":226},[8953],{"type":34,"value":752},{"type":28,"tag":192,"props":8955,"children":8956},{"class":194,"line":258},[8957],{"type":28,"tag":192,"props":8958,"children":8959},{"style":226},[8960],{"type":34,"value":588},{"type":28,"tag":192,"props":8962,"children":8963},{"class":194,"line":280},[8964],{"type":28,"tag":192,"props":8965,"children":8966},{"emptyLinePlaceholder":13},[8967],{"type":34,"value":313},{"type":28,"tag":192,"props":8969,"children":8970},{"class":194,"line":307},[8971],{"type":28,"tag":192,"props":8972,"children":8973},{"style":199},[8974],{"type":34,"value":8975},"// Implémentation pour l'email\n",{"type":28,"tag":192,"props":8977,"children":8978},{"class":194,"line":316},[8979,8983,8987,8992,8996,9000],{"type":28,"tag":192,"props":8980,"children":8981},{"style":209},[8982],{"type":34,"value":212},{"type":28,"tag":192,"props":8984,"children":8985},{"style":209},[8986],{"type":34,"value":217},{"type":28,"tag":192,"props":8988,"children":8989},{"style":220},[8990],{"type":34,"value":8991}," EmailSender",{"type":28,"tag":192,"props":8993,"children":8994},{"style":209},[8995],{"type":34,"value":5343},{"type":28,"tag":192,"props":8997,"children":8998},{"style":220},[8999],{"type":34,"value":8921},{"type":28,"tag":192,"props":9001,"children":9002},{"style":226},[9003],{"type":34,"value":229},{"type":28,"tag":192,"props":9005,"children":9006},{"class":194,"line":367},[9007,9011],{"type":28,"tag":192,"props":9008,"children":9009},{"style":667},[9010],{"type":34,"value":5359},{"type":28,"tag":192,"props":9012,"children":9013},{"style":673},[9014],{"type":34,"value":5364},{"type":28,"tag":192,"props":9016,"children":9017},{"class":194,"line":401},[9018,9022,9026,9030,9034,9038,9042,9046],{"type":28,"tag":192,"props":9019,"children":9020},{"style":209},[9021],{"type":34,"value":322},{"type":28,"tag":192,"props":9023,"children":9024},{"style":209},[9025],{"type":34,"value":688},{"type":28,"tag":192,"props":9027,"children":9028},{"style":325},[9029],{"type":34,"value":8937},{"type":28,"tag":192,"props":9031,"children":9032},{"style":226},[9033],{"type":34,"value":332},{"type":28,"tag":192,"props":9035,"children":9036},{"style":241},[9037],{"type":34,"value":337},{"type":28,"tag":192,"props":9039,"children":9040},{"style":340},[9041],{"type":34,"value":8580},{"type":28,"tag":192,"props":9043,"children":9044},{"style":226},[9045],{"type":34,"value":360},{"type":28,"tag":192,"props":9047,"children":9048},{"style":226},[9049],{"type":34,"value":229},{"type":28,"tag":192,"props":9051,"children":9052},{"class":194,"line":430},[9053,9057,9061,9065,9069,9073,9077,9081,9085,9089],{"type":28,"tag":192,"props":9054,"children":9055},{"style":247},[9056],{"type":34,"value":4327},{"type":28,"tag":192,"props":9058,"children":9059},{"style":226},[9060],{"type":34,"value":379},{"type":28,"tag":192,"props":9062,"children":9063},{"style":247},[9064],{"type":34,"value":2673},{"type":28,"tag":192,"props":9066,"children":9067},{"style":226},[9068],{"type":34,"value":379},{"type":28,"tag":192,"props":9070,"children":9071},{"style":325},[9072],{"type":34,"value":2682},{"type":28,"tag":192,"props":9074,"children":9075},{"style":226},[9076],{"type":34,"value":332},{"type":28,"tag":192,"props":9078,"children":9079},{"style":734},[9080],{"type":34,"value":8620},{"type":28,"tag":192,"props":9082,"children":9083},{"style":387},[9084],{"type":34,"value":2696},{"type":28,"tag":192,"props":9086,"children":9087},{"style":247},[9088],{"type":34,"value":8580},{"type":28,"tag":192,"props":9090,"children":9091},{"style":226},[9092],{"type":34,"value":752},{"type":28,"tag":192,"props":9094,"children":9095},{"class":194,"line":439},[9096],{"type":28,"tag":192,"props":9097,"children":9098},{"style":226},[9099],{"type":34,"value":445},{"type":28,"tag":192,"props":9101,"children":9102},{"class":194,"line":448},[9103],{"type":28,"tag":192,"props":9104,"children":9105},{"style":226},[9106],{"type":34,"value":588},{"type":28,"tag":192,"props":9108,"children":9109},{"class":194,"line":456},[9110],{"type":28,"tag":192,"props":9111,"children":9112},{"emptyLinePlaceholder":13},[9113],{"type":34,"value":313},{"type":28,"tag":192,"props":9115,"children":9116},{"class":194,"line":482},[9117],{"type":28,"tag":192,"props":9118,"children":9119},{"style":199},[9120],{"type":34,"value":9121},"// Implémentation pour SMS\n",{"type":28,"tag":192,"props":9123,"children":9124},{"class":194,"line":499},[9125,9129,9133,9138,9142,9146],{"type":28,"tag":192,"props":9126,"children":9127},{"style":209},[9128],{"type":34,"value":212},{"type":28,"tag":192,"props":9130,"children":9131},{"style":209},[9132],{"type":34,"value":217},{"type":28,"tag":192,"props":9134,"children":9135},{"style":220},[9136],{"type":34,"value":9137}," SMSSender",{"type":28,"tag":192,"props":9139,"children":9140},{"style":209},[9141],{"type":34,"value":5343},{"type":28,"tag":192,"props":9143,"children":9144},{"style":220},[9145],{"type":34,"value":8921},{"type":28,"tag":192,"props":9147,"children":9148},{"style":226},[9149],{"type":34,"value":229},{"type":28,"tag":192,"props":9151,"children":9152},{"class":194,"line":507},[9153,9157],{"type":28,"tag":192,"props":9154,"children":9155},{"style":667},[9156],{"type":34,"value":5359},{"type":28,"tag":192,"props":9158,"children":9159},{"style":673},[9160],{"type":34,"value":5364},{"type":28,"tag":192,"props":9162,"children":9163},{"class":194,"line":515},[9164,9168,9172,9176,9180,9184,9188,9192],{"type":28,"tag":192,"props":9165,"children":9166},{"style":209},[9167],{"type":34,"value":322},{"type":28,"tag":192,"props":9169,"children":9170},{"style":209},[9171],{"type":34,"value":688},{"type":28,"tag":192,"props":9173,"children":9174},{"style":325},[9175],{"type":34,"value":8937},{"type":28,"tag":192,"props":9177,"children":9178},{"style":226},[9179],{"type":34,"value":332},{"type":28,"tag":192,"props":9181,"children":9182},{"style":241},[9183],{"type":34,"value":337},{"type":28,"tag":192,"props":9185,"children":9186},{"style":340},[9187],{"type":34,"value":8580},{"type":28,"tag":192,"props":9189,"children":9190},{"style":226},[9191],{"type":34,"value":360},{"type":28,"tag":192,"props":9193,"children":9194},{"style":226},[9195],{"type":34,"value":229},{"type":28,"tag":192,"props":9197,"children":9198},{"class":194,"line":540},[9199,9203,9207,9211,9215,9219,9223,9228,9232,9236],{"type":28,"tag":192,"props":9200,"children":9201},{"style":247},[9202],{"type":34,"value":4327},{"type":28,"tag":192,"props":9204,"children":9205},{"style":226},[9206],{"type":34,"value":379},{"type":28,"tag":192,"props":9208,"children":9209},{"style":247},[9210],{"type":34,"value":2673},{"type":28,"tag":192,"props":9212,"children":9213},{"style":226},[9214],{"type":34,"value":379},{"type":28,"tag":192,"props":9216,"children":9217},{"style":325},[9218],{"type":34,"value":2682},{"type":28,"tag":192,"props":9220,"children":9221},{"style":226},[9222],{"type":34,"value":332},{"type":28,"tag":192,"props":9224,"children":9225},{"style":734},[9226],{"type":34,"value":9227},"\"Envoi du SMS : \"",{"type":28,"tag":192,"props":9229,"children":9230},{"style":387},[9231],{"type":34,"value":2696},{"type":28,"tag":192,"props":9233,"children":9234},{"style":247},[9235],{"type":34,"value":8580},{"type":28,"tag":192,"props":9237,"children":9238},{"style":226},[9239],{"type":34,"value":752},{"type":28,"tag":192,"props":9241,"children":9242},{"class":194,"line":556},[9243],{"type":28,"tag":192,"props":9244,"children":9245},{"style":226},[9246],{"type":34,"value":445},{"type":28,"tag":192,"props":9248,"children":9249},{"class":194,"line":564},[9250],{"type":28,"tag":192,"props":9251,"children":9252},{"style":226},[9253],{"type":34,"value":588},{"type":28,"tag":192,"props":9255,"children":9256},{"class":194,"line":573},[9257],{"type":28,"tag":192,"props":9258,"children":9259},{"emptyLinePlaceholder":13},[9260],{"type":34,"value":313},{"type":28,"tag":192,"props":9262,"children":9263},{"class":194,"line":582},[9264],{"type":28,"tag":192,"props":9265,"children":9266},{"style":199},[9267],{"type":34,"value":9268},"// Service de notification utilisant l'interface NotificationSender\n",{"type":28,"tag":192,"props":9270,"children":9271},{"class":194,"line":5580},[9272,9276,9280,9284],{"type":28,"tag":192,"props":9273,"children":9274},{"style":209},[9275],{"type":34,"value":212},{"type":28,"tag":192,"props":9277,"children":9278},{"style":209},[9279],{"type":34,"value":217},{"type":28,"tag":192,"props":9281,"children":9282},{"style":220},[9283],{"type":34,"value":8669},{"type":28,"tag":192,"props":9285,"children":9286},{"style":226},[9287],{"type":34,"value":229},{"type":28,"tag":192,"props":9289,"children":9290},{"class":194,"line":5600},[9291,9295,9299,9304],{"type":28,"tag":192,"props":9292,"children":9293},{"style":209},[9294],{"type":34,"value":238},{"type":28,"tag":192,"props":9296,"children":9297},{"style":241},[9298],{"type":34,"value":8921},{"type":28,"tag":192,"props":9300,"children":9301},{"style":247},[9302],{"type":34,"value":9303}," sender",{"type":28,"tag":192,"props":9305,"children":9306},{"style":226},[9307],{"type":34,"value":255},{"type":28,"tag":192,"props":9309,"children":9310},{"class":194,"line":5638},[9311],{"type":28,"tag":192,"props":9312,"children":9313},{"emptyLinePlaceholder":13},[9314],{"type":34,"value":313},{"type":28,"tag":192,"props":9316,"children":9317},{"class":194,"line":5660},[9318],{"type":28,"tag":192,"props":9319,"children":9320},{"style":199},[9321],{"type":34,"value":9322},"    // Injection de dépendance via le constructeur\n",{"type":28,"tag":192,"props":9324,"children":9325},{"class":194,"line":5668},[9326,9330,9334,9338,9342,9346,9350],{"type":28,"tag":192,"props":9327,"children":9328},{"style":209},[9329],{"type":34,"value":322},{"type":28,"tag":192,"props":9331,"children":9332},{"style":325},[9333],{"type":34,"value":8669},{"type":28,"tag":192,"props":9335,"children":9336},{"style":226},[9337],{"type":34,"value":332},{"type":28,"tag":192,"props":9339,"children":9340},{"style":241},[9341],{"type":34,"value":8888},{"type":28,"tag":192,"props":9343,"children":9344},{"style":340},[9345],{"type":34,"value":9303},{"type":28,"tag":192,"props":9347,"children":9348},{"style":226},[9349],{"type":34,"value":360},{"type":28,"tag":192,"props":9351,"children":9352},{"style":226},[9353],{"type":34,"value":229},{"type":28,"tag":192,"props":9355,"children":9356},{"class":194,"line":6718},[9357,9361,9365,9370,9374,9378],{"type":28,"tag":192,"props":9358,"children":9359},{"style":371},[9360],{"type":34,"value":374},{"type":28,"tag":192,"props":9362,"children":9363},{"style":226},[9364],{"type":34,"value":379},{"type":28,"tag":192,"props":9366,"children":9367},{"style":247},[9368],{"type":34,"value":9369},"sender ",{"type":28,"tag":192,"props":9371,"children":9372},{"style":387},[9373],{"type":34,"value":390},{"type":28,"tag":192,"props":9375,"children":9376},{"style":247},[9377],{"type":34,"value":9303},{"type":28,"tag":192,"props":9379,"children":9380},{"style":226},[9381],{"type":34,"value":255},{"type":28,"tag":192,"props":9383,"children":9384},{"class":194,"line":6754},[9385],{"type":28,"tag":192,"props":9386,"children":9387},{"style":226},[9388],{"type":34,"value":445},{"type":28,"tag":192,"props":9390,"children":9391},{"class":194,"line":6782},[9392],{"type":28,"tag":192,"props":9393,"children":9394},{"emptyLinePlaceholder":13},[9395],{"type":34,"value":313},{"type":28,"tag":192,"props":9397,"children":9398},{"class":194,"line":6814},[9399,9403,9407,9411,9415,9419,9423,9427],{"type":28,"tag":192,"props":9400,"children":9401},{"style":209},[9402],{"type":34,"value":322},{"type":28,"tag":192,"props":9404,"children":9405},{"style":209},[9406],{"type":34,"value":688},{"type":28,"tag":192,"props":9408,"children":9409},{"style":325},[9410],{"type":34,"value":8781},{"type":28,"tag":192,"props":9412,"children":9413},{"style":226},[9414],{"type":34,"value":332},{"type":28,"tag":192,"props":9416,"children":9417},{"style":241},[9418],{"type":34,"value":337},{"type":28,"tag":192,"props":9420,"children":9421},{"style":340},[9422],{"type":34,"value":8580},{"type":28,"tag":192,"props":9424,"children":9425},{"style":226},[9426],{"type":34,"value":360},{"type":28,"tag":192,"props":9428,"children":9429},{"style":226},[9430],{"type":34,"value":229},{"type":28,"tag":192,"props":9432,"children":9433},{"class":194,"line":6822},[9434,9439,9443,9448,9452,9456],{"type":28,"tag":192,"props":9435,"children":9436},{"style":247},[9437],{"type":34,"value":9438},"        sender",{"type":28,"tag":192,"props":9440,"children":9441},{"style":226},[9442],{"type":34,"value":379},{"type":28,"tag":192,"props":9444,"children":9445},{"style":325},[9446],{"type":34,"value":9447},"send",{"type":28,"tag":192,"props":9449,"children":9450},{"style":226},[9451],{"type":34,"value":332},{"type":28,"tag":192,"props":9453,"children":9454},{"style":247},[9455],{"type":34,"value":8827},{"type":28,"tag":192,"props":9457,"children":9458},{"style":226},[9459],{"type":34,"value":752},{"type":28,"tag":192,"props":9461,"children":9463},{"class":194,"line":9462},33,[9464],{"type":28,"tag":192,"props":9465,"children":9466},{"style":226},[9467],{"type":34,"value":445},{"type":28,"tag":192,"props":9469,"children":9471},{"class":194,"line":9470},34,[9472],{"type":28,"tag":192,"props":9473,"children":9474},{"style":226},[9475],{"type":34,"value":588},{"type":28,"tag":44,"props":9477,"children":9478},{},[9479,9481,9486,9488,9494,9496,9501,9503,9509,9511,9516],{"type":34,"value":9480},"Maintenant, ",{"type":28,"tag":188,"props":9482,"children":9484},{"className":9483},[],[9485],{"type":34,"value":8504},{"type":34,"value":9487}," ne dépend plus d'une implémentation concrète comme ",{"type":28,"tag":188,"props":9489,"children":9491},{"className":9490},[],[9492],{"type":34,"value":9493},"EmailSender",{"type":34,"value":9495},", mais d'une abstraction (",{"type":28,"tag":188,"props":9497,"children":9499},{"className":9498},[],[9500],{"type":34,"value":8888},{"type":34,"value":9502},"). Changer d'implémentation devient trivial : pour envoyer des SMS à la place des emails, il suffit de passer un ",{"type":28,"tag":188,"props":9504,"children":9506},{"className":9505},[],[9507],{"type":34,"value":9508},"SMSSender",{"type":34,"value":9510}," au lieu d'un ",{"type":28,"tag":188,"props":9512,"children":9514},{"className":9513},[],[9515],{"type":34,"value":9493},{"type":34,"value":5685},{"type":28,"tag":181,"props":9518,"children":9520},{"className":183,"code":9519,"language":185,"meta":8,"style":8},"public class Main {\n    public static void main(String[] args) {\n        // Envoi de notification par email\n        NotificationSender emailSender = new EmailSender();\n        NotificationService notificationService = new NotificationService(emailSender);\n        notificationService.sendNotification(\"Message par email\");\n\n        // Envoi de notification par SMS\n        NotificationSender smsSender = new SMSSender();\n        NotificationService smsNotificationService\n\n = new NotificationService(smsSender);\n        smsNotificationService.sendNotification(\"Message par SMS\");\n    }\n}\n",[9521],{"type":28,"tag":188,"props":9522,"children":9523},{"__ignoreMap":8},[9524,9543,9586,9594,9623,9661,9691,9698,9706,9734,9746,9753,9782,9811,9818],{"type":28,"tag":192,"props":9525,"children":9526},{"class":194,"line":195},[9527,9531,9535,9539],{"type":28,"tag":192,"props":9528,"children":9529},{"style":209},[9530],{"type":34,"value":212},{"type":28,"tag":192,"props":9532,"children":9533},{"style":209},[9534],{"type":34,"value":217},{"type":28,"tag":192,"props":9536,"children":9537},{"style":220},[9538],{"type":34,"value":5846},{"type":28,"tag":192,"props":9540,"children":9541},{"style":226},[9542],{"type":34,"value":229},{"type":28,"tag":192,"props":9544,"children":9545},{"class":194,"line":205},[9546,9550,9554,9558,9562,9566,9570,9574,9578,9582],{"type":28,"tag":192,"props":9547,"children":9548},{"style":209},[9549],{"type":34,"value":322},{"type":28,"tag":192,"props":9551,"children":9552},{"style":209},[9553],{"type":34,"value":5862},{"type":28,"tag":192,"props":9555,"children":9556},{"style":209},[9557],{"type":34,"value":688},{"type":28,"tag":192,"props":9559,"children":9560},{"style":325},[9561],{"type":34,"value":5871},{"type":28,"tag":192,"props":9563,"children":9564},{"style":226},[9565],{"type":34,"value":332},{"type":28,"tag":192,"props":9567,"children":9568},{"style":209},[9569],{"type":34,"value":337},{"type":28,"tag":192,"props":9571,"children":9572},{"style":226},[9573],{"type":34,"value":5884},{"type":28,"tag":192,"props":9575,"children":9576},{"style":340},[9577],{"type":34,"value":5889},{"type":28,"tag":192,"props":9579,"children":9580},{"style":226},[9581],{"type":34,"value":360},{"type":28,"tag":192,"props":9583,"children":9584},{"style":226},[9585],{"type":34,"value":229},{"type":28,"tag":192,"props":9587,"children":9588},{"class":194,"line":232},[9589],{"type":28,"tag":192,"props":9590,"children":9591},{"style":199},[9592],{"type":34,"value":9593},"        // Envoi de notification par email\n",{"type":28,"tag":192,"props":9595,"children":9596},{"class":194,"line":258},[9597,9602,9607,9611,9615,9619],{"type":28,"tag":192,"props":9598,"children":9599},{"style":241},[9600],{"type":34,"value":9601},"        NotificationSender",{"type":28,"tag":192,"props":9603,"children":9604},{"style":247},[9605],{"type":34,"value":9606}," emailSender ",{"type":28,"tag":192,"props":9608,"children":9609},{"style":387},[9610],{"type":34,"value":390},{"type":28,"tag":192,"props":9612,"children":9613},{"style":209},[9614],{"type":34,"value":723},{"type":28,"tag":192,"props":9616,"children":9617},{"style":325},[9618],{"type":34,"value":8991},{"type":28,"tag":192,"props":9620,"children":9621},{"style":226},[9622],{"type":34,"value":1973},{"type":28,"tag":192,"props":9624,"children":9625},{"class":194,"line":280},[9626,9631,9636,9640,9644,9648,9652,9657],{"type":28,"tag":192,"props":9627,"children":9628},{"style":241},[9629],{"type":34,"value":9630},"        NotificationService",{"type":28,"tag":192,"props":9632,"children":9633},{"style":247},[9634],{"type":34,"value":9635}," notificationService ",{"type":28,"tag":192,"props":9637,"children":9638},{"style":387},[9639],{"type":34,"value":390},{"type":28,"tag":192,"props":9641,"children":9642},{"style":209},[9643],{"type":34,"value":723},{"type":28,"tag":192,"props":9645,"children":9646},{"style":325},[9647],{"type":34,"value":8669},{"type":28,"tag":192,"props":9649,"children":9650},{"style":226},[9651],{"type":34,"value":332},{"type":28,"tag":192,"props":9653,"children":9654},{"style":247},[9655],{"type":34,"value":9656},"emailSender",{"type":28,"tag":192,"props":9658,"children":9659},{"style":226},[9660],{"type":34,"value":752},{"type":28,"tag":192,"props":9662,"children":9663},{"class":194,"line":307},[9664,9669,9673,9678,9682,9687],{"type":28,"tag":192,"props":9665,"children":9666},{"style":247},[9667],{"type":34,"value":9668},"        notificationService",{"type":28,"tag":192,"props":9670,"children":9671},{"style":226},[9672],{"type":34,"value":379},{"type":28,"tag":192,"props":9674,"children":9675},{"style":325},[9676],{"type":34,"value":9677},"sendNotification",{"type":28,"tag":192,"props":9679,"children":9680},{"style":226},[9681],{"type":34,"value":332},{"type":28,"tag":192,"props":9683,"children":9684},{"style":734},[9685],{"type":34,"value":9686},"\"Message par email\"",{"type":28,"tag":192,"props":9688,"children":9689},{"style":226},[9690],{"type":34,"value":752},{"type":28,"tag":192,"props":9692,"children":9693},{"class":194,"line":316},[9694],{"type":28,"tag":192,"props":9695,"children":9696},{"emptyLinePlaceholder":13},[9697],{"type":34,"value":313},{"type":28,"tag":192,"props":9699,"children":9700},{"class":194,"line":367},[9701],{"type":28,"tag":192,"props":9702,"children":9703},{"style":199},[9704],{"type":34,"value":9705},"        // Envoi de notification par SMS\n",{"type":28,"tag":192,"props":9707,"children":9708},{"class":194,"line":401},[9709,9713,9718,9722,9726,9730],{"type":28,"tag":192,"props":9710,"children":9711},{"style":241},[9712],{"type":34,"value":9601},{"type":28,"tag":192,"props":9714,"children":9715},{"style":247},[9716],{"type":34,"value":9717}," smsSender ",{"type":28,"tag":192,"props":9719,"children":9720},{"style":387},[9721],{"type":34,"value":390},{"type":28,"tag":192,"props":9723,"children":9724},{"style":209},[9725],{"type":34,"value":723},{"type":28,"tag":192,"props":9727,"children":9728},{"style":325},[9729],{"type":34,"value":9137},{"type":28,"tag":192,"props":9731,"children":9732},{"style":226},[9733],{"type":34,"value":1973},{"type":28,"tag":192,"props":9735,"children":9736},{"class":194,"line":430},[9737,9741],{"type":28,"tag":192,"props":9738,"children":9739},{"style":241},[9740],{"type":34,"value":9630},{"type":28,"tag":192,"props":9742,"children":9743},{"style":247},[9744],{"type":34,"value":9745}," smsNotificationService\n",{"type":28,"tag":192,"props":9747,"children":9748},{"class":194,"line":439},[9749],{"type":28,"tag":192,"props":9750,"children":9751},{"emptyLinePlaceholder":13},[9752],{"type":34,"value":313},{"type":28,"tag":192,"props":9754,"children":9755},{"class":194,"line":448},[9756,9761,9765,9769,9773,9778],{"type":28,"tag":192,"props":9757,"children":9758},{"style":387},[9759],{"type":34,"value":9760}," =",{"type":28,"tag":192,"props":9762,"children":9763},{"style":209},[9764],{"type":34,"value":723},{"type":28,"tag":192,"props":9766,"children":9767},{"style":325},[9768],{"type":34,"value":8669},{"type":28,"tag":192,"props":9770,"children":9771},{"style":226},[9772],{"type":34,"value":332},{"type":28,"tag":192,"props":9774,"children":9775},{"style":247},[9776],{"type":34,"value":9777},"smsSender",{"type":28,"tag":192,"props":9779,"children":9780},{"style":226},[9781],{"type":34,"value":752},{"type":28,"tag":192,"props":9783,"children":9784},{"class":194,"line":456},[9785,9790,9794,9798,9802,9807],{"type":28,"tag":192,"props":9786,"children":9787},{"style":247},[9788],{"type":34,"value":9789},"        smsNotificationService",{"type":28,"tag":192,"props":9791,"children":9792},{"style":226},[9793],{"type":34,"value":379},{"type":28,"tag":192,"props":9795,"children":9796},{"style":325},[9797],{"type":34,"value":9677},{"type":28,"tag":192,"props":9799,"children":9800},{"style":226},[9801],{"type":34,"value":332},{"type":28,"tag":192,"props":9803,"children":9804},{"style":734},[9805],{"type":34,"value":9806},"\"Message par SMS\"",{"type":28,"tag":192,"props":9808,"children":9809},{"style":226},[9810],{"type":34,"value":752},{"type":28,"tag":192,"props":9812,"children":9813},{"class":194,"line":482},[9814],{"type":28,"tag":192,"props":9815,"children":9816},{"style":226},[9817],{"type":34,"value":445},{"type":28,"tag":192,"props":9819,"children":9820},{"class":194,"line":499},[9821],{"type":28,"tag":192,"props":9822,"children":9823},{"style":226},[9824],{"type":34,"value":588},{"type":28,"tag":83,"props":9826,"children":9827},{},[],{"type":28,"tag":1841,"props":9829,"children":9830},{"type":1843},[9831],{"type":28,"tag":44,"props":9832,"children":9833},{},[9834,9839],{"type":28,"tag":55,"props":9835,"children":9836},{},[9837],{"type":34,"value":9838},"Injectez vos dépendances",{"type":34,"value":9840}," via des interfaces ou des classes abstraites plutôt que d'utiliser des classes concrètes. Cela rendra vos modules de haut niveau plus flexibles et plus faciles à modifier à l'avenir.",{"type":28,"tag":29,"props":9842,"children":9844},{"id":9843},"_6-exemples-concrets-de-chaque-principe-en-java",[9845],{"type":34,"value":9846},"6. Exemples concrets de chaque principe en Java",{"type":28,"tag":1644,"props":9848,"children":9849},{},[9850,9874,9891,9922,9961],{"type":28,"tag":148,"props":9851,"children":9852},{},[9853,9858,9859],{"type":28,"tag":55,"props":9854,"children":9855},{},[9856],{"type":34,"value":9857},"Single Responsibility Principle (SRP)",{"type":34,"value":5685},{"type":28,"tag":144,"props":9860,"children":9861},{},[9862],{"type":28,"tag":148,"props":9863,"children":9864},{},[9865,9867,9872],{"type":34,"value":9866},"Exemple : Une classe ",{"type":28,"tag":188,"props":9868,"children":9870},{"className":9869},[],[9871],{"type":34,"value":4145},{"type":34,"value":9873}," qui génère des rapports ne doit pas aussi gérer l'enregistrement des fichiers PDF. Divisez ces responsabilités en deux classes distinctes.",{"type":28,"tag":148,"props":9875,"children":9876},{},[9877,9882,9883],{"type":28,"tag":55,"props":9878,"children":9879},{},[9880],{"type":34,"value":9881},"Open/Closed Principle (OCP)",{"type":34,"value":5685},{"type":28,"tag":144,"props":9884,"children":9885},{},[9886],{"type":28,"tag":148,"props":9887,"children":9888},{},[9889],{"type":34,"value":9890},"Exemple : Une classe de traitement de paiements qui supporte plusieurs méthodes de paiement (carte bancaire, PayPal, e-wallet) doit être extensible via de nouvelles implémentations de méthodes de paiement sans modifier la classe de base.",{"type":28,"tag":148,"props":9892,"children":9893},{},[9894,9899,9900],{"type":28,"tag":55,"props":9895,"children":9896},{},[9897],{"type":34,"value":9898},"Liskov Substitution Principle (LSP)",{"type":34,"value":5685},{"type":28,"tag":144,"props":9901,"children":9902},{},[9903],{"type":28,"tag":148,"props":9904,"children":9905},{},[9906,9908,9913,9915,9920],{"type":34,"value":9907},"Exemple : Évitez d'utiliser l'héritage entre une classe ",{"type":28,"tag":188,"props":9909,"children":9911},{"className":9910},[],[9912],{"type":34,"value":6208},{"type":34,"value":9914}," et une classe ",{"type":28,"tag":188,"props":9916,"children":9918},{"className":9917},[],[9919],{"type":34,"value":6216},{"type":34,"value":9921}," si leurs comportements sont fondamentalement différents (comme les changements indépendants de largeur et de hauteur).",{"type":28,"tag":148,"props":9923,"children":9924},{},[9925,9930,9931],{"type":28,"tag":55,"props":9926,"children":9927},{},[9928],{"type":34,"value":9929},"Interface Segregation Principle (ISP)",{"type":34,"value":5685},{"type":28,"tag":144,"props":9932,"children":9933},{},[9934],{"type":28,"tag":148,"props":9935,"children":9936},{},[9937,9939,9945,9946,9952,9954,9959],{"type":34,"value":9938},"Exemple : Créez des interfaces spécifiques (",{"type":28,"tag":188,"props":9940,"children":9942},{"className":9941},[],[9943],{"type":34,"value":9944},"FlyingBird",{"type":34,"value":7524},{"type":28,"tag":188,"props":9947,"children":9949},{"className":9948},[],[9950],{"type":34,"value":9951},"SwimmingBird",{"type":34,"value":9953},", etc.) au lieu d'une seule interface générale ",{"type":28,"tag":188,"props":9955,"children":9957},{"className":9956},[],[9958],{"type":34,"value":7416},{"type":34,"value":9960}," qui oblige toutes les classes à implémenter des méthodes non pertinentes.",{"type":28,"tag":148,"props":9962,"children":9963},{},[9964,9969,9970],{"type":28,"tag":55,"props":9965,"children":9966},{},[9967],{"type":34,"value":9968},"Dependency Inversion Principle (DIP)",{"type":34,"value":5685},{"type":28,"tag":144,"props":9971,"children":9972},{},[9973],{"type":28,"tag":148,"props":9974,"children":9975},{},[9976,9978,9983,9985,9990],{"type":34,"value":9977},"Exemple : Au lieu de dépendre directement d'une classe ",{"type":28,"tag":188,"props":9979,"children":9981},{"className":9980},[],[9982],{"type":34,"value":8523},{"type":34,"value":9984},", utilisez une interface ",{"type":28,"tag":188,"props":9986,"children":9988},{"className":9987},[],[9989],{"type":34,"value":8888},{"type":34,"value":9991}," pour injecter des services d'envoi de notifications par email, SMS, etc.",{"type":28,"tag":120,"props":9993,"children":9995},{"cta":1327,"href":1328,"title":9994,"type":1330},"SOLID, ce sont 5 leviers : il en existe 100 pour coder propre",[9996],{"type":28,"tag":44,"props":9997,"children":9998},{},[9999],{"type":34,"value":10000},"Cet article détaille les cinq principes SOLID, mais bien écrire ne s'arrête pas là. Le Craft Bundle réunit les 100 pratiques que j'applique au quotidien pour garder un code lisible et faible en couplage, du nommage à la gestion des dépendances. Ce sont celles que l'IA ne vous apprendra jamais, parce qu'elle ne les a jamais vues tenir sur dix ans de production.",{"type":28,"tag":83,"props":10002,"children":10003},{},[],{"type":28,"tag":29,"props":10005,"children":10007},{"id":10006},"_7-faq-sur-les-principes-solid-en-java",[10008],{"type":34,"value":10009},"7. FAQ sur les principes SOLID en Java",{"type":28,"tag":1347,"props":10011,"children":10012},{},[10013,10018],{"type":28,"tag":1351,"props":10014,"children":10015},{},[10016],{"type":34,"value":10017},"Pourquoi appliquer les principes SOLID en Java ?",{"type":28,"tag":44,"props":10019,"children":10020},{},[10021],{"type":34,"value":10022},"Les principes SOLID conduisent à un code plus propre, plus modulaire et plus maintenable. Ils réduisent les risques de régression lors des modifications et rendent l'ajout de nouvelles fonctionnalités plus sûr.",{"type":28,"tag":1347,"props":10024,"children":10025},{},[10026,10031],{"type":28,"tag":1351,"props":10027,"children":10028},{},[10029],{"type":34,"value":10030},"Est-ce que les principes SOLID sont applicables à tous les projets Java ?",{"type":28,"tag":44,"props":10032,"children":10033},{},[10034],{"type":34,"value":10035},"Oui, du petit projet aux grands systèmes, ces principes aident à tenir la qualité du code. Évitez l'application zélée pour autant : utilisez le bon outil pour le bon problème : sur-abstraire vaut souvent pire que rien.",{"type":28,"tag":1347,"props":10037,"children":10038},{},[10039,10044],{"type":28,"tag":1351,"props":10040,"children":10041},{},[10042],{"type":34,"value":10043},"Quel est le principe SOLID le plus important ?",{"type":28,"tag":44,"props":10045,"children":10046},{},[10047],{"type":34,"value":10048},"Tous les principes sont importants, mais si vous débutez, le SRP (principe de responsabilité unique) et le OCP (principe ouvert/fermé) sont souvent les plus critiques pour améliorer la maintenabilité de votre code.",{"type":28,"tag":1347,"props":10050,"children":10051},{},[10052,10057],{"type":28,"tag":1351,"props":10053,"children":10054},{},[10055],{"type":34,"value":10056},"Comment appliquer SOLID dans un projet existant ?",{"type":28,"tag":44,"props":10058,"children":10059},{},[10060],{"type":34,"value":10061},"Appliquez progressivement les principes en identifiant les endroits où le code est fortement couplé ou difficile à maintenir. Refactorisez au fur et à mesure, en créant des abstractions et en séparant les responsabilités lorsque nécessaire.",{"type":28,"tag":83,"props":10063,"children":10064},{},[],{"type":28,"tag":120,"props":10066,"children":10067},{"cta":1444,"href":1445,"title":1446,"type":1447},[10068],{"type":28,"tag":44,"props":10069,"children":10070},{},[10071],{"type":34,"value":10072},"30 questions, 5 dimensions, score sur 100. Mesurez la maturité engineering de votre équipe et identifiez les 3 chantiers qui débloquent immédiatement votre vélocité.",{"type":28,"tag":1455,"props":10074,"children":10075},{},[10076],{"type":34,"value":1459},{"title":8,"searchDepth":205,"depth":205,"links":10078},[10079,10080,10081,10085,10089,10093,10097,10101,10102],{"id":3997,"depth":205,"text":4000},{"id":4088,"depth":205,"text":4091},{"id":4102,"depth":205,"text":4105,"children":10082},[10083,10084],{"id":4120,"depth":232,"text":4123},{"id":4131,"depth":232,"text":4134},{"id":4884,"depth":205,"text":4887,"children":10086},[10087,10088],{"id":4909,"depth":232,"text":4123},{"id":4919,"depth":232,"text":4134},{"id":6174,"depth":205,"text":6177,"children":10090},[10091,10092],{"id":6185,"depth":232,"text":4123},{"id":6195,"depth":232,"text":4134},{"id":7382,"depth":205,"text":7385,"children":10094},[10095,10096],{"id":7393,"depth":232,"text":4123},{"id":7403,"depth":232,"text":4134},{"id":8471,"depth":205,"text":8474,"children":10098},[10099,10100],{"id":8482,"depth":232,"text":4123},{"id":8492,"depth":232,"text":4134},{"id":9843,"depth":205,"text":9846},{"id":10006,"depth":205,"text":10009},"content:fr:architecture-craft:principes-solid-java-exemples.md","fr/architecture-craft/principes-solid-java-exemples.md","fr/architecture-craft/principes-solid-java-exemples",{"_path":4080,"_dir":3980,"_draft":7,"_partial":7,"_locale":8,"title":10107,"description":10108,"id":10109,"date":10110,"listed":13,"nocomments":7,"hidden":7,"categories":10111,"tags":10112,"cover":10113,"readingTime":10114,"body":10119,"_type":1471,"_id":13465,"_source":1473,"_file":13466,"_stem":13467,"_extension":1476},"Comprendre et appliquer le principe DIP en Java pour un code plus flexible","Découvrez comment le principe DIP (Dependency Inversion Principle) améliore la flexibilité et la maintenabilité de votre code Java. Apprenez à...",45,"2024-04-01",[1484],[1486,1487],"covers/articles/principe-dip.jpg",{"text":10115,"minutes":10116,"time":10117,"words":10118},"13 min read",12.14,728400,2428,{"type":25,"children":10120,"toc":13446},[10121,10127,10132,10151,10162,10165,10171,10187,10199,10210,10253,10262,10265,10274,10280,10298,10304,10309,10321,10327,10332,10354,10357,10401,10404,10410,10421,10427,10432,10741,10772,10778,10803,11385,11418,11706,11712,11724,11735,11750,11765,11768,11774,11798,11804,11822,11845,11848,11854,11859,11871,12228,12240,12266,12502,12514,12519,12774,12781,12874,12880,12917,13142,13155,13163,13166,13175,13178,13184,13202,13234,13260,13287,13300,13338,13382,13385,13389,13407,13412,13432,13442],{"type":28,"tag":29,"props":10122,"children":10124},{"id":10123},"introduction-au-dip-dependency-inversion-principle",[10125],{"type":34,"value":10126},"Introduction au DIP (Dependency Inversion Principle)",{"type":28,"tag":44,"props":10128,"children":10129},{},[10130],{"type":34,"value":10131},"Une petite modification dans un service ou une couche d'accès aux données, et c'est la cascade : tests cassés, modules qui ne compilent plus, dépendances absurdes entre classes de haut et de bas niveau. C'est le quotidien de la plupart des bases de code que j'audite.",{"type":28,"tag":44,"props":10133,"children":10134},{},[10135,10137,10142,10144,10149],{"type":34,"value":10136},"Le principe de l'inversion des dépendances (",{"type":28,"tag":55,"props":10138,"children":10139},{},[10140],{"type":34,"value":10141},"DIP",{"type":34,"value":10143},", Dependency Inversion Principle) attaque exactement cette ",{"type":28,"tag":55,"props":10145,"children":10146},{},[10147],{"type":34,"value":10148},"rigidité",{"type":34,"value":10150}," qui rend chaque modification coûteuse. Mieux modulariser, mieux tester, casser le couplage : c'est ce que le DIP apporte concrètement.",{"type":28,"tag":44,"props":10152,"children":10153},{},[10154,10156,10160],{"type":34,"value":10155},"Dans une grande DSI du secteur assurance, le couplage entre services métier et infrastructure retardait chaque livraison de plusieurs semaines. Appliquer le DIP a découplé les couches et raccourci les cycles. Cet article explique comment ce principe fonctionne, pourquoi il est central en Software Craftsmanship (formalisé par Robert C. Martin dans ",{"type":28,"tag":63,"props":10157,"children":10158},{},[10159],{"type":34,"value":4015},{"type":34,"value":10161},"), et comment l'appliquer dans vos projets Java.",{"type":28,"tag":83,"props":10163,"children":10164},{},[],{"type":28,"tag":29,"props":10166,"children":10168},{"id":10167},"pourquoi-le-dip-est-essentiel-dans-le-software-craftsmanship",[10169],{"type":34,"value":10170},"Pourquoi le DIP est essentiel dans le Software Craftsmanship",{"type":28,"tag":44,"props":10172,"children":10173},{},[10174,10175,10179,10181,10185],{"type":34,"value":1636},{"type":28,"tag":55,"props":10176,"children":10177},{},[10178],{"type":34,"value":1522},{"type":34,"value":10180}," repose sur l'idée que le code doit être traité comme un artisanat. Un bon code ne se limite pas à fonctionner ; il doit être propre, maintenable et flexible. C'est ici que le ",{"type":28,"tag":55,"props":10182,"children":10183},{},[10184],{"type":34,"value":10141},{"type":34,"value":10186}," joue un rôle crucial.",{"type":28,"tag":44,"props":10188,"children":10189},{},[10190,10192,10197],{"type":34,"value":10191},"Le principe de l'inversion des dépendances nous apprend que les modules de haut niveau ne doivent pas dépendre des modules de bas niveau. Au lieu de cela, tous deux doivent dépendre d’abstractions. De plus, ces abstractions ne doivent pas dépendre des détails d'implémentation, mais c'est plutôt ces détails qui doivent dépendre d’abstractions. Autrement dit, le DIP encourage la ",{"type":28,"tag":55,"props":10193,"children":10194},{},[10195],{"type":34,"value":10196},"séparation des préoccupations",{"type":34,"value":10198}," et aide à découpler les différentes parties du système.",{"type":28,"tag":44,"props":10200,"children":10201},{},[10202,10204,10208],{"type":34,"value":10203},"Voici pourquoi le DIP est essentiel dans une démarche de ",{"type":28,"tag":55,"props":10205,"children":10206},{},[10207],{"type":34,"value":1522},{"type":34,"value":10209}," :",{"type":28,"tag":144,"props":10211,"children":10212},{},[10213,10223,10233,10243],{"type":28,"tag":148,"props":10214,"children":10215},{},[10216,10221],{"type":28,"tag":55,"props":10217,"children":10218},{},[10219],{"type":34,"value":10220},"Réduction des couplages forts",{"type":34,"value":10222}," : le couplage fort entre modules est l'une des causes principales des bugs et des cauchemars de maintenance. Le DIP brise cette dépendance directe en intercalant des interfaces et des abstractions.",{"type":28,"tag":148,"props":10224,"children":10225},{},[10226,10231],{"type":28,"tag":55,"props":10227,"children":10228},{},[10229],{"type":34,"value":10230},"Facilite les tests",{"type":34,"value":10232}," : un code qui suit le DIP devient testable. Remplacer une implémentation concrète par un mock ou un stub se fait sans rien casser dans les modules de haut niveau.",{"type":28,"tag":148,"props":10234,"children":10235},{},[10236,10241],{"type":28,"tag":55,"props":10237,"children":10238},{},[10239],{"type":34,"value":10240},"Encourage la réutilisabilité",{"type":34,"value":10242}," : avec des modules découplés, certains composants se réutilisent directement dans d'autres contextes, sans rien toucher au reste du système.",{"type":28,"tag":148,"props":10244,"children":10245},{},[10246,10251],{"type":28,"tag":55,"props":10247,"children":10248},{},[10249],{"type":34,"value":10250},"Simplification des évolutions",{"type":34,"value":10252}," : faire évoluer une implémentation devient une opération locale. Modifier ou remplacer une classe de bas niveau n'impacte plus les modules de haut niveau, et les cycles de développement raccourcissent.",{"type":28,"tag":1841,"props":10254,"children":10256},{"type":10255},"warning",[10257],{"type":28,"tag":44,"props":10258,"children":10259},{},[10260],{"type":34,"value":10261},"Si vous négligez d’appliquer le DIP, vous risquez d’avoir un code rigide où la moindre modification entraînera des effets secondaires inattendus dans plusieurs modules. Cela rendra votre code difficile à maintenir à long terme.",{"type":28,"tag":83,"props":10263,"children":10264},{},[],{"type":28,"tag":120,"props":10266,"children":10268},{"cta":122,"href":123,"title":10267,"type":125},"Vous voulez savoir placer une abstraction là où elle découple vraiment, et pas partout par réflexe ?",[10269],{"type":28,"tag":44,"props":10270,"children":10271},{},[10272],{"type":34,"value":10273},"Inverser une dépendance au bon endroit, ça ne s'apprend pas en mémorisant la définition du DIP : ça se travaille sur votre vrai code. En mentoring 1:1, je relis vos services et vos couches d'accès avec vous, on identifie les couplages qui font mal et ceux qui peuvent rester, et vous repartez avec le réflexe de concevoir l'interface avant l'implémentation.",{"type":28,"tag":29,"props":10275,"children":10277},{"id":10276},"les-deux-règles-principales-du-dip",[10278],{"type":34,"value":10279},"Les deux règles principales du DIP",{"type":28,"tag":44,"props":10281,"children":10282},{},[10283,10284,10288,10290,10296],{"type":34,"value":1636},{"type":28,"tag":55,"props":10285,"children":10286},{},[10287],{"type":34,"value":10141},{"type":34,"value":10289}," (Dependency Inversion Principle) repose sur deux règles simples mais puissantes. En les respectant, vous pourrez transformer votre code en un ensemble de modules bien découplés et faciles à maintenir. C'est ce même principe qui est au cœur de la ",{"type":28,"tag":103,"props":10291,"children":10293},{"href":10292},"/fr/architecture-craft/clean-architecture-3-regles",[10294],{"type":34,"value":10295},"Clean Architecture",{"type":34,"value":10297}," : les flèches de dépendance pointent toujours vers le domaine métier, jamais vers l'infrastructure. Voyons ces deux règles en détail :",{"type":28,"tag":37,"props":10299,"children":10301},{"id":10300},"_1-les-modules-de-haut-niveau-ne-doivent-pas-dépendre-des-modules-de-bas-niveau-tous-deux-doivent-dépendre-dabstractions",[10302],{"type":34,"value":10303},"1. Les modules de haut niveau ne doivent pas dépendre des modules de bas niveau. Tous deux doivent dépendre d'abstractions.",{"type":28,"tag":44,"props":10305,"children":10306},{},[10307],{"type":34,"value":10308},"Dans un système classique, les classes de haut niveau (comme les contrôleurs ou les services principaux) ont souvent des dépendances directes sur des classes de bas niveau (par exemple, les couches d’accès aux données). Cela crée une forte interdépendance entre ces différentes couches. Le problème ici, c'est que toute modification dans les détails d'implémentation des classes de bas niveau va entraîner des changements dans les classes de haut niveau.",{"type":28,"tag":44,"props":10310,"children":10311},{},[10312,10314,10319],{"type":34,"value":10313},"En appliquant le DIP, vous devez introduire des ",{"type":28,"tag":55,"props":10315,"children":10316},{},[10317],{"type":34,"value":10318},"interfaces ou des abstractions",{"type":34,"value":10320}," entre ces couches. Ainsi, les classes de haut et de bas niveau ne communiquent plus directement. Par exemple, une classe de service ne devrait pas connaître la classe d’accès aux données spécifique, mais plutôt dépendre d’une interface générale pour interagir avec la base de données.",{"type":28,"tag":37,"props":10322,"children":10324},{"id":10323},"_2-les-abstractions-ne-doivent-pas-dépendre-des-détails-ce-sont-les-détails-qui-doivent-dépendre-des-abstractions",[10325],{"type":34,"value":10326},"2. Les abstractions ne doivent pas dépendre des détails. Ce sont les détails qui doivent dépendre des abstractions.",{"type":28,"tag":44,"props":10328,"children":10329},{},[10330],{"type":34,"value":10331},"Dans cette seconde règle, il s’agit d’inverser la dépendance traditionnelle. Autrement dit, les interfaces et abstractions doivent être stables et définir des comportements génériques, tandis que les classes concrètes (les \"détails\") doivent dépendre de ces abstractions.",{"type":28,"tag":1841,"props":10333,"children":10334},{"type":1843},[10335],{"type":28,"tag":44,"props":10336,"children":10337},{},[10338,10340,10345,10347,10352],{"type":34,"value":10339},"Pour respecter ces deux règles, je vous recommande de toujours concevoir des ",{"type":28,"tag":55,"props":10341,"children":10342},{},[10343],{"type":34,"value":10344},"interfaces",{"type":34,"value":10346}," ou des ",{"type":28,"tag":55,"props":10348,"children":10349},{},[10350],{"type":34,"value":10351},"abstractions",{"type":34,"value":10353}," avant de créer des implémentations concrètes. Cela vous permet d’anticiper les changements et d’introduire de la flexibilité dans votre code.",{"type":28,"tag":83,"props":10355,"children":10356},{},[],{"type":28,"tag":44,"props":10358,"children":10359},{},[10360,10362,10368,10370,10376,10378,10384,10386,10392,10393,10399],{"type":34,"value":10361},"Prenons un exemple concret : avec une interface ",{"type":28,"tag":188,"props":10363,"children":10365},{"className":10364},[],[10366],{"type":34,"value":10367},"IDatabase",{"type":34,"value":10369}," qui définit ",{"type":28,"tag":188,"props":10371,"children":10373},{"className":10372},[],[10374],{"type":34,"value":10375},"save()",{"type":34,"value":10377}," et ",{"type":28,"tag":188,"props":10379,"children":10381},{"className":10380},[],[10382],{"type":34,"value":10383},"find()",{"type":34,"value":10385},", ce sont les implémentations (",{"type":28,"tag":188,"props":10387,"children":10389},{"className":10388},[],[10390],{"type":34,"value":10391},"MySQLDatabase",{"type":34,"value":7524},{"type":28,"tag":188,"props":10394,"children":10396},{"className":10395},[],[10397],{"type":34,"value":10398},"MongoDatabase",{"type":34,"value":10400},") qui s'adaptent à l'abstraction, jamais l'inverse. Vous changez d'implémentation (par exemple, MySQL vers MongoDB) sans toucher au reste du système.",{"type":28,"tag":83,"props":10402,"children":10403},{},[],{"type":28,"tag":29,"props":10405,"children":10407},{"id":10406},"exemples-concrets-de-violation-et-application-du-dip-en-java",[10408],{"type":34,"value":10409},"Exemples concrets de violation et application du DIP en Java",{"type":28,"tag":44,"props":10411,"children":10412},{},[10413,10415,10419],{"type":34,"value":10414},"Pour bien comprendre le ",{"type":28,"tag":55,"props":10416,"children":10417},{},[10418],{"type":34,"value":10141},{"type":34,"value":10420},", il est utile de voir à quoi ressemble une violation de ce principe et comment on peut corriger cela. Voici un exemple en Java pour illustrer à la fois le problème et la solution.",{"type":28,"tag":37,"props":10422,"children":10424},{"id":10423},"exemple-de-violation-du-dip",[10425],{"type":34,"value":10426},"Exemple de violation du DIP",{"type":28,"tag":44,"props":10428,"children":10429},{},[10430],{"type":34,"value":10431},"Voici un cas simple où une classe de service dépend directement d’une classe de bas niveau, comme un service de messagerie qui envoie des emails :",{"type":28,"tag":181,"props":10433,"children":10435},{"className":183,"code":10434,"language":185,"meta":8,"style":8},"public class NotificationService {\n    private EmailSender emailSender;\n\n    public NotificationService() {\n        this.emailSender = new EmailSender();\n    }\n\n    public void sendNotification(String message) {\n        emailSender.sendEmail(message);\n    }\n}\n\nclass EmailSender {\n    public void sendEmail(String message) {\n        System.out.println(\"Envoi de l'email : \" + message);\n    }\n}\n",[10436],{"type":28,"tag":188,"props":10437,"children":10438},{"__ignoreMap":8},[10439,10458,10478,10485,10504,10536,10543,10550,10585,10613,10620,10627,10634,10649,10684,10727,10734],{"type":28,"tag":192,"props":10440,"children":10441},{"class":194,"line":195},[10442,10446,10450,10454],{"type":28,"tag":192,"props":10443,"children":10444},{"style":209},[10445],{"type":34,"value":212},{"type":28,"tag":192,"props":10447,"children":10448},{"style":209},[10449],{"type":34,"value":217},{"type":28,"tag":192,"props":10451,"children":10452},{"style":220},[10453],{"type":34,"value":8669},{"type":28,"tag":192,"props":10455,"children":10456},{"style":226},[10457],{"type":34,"value":229},{"type":28,"tag":192,"props":10459,"children":10460},{"class":194,"line":205},[10461,10465,10469,10474],{"type":28,"tag":192,"props":10462,"children":10463},{"style":209},[10464],{"type":34,"value":238},{"type":28,"tag":192,"props":10466,"children":10467},{"style":241},[10468],{"type":34,"value":8991},{"type":28,"tag":192,"props":10470,"children":10471},{"style":247},[10472],{"type":34,"value":10473}," emailSender",{"type":28,"tag":192,"props":10475,"children":10476},{"style":226},[10477],{"type":34,"value":255},{"type":28,"tag":192,"props":10479,"children":10480},{"class":194,"line":232},[10481],{"type":28,"tag":192,"props":10482,"children":10483},{"emptyLinePlaceholder":13},[10484],{"type":34,"value":313},{"type":28,"tag":192,"props":10486,"children":10487},{"class":194,"line":258},[10488,10492,10496,10500],{"type":28,"tag":192,"props":10489,"children":10490},{"style":209},[10491],{"type":34,"value":322},{"type":28,"tag":192,"props":10493,"children":10494},{"style":325},[10495],{"type":34,"value":8669},{"type":28,"tag":192,"props":10497,"children":10498},{"style":226},[10499],{"type":34,"value":475},{"type":28,"tag":192,"props":10501,"children":10502},{"style":226},[10503],{"type":34,"value":229},{"type":28,"tag":192,"props":10505,"children":10506},{"class":194,"line":280},[10507,10511,10515,10520,10524,10528,10532],{"type":28,"tag":192,"props":10508,"children":10509},{"style":371},[10510],{"type":34,"value":374},{"type":28,"tag":192,"props":10512,"children":10513},{"style":226},[10514],{"type":34,"value":379},{"type":28,"tag":192,"props":10516,"children":10517},{"style":247},[10518],{"type":34,"value":10519},"emailSender ",{"type":28,"tag":192,"props":10521,"children":10522},{"style":387},[10523],{"type":34,"value":390},{"type":28,"tag":192,"props":10525,"children":10526},{"style":209},[10527],{"type":34,"value":723},{"type":28,"tag":192,"props":10529,"children":10530},{"style":325},[10531],{"type":34,"value":8991},{"type":28,"tag":192,"props":10533,"children":10534},{"style":226},[10535],{"type":34,"value":1973},{"type":28,"tag":192,"props":10537,"children":10538},{"class":194,"line":307},[10539],{"type":28,"tag":192,"props":10540,"children":10541},{"style":226},[10542],{"type":34,"value":445},{"type":28,"tag":192,"props":10544,"children":10545},{"class":194,"line":316},[10546],{"type":28,"tag":192,"props":10547,"children":10548},{"emptyLinePlaceholder":13},[10549],{"type":34,"value":313},{"type":28,"tag":192,"props":10551,"children":10552},{"class":194,"line":367},[10553,10557,10561,10565,10569,10573,10577,10581],{"type":28,"tag":192,"props":10554,"children":10555},{"style":209},[10556],{"type":34,"value":322},{"type":28,"tag":192,"props":10558,"children":10559},{"style":209},[10560],{"type":34,"value":688},{"type":28,"tag":192,"props":10562,"children":10563},{"style":325},[10564],{"type":34,"value":8781},{"type":28,"tag":192,"props":10566,"children":10567},{"style":226},[10568],{"type":34,"value":332},{"type":28,"tag":192,"props":10570,"children":10571},{"style":241},[10572],{"type":34,"value":337},{"type":28,"tag":192,"props":10574,"children":10575},{"style":340},[10576],{"type":34,"value":8580},{"type":28,"tag":192,"props":10578,"children":10579},{"style":226},[10580],{"type":34,"value":360},{"type":28,"tag":192,"props":10582,"children":10583},{"style":226},[10584],{"type":34,"value":229},{"type":28,"tag":192,"props":10586,"children":10587},{"class":194,"line":401},[10588,10593,10597,10601,10605,10609],{"type":28,"tag":192,"props":10589,"children":10590},{"style":247},[10591],{"type":34,"value":10592},"        emailSender",{"type":28,"tag":192,"props":10594,"children":10595},{"style":226},[10596],{"type":34,"value":379},{"type":28,"tag":192,"props":10598,"children":10599},{"style":325},[10600],{"type":34,"value":8818},{"type":28,"tag":192,"props":10602,"children":10603},{"style":226},[10604],{"type":34,"value":332},{"type":28,"tag":192,"props":10606,"children":10607},{"style":247},[10608],{"type":34,"value":8827},{"type":28,"tag":192,"props":10610,"children":10611},{"style":226},[10612],{"type":34,"value":752},{"type":28,"tag":192,"props":10614,"children":10615},{"class":194,"line":430},[10616],{"type":28,"tag":192,"props":10617,"children":10618},{"style":226},[10619],{"type":34,"value":445},{"type":28,"tag":192,"props":10621,"children":10622},{"class":194,"line":439},[10623],{"type":28,"tag":192,"props":10624,"children":10625},{"style":226},[10626],{"type":34,"value":588},{"type":28,"tag":192,"props":10628,"children":10629},{"class":194,"line":448},[10630],{"type":28,"tag":192,"props":10631,"children":10632},{"emptyLinePlaceholder":13},[10633],{"type":34,"value":313},{"type":28,"tag":192,"props":10635,"children":10636},{"class":194,"line":456},[10637,10641,10645],{"type":28,"tag":192,"props":10638,"children":10639},{"style":209},[10640],{"type":34,"value":3696},{"type":28,"tag":192,"props":10642,"children":10643},{"style":220},[10644],{"type":34,"value":8991},{"type":28,"tag":192,"props":10646,"children":10647},{"style":226},[10648],{"type":34,"value":229},{"type":28,"tag":192,"props":10650,"children":10651},{"class":194,"line":482},[10652,10656,10660,10664,10668,10672,10676,10680],{"type":28,"tag":192,"props":10653,"children":10654},{"style":209},[10655],{"type":34,"value":322},{"type":28,"tag":192,"props":10657,"children":10658},{"style":209},[10659],{"type":34,"value":688},{"type":28,"tag":192,"props":10661,"children":10662},{"style":325},[10663],{"type":34,"value":8567},{"type":28,"tag":192,"props":10665,"children":10666},{"style":226},[10667],{"type":34,"value":332},{"type":28,"tag":192,"props":10669,"children":10670},{"style":241},[10671],{"type":34,"value":337},{"type":28,"tag":192,"props":10673,"children":10674},{"style":340},[10675],{"type":34,"value":8580},{"type":28,"tag":192,"props":10677,"children":10678},{"style":226},[10679],{"type":34,"value":360},{"type":28,"tag":192,"props":10681,"children":10682},{"style":226},[10683],{"type":34,"value":229},{"type":28,"tag":192,"props":10685,"children":10686},{"class":194,"line":499},[10687,10691,10695,10699,10703,10707,10711,10715,10719,10723],{"type":28,"tag":192,"props":10688,"children":10689},{"style":247},[10690],{"type":34,"value":4327},{"type":28,"tag":192,"props":10692,"children":10693},{"style":226},[10694],{"type":34,"value":379},{"type":28,"tag":192,"props":10696,"children":10697},{"style":247},[10698],{"type":34,"value":2673},{"type":28,"tag":192,"props":10700,"children":10701},{"style":226},[10702],{"type":34,"value":379},{"type":28,"tag":192,"props":10704,"children":10705},{"style":325},[10706],{"type":34,"value":2682},{"type":28,"tag":192,"props":10708,"children":10709},{"style":226},[10710],{"type":34,"value":332},{"type":28,"tag":192,"props":10712,"children":10713},{"style":734},[10714],{"type":34,"value":8620},{"type":28,"tag":192,"props":10716,"children":10717},{"style":387},[10718],{"type":34,"value":2696},{"type":28,"tag":192,"props":10720,"children":10721},{"style":247},[10722],{"type":34,"value":8580},{"type":28,"tag":192,"props":10724,"children":10725},{"style":226},[10726],{"type":34,"value":752},{"type":28,"tag":192,"props":10728,"children":10729},{"class":194,"line":507},[10730],{"type":28,"tag":192,"props":10731,"children":10732},{"style":226},[10733],{"type":34,"value":445},{"type":28,"tag":192,"props":10735,"children":10736},{"class":194,"line":515},[10737],{"type":28,"tag":192,"props":10738,"children":10739},{"style":226},[10740],{"type":34,"value":588},{"type":28,"tag":44,"props":10742,"children":10743},{},[10744,10745,10750,10752,10757,10759,10763,10765,10770],{"type":34,"value":4486},{"type":28,"tag":188,"props":10746,"children":10748},{"className":10747},[],[10749],{"type":34,"value":8504},{"type":34,"value":10751}," dépend directement de ",{"type":28,"tag":188,"props":10753,"children":10755},{"className":10754},[],[10756],{"type":34,"value":9493},{"type":34,"value":10758},", ce qui viole le ",{"type":28,"tag":55,"props":10760,"children":10761},{},[10762],{"type":34,"value":10141},{"type":34,"value":10764},". Si un jour on veut changer le mode de notification (par exemple, passer à un SMS ou à un système de notifications push), il faudrait modifier ",{"type":28,"tag":188,"props":10766,"children":10768},{"className":10767},[],[10769],{"type":34,"value":8504},{"type":34,"value":10771},", ce qui n’est pas optimal.",{"type":28,"tag":37,"props":10773,"children":10775},{"id":10774},"correction-avec-le-dip",[10776],{"type":34,"value":10777},"Correction avec le DIP",{"type":28,"tag":44,"props":10779,"children":10780},{},[10781,10783,10787,10789,10794,10796,10801],{"type":34,"value":10782},"Pour appliquer le ",{"type":28,"tag":55,"props":10784,"children":10785},{},[10786],{"type":34,"value":10141},{"type":34,"value":10788},", nous allons introduire une ",{"type":28,"tag":55,"props":10790,"children":10791},{},[10792],{"type":34,"value":10793},"interface",{"type":34,"value":10795}," pour définir le comportement attendu d'un système d'envoi de notifications, et faire en sorte que ",{"type":28,"tag":188,"props":10797,"children":10799},{"className":10798},[],[10800],{"type":34,"value":8504},{"type":34,"value":10802}," dépende de cette abstraction :",{"type":28,"tag":181,"props":10804,"children":10806},{"className":183,"code":10805,"language":185,"meta":8,"style":8},"// Interface qui respecte le DIP\npublic interface MessageSender {\n    void sendMessage(String message);\n}\n\n// Implémentation pour l'envoi d'emails\npublic class EmailSender implements MessageSender {\n    @Override\n    public void sendMessage(String message) {\n        System.out.println(\"Envoi de l'email : \" + message);\n    }\n}\n\n// Implémentation pour l'envoi de SMS\npublic class SmsSender implements MessageSender {\n    @Override\n    public void sendMessage(String message) {\n        System.out.println(\"Envoi du SMS : \" + message);\n    }\n}\n\n// Service de notification respectant le DIP\npublic class NotificationService {\n    private MessageSender messageSender;\n\n    // Injection de la dépendance via le constructeur\n    public NotificationService(MessageSender messageSender) {\n        this.messageSender = messageSender;\n    }\n\n    public void sendNotification(String message) {\n        messageSender.sendMessage(message);\n    }\n}\n",[10807],{"type":28,"tag":188,"props":10808,"children":10809},{"__ignoreMap":8},[10810,10818,10838,10866,10873,10880,10888,10915,10926,10961,11004,11011,11018,11025,11033,11061,11072,11107,11150,11157,11164,11171,11179,11198,11218,11225,11233,11265,11293,11300,11307,11342,11371,11378],{"type":28,"tag":192,"props":10811,"children":10812},{"class":194,"line":195},[10813],{"type":28,"tag":192,"props":10814,"children":10815},{"style":199},[10816],{"type":34,"value":10817},"// Interface qui respecte le DIP\n",{"type":28,"tag":192,"props":10819,"children":10820},{"class":194,"line":205},[10821,10825,10829,10834],{"type":28,"tag":192,"props":10822,"children":10823},{"style":209},[10824],{"type":34,"value":212},{"type":28,"tag":192,"props":10826,"children":10827},{"style":209},[10828],{"type":34,"value":5275},{"type":28,"tag":192,"props":10830,"children":10831},{"style":220},[10832],{"type":34,"value":10833}," MessageSender",{"type":28,"tag":192,"props":10835,"children":10836},{"style":226},[10837],{"type":34,"value":229},{"type":28,"tag":192,"props":10839,"children":10840},{"class":194,"line":232},[10841,10845,10850,10854,10858,10862],{"type":28,"tag":192,"props":10842,"children":10843},{"style":209},[10844],{"type":34,"value":5292},{"type":28,"tag":192,"props":10846,"children":10847},{"style":325},[10848],{"type":34,"value":10849}," sendMessage",{"type":28,"tag":192,"props":10851,"children":10852},{"style":226},[10853],{"type":34,"value":332},{"type":28,"tag":192,"props":10855,"children":10856},{"style":241},[10857],{"type":34,"value":337},{"type":28,"tag":192,"props":10859,"children":10860},{"style":340},[10861],{"type":34,"value":8580},{"type":28,"tag":192,"props":10863,"children":10864},{"style":226},[10865],{"type":34,"value":752},{"type":28,"tag":192,"props":10867,"children":10868},{"class":194,"line":258},[10869],{"type":28,"tag":192,"props":10870,"children":10871},{"style":226},[10872],{"type":34,"value":588},{"type":28,"tag":192,"props":10874,"children":10875},{"class":194,"line":280},[10876],{"type":28,"tag":192,"props":10877,"children":10878},{"emptyLinePlaceholder":13},[10879],{"type":34,"value":313},{"type":28,"tag":192,"props":10881,"children":10882},{"class":194,"line":307},[10883],{"type":28,"tag":192,"props":10884,"children":10885},{"style":199},[10886],{"type":34,"value":10887},"// Implémentation pour l'envoi d'emails\n",{"type":28,"tag":192,"props":10889,"children":10890},{"class":194,"line":316},[10891,10895,10899,10903,10907,10911],{"type":28,"tag":192,"props":10892,"children":10893},{"style":209},[10894],{"type":34,"value":212},{"type":28,"tag":192,"props":10896,"children":10897},{"style":209},[10898],{"type":34,"value":217},{"type":28,"tag":192,"props":10900,"children":10901},{"style":220},[10902],{"type":34,"value":8991},{"type":28,"tag":192,"props":10904,"children":10905},{"style":209},[10906],{"type":34,"value":5343},{"type":28,"tag":192,"props":10908,"children":10909},{"style":220},[10910],{"type":34,"value":10833},{"type":28,"tag":192,"props":10912,"children":10913},{"style":226},[10914],{"type":34,"value":229},{"type":28,"tag":192,"props":10916,"children":10917},{"class":194,"line":367},[10918,10922],{"type":28,"tag":192,"props":10919,"children":10920},{"style":667},[10921],{"type":34,"value":5359},{"type":28,"tag":192,"props":10923,"children":10924},{"style":673},[10925],{"type":34,"value":5364},{"type":28,"tag":192,"props":10927,"children":10928},{"class":194,"line":401},[10929,10933,10937,10941,10945,10949,10953,10957],{"type":28,"tag":192,"props":10930,"children":10931},{"style":209},[10932],{"type":34,"value":322},{"type":28,"tag":192,"props":10934,"children":10935},{"style":209},[10936],{"type":34,"value":688},{"type":28,"tag":192,"props":10938,"children":10939},{"style":325},[10940],{"type":34,"value":10849},{"type":28,"tag":192,"props":10942,"children":10943},{"style":226},[10944],{"type":34,"value":332},{"type":28,"tag":192,"props":10946,"children":10947},{"style":241},[10948],{"type":34,"value":337},{"type":28,"tag":192,"props":10950,"children":10951},{"style":340},[10952],{"type":34,"value":8580},{"type":28,"tag":192,"props":10954,"children":10955},{"style":226},[10956],{"type":34,"value":360},{"type":28,"tag":192,"props":10958,"children":10959},{"style":226},[10960],{"type":34,"value":229},{"type":28,"tag":192,"props":10962,"children":10963},{"class":194,"line":430},[10964,10968,10972,10976,10980,10984,10988,10992,10996,11000],{"type":28,"tag":192,"props":10965,"children":10966},{"style":247},[10967],{"type":34,"value":4327},{"type":28,"tag":192,"props":10969,"children":10970},{"style":226},[10971],{"type":34,"value":379},{"type":28,"tag":192,"props":10973,"children":10974},{"style":247},[10975],{"type":34,"value":2673},{"type":28,"tag":192,"props":10977,"children":10978},{"style":226},[10979],{"type":34,"value":379},{"type":28,"tag":192,"props":10981,"children":10982},{"style":325},[10983],{"type":34,"value":2682},{"type":28,"tag":192,"props":10985,"children":10986},{"style":226},[10987],{"type":34,"value":332},{"type":28,"tag":192,"props":10989,"children":10990},{"style":734},[10991],{"type":34,"value":8620},{"type":28,"tag":192,"props":10993,"children":10994},{"style":387},[10995],{"type":34,"value":2696},{"type":28,"tag":192,"props":10997,"children":10998},{"style":247},[10999],{"type":34,"value":8580},{"type":28,"tag":192,"props":11001,"children":11002},{"style":226},[11003],{"type":34,"value":752},{"type":28,"tag":192,"props":11005,"children":11006},{"class":194,"line":439},[11007],{"type":28,"tag":192,"props":11008,"children":11009},{"style":226},[11010],{"type":34,"value":445},{"type":28,"tag":192,"props":11012,"children":11013},{"class":194,"line":448},[11014],{"type":28,"tag":192,"props":11015,"children":11016},{"style":226},[11017],{"type":34,"value":588},{"type":28,"tag":192,"props":11019,"children":11020},{"class":194,"line":456},[11021],{"type":28,"tag":192,"props":11022,"children":11023},{"emptyLinePlaceholder":13},[11024],{"type":34,"value":313},{"type":28,"tag":192,"props":11026,"children":11027},{"class":194,"line":482},[11028],{"type":28,"tag":192,"props":11029,"children":11030},{"style":199},[11031],{"type":34,"value":11032},"// Implémentation pour l'envoi de SMS\n",{"type":28,"tag":192,"props":11034,"children":11035},{"class":194,"line":499},[11036,11040,11044,11049,11053,11057],{"type":28,"tag":192,"props":11037,"children":11038},{"style":209},[11039],{"type":34,"value":212},{"type":28,"tag":192,"props":11041,"children":11042},{"style":209},[11043],{"type":34,"value":217},{"type":28,"tag":192,"props":11045,"children":11046},{"style":220},[11047],{"type":34,"value":11048}," SmsSender",{"type":28,"tag":192,"props":11050,"children":11051},{"style":209},[11052],{"type":34,"value":5343},{"type":28,"tag":192,"props":11054,"children":11055},{"style":220},[11056],{"type":34,"value":10833},{"type":28,"tag":192,"props":11058,"children":11059},{"style":226},[11060],{"type":34,"value":229},{"type":28,"tag":192,"props":11062,"children":11063},{"class":194,"line":507},[11064,11068],{"type":28,"tag":192,"props":11065,"children":11066},{"style":667},[11067],{"type":34,"value":5359},{"type":28,"tag":192,"props":11069,"children":11070},{"style":673},[11071],{"type":34,"value":5364},{"type":28,"tag":192,"props":11073,"children":11074},{"class":194,"line":515},[11075,11079,11083,11087,11091,11095,11099,11103],{"type":28,"tag":192,"props":11076,"children":11077},{"style":209},[11078],{"type":34,"value":322},{"type":28,"tag":192,"props":11080,"children":11081},{"style":209},[11082],{"type":34,"value":688},{"type":28,"tag":192,"props":11084,"children":11085},{"style":325},[11086],{"type":34,"value":10849},{"type":28,"tag":192,"props":11088,"children":11089},{"style":226},[11090],{"type":34,"value":332},{"type":28,"tag":192,"props":11092,"children":11093},{"style":241},[11094],{"type":34,"value":337},{"type":28,"tag":192,"props":11096,"children":11097},{"style":340},[11098],{"type":34,"value":8580},{"type":28,"tag":192,"props":11100,"children":11101},{"style":226},[11102],{"type":34,"value":360},{"type":28,"tag":192,"props":11104,"children":11105},{"style":226},[11106],{"type":34,"value":229},{"type":28,"tag":192,"props":11108,"children":11109},{"class":194,"line":540},[11110,11114,11118,11122,11126,11130,11134,11138,11142,11146],{"type":28,"tag":192,"props":11111,"children":11112},{"style":247},[11113],{"type":34,"value":4327},{"type":28,"tag":192,"props":11115,"children":11116},{"style":226},[11117],{"type":34,"value":379},{"type":28,"tag":192,"props":11119,"children":11120},{"style":247},[11121],{"type":34,"value":2673},{"type":28,"tag":192,"props":11123,"children":11124},{"style":226},[11125],{"type":34,"value":379},{"type":28,"tag":192,"props":11127,"children":11128},{"style":325},[11129],{"type":34,"value":2682},{"type":28,"tag":192,"props":11131,"children":11132},{"style":226},[11133],{"type":34,"value":332},{"type":28,"tag":192,"props":11135,"children":11136},{"style":734},[11137],{"type":34,"value":9227},{"type":28,"tag":192,"props":11139,"children":11140},{"style":387},[11141],{"type":34,"value":2696},{"type":28,"tag":192,"props":11143,"children":11144},{"style":247},[11145],{"type":34,"value":8580},{"type":28,"tag":192,"props":11147,"children":11148},{"style":226},[11149],{"type":34,"value":752},{"type":28,"tag":192,"props":11151,"children":11152},{"class":194,"line":556},[11153],{"type":28,"tag":192,"props":11154,"children":11155},{"style":226},[11156],{"type":34,"value":445},{"type":28,"tag":192,"props":11158,"children":11159},{"class":194,"line":564},[11160],{"type":28,"tag":192,"props":11161,"children":11162},{"style":226},[11163],{"type":34,"value":588},{"type":28,"tag":192,"props":11165,"children":11166},{"class":194,"line":573},[11167],{"type":28,"tag":192,"props":11168,"children":11169},{"emptyLinePlaceholder":13},[11170],{"type":34,"value":313},{"type":28,"tag":192,"props":11172,"children":11173},{"class":194,"line":582},[11174],{"type":28,"tag":192,"props":11175,"children":11176},{"style":199},[11177],{"type":34,"value":11178},"// Service de notification respectant le DIP\n",{"type":28,"tag":192,"props":11180,"children":11181},{"class":194,"line":5580},[11182,11186,11190,11194],{"type":28,"tag":192,"props":11183,"children":11184},{"style":209},[11185],{"type":34,"value":212},{"type":28,"tag":192,"props":11187,"children":11188},{"style":209},[11189],{"type":34,"value":217},{"type":28,"tag":192,"props":11191,"children":11192},{"style":220},[11193],{"type":34,"value":8669},{"type":28,"tag":192,"props":11195,"children":11196},{"style":226},[11197],{"type":34,"value":229},{"type":28,"tag":192,"props":11199,"children":11200},{"class":194,"line":5600},[11201,11205,11209,11214],{"type":28,"tag":192,"props":11202,"children":11203},{"style":209},[11204],{"type":34,"value":238},{"type":28,"tag":192,"props":11206,"children":11207},{"style":241},[11208],{"type":34,"value":10833},{"type":28,"tag":192,"props":11210,"children":11211},{"style":247},[11212],{"type":34,"value":11213}," messageSender",{"type":28,"tag":192,"props":11215,"children":11216},{"style":226},[11217],{"type":34,"value":255},{"type":28,"tag":192,"props":11219,"children":11220},{"class":194,"line":5638},[11221],{"type":28,"tag":192,"props":11222,"children":11223},{"emptyLinePlaceholder":13},[11224],{"type":34,"value":313},{"type":28,"tag":192,"props":11226,"children":11227},{"class":194,"line":5660},[11228],{"type":28,"tag":192,"props":11229,"children":11230},{"style":199},[11231],{"type":34,"value":11232},"    // Injection de la dépendance via le constructeur\n",{"type":28,"tag":192,"props":11234,"children":11235},{"class":194,"line":5668},[11236,11240,11244,11248,11253,11257,11261],{"type":28,"tag":192,"props":11237,"children":11238},{"style":209},[11239],{"type":34,"value":322},{"type":28,"tag":192,"props":11241,"children":11242},{"style":325},[11243],{"type":34,"value":8669},{"type":28,"tag":192,"props":11245,"children":11246},{"style":226},[11247],{"type":34,"value":332},{"type":28,"tag":192,"props":11249,"children":11250},{"style":241},[11251],{"type":34,"value":11252},"MessageSender",{"type":28,"tag":192,"props":11254,"children":11255},{"style":340},[11256],{"type":34,"value":11213},{"type":28,"tag":192,"props":11258,"children":11259},{"style":226},[11260],{"type":34,"value":360},{"type":28,"tag":192,"props":11262,"children":11263},{"style":226},[11264],{"type":34,"value":229},{"type":28,"tag":192,"props":11266,"children":11267},{"class":194,"line":6718},[11268,11272,11276,11281,11285,11289],{"type":28,"tag":192,"props":11269,"children":11270},{"style":371},[11271],{"type":34,"value":374},{"type":28,"tag":192,"props":11273,"children":11274},{"style":226},[11275],{"type":34,"value":379},{"type":28,"tag":192,"props":11277,"children":11278},{"style":247},[11279],{"type":34,"value":11280},"messageSender ",{"type":28,"tag":192,"props":11282,"children":11283},{"style":387},[11284],{"type":34,"value":390},{"type":28,"tag":192,"props":11286,"children":11287},{"style":247},[11288],{"type":34,"value":11213},{"type":28,"tag":192,"props":11290,"children":11291},{"style":226},[11292],{"type":34,"value":255},{"type":28,"tag":192,"props":11294,"children":11295},{"class":194,"line":6754},[11296],{"type":28,"tag":192,"props":11297,"children":11298},{"style":226},[11299],{"type":34,"value":445},{"type":28,"tag":192,"props":11301,"children":11302},{"class":194,"line":6782},[11303],{"type":28,"tag":192,"props":11304,"children":11305},{"emptyLinePlaceholder":13},[11306],{"type":34,"value":313},{"type":28,"tag":192,"props":11308,"children":11309},{"class":194,"line":6814},[11310,11314,11318,11322,11326,11330,11334,11338],{"type":28,"tag":192,"props":11311,"children":11312},{"style":209},[11313],{"type":34,"value":322},{"type":28,"tag":192,"props":11315,"children":11316},{"style":209},[11317],{"type":34,"value":688},{"type":28,"tag":192,"props":11319,"children":11320},{"style":325},[11321],{"type":34,"value":8781},{"type":28,"tag":192,"props":11323,"children":11324},{"style":226},[11325],{"type":34,"value":332},{"type":28,"tag":192,"props":11327,"children":11328},{"style":241},[11329],{"type":34,"value":337},{"type":28,"tag":192,"props":11331,"children":11332},{"style":340},[11333],{"type":34,"value":8580},{"type":28,"tag":192,"props":11335,"children":11336},{"style":226},[11337],{"type":34,"value":360},{"type":28,"tag":192,"props":11339,"children":11340},{"style":226},[11341],{"type":34,"value":229},{"type":28,"tag":192,"props":11343,"children":11344},{"class":194,"line":6822},[11345,11350,11354,11359,11363,11367],{"type":28,"tag":192,"props":11346,"children":11347},{"style":247},[11348],{"type":34,"value":11349},"        messageSender",{"type":28,"tag":192,"props":11351,"children":11352},{"style":226},[11353],{"type":34,"value":379},{"type":28,"tag":192,"props":11355,"children":11356},{"style":325},[11357],{"type":34,"value":11358},"sendMessage",{"type":28,"tag":192,"props":11360,"children":11361},{"style":226},[11362],{"type":34,"value":332},{"type":28,"tag":192,"props":11364,"children":11365},{"style":247},[11366],{"type":34,"value":8827},{"type":28,"tag":192,"props":11368,"children":11369},{"style":226},[11370],{"type":34,"value":752},{"type":28,"tag":192,"props":11372,"children":11373},{"class":194,"line":9462},[11374],{"type":28,"tag":192,"props":11375,"children":11376},{"style":226},[11377],{"type":34,"value":445},{"type":28,"tag":192,"props":11379,"children":11380},{"class":194,"line":9470},[11381],{"type":28,"tag":192,"props":11382,"children":11383},{"style":226},[11384],{"type":34,"value":588},{"type":28,"tag":44,"props":11386,"children":11387},{},[11388,11390,11395,11397,11402,11404,11409,11411,11416],{"type":34,"value":11389},"Dans ce nouvel exemple, ",{"type":28,"tag":188,"props":11391,"children":11393},{"className":11392},[],[11394],{"type":34,"value":8504},{"type":34,"value":11396}," dépend d'une abstraction (",{"type":28,"tag":188,"props":11398,"children":11400},{"className":11399},[],[11401],{"type":34,"value":11252},{"type":34,"value":11403},"), plus d'une implémentation concrète comme ",{"type":28,"tag":188,"props":11405,"children":11407},{"className":11406},[],[11408],{"type":34,"value":9493},{"type":34,"value":11410},". Changer le mode d'envoi devient trivial, sans modifier ",{"type":28,"tag":188,"props":11412,"children":11414},{"className":11413},[],[11415],{"type":34,"value":8504},{"type":34,"value":11417},". Pour passer aux SMS au lieu des emails :",{"type":28,"tag":181,"props":11419,"children":11421},{"className":183,"code":11420,"language":185,"meta":8,"style":8},"public class Main {\n    public static void main(String[] args) {\n        // Injection d'une implémentation concrète\n        MessageSender emailSender = new EmailSender();\n        NotificationService notificationService = new NotificationService(emailSender);\n        notificationService.sendNotification(\"Hello par Email!\");\n\n        // Changement facile d'implémentation sans modifier NotificationService\n        MessageSender smsSender = new SmsSender();\n        NotificationService smsNotificationService = new NotificationService(smsSender);\n        smsNotificationService.sendNotification(\"Hello par SMS!\");\n    }\n}\n",[11422],{"type":28,"tag":188,"props":11423,"children":11424},{"__ignoreMap":8},[11425,11444,11487,11495,11523,11558,11586,11593,11601,11628,11664,11692,11699],{"type":28,"tag":192,"props":11426,"children":11427},{"class":194,"line":195},[11428,11432,11436,11440],{"type":28,"tag":192,"props":11429,"children":11430},{"style":209},[11431],{"type":34,"value":212},{"type":28,"tag":192,"props":11433,"children":11434},{"style":209},[11435],{"type":34,"value":217},{"type":28,"tag":192,"props":11437,"children":11438},{"style":220},[11439],{"type":34,"value":5846},{"type":28,"tag":192,"props":11441,"children":11442},{"style":226},[11443],{"type":34,"value":229},{"type":28,"tag":192,"props":11445,"children":11446},{"class":194,"line":205},[11447,11451,11455,11459,11463,11467,11471,11475,11479,11483],{"type":28,"tag":192,"props":11448,"children":11449},{"style":209},[11450],{"type":34,"value":322},{"type":28,"tag":192,"props":11452,"children":11453},{"style":209},[11454],{"type":34,"value":5862},{"type":28,"tag":192,"props":11456,"children":11457},{"style":209},[11458],{"type":34,"value":688},{"type":28,"tag":192,"props":11460,"children":11461},{"style":325},[11462],{"type":34,"value":5871},{"type":28,"tag":192,"props":11464,"children":11465},{"style":226},[11466],{"type":34,"value":332},{"type":28,"tag":192,"props":11468,"children":11469},{"style":209},[11470],{"type":34,"value":337},{"type":28,"tag":192,"props":11472,"children":11473},{"style":226},[11474],{"type":34,"value":5884},{"type":28,"tag":192,"props":11476,"children":11477},{"style":340},[11478],{"type":34,"value":5889},{"type":28,"tag":192,"props":11480,"children":11481},{"style":226},[11482],{"type":34,"value":360},{"type":28,"tag":192,"props":11484,"children":11485},{"style":226},[11486],{"type":34,"value":229},{"type":28,"tag":192,"props":11488,"children":11489},{"class":194,"line":232},[11490],{"type":28,"tag":192,"props":11491,"children":11492},{"style":199},[11493],{"type":34,"value":11494},"        // Injection d'une implémentation concrète\n",{"type":28,"tag":192,"props":11496,"children":11497},{"class":194,"line":258},[11498,11503,11507,11511,11515,11519],{"type":28,"tag":192,"props":11499,"children":11500},{"style":241},[11501],{"type":34,"value":11502},"        MessageSender",{"type":28,"tag":192,"props":11504,"children":11505},{"style":247},[11506],{"type":34,"value":9606},{"type":28,"tag":192,"props":11508,"children":11509},{"style":387},[11510],{"type":34,"value":390},{"type":28,"tag":192,"props":11512,"children":11513},{"style":209},[11514],{"type":34,"value":723},{"type":28,"tag":192,"props":11516,"children":11517},{"style":325},[11518],{"type":34,"value":8991},{"type":28,"tag":192,"props":11520,"children":11521},{"style":226},[11522],{"type":34,"value":1973},{"type":28,"tag":192,"props":11524,"children":11525},{"class":194,"line":280},[11526,11530,11534,11538,11542,11546,11550,11554],{"type":28,"tag":192,"props":11527,"children":11528},{"style":241},[11529],{"type":34,"value":9630},{"type":28,"tag":192,"props":11531,"children":11532},{"style":247},[11533],{"type":34,"value":9635},{"type":28,"tag":192,"props":11535,"children":11536},{"style":387},[11537],{"type":34,"value":390},{"type":28,"tag":192,"props":11539,"children":11540},{"style":209},[11541],{"type":34,"value":723},{"type":28,"tag":192,"props":11543,"children":11544},{"style":325},[11545],{"type":34,"value":8669},{"type":28,"tag":192,"props":11547,"children":11548},{"style":226},[11549],{"type":34,"value":332},{"type":28,"tag":192,"props":11551,"children":11552},{"style":247},[11553],{"type":34,"value":9656},{"type":28,"tag":192,"props":11555,"children":11556},{"style":226},[11557],{"type":34,"value":752},{"type":28,"tag":192,"props":11559,"children":11560},{"class":194,"line":307},[11561,11565,11569,11573,11577,11582],{"type":28,"tag":192,"props":11562,"children":11563},{"style":247},[11564],{"type":34,"value":9668},{"type":28,"tag":192,"props":11566,"children":11567},{"style":226},[11568],{"type":34,"value":379},{"type":28,"tag":192,"props":11570,"children":11571},{"style":325},[11572],{"type":34,"value":9677},{"type":28,"tag":192,"props":11574,"children":11575},{"style":226},[11576],{"type":34,"value":332},{"type":28,"tag":192,"props":11578,"children":11579},{"style":734},[11580],{"type":34,"value":11581},"\"Hello par Email!\"",{"type":28,"tag":192,"props":11583,"children":11584},{"style":226},[11585],{"type":34,"value":752},{"type":28,"tag":192,"props":11587,"children":11588},{"class":194,"line":316},[11589],{"type":28,"tag":192,"props":11590,"children":11591},{"emptyLinePlaceholder":13},[11592],{"type":34,"value":313},{"type":28,"tag":192,"props":11594,"children":11595},{"class":194,"line":367},[11596],{"type":28,"tag":192,"props":11597,"children":11598},{"style":199},[11599],{"type":34,"value":11600},"        // Changement facile d'implémentation sans modifier NotificationService\n",{"type":28,"tag":192,"props":11602,"children":11603},{"class":194,"line":401},[11604,11608,11612,11616,11620,11624],{"type":28,"tag":192,"props":11605,"children":11606},{"style":241},[11607],{"type":34,"value":11502},{"type":28,"tag":192,"props":11609,"children":11610},{"style":247},[11611],{"type":34,"value":9717},{"type":28,"tag":192,"props":11613,"children":11614},{"style":387},[11615],{"type":34,"value":390},{"type":28,"tag":192,"props":11617,"children":11618},{"style":209},[11619],{"type":34,"value":723},{"type":28,"tag":192,"props":11621,"children":11622},{"style":325},[11623],{"type":34,"value":11048},{"type":28,"tag":192,"props":11625,"children":11626},{"style":226},[11627],{"type":34,"value":1973},{"type":28,"tag":192,"props":11629,"children":11630},{"class":194,"line":430},[11631,11635,11640,11644,11648,11652,11656,11660],{"type":28,"tag":192,"props":11632,"children":11633},{"style":241},[11634],{"type":34,"value":9630},{"type":28,"tag":192,"props":11636,"children":11637},{"style":247},[11638],{"type":34,"value":11639}," smsNotificationService ",{"type":28,"tag":192,"props":11641,"children":11642},{"style":387},[11643],{"type":34,"value":390},{"type":28,"tag":192,"props":11645,"children":11646},{"style":209},[11647],{"type":34,"value":723},{"type":28,"tag":192,"props":11649,"children":11650},{"style":325},[11651],{"type":34,"value":8669},{"type":28,"tag":192,"props":11653,"children":11654},{"style":226},[11655],{"type":34,"value":332},{"type":28,"tag":192,"props":11657,"children":11658},{"style":247},[11659],{"type":34,"value":9777},{"type":28,"tag":192,"props":11661,"children":11662},{"style":226},[11663],{"type":34,"value":752},{"type":28,"tag":192,"props":11665,"children":11666},{"class":194,"line":439},[11667,11671,11675,11679,11683,11688],{"type":28,"tag":192,"props":11668,"children":11669},{"style":247},[11670],{"type":34,"value":9789},{"type":28,"tag":192,"props":11672,"children":11673},{"style":226},[11674],{"type":34,"value":379},{"type":28,"tag":192,"props":11676,"children":11677},{"style":325},[11678],{"type":34,"value":9677},{"type":28,"tag":192,"props":11680,"children":11681},{"style":226},[11682],{"type":34,"value":332},{"type":28,"tag":192,"props":11684,"children":11685},{"style":734},[11686],{"type":34,"value":11687},"\"Hello par SMS!\"",{"type":28,"tag":192,"props":11689,"children":11690},{"style":226},[11691],{"type":34,"value":752},{"type":28,"tag":192,"props":11693,"children":11694},{"class":194,"line":448},[11695],{"type":28,"tag":192,"props":11696,"children":11697},{"style":226},[11698],{"type":34,"value":445},{"type":28,"tag":192,"props":11700,"children":11701},{"class":194,"line":456},[11702],{"type":28,"tag":192,"props":11703,"children":11704},{"style":226},[11705],{"type":34,"value":588},{"type":28,"tag":37,"props":11707,"children":11709},{"id":11708},"ce-que-nous-avons-corrigé",[11710],{"type":34,"value":11711},"Ce que nous avons corrigé :",{"type":28,"tag":144,"props":11713,"children":11714},{},[11715],{"type":28,"tag":148,"props":11716,"children":11717},{},[11718,11720],{"type":34,"value":11719},"La ",{"type":28,"tag":55,"props":11721,"children":11722},{},[11723],{"type":34,"value":8504},{"type":28,"tag":44,"props":11725,"children":11726},{},[11727,11729,11734],{"type":34,"value":11728},"n’a plus besoin de connaître les détails d'implémentation de la manière dont les messages sont envoyés (email, SMS, etc.). Elle dépend uniquement d'une interface abstraite (",{"type":28,"tag":188,"props":11730,"children":11732},{"className":11731},[],[11733],{"type":34,"value":11252},{"type":34,"value":1798},{"type":28,"tag":144,"props":11736,"children":11737},{},[11738],{"type":28,"tag":148,"props":11739,"children":11740},{},[11741,11743,11748],{"type":34,"value":11742},"Si nous devons un jour ajouter une nouvelle manière d'envoyer des notifications (par exemple via une API de notifications push), nous pourrons simplement créer une nouvelle classe qui implémente ",{"type":28,"tag":188,"props":11744,"children":11746},{"className":11745},[],[11747],{"type":34,"value":11252},{"type":34,"value":11749}," sans toucher au code existant.",{"type":28,"tag":1841,"props":11751,"children":11753},{"type":11752},"tip",[11754],{"type":28,"tag":44,"props":11755,"children":11756},{},[11757,11759,11763],{"type":34,"value":11758},"Je vous recommande de toujours préférer l'injection de dépendances via des ",{"type":28,"tag":55,"props":11760,"children":11761},{},[11762],{"type":34,"value":10344},{"type":34,"value":11764},". Cela vous permettra de changer facilement les implémentations sans avoir à modifier plusieurs classes.",{"type":28,"tag":83,"props":11766,"children":11767},{},[],{"type":28,"tag":29,"props":11769,"children":11771},{"id":11770},"comment-appliquer-le-dip-dans-un-projet-java",[11772],{"type":34,"value":11773},"Comment appliquer le DIP dans un projet Java",{"type":28,"tag":44,"props":11775,"children":11776},{},[11777,11779,11784,11786,11790,11792,11797],{"type":34,"value":11778},"Le principe d'inversion des dépendances peut sembler simple en théorie, mais lorsqu'il s'agit de l'appliquer dans un projet Java de grande envergure, les choses peuvent se compliquer un peu. Heureusement, des frameworks comme ",{"type":28,"tag":55,"props":11780,"children":11781},{},[11782],{"type":34,"value":11783},"Spring",{"type":34,"value":11785}," nous facilitent grandement l'implémentation du ",{"type":28,"tag":55,"props":11787,"children":11788},{},[11789],{"type":34,"value":10141},{"type":34,"value":11791}," grâce à des concepts comme l'",{"type":28,"tag":55,"props":11793,"children":11794},{},[11795],{"type":34,"value":11796},"injection de dépendances",{"type":34,"value":379},{"type":28,"tag":37,"props":11799,"children":11801},{"id":11800},"utiliser-spring-pour-appliquer-le-dip",[11802],{"type":34,"value":11803},"Utiliser Spring pour appliquer le DIP",{"type":28,"tag":44,"props":11805,"children":11806},{},[11807,11809,11814,11816,11820],{"type":34,"value":11808},"Dans un projet Java classique, vous pourriez vous retrouver à instancier et gérer manuellement vos dépendances, comme dans les exemples précédents. Mais dans un projet de plus grande taille, cela peut devenir difficile à gérer. C’est là que le ",{"type":28,"tag":55,"props":11810,"children":11811},{},[11812],{"type":34,"value":11813},"framework Spring",{"type":34,"value":11815}," entre en jeu. Spring facilite l’application du ",{"type":28,"tag":55,"props":11817,"children":11818},{},[11819],{"type":34,"value":10141},{"type":34,"value":11821}," en fournissant un conteneur d’injection de dépendances qui gère la création et l’injection des objets à votre place.",{"type":28,"tag":1841,"props":11823,"children":11824},{"type":11752},[11825],{"type":28,"tag":44,"props":11826,"children":11827},{},[11828,11830,11836,11837,11843],{"type":34,"value":11829},"Utilisez les annotations ",{"type":28,"tag":188,"props":11831,"children":11833},{"className":11832},[],[11834],{"type":34,"value":11835},"@Autowired",{"type":34,"value":10377},{"type":28,"tag":188,"props":11838,"children":11840},{"className":11839},[],[11841],{"type":34,"value":11842},"@Component",{"type":34,"value":11844}," de Spring pour que le framework gère automatiquement l'injection des dépendances. Cela simplifie grandement la gestion des dépendances dans des projets complexes.",{"type":28,"tag":83,"props":11846,"children":11847},{},[],{"type":28,"tag":37,"props":11849,"children":11851},{"id":11850},"exemple-avec-spring",[11852],{"type":34,"value":11853},"Exemple avec Spring",{"type":28,"tag":44,"props":11855,"children":11856},{},[11857],{"type":34,"value":11858},"Supposons que nous ayons le même système de notification que dans l’exemple précédent, mais cette fois, nous allons utiliser Spring pour gérer les dépendances :",{"type":28,"tag":1644,"props":11860,"children":11861},{},[11862],{"type":28,"tag":148,"props":11863,"children":11864},{},[11865,11870],{"type":28,"tag":55,"props":11866,"children":11867},{},[11868],{"type":34,"value":11869},"Définir les interfaces et implémentations comme avant",{"type":34,"value":5685},{"type":28,"tag":181,"props":11872,"children":11874},{"className":183,"code":11873,"language":185,"meta":8,"style":8},"public interface MessageSender {\n    void sendMessage(String message);\n}\n\n@Component\npublic class EmailSender implements MessageSender {\n    @Override\n    public void sendMessage(String message) {\n        System.out.println(\"Envoi de l'email : \" + message);\n    }\n}\n\n@Component\npublic class SmsSender implements MessageSender {\n    @Override\n    public void sendMessage(String message) {\n        System.out.println(\"Envoi du SMS : \" + message);\n    }\n}\n",[11875],{"type":28,"tag":188,"props":11876,"children":11877},{"__ignoreMap":8},[11878,11897,11924,11931,11938,11950,11977,11988,12023,12066,12073,12080,12087,12098,12125,12136,12171,12214,12221],{"type":28,"tag":192,"props":11879,"children":11880},{"class":194,"line":195},[11881,11885,11889,11893],{"type":28,"tag":192,"props":11882,"children":11883},{"style":209},[11884],{"type":34,"value":212},{"type":28,"tag":192,"props":11886,"children":11887},{"style":209},[11888],{"type":34,"value":5275},{"type":28,"tag":192,"props":11890,"children":11891},{"style":220},[11892],{"type":34,"value":10833},{"type":28,"tag":192,"props":11894,"children":11895},{"style":226},[11896],{"type":34,"value":229},{"type":28,"tag":192,"props":11898,"children":11899},{"class":194,"line":205},[11900,11904,11908,11912,11916,11920],{"type":28,"tag":192,"props":11901,"children":11902},{"style":209},[11903],{"type":34,"value":5292},{"type":28,"tag":192,"props":11905,"children":11906},{"style":325},[11907],{"type":34,"value":10849},{"type":28,"tag":192,"props":11909,"children":11910},{"style":226},[11911],{"type":34,"value":332},{"type":28,"tag":192,"props":11913,"children":11914},{"style":241},[11915],{"type":34,"value":337},{"type":28,"tag":192,"props":11917,"children":11918},{"style":340},[11919],{"type":34,"value":8580},{"type":28,"tag":192,"props":11921,"children":11922},{"style":226},[11923],{"type":34,"value":752},{"type":28,"tag":192,"props":11925,"children":11926},{"class":194,"line":232},[11927],{"type":28,"tag":192,"props":11928,"children":11929},{"style":226},[11930],{"type":34,"value":588},{"type":28,"tag":192,"props":11932,"children":11933},{"class":194,"line":258},[11934],{"type":28,"tag":192,"props":11935,"children":11936},{"emptyLinePlaceholder":13},[11937],{"type":34,"value":313},{"type":28,"tag":192,"props":11939,"children":11940},{"class":194,"line":280},[11941,11945],{"type":28,"tag":192,"props":11942,"children":11943},{"style":667},[11944],{"type":34,"value":670},{"type":28,"tag":192,"props":11946,"children":11947},{"style":673},[11948],{"type":34,"value":11949},"Component\n",{"type":28,"tag":192,"props":11951,"children":11952},{"class":194,"line":307},[11953,11957,11961,11965,11969,11973],{"type":28,"tag":192,"props":11954,"children":11955},{"style":209},[11956],{"type":34,"value":212},{"type":28,"tag":192,"props":11958,"children":11959},{"style":209},[11960],{"type":34,"value":217},{"type":28,"tag":192,"props":11962,"children":11963},{"style":220},[11964],{"type":34,"value":8991},{"type":28,"tag":192,"props":11966,"children":11967},{"style":209},[11968],{"type":34,"value":5343},{"type":28,"tag":192,"props":11970,"children":11971},{"style":220},[11972],{"type":34,"value":10833},{"type":28,"tag":192,"props":11974,"children":11975},{"style":226},[11976],{"type":34,"value":229},{"type":28,"tag":192,"props":11978,"children":11979},{"class":194,"line":316},[11980,11984],{"type":28,"tag":192,"props":11981,"children":11982},{"style":667},[11983],{"type":34,"value":5359},{"type":28,"tag":192,"props":11985,"children":11986},{"style":673},[11987],{"type":34,"value":5364},{"type":28,"tag":192,"props":11989,"children":11990},{"class":194,"line":367},[11991,11995,11999,12003,12007,12011,12015,12019],{"type":28,"tag":192,"props":11992,"children":11993},{"style":209},[11994],{"type":34,"value":322},{"type":28,"tag":192,"props":11996,"children":11997},{"style":209},[11998],{"type":34,"value":688},{"type":28,"tag":192,"props":12000,"children":12001},{"style":325},[12002],{"type":34,"value":10849},{"type":28,"tag":192,"props":12004,"children":12005},{"style":226},[12006],{"type":34,"value":332},{"type":28,"tag":192,"props":12008,"children":12009},{"style":241},[12010],{"type":34,"value":337},{"type":28,"tag":192,"props":12012,"children":12013},{"style":340},[12014],{"type":34,"value":8580},{"type":28,"tag":192,"props":12016,"children":12017},{"style":226},[12018],{"type":34,"value":360},{"type":28,"tag":192,"props":12020,"children":12021},{"style":226},[12022],{"type":34,"value":229},{"type":28,"tag":192,"props":12024,"children":12025},{"class":194,"line":401},[12026,12030,12034,12038,12042,12046,12050,12054,12058,12062],{"type":28,"tag":192,"props":12027,"children":12028},{"style":247},[12029],{"type":34,"value":4327},{"type":28,"tag":192,"props":12031,"children":12032},{"style":226},[12033],{"type":34,"value":379},{"type":28,"tag":192,"props":12035,"children":12036},{"style":247},[12037],{"type":34,"value":2673},{"type":28,"tag":192,"props":12039,"children":12040},{"style":226},[12041],{"type":34,"value":379},{"type":28,"tag":192,"props":12043,"children":12044},{"style":325},[12045],{"type":34,"value":2682},{"type":28,"tag":192,"props":12047,"children":12048},{"style":226},[12049],{"type":34,"value":332},{"type":28,"tag":192,"props":12051,"children":12052},{"style":734},[12053],{"type":34,"value":8620},{"type":28,"tag":192,"props":12055,"children":12056},{"style":387},[12057],{"type":34,"value":2696},{"type":28,"tag":192,"props":12059,"children":12060},{"style":247},[12061],{"type":34,"value":8580},{"type":28,"tag":192,"props":12063,"children":12064},{"style":226},[12065],{"type":34,"value":752},{"type":28,"tag":192,"props":12067,"children":12068},{"class":194,"line":430},[12069],{"type":28,"tag":192,"props":12070,"children":12071},{"style":226},[12072],{"type":34,"value":445},{"type":28,"tag":192,"props":12074,"children":12075},{"class":194,"line":439},[12076],{"type":28,"tag":192,"props":12077,"children":12078},{"style":226},[12079],{"type":34,"value":588},{"type":28,"tag":192,"props":12081,"children":12082},{"class":194,"line":448},[12083],{"type":28,"tag":192,"props":12084,"children":12085},{"emptyLinePlaceholder":13},[12086],{"type":34,"value":313},{"type":28,"tag":192,"props":12088,"children":12089},{"class":194,"line":456},[12090,12094],{"type":28,"tag":192,"props":12091,"children":12092},{"style":667},[12093],{"type":34,"value":670},{"type":28,"tag":192,"props":12095,"children":12096},{"style":673},[12097],{"type":34,"value":11949},{"type":28,"tag":192,"props":12099,"children":12100},{"class":194,"line":482},[12101,12105,12109,12113,12117,12121],{"type":28,"tag":192,"props":12102,"children":12103},{"style":209},[12104],{"type":34,"value":212},{"type":28,"tag":192,"props":12106,"children":12107},{"style":209},[12108],{"type":34,"value":217},{"type":28,"tag":192,"props":12110,"children":12111},{"style":220},[12112],{"type":34,"value":11048},{"type":28,"tag":192,"props":12114,"children":12115},{"style":209},[12116],{"type":34,"value":5343},{"type":28,"tag":192,"props":12118,"children":12119},{"style":220},[12120],{"type":34,"value":10833},{"type":28,"tag":192,"props":12122,"children":12123},{"style":226},[12124],{"type":34,"value":229},{"type":28,"tag":192,"props":12126,"children":12127},{"class":194,"line":499},[12128,12132],{"type":28,"tag":192,"props":12129,"children":12130},{"style":667},[12131],{"type":34,"value":5359},{"type":28,"tag":192,"props":12133,"children":12134},{"style":673},[12135],{"type":34,"value":5364},{"type":28,"tag":192,"props":12137,"children":12138},{"class":194,"line":507},[12139,12143,12147,12151,12155,12159,12163,12167],{"type":28,"tag":192,"props":12140,"children":12141},{"style":209},[12142],{"type":34,"value":322},{"type":28,"tag":192,"props":12144,"children":12145},{"style":209},[12146],{"type":34,"value":688},{"type":28,"tag":192,"props":12148,"children":12149},{"style":325},[12150],{"type":34,"value":10849},{"type":28,"tag":192,"props":12152,"children":12153},{"style":226},[12154],{"type":34,"value":332},{"type":28,"tag":192,"props":12156,"children":12157},{"style":241},[12158],{"type":34,"value":337},{"type":28,"tag":192,"props":12160,"children":12161},{"style":340},[12162],{"type":34,"value":8580},{"type":28,"tag":192,"props":12164,"children":12165},{"style":226},[12166],{"type":34,"value":360},{"type":28,"tag":192,"props":12168,"children":12169},{"style":226},[12170],{"type":34,"value":229},{"type":28,"tag":192,"props":12172,"children":12173},{"class":194,"line":515},[12174,12178,12182,12186,12190,12194,12198,12202,12206,12210],{"type":28,"tag":192,"props":12175,"children":12176},{"style":247},[12177],{"type":34,"value":4327},{"type":28,"tag":192,"props":12179,"children":12180},{"style":226},[12181],{"type":34,"value":379},{"type":28,"tag":192,"props":12183,"children":12184},{"style":247},[12185],{"type":34,"value":2673},{"type":28,"tag":192,"props":12187,"children":12188},{"style":226},[12189],{"type":34,"value":379},{"type":28,"tag":192,"props":12191,"children":12192},{"style":325},[12193],{"type":34,"value":2682},{"type":28,"tag":192,"props":12195,"children":12196},{"style":226},[12197],{"type":34,"value":332},{"type":28,"tag":192,"props":12199,"children":12200},{"style":734},[12201],{"type":34,"value":9227},{"type":28,"tag":192,"props":12203,"children":12204},{"style":387},[12205],{"type":34,"value":2696},{"type":28,"tag":192,"props":12207,"children":12208},{"style":247},[12209],{"type":34,"value":8580},{"type":28,"tag":192,"props":12211,"children":12212},{"style":226},[12213],{"type":34,"value":752},{"type":28,"tag":192,"props":12215,"children":12216},{"class":194,"line":540},[12217],{"type":28,"tag":192,"props":12218,"children":12219},{"style":226},[12220],{"type":34,"value":445},{"type":28,"tag":192,"props":12222,"children":12223},{"class":194,"line":556},[12224],{"type":28,"tag":192,"props":12225,"children":12226},{"style":226},[12227],{"type":34,"value":588},{"type":28,"tag":1644,"props":12229,"children":12230},{"start":205},[12231],{"type":28,"tag":148,"props":12232,"children":12233},{},[12234,12239],{"type":28,"tag":55,"props":12235,"children":12236},{},[12237],{"type":34,"value":12238},"Injection de dépendances avec Spring",{"type":34,"value":5685},{"type":28,"tag":44,"props":12241,"children":12242},{},[12243,12245,12250,12252,12257,12259,12264],{"type":34,"value":12244},"Nous allons maintenant utiliser l'annotation ",{"type":28,"tag":188,"props":12246,"children":12248},{"className":12247},[],[12249],{"type":34,"value":11835},{"type":34,"value":12251}," de Spring pour injecter l'implémentation concrète de ",{"type":28,"tag":188,"props":12253,"children":12255},{"className":12254},[],[12256],{"type":34,"value":11252},{"type":34,"value":12258}," dans ",{"type":28,"tag":188,"props":12260,"children":12262},{"className":12261},[],[12263],{"type":34,"value":8504},{"type":34,"value":12265},", sans avoir à gérer manuellement l'instanciation.",{"type":28,"tag":181,"props":12267,"children":12269},{"className":183,"code":12268,"language":185,"meta":8,"style":8},"@Component\npublic class NotificationService {\n    private final MessageSender messageSender;\n\n    // Injection de la dépendance par constructeur\n    @Autowired\n    public NotificationService(MessageSender messageSender) {\n        this.messageSender = messageSender;\n    }\n\n    public void sendNotification(String message) {\n        messageSender.sendMessage(message);\n    }\n}\n",[12270],{"type":28,"tag":188,"props":12271,"children":12272},{"__ignoreMap":8},[12273,12284,12303,12327,12334,12342,12354,12385,12412,12419,12426,12461,12488,12495],{"type":28,"tag":192,"props":12274,"children":12275},{"class":194,"line":195},[12276,12280],{"type":28,"tag":192,"props":12277,"children":12278},{"style":667},[12279],{"type":34,"value":670},{"type":28,"tag":192,"props":12281,"children":12282},{"style":673},[12283],{"type":34,"value":11949},{"type":28,"tag":192,"props":12285,"children":12286},{"class":194,"line":205},[12287,12291,12295,12299],{"type":28,"tag":192,"props":12288,"children":12289},{"style":209},[12290],{"type":34,"value":212},{"type":28,"tag":192,"props":12292,"children":12293},{"style":209},[12294],{"type":34,"value":217},{"type":28,"tag":192,"props":12296,"children":12297},{"style":220},[12298],{"type":34,"value":8669},{"type":28,"tag":192,"props":12300,"children":12301},{"style":226},[12302],{"type":34,"value":229},{"type":28,"tag":192,"props":12304,"children":12305},{"class":194,"line":232},[12306,12310,12315,12319,12323],{"type":28,"tag":192,"props":12307,"children":12308},{"style":209},[12309],{"type":34,"value":238},{"type":28,"tag":192,"props":12311,"children":12312},{"style":209},[12313],{"type":34,"value":12314}," final",{"type":28,"tag":192,"props":12316,"children":12317},{"style":241},[12318],{"type":34,"value":10833},{"type":28,"tag":192,"props":12320,"children":12321},{"style":247},[12322],{"type":34,"value":11213},{"type":28,"tag":192,"props":12324,"children":12325},{"style":226},[12326],{"type":34,"value":255},{"type":28,"tag":192,"props":12328,"children":12329},{"class":194,"line":258},[12330],{"type":28,"tag":192,"props":12331,"children":12332},{"emptyLinePlaceholder":13},[12333],{"type":34,"value":313},{"type":28,"tag":192,"props":12335,"children":12336},{"class":194,"line":280},[12337],{"type":28,"tag":192,"props":12338,"children":12339},{"style":199},[12340],{"type":34,"value":12341},"    // Injection de la dépendance par constructeur\n",{"type":28,"tag":192,"props":12343,"children":12344},{"class":194,"line":307},[12345,12349],{"type":28,"tag":192,"props":12346,"children":12347},{"style":667},[12348],{"type":34,"value":5359},{"type":28,"tag":192,"props":12350,"children":12351},{"style":673},[12352],{"type":34,"value":12353},"Autowired\n",{"type":28,"tag":192,"props":12355,"children":12356},{"class":194,"line":316},[12357,12361,12365,12369,12373,12377,12381],{"type":28,"tag":192,"props":12358,"children":12359},{"style":209},[12360],{"type":34,"value":322},{"type":28,"tag":192,"props":12362,"children":12363},{"style":325},[12364],{"type":34,"value":8669},{"type":28,"tag":192,"props":12366,"children":12367},{"style":226},[12368],{"type":34,"value":332},{"type":28,"tag":192,"props":12370,"children":12371},{"style":241},[12372],{"type":34,"value":11252},{"type":28,"tag":192,"props":12374,"children":12375},{"style":340},[12376],{"type":34,"value":11213},{"type":28,"tag":192,"props":12378,"children":12379},{"style":226},[12380],{"type":34,"value":360},{"type":28,"tag":192,"props":12382,"children":12383},{"style":226},[12384],{"type":34,"value":229},{"type":28,"tag":192,"props":12386,"children":12387},{"class":194,"line":367},[12388,12392,12396,12400,12404,12408],{"type":28,"tag":192,"props":12389,"children":12390},{"style":371},[12391],{"type":34,"value":374},{"type":28,"tag":192,"props":12393,"children":12394},{"style":226},[12395],{"type":34,"value":379},{"type":28,"tag":192,"props":12397,"children":12398},{"style":247},[12399],{"type":34,"value":11280},{"type":28,"tag":192,"props":12401,"children":12402},{"style":387},[12403],{"type":34,"value":390},{"type":28,"tag":192,"props":12405,"children":12406},{"style":247},[12407],{"type":34,"value":11213},{"type":28,"tag":192,"props":12409,"children":12410},{"style":226},[12411],{"type":34,"value":255},{"type":28,"tag":192,"props":12413,"children":12414},{"class":194,"line":401},[12415],{"type":28,"tag":192,"props":12416,"children":12417},{"style":226},[12418],{"type":34,"value":445},{"type":28,"tag":192,"props":12420,"children":12421},{"class":194,"line":430},[12422],{"type":28,"tag":192,"props":12423,"children":12424},{"emptyLinePlaceholder":13},[12425],{"type":34,"value":313},{"type":28,"tag":192,"props":12427,"children":12428},{"class":194,"line":439},[12429,12433,12437,12441,12445,12449,12453,12457],{"type":28,"tag":192,"props":12430,"children":12431},{"style":209},[12432],{"type":34,"value":322},{"type":28,"tag":192,"props":12434,"children":12435},{"style":209},[12436],{"type":34,"value":688},{"type":28,"tag":192,"props":12438,"children":12439},{"style":325},[12440],{"type":34,"value":8781},{"type":28,"tag":192,"props":12442,"children":12443},{"style":226},[12444],{"type":34,"value":332},{"type":28,"tag":192,"props":12446,"children":12447},{"style":241},[12448],{"type":34,"value":337},{"type":28,"tag":192,"props":12450,"children":12451},{"style":340},[12452],{"type":34,"value":8580},{"type":28,"tag":192,"props":12454,"children":12455},{"style":226},[12456],{"type":34,"value":360},{"type":28,"tag":192,"props":12458,"children":12459},{"style":226},[12460],{"type":34,"value":229},{"type":28,"tag":192,"props":12462,"children":12463},{"class":194,"line":448},[12464,12468,12472,12476,12480,12484],{"type":28,"tag":192,"props":12465,"children":12466},{"style":247},[12467],{"type":34,"value":11349},{"type":28,"tag":192,"props":12469,"children":12470},{"style":226},[12471],{"type":34,"value":379},{"type":28,"tag":192,"props":12473,"children":12474},{"style":325},[12475],{"type":34,"value":11358},{"type":28,"tag":192,"props":12477,"children":12478},{"style":226},[12479],{"type":34,"value":332},{"type":28,"tag":192,"props":12481,"children":12482},{"style":247},[12483],{"type":34,"value":8827},{"type":28,"tag":192,"props":12485,"children":12486},{"style":226},[12487],{"type":34,"value":752},{"type":28,"tag":192,"props":12489,"children":12490},{"class":194,"line":456},[12491],{"type":28,"tag":192,"props":12492,"children":12493},{"style":226},[12494],{"type":34,"value":445},{"type":28,"tag":192,"props":12496,"children":12497},{"class":194,"line":482},[12498],{"type":28,"tag":192,"props":12499,"children":12500},{"style":226},[12501],{"type":34,"value":588},{"type":28,"tag":1644,"props":12503,"children":12504},{"start":232},[12505],{"type":28,"tag":148,"props":12506,"children":12507},{},[12508,12513],{"type":28,"tag":55,"props":12509,"children":12510},{},[12511],{"type":34,"value":12512},"Configurer et exécuter l’application",{"type":34,"value":5685},{"type":28,"tag":44,"props":12515,"children":12516},{},[12517],{"type":34,"value":12518},"Enfin, vous n’avez plus qu’à configurer votre application Spring pour que le framework se charge d’injecter les dépendances au moment de l’exécution.",{"type":28,"tag":181,"props":12520,"children":12522},{"className":183,"code":12521,"language":185,"meta":8,"style":8},"@SpringBootApplication\npublic class DipExampleApplication {\n\n    public static void main(String[] args) {\n        ApplicationContext context = SpringApplication.run(DipExampleApplication.class, args);\n\n        // Obtenir NotificationService du contexte Spring\n        NotificationService notificationService = context.getBean(NotificationService.class);\n        notificationService.sendNotification(\"Hello via Spring!\");\n    }\n}\n",[12523],{"type":28,"tag":188,"props":12524,"children":12525},{"__ignoreMap":8},[12526,12538,12558,12565,12608,12668,12675,12683,12732,12760,12767],{"type":28,"tag":192,"props":12527,"children":12528},{"class":194,"line":195},[12529,12533],{"type":28,"tag":192,"props":12530,"children":12531},{"style":667},[12532],{"type":34,"value":670},{"type":28,"tag":192,"props":12534,"children":12535},{"style":673},[12536],{"type":34,"value":12537},"SpringBootApplication\n",{"type":28,"tag":192,"props":12539,"children":12540},{"class":194,"line":205},[12541,12545,12549,12554],{"type":28,"tag":192,"props":12542,"children":12543},{"style":209},[12544],{"type":34,"value":212},{"type":28,"tag":192,"props":12546,"children":12547},{"style":209},[12548],{"type":34,"value":217},{"type":28,"tag":192,"props":12550,"children":12551},{"style":220},[12552],{"type":34,"value":12553}," DipExampleApplication",{"type":28,"tag":192,"props":12555,"children":12556},{"style":226},[12557],{"type":34,"value":229},{"type":28,"tag":192,"props":12559,"children":12560},{"class":194,"line":232},[12561],{"type":28,"tag":192,"props":12562,"children":12563},{"emptyLinePlaceholder":13},[12564],{"type":34,"value":313},{"type":28,"tag":192,"props":12566,"children":12567},{"class":194,"line":258},[12568,12572,12576,12580,12584,12588,12592,12596,12600,12604],{"type":28,"tag":192,"props":12569,"children":12570},{"style":209},[12571],{"type":34,"value":322},{"type":28,"tag":192,"props":12573,"children":12574},{"style":209},[12575],{"type":34,"value":5862},{"type":28,"tag":192,"props":12577,"children":12578},{"style":209},[12579],{"type":34,"value":688},{"type":28,"tag":192,"props":12581,"children":12582},{"style":325},[12583],{"type":34,"value":5871},{"type":28,"tag":192,"props":12585,"children":12586},{"style":226},[12587],{"type":34,"value":332},{"type":28,"tag":192,"props":12589,"children":12590},{"style":209},[12591],{"type":34,"value":337},{"type":28,"tag":192,"props":12593,"children":12594},{"style":226},[12595],{"type":34,"value":5884},{"type":28,"tag":192,"props":12597,"children":12598},{"style":340},[12599],{"type":34,"value":5889},{"type":28,"tag":192,"props":12601,"children":12602},{"style":226},[12603],{"type":34,"value":360},{"type":28,"tag":192,"props":12605,"children":12606},{"style":226},[12607],{"type":34,"value":229},{"type":28,"tag":192,"props":12609,"children":12610},{"class":194,"line":280},[12611,12616,12621,12625,12630,12634,12639,12643,12648,12652,12656,12660,12664],{"type":28,"tag":192,"props":12612,"children":12613},{"style":241},[12614],{"type":34,"value":12615},"        ApplicationContext",{"type":28,"tag":192,"props":12617,"children":12618},{"style":247},[12619],{"type":34,"value":12620}," context ",{"type":28,"tag":192,"props":12622,"children":12623},{"style":387},[12624],{"type":34,"value":390},{"type":28,"tag":192,"props":12626,"children":12627},{"style":247},[12628],{"type":34,"value":12629}," SpringApplication",{"type":28,"tag":192,"props":12631,"children":12632},{"style":226},[12633],{"type":34,"value":379},{"type":28,"tag":192,"props":12635,"children":12636},{"style":325},[12637],{"type":34,"value":12638},"run",{"type":28,"tag":192,"props":12640,"children":12641},{"style":226},[12642],{"type":34,"value":332},{"type":28,"tag":192,"props":12644,"children":12645},{"style":247},[12646],{"type":34,"value":12647},"DipExampleApplication",{"type":28,"tag":192,"props":12649,"children":12650},{"style":226},[12651],{"type":34,"value":379},{"type":28,"tag":192,"props":12653,"children":12654},{"style":247},[12655],{"type":34,"value":3696},{"type":28,"tag":192,"props":12657,"children":12658},{"style":226},[12659],{"type":34,"value":347},{"type":28,"tag":192,"props":12661,"children":12662},{"style":247},[12663],{"type":34,"value":5889},{"type":28,"tag":192,"props":12665,"children":12666},{"style":226},[12667],{"type":34,"value":752},{"type":28,"tag":192,"props":12669,"children":12670},{"class":194,"line":307},[12671],{"type":28,"tag":192,"props":12672,"children":12673},{"emptyLinePlaceholder":13},[12674],{"type":34,"value":313},{"type":28,"tag":192,"props":12676,"children":12677},{"class":194,"line":316},[12678],{"type":28,"tag":192,"props":12679,"children":12680},{"style":199},[12681],{"type":34,"value":12682},"        // Obtenir NotificationService du contexte Spring\n",{"type":28,"tag":192,"props":12684,"children":12685},{"class":194,"line":367},[12686,12690,12694,12698,12703,12707,12712,12716,12720,12724,12728],{"type":28,"tag":192,"props":12687,"children":12688},{"style":241},[12689],{"type":34,"value":9630},{"type":28,"tag":192,"props":12691,"children":12692},{"style":247},[12693],{"type":34,"value":9635},{"type":28,"tag":192,"props":12695,"children":12696},{"style":387},[12697],{"type":34,"value":390},{"type":28,"tag":192,"props":12699,"children":12700},{"style":247},[12701],{"type":34,"value":12702}," context",{"type":28,"tag":192,"props":12704,"children":12705},{"style":226},[12706],{"type":34,"value":379},{"type":28,"tag":192,"props":12708,"children":12709},{"style":325},[12710],{"type":34,"value":12711},"getBean",{"type":28,"tag":192,"props":12713,"children":12714},{"style":226},[12715],{"type":34,"value":332},{"type":28,"tag":192,"props":12717,"children":12718},{"style":247},[12719],{"type":34,"value":8504},{"type":28,"tag":192,"props":12721,"children":12722},{"style":226},[12723],{"type":34,"value":379},{"type":28,"tag":192,"props":12725,"children":12726},{"style":247},[12727],{"type":34,"value":3696},{"type":28,"tag":192,"props":12729,"children":12730},{"style":226},[12731],{"type":34,"value":752},{"type":28,"tag":192,"props":12733,"children":12734},{"class":194,"line":401},[12735,12739,12743,12747,12751,12756],{"type":28,"tag":192,"props":12736,"children":12737},{"style":247},[12738],{"type":34,"value":9668},{"type":28,"tag":192,"props":12740,"children":12741},{"style":226},[12742],{"type":34,"value":379},{"type":28,"tag":192,"props":12744,"children":12745},{"style":325},[12746],{"type":34,"value":9677},{"type":28,"tag":192,"props":12748,"children":12749},{"style":226},[12750],{"type":34,"value":332},{"type":28,"tag":192,"props":12752,"children":12753},{"style":734},[12754],{"type":34,"value":12755},"\"Hello via Spring!\"",{"type":28,"tag":192,"props":12757,"children":12758},{"style":226},[12759],{"type":34,"value":752},{"type":28,"tag":192,"props":12761,"children":12762},{"class":194,"line":430},[12763],{"type":28,"tag":192,"props":12764,"children":12765},{"style":226},[12766],{"type":34,"value":445},{"type":28,"tag":192,"props":12768,"children":12769},{"class":194,"line":439},[12770],{"type":28,"tag":192,"props":12771,"children":12772},{"style":226},[12773],{"type":34,"value":588},{"type":28,"tag":12775,"props":12776,"children":12778},"h5",{"id":12777},"ce-que-spring-fait-pour-vous",[12779],{"type":34,"value":12780},"Ce que Spring fait pour vous :",{"type":28,"tag":144,"props":12782,"children":12783},{},[12784,12821,12851],{"type":28,"tag":148,"props":12785,"children":12786},{},[12787,12792,12794,12799,12801,12806,12807,12813,12815,12820],{"type":28,"tag":55,"props":12788,"children":12789},{},[12790],{"type":34,"value":12791},"Gestion automatique des dépendances",{"type":34,"value":12793}," : Grâce à Spring, vous n’avez pas besoin de créer manuellement les objets de type ",{"type":28,"tag":188,"props":12795,"children":12797},{"className":12796},[],[12798],{"type":34,"value":11252},{"type":34,"value":12800},". Spring instancie automatiquement la classe ",{"type":28,"tag":188,"props":12802,"children":12804},{"className":12803},[],[12805],{"type":34,"value":9493},{"type":34,"value":1865},{"type":28,"tag":188,"props":12808,"children":12810},{"className":12809},[],[12811],{"type":34,"value":12812},"SmsSender",{"type":34,"value":12814}," (selon la configuration) et l’injecte dans ",{"type":28,"tag":188,"props":12816,"children":12818},{"className":12817},[],[12819],{"type":34,"value":8504},{"type":34,"value":379},{"type":28,"tag":148,"props":12822,"children":12823},{},[12824,12829,12831,12836,12838,12843,12845,12850],{"type":28,"tag":55,"props":12825,"children":12826},{},[12827],{"type":34,"value":12828},"Découplage",{"type":34,"value":12830}," : Comme ",{"type":28,"tag":188,"props":12832,"children":12834},{"className":12833},[],[12835],{"type":34,"value":8504},{"type":34,"value":12837}," dépend de l’interface ",{"type":28,"tag":188,"props":12839,"children":12841},{"className":12840},[],[12842],{"type":34,"value":11252},{"type":34,"value":12844},", vous pouvez facilement changer l’implémentation injectée sans modifier le code de ",{"type":28,"tag":188,"props":12846,"children":12848},{"className":12847},[],[12849],{"type":34,"value":8504},{"type":34,"value":379},{"type":28,"tag":148,"props":12852,"children":12853},{},[12854,12859,12861,12866,12867,12872],{"type":28,"tag":55,"props":12855,"children":12856},{},[12857],{"type":34,"value":12858},"Facilité de configuration",{"type":34,"value":12860}," : Avec des annotations comme ",{"type":28,"tag":188,"props":12862,"children":12864},{"className":12863},[],[12865],{"type":34,"value":11842},{"type":34,"value":10377},{"type":28,"tag":188,"props":12868,"children":12870},{"className":12869},[],[12871],{"type":34,"value":11835},{"type":34,"value":12873},", la configuration des dépendances est claire et concise. Vous n’avez plus à vous soucier de l’instanciation manuelle ou de l’injection de dépendances au runtime.",{"type":28,"tag":169,"props":12875,"children":12877},{"id":12876},"avantages-dappliquer-le-dip-dans-un-projet-spring",[12878],{"type":34,"value":12879},"Avantages d’appliquer le DIP dans un projet Spring",{"type":28,"tag":1644,"props":12881,"children":12882},{},[12883,12893],{"type":28,"tag":148,"props":12884,"children":12885},{},[12886,12891],{"type":28,"tag":55,"props":12887,"children":12888},{},[12889],{"type":34,"value":12890},"Flexibilité accrue",{"type":34,"value":12892}," : avec des interfaces injectées, remplacer un composant ne demande rien d'autre : passer d'un envoi d'emails à des notifications push devient trivial.",{"type":28,"tag":148,"props":12894,"children":12895},{},[12896,12901,12903,12908,12910,12915],{"type":28,"tag":55,"props":12897,"children":12898},{},[12899],{"type":34,"value":12900},"Tests unitaires simplifiés",{"type":34,"value":12902}," : grâce aux abstractions, mocker ou stubber les dépendances dans les tests unitaires devient direct. Tester ",{"type":28,"tag":188,"props":12904,"children":12906},{"className":12905},[],[12907],{"type":34,"value":8504},{"type":34,"value":12909}," sans implémenter un vrai ",{"type":28,"tag":188,"props":12911,"children":12913},{"className":12912},[],[12914],{"type":34,"value":11252},{"type":34,"value":12916}," se résume à :",{"type":28,"tag":181,"props":12918,"children":12920},{"className":183,"code":12919,"language":185,"meta":8,"style":8},"@Test\npublic void testSendNotification() {\n    MessageSender mockSender = Mockito.mock(MessageSender.class);\n    NotificationService service = new NotificationService(mockSender);\n\n    service.sendNotification(\"Test message\");\n\n    Mockito.verify(mockSender).sendMessage(\"Test message\");\n}\n",[12921],{"type":28,"tag":188,"props":12922,"children":12923},{"__ignoreMap":8},[12924,12935,12959,13010,13047,13054,13083,13090,13135],{"type":28,"tag":192,"props":12925,"children":12926},{"class":194,"line":195},[12927,12931],{"type":28,"tag":192,"props":12928,"children":12929},{"style":667},[12930],{"type":34,"value":670},{"type":28,"tag":192,"props":12932,"children":12933},{"style":673},[12934],{"type":34,"value":676},{"type":28,"tag":192,"props":12936,"children":12937},{"class":194,"line":205},[12938,12942,12946,12951,12955],{"type":28,"tag":192,"props":12939,"children":12940},{"style":209},[12941],{"type":34,"value":212},{"type":28,"tag":192,"props":12943,"children":12944},{"style":209},[12945],{"type":34,"value":688},{"type":28,"tag":192,"props":12947,"children":12948},{"style":325},[12949],{"type":34,"value":12950}," testSendNotification",{"type":28,"tag":192,"props":12952,"children":12953},{"style":226},[12954],{"type":34,"value":475},{"type":28,"tag":192,"props":12956,"children":12957},{"style":226},[12958],{"type":34,"value":229},{"type":28,"tag":192,"props":12960,"children":12961},{"class":194,"line":232},[12962,12967,12972,12976,12981,12985,12990,12994,12998,13002,13006],{"type":28,"tag":192,"props":12963,"children":12964},{"style":241},[12965],{"type":34,"value":12966},"    MessageSender",{"type":28,"tag":192,"props":12968,"children":12969},{"style":247},[12970],{"type":34,"value":12971}," mockSender ",{"type":28,"tag":192,"props":12973,"children":12974},{"style":387},[12975],{"type":34,"value":390},{"type":28,"tag":192,"props":12977,"children":12978},{"style":247},[12979],{"type":34,"value":12980}," Mockito",{"type":28,"tag":192,"props":12982,"children":12983},{"style":226},[12984],{"type":34,"value":379},{"type":28,"tag":192,"props":12986,"children":12987},{"style":325},[12988],{"type":34,"value":12989},"mock",{"type":28,"tag":192,"props":12991,"children":12992},{"style":226},[12993],{"type":34,"value":332},{"type":28,"tag":192,"props":12995,"children":12996},{"style":247},[12997],{"type":34,"value":11252},{"type":28,"tag":192,"props":12999,"children":13000},{"style":226},[13001],{"type":34,"value":379},{"type":28,"tag":192,"props":13003,"children":13004},{"style":247},[13005],{"type":34,"value":3696},{"type":28,"tag":192,"props":13007,"children":13008},{"style":226},[13009],{"type":34,"value":752},{"type":28,"tag":192,"props":13011,"children":13012},{"class":194,"line":258},[13013,13018,13022,13026,13030,13034,13038,13043],{"type":28,"tag":192,"props":13014,"children":13015},{"style":241},[13016],{"type":34,"value":13017},"    NotificationService",{"type":28,"tag":192,"props":13019,"children":13020},{"style":247},[13021],{"type":34,"value":3669},{"type":28,"tag":192,"props":13023,"children":13024},{"style":387},[13025],{"type":34,"value":390},{"type":28,"tag":192,"props":13027,"children":13028},{"style":209},[13029],{"type":34,"value":723},{"type":28,"tag":192,"props":13031,"children":13032},{"style":325},[13033],{"type":34,"value":8669},{"type":28,"tag":192,"props":13035,"children":13036},{"style":226},[13037],{"type":34,"value":332},{"type":28,"tag":192,"props":13039,"children":13040},{"style":247},[13041],{"type":34,"value":13042},"mockSender",{"type":28,"tag":192,"props":13044,"children":13045},{"style":226},[13046],{"type":34,"value":752},{"type":28,"tag":192,"props":13048,"children":13049},{"class":194,"line":280},[13050],{"type":28,"tag":192,"props":13051,"children":13052},{"emptyLinePlaceholder":13},[13053],{"type":34,"value":313},{"type":28,"tag":192,"props":13055,"children":13056},{"class":194,"line":307},[13057,13062,13066,13070,13074,13079],{"type":28,"tag":192,"props":13058,"children":13059},{"style":247},[13060],{"type":34,"value":13061},"    service",{"type":28,"tag":192,"props":13063,"children":13064},{"style":226},[13065],{"type":34,"value":379},{"type":28,"tag":192,"props":13067,"children":13068},{"style":325},[13069],{"type":34,"value":9677},{"type":28,"tag":192,"props":13071,"children":13072},{"style":226},[13073],{"type":34,"value":332},{"type":28,"tag":192,"props":13075,"children":13076},{"style":734},[13077],{"type":34,"value":13078},"\"Test message\"",{"type":28,"tag":192,"props":13080,"children":13081},{"style":226},[13082],{"type":34,"value":752},{"type":28,"tag":192,"props":13084,"children":13085},{"class":194,"line":316},[13086],{"type":28,"tag":192,"props":13087,"children":13088},{"emptyLinePlaceholder":13},[13089],{"type":34,"value":313},{"type":28,"tag":192,"props":13091,"children":13092},{"class":194,"line":367},[13093,13098,13102,13107,13111,13115,13119,13123,13127,13131],{"type":28,"tag":192,"props":13094,"children":13095},{"style":247},[13096],{"type":34,"value":13097},"    Mockito",{"type":28,"tag":192,"props":13099,"children":13100},{"style":226},[13101],{"type":34,"value":379},{"type":28,"tag":192,"props":13103,"children":13104},{"style":325},[13105],{"type":34,"value":13106},"verify",{"type":28,"tag":192,"props":13108,"children":13109},{"style":226},[13110],{"type":34,"value":332},{"type":28,"tag":192,"props":13112,"children":13113},{"style":247},[13114],{"type":34,"value":13042},{"type":28,"tag":192,"props":13116,"children":13117},{"style":226},[13118],{"type":34,"value":1798},{"type":28,"tag":192,"props":13120,"children":13121},{"style":325},[13122],{"type":34,"value":11358},{"type":28,"tag":192,"props":13124,"children":13125},{"style":226},[13126],{"type":34,"value":332},{"type":28,"tag":192,"props":13128,"children":13129},{"style":734},[13130],{"type":34,"value":13078},{"type":28,"tag":192,"props":13132,"children":13133},{"style":226},[13134],{"type":34,"value":752},{"type":28,"tag":192,"props":13136,"children":13137},{"class":194,"line":401},[13138],{"type":28,"tag":192,"props":13139,"children":13140},{"style":226},[13141],{"type":34,"value":588},{"type":28,"tag":1644,"props":13143,"children":13144},{"start":232},[13145],{"type":28,"tag":148,"props":13146,"children":13147},{},[13148,13153],{"type":28,"tag":55,"props":13149,"children":13150},{},[13151],{"type":34,"value":13152},"Scalabilité",{"type":34,"value":13154}," : avec un framework comme Spring, le DIP ouvre la voie à des systèmes évolutifs où chaque module se modifie, se teste ou se remplace sans impact significatif sur les autres composants.",{"type":28,"tag":1841,"props":13156,"children":13157},{"type":10255},[13158],{"type":28,"tag":44,"props":13159,"children":13160},{},[13161],{"type":34,"value":13162},"Veillez à ne pas tomber dans le piège de créer trop d'abstractions inutiles. Le DIP doit être utilisé de manière pragmatique pour éviter de sur-complexifier le système.",{"type":28,"tag":83,"props":13164,"children":13165},{},[],{"type":28,"tag":120,"props":13167,"children":13169},{"cta":1327,"href":1328,"title":13168,"type":1330},"Le DIP n'est qu'une pratique parmi les 100 que j'applique pour garder un code propre",[13170],{"type":28,"tag":44,"props":13171,"children":13172},{},[13173],{"type":34,"value":13174},"Cet article détaille une seule pratique : inverser ses dépendances pour découpler le métier de l'infrastructure. Le Craft Bundle réunit les 100 pratiques craft que j'applique au quotidien pour concevoir, tester et faire évoluer du code sans le casser, celles que l'IA ne vous apprendra jamais parce qu'elle ne les a jamais vues tenir sur la durée en production.",{"type":28,"tag":83,"props":13176,"children":13177},{},[],{"type":28,"tag":29,"props":13179,"children":13181},{"id":13180},"faq-réponses-aux-questions-fréquentes-sur-le-dip",[13182],{"type":34,"value":13183},"FAQ : Réponses aux questions fréquentes sur le DIP",{"type":28,"tag":1347,"props":13185,"children":13186},{},[13187,13192],{"type":28,"tag":1351,"props":13188,"children":13189},{},[13190],{"type":34,"value":13191},"1. Qu’est-ce que le DIP en termes simples ?",{"type":28,"tag":44,"props":13193,"children":13194},{},[13195,13196,13200],{"type":34,"value":1636},{"type":28,"tag":55,"props":13197,"children":13198},{},[13199],{"type":34,"value":10141},{"type":34,"value":13201}," (Dependency Inversion Principle) est un principe de conception : les modules de haut niveau ne doivent pas dépendre des modules de bas niveau, les deux doivent dépendre d'abstractions (interfaces). Résultat : des composants découplés, plus flexibles et plus simples à maintenir.",{"type":28,"tag":1347,"props":13203,"children":13204},{},[13205,13210],{"type":28,"tag":1351,"props":13206,"children":13207},{},[13208],{"type":34,"value":13209},"2. Pourquoi est-il si important d’appliquer le DIP ?",{"type":28,"tag":44,"props":13211,"children":13212},{},[13213,13215,13220,13221,13226,13227,13232],{"type":34,"value":13214},"Le DIP réduit le couplage entre les différentes parties d'une application. Vous pouvez modifier une partie sans toucher au reste, ce qui rend le code ",{"type":28,"tag":55,"props":13216,"children":13217},{},[13218],{"type":34,"value":13219},"flexible",{"type":34,"value":7524},{"type":28,"tag":55,"props":13222,"children":13223},{},[13224],{"type":34,"value":13225},"évolutif",{"type":34,"value":10377},{"type":28,"tag":55,"props":13228,"children":13229},{},[13230],{"type":34,"value":13231},"testable",{"type":34,"value":13233},". Décisif dans des projets à long terme ou de grande envergure.",{"type":28,"tag":1347,"props":13235,"children":13236},{},[13237,13242],{"type":28,"tag":1351,"props":13238,"children":13239},{},[13240],{"type":34,"value":13241},"3. Est-ce que le DIP rend le code plus complexe ?",{"type":28,"tag":44,"props":13243,"children":13244},{},[13245,13247,13251,13253,13258],{"type":34,"value":13246},"Cela peut paraître plus complexe au début, car vous ajoutez des ",{"type":28,"tag":55,"props":13248,"children":13249},{},[13250],{"type":34,"value":10344},{"type":34,"value":13252}," et des abstractions. Cependant, cette complexité initiale est compensée par les avantages à long terme : un code plus facile à tester, à maintenir et à faire évoluer. Il s’agit d’un ",{"type":28,"tag":55,"props":13254,"children":13255},{},[13256],{"type":34,"value":13257},"investissement",{"type":34,"value":13259}," en qualité.",{"type":28,"tag":1347,"props":13261,"children":13262},{},[13263,13268,13273],{"type":28,"tag":1351,"props":13264,"children":13265},{},[13266],{"type":34,"value":13267},"4. Dois-je appliquer le DIP dans tous mes projets, même les petits ?",{"type":28,"tag":44,"props":13269,"children":13270},{},[13271],{"type":34,"value":13272},"Le DIP est particulièrement utile dans les projets de grande taille, où les modifications fréquentes peuvent rendre la maintenance difficile. Pour les petits projets, il n’est pas toujours nécessaire de tout structurer de cette manière. Cependant, même dans des projets plus modestes, adopter de bonnes pratiques comme le DIP peut vous éviter des surprises désagréables à mesure que le projet grandit.",{"type":28,"tag":13274,"props":13275,"children":13276},"blockquote",{},[13277],{"type":28,"tag":44,"props":13278,"children":13279},{},[13280,13285],{"type":28,"tag":55,"props":13281,"children":13282},{},[13283],{"type":34,"value":13284},"TIP :",{"type":34,"value":13286}," Si vous travaillez sur un petit projet, vous pouvez choisir d’appliquer le DIP uniquement dans les parties critiques du système, comme les services ou les accès aux données, plutôt que sur toutes les classes.",{"type":28,"tag":1347,"props":13288,"children":13289},{},[13290,13295],{"type":28,"tag":1351,"props":13291,"children":13292},{},[13293],{"type":34,"value":13294},"5. Comment puis-je savoir si mon code viole le DIP ?",{"type":28,"tag":44,"props":13296,"children":13297},{},[13298],{"type":34,"value":13299},"Votre code viole le DIP si une classe de haut niveau dépend directement d’une implémentation concrète, plutôt que d’une interface ou d’une abstraction. Si un changement dans une classe bas niveau (comme une classe d’accès aux données) provoque des modifications dans les classes de haut niveau (comme les services ou les contrôleurs), c’est un signe de violation du DIP.",{"type":28,"tag":1347,"props":13301,"children":13302},{},[13303,13308],{"type":28,"tag":1351,"props":13304,"children":13305},{},[13306],{"type":34,"value":13307},"6. Comment le DIP fonctionne-t-il avec d’autres principes SOLID ?",{"type":28,"tag":44,"props":13309,"children":13310},{},[13311,13313,13318,13320,13324,13326,13330,13332,13336],{"type":34,"value":13312},"Le DIP est étroitement lié à d’autres principes du ",{"type":28,"tag":55,"props":13314,"children":13315},{},[13316],{"type":34,"value":13317},"SOLID",{"type":34,"value":13319},". Par exemple, il complète le ",{"type":28,"tag":55,"props":13321,"children":13322},{},[13323],{"type":34,"value":9898},{"type":34,"value":13325}," et le ",{"type":28,"tag":55,"props":13327,"children":13328},{},[13329],{"type":34,"value":9881},{"type":34,"value":13331},", car il permet de remplacer des implémentations sans affecter les clients de ces implémentations. En appliquant le DIP, vous facilitez également le respect du ",{"type":28,"tag":55,"props":13333,"children":13334},{},[13335],{"type":34,"value":9857},{"type":34,"value":13337},", car chaque module devient responsable d’une tâche unique.",{"type":28,"tag":1347,"props":13339,"children":13340},{},[13341,13346],{"type":28,"tag":1351,"props":13342,"children":13343},{},[13344],{"type":34,"value":13345},"7. Quels outils et frameworks peuvent m’aider à appliquer le DIP en Java ?",{"type":28,"tag":44,"props":13347,"children":13348},{},[13349,13350,13354,13356,13360,13362,13367,13369,13374,13375,13380],{"type":34,"value":1636},{"type":28,"tag":55,"props":13351,"children":13352},{},[13353],{"type":34,"value":11813},{"type":34,"value":13355}," est l’un des outils les plus populaires pour appliquer le DIP en Java. Avec des concepts comme l’",{"type":28,"tag":55,"props":13357,"children":13358},{},[13359],{"type":34,"value":11796},{"type":34,"value":13361}," (DI) et l’utilisation d’annotations comme ",{"type":28,"tag":188,"props":13363,"children":13365},{"className":13364},[],[13366],{"type":34,"value":11835},{"type":34,"value":13368},", vous pouvez facilement structurer vos applications en respectant le DIP. D’autres frameworks comme ",{"type":28,"tag":55,"props":13370,"children":13371},{},[13372],{"type":34,"value":13373},"Guice",{"type":34,"value":1865},{"type":28,"tag":55,"props":13376,"children":13377},{},[13378],{"type":34,"value":13379},"Jakarta EE CDI",{"type":34,"value":13381}," offrent également des solutions pour gérer les dépendances.",{"type":28,"tag":83,"props":13383,"children":13384},{},[],{"type":28,"tag":29,"props":13386,"children":13387},{"id":1419},[13388],{"type":34,"value":1422},{"type":28,"tag":44,"props":13390,"children":13391},{},[13392,13394,13399,13401,13405],{"type":34,"value":13393},"Cinquième des ",{"type":28,"tag":103,"props":13395,"children":13396},{"href":3979},[13397],{"type":34,"value":13398},"principes SOLID",{"type":34,"value":13400},", le ",{"type":28,"tag":55,"props":13402,"children":13403},{},[13404],{"type":34,"value":10141},{"type":34,"value":13406}," est un levier puissant pour la qualité du code. Découpler les modules rend l'application plus flexible, plus évolutive, plus testable. L'effort initial est réel. Le retour sur investissement, lui, ne se discute pas sur le long terme.",{"type":28,"tag":44,"props":13408,"children":13409},{},[13410],{"type":34,"value":13411},"Pour un code plus maintenable, commencez à adopter le DIP dès maintenant. Avec ou sans Spring, le principe reste bénéfique.",{"type":28,"tag":13274,"props":13413,"children":13414},{},[13415],{"type":28,"tag":44,"props":13416,"children":13417},{},[13418,13423,13425,13430],{"type":28,"tag":55,"props":13419,"children":13420},{},[13421],{"type":34,"value":13422},"Attention :",{"type":34,"value":13424}," L’objectif du DIP est de rendre votre code ",{"type":28,"tag":55,"props":13426,"children":13427},{},[13428],{"type":34,"value":13429},"modulable et adaptable",{"type":34,"value":13431},". N’utilisez pas le DIP simplement pour suivre une mode, mais pour résoudre des problèmes spécifiques de dépendance dans votre projet.",{"type":28,"tag":120,"props":13433,"children":13436},{"cta":13434,"href":1445,"title":13435,"type":1447},"Accéder au template gratuit →","Ressource gratuite : Faites votre propre audit engineering en 2 heures",[13437],{"type":28,"tag":44,"props":13438,"children":13439},{},[13440],{"type":34,"value":13441},"Le template Notion utilisé dans 15+ audits professionnels. 6 sections, 40 questions guidées, scoring visuel automatique, format décisionnel prêt à présenter à votre direction.",{"type":28,"tag":1455,"props":13443,"children":13444},{},[13445],{"type":34,"value":1459},{"title":8,"searchDepth":205,"depth":205,"links":13447},[13448,13449,13450,13454,13459,13463,13464],{"id":10123,"depth":205,"text":10126},{"id":10167,"depth":205,"text":10170},{"id":10276,"depth":205,"text":10279,"children":13451},[13452,13453],{"id":10300,"depth":232,"text":10303},{"id":10323,"depth":232,"text":10326},{"id":10406,"depth":205,"text":10409,"children":13455},[13456,13457,13458],{"id":10423,"depth":232,"text":10426},{"id":10774,"depth":232,"text":10777},{"id":11708,"depth":232,"text":11711},{"id":11770,"depth":205,"text":11773,"children":13460},[13461,13462],{"id":11800,"depth":232,"text":11803},{"id":11850,"depth":232,"text":11853},{"id":13180,"depth":205,"text":13183},{"id":1419,"depth":205,"text":1422},"content:fr:architecture-craft:principe-inversion-dependances-dip-java-guide-complet.md","fr/architecture-craft/principe-inversion-dependances-dip-java-guide-complet.md","fr/architecture-craft/principe-inversion-dependances-dip-java-guide-complet",{"_path":4069,"_dir":3980,"_draft":7,"_partial":7,"_locale":8,"title":13469,"description":13470,"id":13471,"date":13472,"listed":13,"nocomments":7,"hidden":7,"categories":13473,"tags":13474,"cover":13475,"readingTime":13476,"body":13481,"_type":1471,"_id":16297,"_source":1473,"_file":16298,"_stem":16299,"_extension":1476},"Principe ISP en Software Craftsmanship, Guide Pratique avec Exemples Java","Découvrez le principe de séparation d'interface (ISP) en Software Craftsmanship avec des exemples de code Java et des conseils pratiques pour un code...",43,"2024-03-27",[1484],[1486,1487],"covers/articles/principe-isp.jpg",{"text":13477,"minutes":13478,"time":13479,"words":13480},"12 min read",11.17,670200,2234,{"type":25,"children":13482,"toc":16277},[13483,13496,13501,13512,13515,13521,13532,13537,13543,13571,13576,13589,13595,13622,13628,13633,13639,13644,13657,13660,13666,13671,13677,13689,13771,13784,14014,14026,14046,14052,14064,14211,14230,14347,14374,14585,14590,14602,14608,14621,14703,14724,14837,14849,15052,15079,15374,15379,15382,15391,15397,15402,15408,15413,15420,15569,15574,15586,15592,15597,15604,15702,15715,15721,15733,15741,16057,16069,16075,16080,16092,16095,16104,16107,16113,16126,16139,16159,16172,16193,16206,16219,16232,16245,16248,16260,16263,16273],{"type":28,"tag":44,"props":13484,"children":13485},{},[13486,13488,13494],{"type":34,"value":13487},"Sur une mission récente dans la banque, j'ai retrouvé une interface ",{"type":28,"tag":188,"props":13489,"children":13491},{"className":13490},[],[13492],{"type":34,"value":13493},"Service",{"type":34,"value":13495}," qui rassemblait 23 méthodes. Toutes les classes qui l'implémentaient en ignoraient au moins la moitié. À chaque ajout de fonctionnalité, le code mort prolifère et le moindre changement casse des implémentations qui n'avaient rien demandé.",{"type":28,"tag":44,"props":13497,"children":13498},{},[13499],{"type":34,"value":13500},"C'est la signature classique d'une mauvaise conception d'interface, et le principe de séparation d'interface (ISP) attaque exactement ce problème. Quatrième des cinq principes SOLID, ISP impose une règle simple : une interface ne doit jamais forcer une classe à implémenter des méthodes dont elle n'a pas besoin.",{"type":28,"tag":44,"props":13502,"children":13503},{},[13504,13506,13510],{"type":34,"value":13505},"Dans le secteur financier, ce type d'interface \"fourre-tout\" est endémique : j'en ai croisé sur la plupart de mes missions. Robert C. Martin, dans ",{"type":28,"tag":63,"props":13507,"children":13508},{},[13509],{"type":34,"value":4015},{"type":34,"value":13511},", formalise d'ailleurs ISP comme l'un des piliers d'une architecture orientée objet saine. Cet article montre comment l'appliquer en Java, exemples à l'appui, avec les erreurs typiques à éviter.",{"type":28,"tag":83,"props":13513,"children":13514},{},[],{"type":28,"tag":29,"props":13516,"children":13518},{"id":13517},"pourquoi-respecter-le-principe-isp",[13519],{"type":34,"value":13520},"Pourquoi respecter le principe ISP ?",{"type":28,"tag":44,"props":13522,"children":13523},{},[13524,13526,13530],{"type":34,"value":13525},"Le principe de séparation d’interface (ISP) fait partie des cinq ",{"type":28,"tag":103,"props":13527,"children":13528},{"href":3979},[13529],{"type":34,"value":13398},{"type":34,"value":13531},", qui sont des lignes directrices destinées à rendre notre code plus modulable, maintenable et évolutif. ISP stipule qu’une interface ne doit pas forcer une classe à implémenter des méthodes dont elle n’a pas besoin.",{"type":28,"tag":44,"props":13533,"children":13534},{},[13535],{"type":34,"value":13536},"Mais pourquoi est-ce si important ?",{"type":28,"tag":37,"props":13538,"children":13540},{"id":13539},"_1-faciliter-la-maintenance-et-lévolution-du-code",[13541],{"type":34,"value":13542},"1. Faciliter la maintenance et l’évolution du code",{"type":28,"tag":44,"props":13544,"children":13545},{},[13546,13548,13554,13556,13562,13563,13569],{"type":34,"value":13547},"Avec une interface trop large, le moindre ajout impacte toutes les classes qui l'implémentent, même celles qui ne sont pas concernées. Prenez une interface ",{"type":28,"tag":188,"props":13549,"children":13551},{"className":13550},[],[13552],{"type":34,"value":13553},"Employe",{"type":34,"value":13555}," avec ",{"type":28,"tag":188,"props":13557,"children":13559},{"className":13558},[],[13560],{"type":34,"value":13561},"calculerSalaire()",{"type":34,"value":10377},{"type":28,"tag":188,"props":13564,"children":13566},{"className":13565},[],[13567],{"type":34,"value":13568},"gererProjets()",{"type":34,"value":13570}," : toutes les classes qui l'implémentent, développeur comme responsable de projet, devront fournir une implémentation pour les deux méthodes, même si l'une est inutile pour elles.",{"type":28,"tag":44,"props":13572,"children":13573},{},[13574],{"type":34,"value":13575},"Résultat : chaque changement dans cette interface déclenche des bugs inattendus et alourdit l'évolution du code.",{"type":28,"tag":13274,"props":13577,"children":13578},{},[13579],{"type":28,"tag":44,"props":13580,"children":13581},{},[13582,13587],{"type":28,"tag":55,"props":13583,"children":13584},{},[13585],{"type":34,"value":13586},"Tip",{"type":34,"value":13588}," : si plusieurs classes implémentent une interface sans utiliser toutes ses méthodes, c'est un signal clair que cette interface est trop large. Découpez-la.",{"type":28,"tag":37,"props":13590,"children":13592},{"id":13591},"_2-favoriser-la-réutilisabilité",[13593],{"type":34,"value":13594},"2. Favoriser la réutilisabilité",{"type":28,"tag":44,"props":13596,"children":13597},{},[13598,13600,13605,13607,13613,13614,13620],{"type":34,"value":13599},"Une interface spécifique, centrée sur une seule tâche, ouvre la voie à la réutilisabilité. Si vous divisez ",{"type":28,"tag":188,"props":13601,"children":13603},{"className":13602},[],[13604],{"type":34,"value":13553},{"type":34,"value":13606}," en deux interfaces ciblées (",{"type":28,"tag":188,"props":13608,"children":13610},{"className":13609},[],[13611],{"type":34,"value":13612},"Salarie",{"type":34,"value":10377},{"type":28,"tag":188,"props":13615,"children":13617},{"className":13616},[],[13618],{"type":34,"value":13619},"Manager",{"type":34,"value":13621},"), chaque classe n'implémente que ce dont elle a besoin. Le code reste propre et les classes deviennent réutilisables sans risquer de casser le reste.",{"type":28,"tag":37,"props":13623,"children":13625},{"id":13624},"_3-réduire-le-couplage",[13626],{"type":34,"value":13627},"3. Réduire le couplage",{"type":28,"tag":44,"props":13629,"children":13630},{},[13631],{"type":34,"value":13632},"Respecter ISP réduit aussi le couplage entre les différentes parties du code. Une classe qui dépend d'une interface large se retrouve liée à plusieurs fonctionnalités, ce qui complique sa modification ou son remplacement. Avec des interfaces ciblées, les classes sont moins couplées et chacune se modifie sans casser le reste du système.",{"type":28,"tag":37,"props":13634,"children":13636},{"id":13635},"_4-améliorer-les-tests-unitaires",[13637],{"type":34,"value":13638},"4. Améliorer les tests unitaires",{"type":28,"tag":44,"props":13640,"children":13641},{},[13642],{"type":34,"value":13643},"Les interfaces ciblées simplifient les tests unitaires. Une classe qui dépend uniquement des méthodes qui la concernent se mocke en quelques lignes. Avec une interface trop large, vous vous retrouvez à gérer des méthodes inutiles dans chaque test, ce qui alourdit la suite.",{"type":28,"tag":13274,"props":13645,"children":13646},{},[13647],{"type":28,"tag":44,"props":13648,"children":13649},{},[13650,13655],{"type":28,"tag":55,"props":13651,"children":13652},{},[13653],{"type":34,"value":13654},"Alerte",{"type":34,"value":13656}," : Des interfaces larges et mal segmentées augmentent le couplage, ce qui rend vos tests plus difficiles à écrire et à maintenir.",{"type":28,"tag":83,"props":13658,"children":13659},{},[],{"type":28,"tag":29,"props":13661,"children":13663},{"id":13662},"comment-appliquer-isp-en-java",[13664],{"type":34,"value":13665},"Comment appliquer ISP en Java ?",{"type":28,"tag":44,"props":13667,"children":13668},{},[13669],{"type":34,"value":13670},"Le principe de séparation d’interface peut sembler abstrait à première vue, mais il est très facile à comprendre une fois qu’on voit comment il s’applique dans un projet. Voici quelques exemples concrets en Java qui illustrent comment respecter ce principe.",{"type":28,"tag":37,"props":13672,"children":13674},{"id":13673},"exemple-1-une-interface-trop-large",[13675],{"type":34,"value":13676},"Exemple 1 : Une interface trop large",{"type":28,"tag":44,"props":13678,"children":13679},{},[13680,13682,13687],{"type":34,"value":13681},"Prenons une interface ",{"type":28,"tag":188,"props":13683,"children":13685},{"className":13684},[],[13686],{"type":34,"value":13553},{"type":34,"value":13688}," qui contient plusieurs méthodes. Cette interface est mal conçue car elle impose à toutes les classes qui l’implémentent de définir des méthodes dont elles n’ont peut-être pas besoin :",{"type":28,"tag":181,"props":13690,"children":13692},{"className":183,"code":13691,"language":185,"meta":8,"style":8},"public interface Employe {\n    void travailler();\n    void gererProjets();\n    void calculerSalaire();\n}\n",[13693],{"type":28,"tag":188,"props":13694,"children":13695},{"__ignoreMap":8},[13696,13716,13732,13748,13764],{"type":28,"tag":192,"props":13697,"children":13698},{"class":194,"line":195},[13699,13703,13707,13712],{"type":28,"tag":192,"props":13700,"children":13701},{"style":209},[13702],{"type":34,"value":212},{"type":28,"tag":192,"props":13704,"children":13705},{"style":209},[13706],{"type":34,"value":5275},{"type":28,"tag":192,"props":13708,"children":13709},{"style":220},[13710],{"type":34,"value":13711}," Employe",{"type":28,"tag":192,"props":13713,"children":13714},{"style":226},[13715],{"type":34,"value":229},{"type":28,"tag":192,"props":13717,"children":13718},{"class":194,"line":205},[13719,13723,13728],{"type":28,"tag":192,"props":13720,"children":13721},{"style":209},[13722],{"type":34,"value":5292},{"type":28,"tag":192,"props":13724,"children":13725},{"style":325},[13726],{"type":34,"value":13727}," travailler",{"type":28,"tag":192,"props":13729,"children":13730},{"style":226},[13731],{"type":34,"value":1973},{"type":28,"tag":192,"props":13733,"children":13734},{"class":194,"line":232},[13735,13739,13744],{"type":28,"tag":192,"props":13736,"children":13737},{"style":209},[13738],{"type":34,"value":5292},{"type":28,"tag":192,"props":13740,"children":13741},{"style":325},[13742],{"type":34,"value":13743}," gererProjets",{"type":28,"tag":192,"props":13745,"children":13746},{"style":226},[13747],{"type":34,"value":1973},{"type":28,"tag":192,"props":13749,"children":13750},{"class":194,"line":258},[13751,13755,13760],{"type":28,"tag":192,"props":13752,"children":13753},{"style":209},[13754],{"type":34,"value":5292},{"type":28,"tag":192,"props":13756,"children":13757},{"style":325},[13758],{"type":34,"value":13759}," calculerSalaire",{"type":28,"tag":192,"props":13761,"children":13762},{"style":226},[13763],{"type":34,"value":1973},{"type":28,"tag":192,"props":13765,"children":13766},{"class":194,"line":280},[13767],{"type":28,"tag":192,"props":13768,"children":13769},{"style":226},[13770],{"type":34,"value":588},{"type":28,"tag":44,"props":13772,"children":13773},{},[13774,13776,13782],{"type":34,"value":13775},"Dans ce cas, une classe ",{"type":28,"tag":188,"props":13777,"children":13779},{"className":13778},[],[13780],{"type":34,"value":13781},"Developpeur",{"type":34,"value":13783}," doit implémenter toutes ces méthodes, même si un développeur n’a pas à gérer des projets ou à calculer des salaires.",{"type":28,"tag":181,"props":13785,"children":13787},{"className":183,"code":13786,"language":185,"meta":8,"style":8},"public class Developpeur implements Employe {\n    @Override\n    public void travailler() {\n        System.out.println(\"Le développeur écrit du code.\");\n    }\n\n    @Override\n    public void gererProjets() {\n        // Non pertinent pour un développeur.\n    }\n\n    @Override\n    public void calculerSalaire() {\n        // Non pertinent pour un développeur.\n    }\n}\n",[13788],{"type":28,"tag":188,"props":13789,"children":13790},{"__ignoreMap":8},[13791,13819,13830,13853,13889,13896,13903,13914,13937,13945,13952,13959,13970,13993,14000,14007],{"type":28,"tag":192,"props":13792,"children":13793},{"class":194,"line":195},[13794,13798,13802,13807,13811,13815],{"type":28,"tag":192,"props":13795,"children":13796},{"style":209},[13797],{"type":34,"value":212},{"type":28,"tag":192,"props":13799,"children":13800},{"style":209},[13801],{"type":34,"value":217},{"type":28,"tag":192,"props":13803,"children":13804},{"style":220},[13805],{"type":34,"value":13806}," Developpeur",{"type":28,"tag":192,"props":13808,"children":13809},{"style":209},[13810],{"type":34,"value":5343},{"type":28,"tag":192,"props":13812,"children":13813},{"style":220},[13814],{"type":34,"value":13711},{"type":28,"tag":192,"props":13816,"children":13817},{"style":226},[13818],{"type":34,"value":229},{"type":28,"tag":192,"props":13820,"children":13821},{"class":194,"line":205},[13822,13826],{"type":28,"tag":192,"props":13823,"children":13824},{"style":667},[13825],{"type":34,"value":5359},{"type":28,"tag":192,"props":13827,"children":13828},{"style":673},[13829],{"type":34,"value":5364},{"type":28,"tag":192,"props":13831,"children":13832},{"class":194,"line":232},[13833,13837,13841,13845,13849],{"type":28,"tag":192,"props":13834,"children":13835},{"style":209},[13836],{"type":34,"value":322},{"type":28,"tag":192,"props":13838,"children":13839},{"style":209},[13840],{"type":34,"value":688},{"type":28,"tag":192,"props":13842,"children":13843},{"style":325},[13844],{"type":34,"value":13727},{"type":28,"tag":192,"props":13846,"children":13847},{"style":226},[13848],{"type":34,"value":475},{"type":28,"tag":192,"props":13850,"children":13851},{"style":226},[13852],{"type":34,"value":229},{"type":28,"tag":192,"props":13854,"children":13855},{"class":194,"line":258},[13856,13860,13864,13868,13872,13876,13880,13885],{"type":28,"tag":192,"props":13857,"children":13858},{"style":247},[13859],{"type":34,"value":4327},{"type":28,"tag":192,"props":13861,"children":13862},{"style":226},[13863],{"type":34,"value":379},{"type":28,"tag":192,"props":13865,"children":13866},{"style":247},[13867],{"type":34,"value":2673},{"type":28,"tag":192,"props":13869,"children":13870},{"style":226},[13871],{"type":34,"value":379},{"type":28,"tag":192,"props":13873,"children":13874},{"style":325},[13875],{"type":34,"value":2682},{"type":28,"tag":192,"props":13877,"children":13878},{"style":226},[13879],{"type":34,"value":332},{"type":28,"tag":192,"props":13881,"children":13882},{"style":734},[13883],{"type":34,"value":13884},"\"Le développeur écrit du code.\"",{"type":28,"tag":192,"props":13886,"children":13887},{"style":226},[13888],{"type":34,"value":752},{"type":28,"tag":192,"props":13890,"children":13891},{"class":194,"line":280},[13892],{"type":28,"tag":192,"props":13893,"children":13894},{"style":226},[13895],{"type":34,"value":445},{"type":28,"tag":192,"props":13897,"children":13898},{"class":194,"line":307},[13899],{"type":28,"tag":192,"props":13900,"children":13901},{"emptyLinePlaceholder":13},[13902],{"type":34,"value":313},{"type":28,"tag":192,"props":13904,"children":13905},{"class":194,"line":316},[13906,13910],{"type":28,"tag":192,"props":13907,"children":13908},{"style":667},[13909],{"type":34,"value":5359},{"type":28,"tag":192,"props":13911,"children":13912},{"style":673},[13913],{"type":34,"value":5364},{"type":28,"tag":192,"props":13915,"children":13916},{"class":194,"line":367},[13917,13921,13925,13929,13933],{"type":28,"tag":192,"props":13918,"children":13919},{"style":209},[13920],{"type":34,"value":322},{"type":28,"tag":192,"props":13922,"children":13923},{"style":209},[13924],{"type":34,"value":688},{"type":28,"tag":192,"props":13926,"children":13927},{"style":325},[13928],{"type":34,"value":13743},{"type":28,"tag":192,"props":13930,"children":13931},{"style":226},[13932],{"type":34,"value":475},{"type":28,"tag":192,"props":13934,"children":13935},{"style":226},[13936],{"type":34,"value":229},{"type":28,"tag":192,"props":13938,"children":13939},{"class":194,"line":401},[13940],{"type":28,"tag":192,"props":13941,"children":13942},{"style":199},[13943],{"type":34,"value":13944},"        // Non pertinent pour un développeur.\n",{"type":28,"tag":192,"props":13946,"children":13947},{"class":194,"line":430},[13948],{"type":28,"tag":192,"props":13949,"children":13950},{"style":226},[13951],{"type":34,"value":445},{"type":28,"tag":192,"props":13953,"children":13954},{"class":194,"line":439},[13955],{"type":28,"tag":192,"props":13956,"children":13957},{"emptyLinePlaceholder":13},[13958],{"type":34,"value":313},{"type":28,"tag":192,"props":13960,"children":13961},{"class":194,"line":448},[13962,13966],{"type":28,"tag":192,"props":13963,"children":13964},{"style":667},[13965],{"type":34,"value":5359},{"type":28,"tag":192,"props":13967,"children":13968},{"style":673},[13969],{"type":34,"value":5364},{"type":28,"tag":192,"props":13971,"children":13972},{"class":194,"line":456},[13973,13977,13981,13985,13989],{"type":28,"tag":192,"props":13974,"children":13975},{"style":209},[13976],{"type":34,"value":322},{"type":28,"tag":192,"props":13978,"children":13979},{"style":209},[13980],{"type":34,"value":688},{"type":28,"tag":192,"props":13982,"children":13983},{"style":325},[13984],{"type":34,"value":13759},{"type":28,"tag":192,"props":13986,"children":13987},{"style":226},[13988],{"type":34,"value":475},{"type":28,"tag":192,"props":13990,"children":13991},{"style":226},[13992],{"type":34,"value":229},{"type":28,"tag":192,"props":13994,"children":13995},{"class":194,"line":482},[13996],{"type":28,"tag":192,"props":13997,"children":13998},{"style":199},[13999],{"type":34,"value":13944},{"type":28,"tag":192,"props":14001,"children":14002},{"class":194,"line":499},[14003],{"type":28,"tag":192,"props":14004,"children":14005},{"style":226},[14006],{"type":34,"value":445},{"type":28,"tag":192,"props":14008,"children":14009},{"class":194,"line":507},[14010],{"type":28,"tag":192,"props":14011,"children":14012},{"style":226},[14013],{"type":34,"value":588},{"type":28,"tag":44,"props":14015,"children":14016},{},[14017,14019,14024],{"type":34,"value":14018},"Ici, ",{"type":28,"tag":188,"props":14020,"children":14022},{"className":14021},[],[14023],{"type":34,"value":13781},{"type":34,"value":14025}," se retrouve à implémenter des méthodes inutiles, ce qui est une violation directe du principe ISP.",{"type":28,"tag":13274,"props":14027,"children":14028},{},[14029],{"type":28,"tag":44,"props":14030,"children":14031},{},[14032,14036,14038,14044],{"type":28,"tag":55,"props":14033,"children":14034},{},[14035],{"type":34,"value":13654},{"type":34,"value":14037}," : Si vous vous retrouvez à laisser des méthodes vides ou à lever des exceptions ",{"type":28,"tag":188,"props":14039,"children":14041},{"className":14040},[],[14042],{"type":34,"value":14043},"UnsupportedOperationException",{"type":34,"value":14045},", c'est un signal clair qu'une interface est trop large.",{"type":28,"tag":37,"props":14047,"children":14049},{"id":14048},"exemple-2-appliquer-le-principe-isp-avec-des-interfaces-spécifiques",[14050],{"type":34,"value":14051},"Exemple 2 : Appliquer le principe ISP avec des interfaces spécifiques",{"type":28,"tag":44,"props":14053,"children":14054},{},[14055,14057,14062],{"type":34,"value":14056},"Pour corriger cette conception, nous devons diviser l'interface ",{"type":28,"tag":188,"props":14058,"children":14060},{"className":14059},[],[14061],{"type":34,"value":13553},{"type":34,"value":14063}," en plusieurs interfaces plus spécifiques. Chaque interface doit refléter un comportement précis, que seules les classes pertinentes implémenteront.",{"type":28,"tag":181,"props":14065,"children":14067},{"className":183,"code":14066,"language":185,"meta":8,"style":8},"public interface Travailleur {\n    void travailler();\n}\n\npublic interface Manager {\n    void gererProjets();\n}\n\npublic interface Salarie {\n    void calculerSalaire();\n}\n",[14068],{"type":28,"tag":188,"props":14069,"children":14070},{"__ignoreMap":8},[14071,14091,14106,14113,14120,14140,14155,14162,14169,14189,14204],{"type":28,"tag":192,"props":14072,"children":14073},{"class":194,"line":195},[14074,14078,14082,14087],{"type":28,"tag":192,"props":14075,"children":14076},{"style":209},[14077],{"type":34,"value":212},{"type":28,"tag":192,"props":14079,"children":14080},{"style":209},[14081],{"type":34,"value":5275},{"type":28,"tag":192,"props":14083,"children":14084},{"style":220},[14085],{"type":34,"value":14086}," Travailleur",{"type":28,"tag":192,"props":14088,"children":14089},{"style":226},[14090],{"type":34,"value":229},{"type":28,"tag":192,"props":14092,"children":14093},{"class":194,"line":205},[14094,14098,14102],{"type":28,"tag":192,"props":14095,"children":14096},{"style":209},[14097],{"type":34,"value":5292},{"type":28,"tag":192,"props":14099,"children":14100},{"style":325},[14101],{"type":34,"value":13727},{"type":28,"tag":192,"props":14103,"children":14104},{"style":226},[14105],{"type":34,"value":1973},{"type":28,"tag":192,"props":14107,"children":14108},{"class":194,"line":232},[14109],{"type":28,"tag":192,"props":14110,"children":14111},{"style":226},[14112],{"type":34,"value":588},{"type":28,"tag":192,"props":14114,"children":14115},{"class":194,"line":258},[14116],{"type":28,"tag":192,"props":14117,"children":14118},{"emptyLinePlaceholder":13},[14119],{"type":34,"value":313},{"type":28,"tag":192,"props":14121,"children":14122},{"class":194,"line":280},[14123,14127,14131,14136],{"type":28,"tag":192,"props":14124,"children":14125},{"style":209},[14126],{"type":34,"value":212},{"type":28,"tag":192,"props":14128,"children":14129},{"style":209},[14130],{"type":34,"value":5275},{"type":28,"tag":192,"props":14132,"children":14133},{"style":220},[14134],{"type":34,"value":14135}," Manager",{"type":28,"tag":192,"props":14137,"children":14138},{"style":226},[14139],{"type":34,"value":229},{"type":28,"tag":192,"props":14141,"children":14142},{"class":194,"line":307},[14143,14147,14151],{"type":28,"tag":192,"props":14144,"children":14145},{"style":209},[14146],{"type":34,"value":5292},{"type":28,"tag":192,"props":14148,"children":14149},{"style":325},[14150],{"type":34,"value":13743},{"type":28,"tag":192,"props":14152,"children":14153},{"style":226},[14154],{"type":34,"value":1973},{"type":28,"tag":192,"props":14156,"children":14157},{"class":194,"line":316},[14158],{"type":28,"tag":192,"props":14159,"children":14160},{"style":226},[14161],{"type":34,"value":588},{"type":28,"tag":192,"props":14163,"children":14164},{"class":194,"line":367},[14165],{"type":28,"tag":192,"props":14166,"children":14167},{"emptyLinePlaceholder":13},[14168],{"type":34,"value":313},{"type":28,"tag":192,"props":14170,"children":14171},{"class":194,"line":401},[14172,14176,14180,14185],{"type":28,"tag":192,"props":14173,"children":14174},{"style":209},[14175],{"type":34,"value":212},{"type":28,"tag":192,"props":14177,"children":14178},{"style":209},[14179],{"type":34,"value":5275},{"type":28,"tag":192,"props":14181,"children":14182},{"style":220},[14183],{"type":34,"value":14184}," Salarie",{"type":28,"tag":192,"props":14186,"children":14187},{"style":226},[14188],{"type":34,"value":229},{"type":28,"tag":192,"props":14190,"children":14191},{"class":194,"line":430},[14192,14196,14200],{"type":28,"tag":192,"props":14193,"children":14194},{"style":209},[14195],{"type":34,"value":5292},{"type":28,"tag":192,"props":14197,"children":14198},{"style":325},[14199],{"type":34,"value":13759},{"type":28,"tag":192,"props":14201,"children":14202},{"style":226},[14203],{"type":34,"value":1973},{"type":28,"tag":192,"props":14205,"children":14206},{"class":194,"line":439},[14207],{"type":28,"tag":192,"props":14208,"children":14209},{"style":226},[14210],{"type":34,"value":588},{"type":28,"tag":44,"props":14212,"children":14213},{},[14214,14216,14221,14223,14229],{"type":34,"value":14215},"Maintenant, la classe ",{"type":28,"tag":188,"props":14217,"children":14219},{"className":14218},[],[14220],{"type":34,"value":13781},{"type":34,"value":14222}," n’a plus besoin d’implémenter des méthodes qui ne sont pas pertinentes pour elle. Elle n’implémente que l’interface ",{"type":28,"tag":188,"props":14224,"children":14226},{"className":14225},[],[14227],{"type":34,"value":14228},"Travailleur",{"type":34,"value":5685},{"type":28,"tag":181,"props":14231,"children":14233},{"className":183,"code":14232,"language":185,"meta":8,"style":8},"public class Developpeur implements Travailleur {\n    @Override\n    public void travailler() {\n        System.out.println(\"Le développeur écrit du code.\");\n    }\n}\n",[14234],{"type":28,"tag":188,"props":14235,"children":14236},{"__ignoreMap":8},[14237,14264,14275,14298,14333,14340],{"type":28,"tag":192,"props":14238,"children":14239},{"class":194,"line":195},[14240,14244,14248,14252,14256,14260],{"type":28,"tag":192,"props":14241,"children":14242},{"style":209},[14243],{"type":34,"value":212},{"type":28,"tag":192,"props":14245,"children":14246},{"style":209},[14247],{"type":34,"value":217},{"type":28,"tag":192,"props":14249,"children":14250},{"style":220},[14251],{"type":34,"value":13806},{"type":28,"tag":192,"props":14253,"children":14254},{"style":209},[14255],{"type":34,"value":5343},{"type":28,"tag":192,"props":14257,"children":14258},{"style":220},[14259],{"type":34,"value":14086},{"type":28,"tag":192,"props":14261,"children":14262},{"style":226},[14263],{"type":34,"value":229},{"type":28,"tag":192,"props":14265,"children":14266},{"class":194,"line":205},[14267,14271],{"type":28,"tag":192,"props":14268,"children":14269},{"style":667},[14270],{"type":34,"value":5359},{"type":28,"tag":192,"props":14272,"children":14273},{"style":673},[14274],{"type":34,"value":5364},{"type":28,"tag":192,"props":14276,"children":14277},{"class":194,"line":232},[14278,14282,14286,14290,14294],{"type":28,"tag":192,"props":14279,"children":14280},{"style":209},[14281],{"type":34,"value":322},{"type":28,"tag":192,"props":14283,"children":14284},{"style":209},[14285],{"type":34,"value":688},{"type":28,"tag":192,"props":14287,"children":14288},{"style":325},[14289],{"type":34,"value":13727},{"type":28,"tag":192,"props":14291,"children":14292},{"style":226},[14293],{"type":34,"value":475},{"type":28,"tag":192,"props":14295,"children":14296},{"style":226},[14297],{"type":34,"value":229},{"type":28,"tag":192,"props":14299,"children":14300},{"class":194,"line":258},[14301,14305,14309,14313,14317,14321,14325,14329],{"type":28,"tag":192,"props":14302,"children":14303},{"style":247},[14304],{"type":34,"value":4327},{"type":28,"tag":192,"props":14306,"children":14307},{"style":226},[14308],{"type":34,"value":379},{"type":28,"tag":192,"props":14310,"children":14311},{"style":247},[14312],{"type":34,"value":2673},{"type":28,"tag":192,"props":14314,"children":14315},{"style":226},[14316],{"type":34,"value":379},{"type":28,"tag":192,"props":14318,"children":14319},{"style":325},[14320],{"type":34,"value":2682},{"type":28,"tag":192,"props":14322,"children":14323},{"style":226},[14324],{"type":34,"value":332},{"type":28,"tag":192,"props":14326,"children":14327},{"style":734},[14328],{"type":34,"value":13884},{"type":28,"tag":192,"props":14330,"children":14331},{"style":226},[14332],{"type":34,"value":752},{"type":28,"tag":192,"props":14334,"children":14335},{"class":194,"line":280},[14336],{"type":28,"tag":192,"props":14337,"children":14338},{"style":226},[14339],{"type":34,"value":445},{"type":28,"tag":192,"props":14341,"children":14342},{"class":194,"line":307},[14343],{"type":28,"tag":192,"props":14344,"children":14345},{"style":226},[14346],{"type":34,"value":588},{"type":28,"tag":44,"props":14348,"children":14349},{},[14350,14352,14358,14360,14365,14367,14372],{"type":34,"value":14351},"De même, un ",{"type":28,"tag":188,"props":14353,"children":14355},{"className":14354},[],[14356],{"type":34,"value":14357},"ResponsableProjet",{"type":34,"value":14359}," pourrait implémenter l’interface ",{"type":28,"tag":188,"props":14361,"children":14363},{"className":14362},[],[14364],{"type":34,"value":13619},{"type":34,"value":14366}," et l’interface ",{"type":28,"tag":188,"props":14368,"children":14370},{"className":14369},[],[14371],{"type":34,"value":14228},{"type":34,"value":14373}," s'il gère des projets tout en travaillant :",{"type":28,"tag":181,"props":14375,"children":14377},{"className":183,"code":14376,"language":185,"meta":8,"style":8},"public class ResponsableProjet implements Manager, Travailleur {\n    @Override\n    public void travailler() {\n        System.out.println(\"Le responsable de projet supervise les tâches.\");\n    }\n\n    @Override\n    public void gererProjets() {\n        System.out.println(\"Le responsable de projet gère les équipes.\");\n    }\n}\n",[14378],{"type":28,"tag":188,"props":14379,"children":14380},{"__ignoreMap":8},[14381,14417,14428,14451,14487,14494,14501,14512,14535,14571,14578],{"type":28,"tag":192,"props":14382,"children":14383},{"class":194,"line":195},[14384,14388,14392,14397,14401,14405,14409,14413],{"type":28,"tag":192,"props":14385,"children":14386},{"style":209},[14387],{"type":34,"value":212},{"type":28,"tag":192,"props":14389,"children":14390},{"style":209},[14391],{"type":34,"value":217},{"type":28,"tag":192,"props":14393,"children":14394},{"style":220},[14395],{"type":34,"value":14396}," ResponsableProjet",{"type":28,"tag":192,"props":14398,"children":14399},{"style":209},[14400],{"type":34,"value":5343},{"type":28,"tag":192,"props":14402,"children":14403},{"style":220},[14404],{"type":34,"value":14135},{"type":28,"tag":192,"props":14406,"children":14407},{"style":226},[14408],{"type":34,"value":347},{"type":28,"tag":192,"props":14410,"children":14411},{"style":220},[14412],{"type":34,"value":14086},{"type":28,"tag":192,"props":14414,"children":14415},{"style":226},[14416],{"type":34,"value":229},{"type":28,"tag":192,"props":14418,"children":14419},{"class":194,"line":205},[14420,14424],{"type":28,"tag":192,"props":14421,"children":14422},{"style":667},[14423],{"type":34,"value":5359},{"type":28,"tag":192,"props":14425,"children":14426},{"style":673},[14427],{"type":34,"value":5364},{"type":28,"tag":192,"props":14429,"children":14430},{"class":194,"line":232},[14431,14435,14439,14443,14447],{"type":28,"tag":192,"props":14432,"children":14433},{"style":209},[14434],{"type":34,"value":322},{"type":28,"tag":192,"props":14436,"children":14437},{"style":209},[14438],{"type":34,"value":688},{"type":28,"tag":192,"props":14440,"children":14441},{"style":325},[14442],{"type":34,"value":13727},{"type":28,"tag":192,"props":14444,"children":14445},{"style":226},[14446],{"type":34,"value":475},{"type":28,"tag":192,"props":14448,"children":14449},{"style":226},[14450],{"type":34,"value":229},{"type":28,"tag":192,"props":14452,"children":14453},{"class":194,"line":258},[14454,14458,14462,14466,14470,14474,14478,14483],{"type":28,"tag":192,"props":14455,"children":14456},{"style":247},[14457],{"type":34,"value":4327},{"type":28,"tag":192,"props":14459,"children":14460},{"style":226},[14461],{"type":34,"value":379},{"type":28,"tag":192,"props":14463,"children":14464},{"style":247},[14465],{"type":34,"value":2673},{"type":28,"tag":192,"props":14467,"children":14468},{"style":226},[14469],{"type":34,"value":379},{"type":28,"tag":192,"props":14471,"children":14472},{"style":325},[14473],{"type":34,"value":2682},{"type":28,"tag":192,"props":14475,"children":14476},{"style":226},[14477],{"type":34,"value":332},{"type":28,"tag":192,"props":14479,"children":14480},{"style":734},[14481],{"type":34,"value":14482},"\"Le responsable de projet supervise les tâches.\"",{"type":28,"tag":192,"props":14484,"children":14485},{"style":226},[14486],{"type":34,"value":752},{"type":28,"tag":192,"props":14488,"children":14489},{"class":194,"line":280},[14490],{"type":28,"tag":192,"props":14491,"children":14492},{"style":226},[14493],{"type":34,"value":445},{"type":28,"tag":192,"props":14495,"children":14496},{"class":194,"line":307},[14497],{"type":28,"tag":192,"props":14498,"children":14499},{"emptyLinePlaceholder":13},[14500],{"type":34,"value":313},{"type":28,"tag":192,"props":14502,"children":14503},{"class":194,"line":316},[14504,14508],{"type":28,"tag":192,"props":14505,"children":14506},{"style":667},[14507],{"type":34,"value":5359},{"type":28,"tag":192,"props":14509,"children":14510},{"style":673},[14511],{"type":34,"value":5364},{"type":28,"tag":192,"props":14513,"children":14514},{"class":194,"line":367},[14515,14519,14523,14527,14531],{"type":28,"tag":192,"props":14516,"children":14517},{"style":209},[14518],{"type":34,"value":322},{"type":28,"tag":192,"props":14520,"children":14521},{"style":209},[14522],{"type":34,"value":688},{"type":28,"tag":192,"props":14524,"children":14525},{"style":325},[14526],{"type":34,"value":13743},{"type":28,"tag":192,"props":14528,"children":14529},{"style":226},[14530],{"type":34,"value":475},{"type":28,"tag":192,"props":14532,"children":14533},{"style":226},[14534],{"type":34,"value":229},{"type":28,"tag":192,"props":14536,"children":14537},{"class":194,"line":401},[14538,14542,14546,14550,14554,14558,14562,14567],{"type":28,"tag":192,"props":14539,"children":14540},{"style":247},[14541],{"type":34,"value":4327},{"type":28,"tag":192,"props":14543,"children":14544},{"style":226},[14545],{"type":34,"value":379},{"type":28,"tag":192,"props":14547,"children":14548},{"style":247},[14549],{"type":34,"value":2673},{"type":28,"tag":192,"props":14551,"children":14552},{"style":226},[14553],{"type":34,"value":379},{"type":28,"tag":192,"props":14555,"children":14556},{"style":325},[14557],{"type":34,"value":2682},{"type":28,"tag":192,"props":14559,"children":14560},{"style":226},[14561],{"type":34,"value":332},{"type":28,"tag":192,"props":14563,"children":14564},{"style":734},[14565],{"type":34,"value":14566},"\"Le responsable de projet gère les équipes.\"",{"type":28,"tag":192,"props":14568,"children":14569},{"style":226},[14570],{"type":34,"value":752},{"type":28,"tag":192,"props":14572,"children":14573},{"class":194,"line":430},[14574],{"type":28,"tag":192,"props":14575,"children":14576},{"style":226},[14577],{"type":34,"value":445},{"type":28,"tag":192,"props":14579,"children":14580},{"class":194,"line":439},[14581],{"type":28,"tag":192,"props":14582,"children":14583},{"style":226},[14584],{"type":34,"value":588},{"type":28,"tag":44,"props":14586,"children":14587},{},[14588],{"type":34,"value":14589},"Cette approche respecte parfaitement le principe ISP, car chaque classe n'implémente que les méthodes dont elle a réellement besoin.",{"type":28,"tag":13274,"props":14591,"children":14592},{},[14593],{"type":28,"tag":44,"props":14594,"children":14595},{},[14596,14600],{"type":28,"tag":55,"props":14597,"children":14598},{},[14599],{"type":34,"value":13586},{"type":34,"value":14601}," : Si vous identifiez une interface large, demandez-vous quelles classes l'utilisent et lesquelles de ses méthodes sont vraiment nécessaires. Découpez-la en interfaces spécifiques pour simplifier la conception.",{"type":28,"tag":37,"props":14603,"children":14605},{"id":14604},"exemple-3-refactoring-dune-interface-lourde",[14606],{"type":34,"value":14607},"Exemple 3 : Refactoring d'une interface lourde",{"type":28,"tag":44,"props":14609,"children":14610},{},[14611,14613,14619],{"type":34,"value":14612},"Imaginons que vous travaillez avec une interface existante qui est trop large, et vous voulez la refactorer pour respecter ISP. Prenons une interface ",{"type":28,"tag":188,"props":14614,"children":14616},{"className":14615},[],[14617],{"type":34,"value":14618},"Machine",{"type":34,"value":14620}," qui force toutes les machines à avoir des comportements différents :",{"type":28,"tag":181,"props":14622,"children":14624},{"className":183,"code":14623,"language":185,"meta":8,"style":8},"public interface Machine {\n    void demarrer();\n    void arreter();\n    void nettoyer();\n}\n",[14625],{"type":28,"tag":188,"props":14626,"children":14627},{"__ignoreMap":8},[14628,14648,14664,14680,14696],{"type":28,"tag":192,"props":14629,"children":14630},{"class":194,"line":195},[14631,14635,14639,14644],{"type":28,"tag":192,"props":14632,"children":14633},{"style":209},[14634],{"type":34,"value":212},{"type":28,"tag":192,"props":14636,"children":14637},{"style":209},[14638],{"type":34,"value":5275},{"type":28,"tag":192,"props":14640,"children":14641},{"style":220},[14642],{"type":34,"value":14643}," Machine",{"type":28,"tag":192,"props":14645,"children":14646},{"style":226},[14647],{"type":34,"value":229},{"type":28,"tag":192,"props":14649,"children":14650},{"class":194,"line":205},[14651,14655,14660],{"type":28,"tag":192,"props":14652,"children":14653},{"style":209},[14654],{"type":34,"value":5292},{"type":28,"tag":192,"props":14656,"children":14657},{"style":325},[14658],{"type":34,"value":14659}," demarrer",{"type":28,"tag":192,"props":14661,"children":14662},{"style":226},[14663],{"type":34,"value":1973},{"type":28,"tag":192,"props":14665,"children":14666},{"class":194,"line":232},[14667,14671,14676],{"type":28,"tag":192,"props":14668,"children":14669},{"style":209},[14670],{"type":34,"value":5292},{"type":28,"tag":192,"props":14672,"children":14673},{"style":325},[14674],{"type":34,"value":14675}," arreter",{"type":28,"tag":192,"props":14677,"children":14678},{"style":226},[14679],{"type":34,"value":1973},{"type":28,"tag":192,"props":14681,"children":14682},{"class":194,"line":258},[14683,14687,14692],{"type":28,"tag":192,"props":14684,"children":14685},{"style":209},[14686],{"type":34,"value":5292},{"type":28,"tag":192,"props":14688,"children":14689},{"style":325},[14690],{"type":34,"value":14691}," nettoyer",{"type":28,"tag":192,"props":14693,"children":14694},{"style":226},[14695],{"type":34,"value":1973},{"type":28,"tag":192,"props":14697,"children":14698},{"class":194,"line":280},[14699],{"type":28,"tag":192,"props":14700,"children":14701},{"style":226},[14702],{"type":34,"value":588},{"type":28,"tag":44,"props":14704,"children":14705},{},[14706,14708,14714,14716,14722],{"type":34,"value":14707},"Si vous implémentez une classe ",{"type":28,"tag":188,"props":14709,"children":14711},{"className":14710},[],[14712],{"type":34,"value":14713},"RobotCuisine",{"type":34,"value":14715},", vous n'avez pas forcément besoin de la méthode ",{"type":28,"tag":188,"props":14717,"children":14719},{"className":14718},[],[14720],{"type":34,"value":14721},"nettoyer",{"type":34,"value":14723},", qui pourrait être propre à une machine spécifique. Pour respecter ISP, je vous recommande de scinder cette interface en plusieurs interfaces plus petites et spécifiques :",{"type":28,"tag":181,"props":14725,"children":14727},{"className":183,"code":14726,"language":185,"meta":8,"style":8},"public interface Demarrage {\n    void demarrer();\n    void arreter();\n}\n\npublic interface Nettoyage {\n    void nettoyer();\n}\n",[14728],{"type":28,"tag":188,"props":14729,"children":14730},{"__ignoreMap":8},[14731,14751,14766,14781,14788,14795,14815,14830],{"type":28,"tag":192,"props":14732,"children":14733},{"class":194,"line":195},[14734,14738,14742,14747],{"type":28,"tag":192,"props":14735,"children":14736},{"style":209},[14737],{"type":34,"value":212},{"type":28,"tag":192,"props":14739,"children":14740},{"style":209},[14741],{"type":34,"value":5275},{"type":28,"tag":192,"props":14743,"children":14744},{"style":220},[14745],{"type":34,"value":14746}," Demarrage",{"type":28,"tag":192,"props":14748,"children":14749},{"style":226},[14750],{"type":34,"value":229},{"type":28,"tag":192,"props":14752,"children":14753},{"class":194,"line":205},[14754,14758,14762],{"type":28,"tag":192,"props":14755,"children":14756},{"style":209},[14757],{"type":34,"value":5292},{"type":28,"tag":192,"props":14759,"children":14760},{"style":325},[14761],{"type":34,"value":14659},{"type":28,"tag":192,"props":14763,"children":14764},{"style":226},[14765],{"type":34,"value":1973},{"type":28,"tag":192,"props":14767,"children":14768},{"class":194,"line":232},[14769,14773,14777],{"type":28,"tag":192,"props":14770,"children":14771},{"style":209},[14772],{"type":34,"value":5292},{"type":28,"tag":192,"props":14774,"children":14775},{"style":325},[14776],{"type":34,"value":14675},{"type":28,"tag":192,"props":14778,"children":14779},{"style":226},[14780],{"type":34,"value":1973},{"type":28,"tag":192,"props":14782,"children":14783},{"class":194,"line":258},[14784],{"type":28,"tag":192,"props":14785,"children":14786},{"style":226},[14787],{"type":34,"value":588},{"type":28,"tag":192,"props":14789,"children":14790},{"class":194,"line":280},[14791],{"type":28,"tag":192,"props":14792,"children":14793},{"emptyLinePlaceholder":13},[14794],{"type":34,"value":313},{"type":28,"tag":192,"props":14796,"children":14797},{"class":194,"line":307},[14798,14802,14806,14811],{"type":28,"tag":192,"props":14799,"children":14800},{"style":209},[14801],{"type":34,"value":212},{"type":28,"tag":192,"props":14803,"children":14804},{"style":209},[14805],{"type":34,"value":5275},{"type":28,"tag":192,"props":14807,"children":14808},{"style":220},[14809],{"type":34,"value":14810}," Nettoyage",{"type":28,"tag":192,"props":14812,"children":14813},{"style":226},[14814],{"type":34,"value":229},{"type":28,"tag":192,"props":14816,"children":14817},{"class":194,"line":316},[14818,14822,14826],{"type":28,"tag":192,"props":14819,"children":14820},{"style":209},[14821],{"type":34,"value":5292},{"type":28,"tag":192,"props":14823,"children":14824},{"style":325},[14825],{"type":34,"value":14691},{"type":28,"tag":192,"props":14827,"children":14828},{"style":226},[14829],{"type":34,"value":1973},{"type":28,"tag":192,"props":14831,"children":14832},{"class":194,"line":367},[14833],{"type":28,"tag":192,"props":14834,"children":14835},{"style":226},[14836],{"type":34,"value":588},{"type":28,"tag":44,"props":14838,"children":14839},{},[14840,14842,14847],{"type":34,"value":14841},"Ensuite, ",{"type":28,"tag":188,"props":14843,"children":14845},{"className":14844},[],[14846],{"type":34,"value":14713},{"type":34,"value":14848}," n’implémentera que les méthodes nécessaires :",{"type":28,"tag":181,"props":14850,"children":14852},{"className":183,"code":14851,"language":185,"meta":8,"style":8},"public class RobotCuisine implements Demarrage {\n    @Override\n    public void demarrer() {\n        System.out.println(\"Le robot démarre.\");\n    }\n\n    @Override\n    public void arreter() {\n        System.out.println(\"Le robot s'arrête.\");\n    }\n}\n",[14853],{"type":28,"tag":188,"props":14854,"children":14855},{"__ignoreMap":8},[14856,14884,14895,14918,14954,14961,14968,14979,15002,15038,15045],{"type":28,"tag":192,"props":14857,"children":14858},{"class":194,"line":195},[14859,14863,14867,14872,14876,14880],{"type":28,"tag":192,"props":14860,"children":14861},{"style":209},[14862],{"type":34,"value":212},{"type":28,"tag":192,"props":14864,"children":14865},{"style":209},[14866],{"type":34,"value":217},{"type":28,"tag":192,"props":14868,"children":14869},{"style":220},[14870],{"type":34,"value":14871}," RobotCuisine",{"type":28,"tag":192,"props":14873,"children":14874},{"style":209},[14875],{"type":34,"value":5343},{"type":28,"tag":192,"props":14877,"children":14878},{"style":220},[14879],{"type":34,"value":14746},{"type":28,"tag":192,"props":14881,"children":14882},{"style":226},[14883],{"type":34,"value":229},{"type":28,"tag":192,"props":14885,"children":14886},{"class":194,"line":205},[14887,14891],{"type":28,"tag":192,"props":14888,"children":14889},{"style":667},[14890],{"type":34,"value":5359},{"type":28,"tag":192,"props":14892,"children":14893},{"style":673},[14894],{"type":34,"value":5364},{"type":28,"tag":192,"props":14896,"children":14897},{"class":194,"line":232},[14898,14902,14906,14910,14914],{"type":28,"tag":192,"props":14899,"children":14900},{"style":209},[14901],{"type":34,"value":322},{"type":28,"tag":192,"props":14903,"children":14904},{"style":209},[14905],{"type":34,"value":688},{"type":28,"tag":192,"props":14907,"children":14908},{"style":325},[14909],{"type":34,"value":14659},{"type":28,"tag":192,"props":14911,"children":14912},{"style":226},[14913],{"type":34,"value":475},{"type":28,"tag":192,"props":14915,"children":14916},{"style":226},[14917],{"type":34,"value":229},{"type":28,"tag":192,"props":14919,"children":14920},{"class":194,"line":258},[14921,14925,14929,14933,14937,14941,14945,14950],{"type":28,"tag":192,"props":14922,"children":14923},{"style":247},[14924],{"type":34,"value":4327},{"type":28,"tag":192,"props":14926,"children":14927},{"style":226},[14928],{"type":34,"value":379},{"type":28,"tag":192,"props":14930,"children":14931},{"style":247},[14932],{"type":34,"value":2673},{"type":28,"tag":192,"props":14934,"children":14935},{"style":226},[14936],{"type":34,"value":379},{"type":28,"tag":192,"props":14938,"children":14939},{"style":325},[14940],{"type":34,"value":2682},{"type":28,"tag":192,"props":14942,"children":14943},{"style":226},[14944],{"type":34,"value":332},{"type":28,"tag":192,"props":14946,"children":14947},{"style":734},[14948],{"type":34,"value":14949},"\"Le robot démarre.\"",{"type":28,"tag":192,"props":14951,"children":14952},{"style":226},[14953],{"type":34,"value":752},{"type":28,"tag":192,"props":14955,"children":14956},{"class":194,"line":280},[14957],{"type":28,"tag":192,"props":14958,"children":14959},{"style":226},[14960],{"type":34,"value":445},{"type":28,"tag":192,"props":14962,"children":14963},{"class":194,"line":307},[14964],{"type":28,"tag":192,"props":14965,"children":14966},{"emptyLinePlaceholder":13},[14967],{"type":34,"value":313},{"type":28,"tag":192,"props":14969,"children":14970},{"class":194,"line":316},[14971,14975],{"type":28,"tag":192,"props":14972,"children":14973},{"style":667},[14974],{"type":34,"value":5359},{"type":28,"tag":192,"props":14976,"children":14977},{"style":673},[14978],{"type":34,"value":5364},{"type":28,"tag":192,"props":14980,"children":14981},{"class":194,"line":367},[14982,14986,14990,14994,14998],{"type":28,"tag":192,"props":14983,"children":14984},{"style":209},[14985],{"type":34,"value":322},{"type":28,"tag":192,"props":14987,"children":14988},{"style":209},[14989],{"type":34,"value":688},{"type":28,"tag":192,"props":14991,"children":14992},{"style":325},[14993],{"type":34,"value":14675},{"type":28,"tag":192,"props":14995,"children":14996},{"style":226},[14997],{"type":34,"value":475},{"type":28,"tag":192,"props":14999,"children":15000},{"style":226},[15001],{"type":34,"value":229},{"type":28,"tag":192,"props":15003,"children":15004},{"class":194,"line":401},[15005,15009,15013,15017,15021,15025,15029,15034],{"type":28,"tag":192,"props":15006,"children":15007},{"style":247},[15008],{"type":34,"value":4327},{"type":28,"tag":192,"props":15010,"children":15011},{"style":226},[15012],{"type":34,"value":379},{"type":28,"tag":192,"props":15014,"children":15015},{"style":247},[15016],{"type":34,"value":2673},{"type":28,"tag":192,"props":15018,"children":15019},{"style":226},[15020],{"type":34,"value":379},{"type":28,"tag":192,"props":15022,"children":15023},{"style":325},[15024],{"type":34,"value":2682},{"type":28,"tag":192,"props":15026,"children":15027},{"style":226},[15028],{"type":34,"value":332},{"type":28,"tag":192,"props":15030,"children":15031},{"style":734},[15032],{"type":34,"value":15033},"\"Le robot s'arrête.\"",{"type":28,"tag":192,"props":15035,"children":15036},{"style":226},[15037],{"type":34,"value":752},{"type":28,"tag":192,"props":15039,"children":15040},{"class":194,"line":430},[15041],{"type":28,"tag":192,"props":15042,"children":15043},{"style":226},[15044],{"type":34,"value":445},{"type":28,"tag":192,"props":15046,"children":15047},{"class":194,"line":439},[15048],{"type":28,"tag":192,"props":15049,"children":15050},{"style":226},[15051],{"type":34,"value":588},{"type":28,"tag":44,"props":15053,"children":15054},{},[15055,15057,15062,15064,15070,15072,15078],{"type":34,"value":15056},"Si vous avez une autre classe qui a besoin de la méthode ",{"type":28,"tag":188,"props":15058,"children":15060},{"className":15059},[],[15061],{"type":34,"value":14721},{"type":34,"value":15063},", comme une classe ",{"type":28,"tag":188,"props":15065,"children":15067},{"className":15066},[],[15068],{"type":34,"value":15069},"LaveVaisselle",{"type":34,"value":15071},", elle peut implémenter l'interface ",{"type":28,"tag":188,"props":15073,"children":15075},{"className":15074},[],[15076],{"type":34,"value":15077},"Nettoyage",{"type":34,"value":5685},{"type":28,"tag":181,"props":15080,"children":15082},{"className":183,"code":15081,"language":185,"meta":8,"style":8},"public class LaveVaisselle implements Demarrage, Nettoyage {\n    @Override\n    public void demarrer() {\n        System.out.println(\"Le lave-vaisselle démarre.\");\n    }\n\n    @Override\n    public void arreter() {\n        System.out.println(\"Le lave-vaisselle s'arrête.\");\n    }\n\n    @Override\n    public void nettoyer() {\n        System.out.println(\"Le lave-vaisselle nettoie.\");\n    }\n}\n",[15083],{"type":28,"tag":188,"props":15084,"children":15085},{"__ignoreMap":8},[15086,15122,15133,15156,15192,15199,15206,15217,15240,15276,15283,15290,15301,15324,15360,15367],{"type":28,"tag":192,"props":15087,"children":15088},{"class":194,"line":195},[15089,15093,15097,15102,15106,15110,15114,15118],{"type":28,"tag":192,"props":15090,"children":15091},{"style":209},[15092],{"type":34,"value":212},{"type":28,"tag":192,"props":15094,"children":15095},{"style":209},[15096],{"type":34,"value":217},{"type":28,"tag":192,"props":15098,"children":15099},{"style":220},[15100],{"type":34,"value":15101}," LaveVaisselle",{"type":28,"tag":192,"props":15103,"children":15104},{"style":209},[15105],{"type":34,"value":5343},{"type":28,"tag":192,"props":15107,"children":15108},{"style":220},[15109],{"type":34,"value":14746},{"type":28,"tag":192,"props":15111,"children":15112},{"style":226},[15113],{"type":34,"value":347},{"type":28,"tag":192,"props":15115,"children":15116},{"style":220},[15117],{"type":34,"value":14810},{"type":28,"tag":192,"props":15119,"children":15120},{"style":226},[15121],{"type":34,"value":229},{"type":28,"tag":192,"props":15123,"children":15124},{"class":194,"line":205},[15125,15129],{"type":28,"tag":192,"props":15126,"children":15127},{"style":667},[15128],{"type":34,"value":5359},{"type":28,"tag":192,"props":15130,"children":15131},{"style":673},[15132],{"type":34,"value":5364},{"type":28,"tag":192,"props":15134,"children":15135},{"class":194,"line":232},[15136,15140,15144,15148,15152],{"type":28,"tag":192,"props":15137,"children":15138},{"style":209},[15139],{"type":34,"value":322},{"type":28,"tag":192,"props":15141,"children":15142},{"style":209},[15143],{"type":34,"value":688},{"type":28,"tag":192,"props":15145,"children":15146},{"style":325},[15147],{"type":34,"value":14659},{"type":28,"tag":192,"props":15149,"children":15150},{"style":226},[15151],{"type":34,"value":475},{"type":28,"tag":192,"props":15153,"children":15154},{"style":226},[15155],{"type":34,"value":229},{"type":28,"tag":192,"props":15157,"children":15158},{"class":194,"line":258},[15159,15163,15167,15171,15175,15179,15183,15188],{"type":28,"tag":192,"props":15160,"children":15161},{"style":247},[15162],{"type":34,"value":4327},{"type":28,"tag":192,"props":15164,"children":15165},{"style":226},[15166],{"type":34,"value":379},{"type":28,"tag":192,"props":15168,"children":15169},{"style":247},[15170],{"type":34,"value":2673},{"type":28,"tag":192,"props":15172,"children":15173},{"style":226},[15174],{"type":34,"value":379},{"type":28,"tag":192,"props":15176,"children":15177},{"style":325},[15178],{"type":34,"value":2682},{"type":28,"tag":192,"props":15180,"children":15181},{"style":226},[15182],{"type":34,"value":332},{"type":28,"tag":192,"props":15184,"children":15185},{"style":734},[15186],{"type":34,"value":15187},"\"Le lave-vaisselle démarre.\"",{"type":28,"tag":192,"props":15189,"children":15190},{"style":226},[15191],{"type":34,"value":752},{"type":28,"tag":192,"props":15193,"children":15194},{"class":194,"line":280},[15195],{"type":28,"tag":192,"props":15196,"children":15197},{"style":226},[15198],{"type":34,"value":445},{"type":28,"tag":192,"props":15200,"children":15201},{"class":194,"line":307},[15202],{"type":28,"tag":192,"props":15203,"children":15204},{"emptyLinePlaceholder":13},[15205],{"type":34,"value":313},{"type":28,"tag":192,"props":15207,"children":15208},{"class":194,"line":316},[15209,15213],{"type":28,"tag":192,"props":15210,"children":15211},{"style":667},[15212],{"type":34,"value":5359},{"type":28,"tag":192,"props":15214,"children":15215},{"style":673},[15216],{"type":34,"value":5364},{"type":28,"tag":192,"props":15218,"children":15219},{"class":194,"line":367},[15220,15224,15228,15232,15236],{"type":28,"tag":192,"props":15221,"children":15222},{"style":209},[15223],{"type":34,"value":322},{"type":28,"tag":192,"props":15225,"children":15226},{"style":209},[15227],{"type":34,"value":688},{"type":28,"tag":192,"props":15229,"children":15230},{"style":325},[15231],{"type":34,"value":14675},{"type":28,"tag":192,"props":15233,"children":15234},{"style":226},[15235],{"type":34,"value":475},{"type":28,"tag":192,"props":15237,"children":15238},{"style":226},[15239],{"type":34,"value":229},{"type":28,"tag":192,"props":15241,"children":15242},{"class":194,"line":401},[15243,15247,15251,15255,15259,15263,15267,15272],{"type":28,"tag":192,"props":15244,"children":15245},{"style":247},[15246],{"type":34,"value":4327},{"type":28,"tag":192,"props":15248,"children":15249},{"style":226},[15250],{"type":34,"value":379},{"type":28,"tag":192,"props":15252,"children":15253},{"style":247},[15254],{"type":34,"value":2673},{"type":28,"tag":192,"props":15256,"children":15257},{"style":226},[15258],{"type":34,"value":379},{"type":28,"tag":192,"props":15260,"children":15261},{"style":325},[15262],{"type":34,"value":2682},{"type":28,"tag":192,"props":15264,"children":15265},{"style":226},[15266],{"type":34,"value":332},{"type":28,"tag":192,"props":15268,"children":15269},{"style":734},[15270],{"type":34,"value":15271},"\"Le lave-vaisselle s'arrête.\"",{"type":28,"tag":192,"props":15273,"children":15274},{"style":226},[15275],{"type":34,"value":752},{"type":28,"tag":192,"props":15277,"children":15278},{"class":194,"line":430},[15279],{"type":28,"tag":192,"props":15280,"children":15281},{"style":226},[15282],{"type":34,"value":445},{"type":28,"tag":192,"props":15284,"children":15285},{"class":194,"line":439},[15286],{"type":28,"tag":192,"props":15287,"children":15288},{"emptyLinePlaceholder":13},[15289],{"type":34,"value":313},{"type":28,"tag":192,"props":15291,"children":15292},{"class":194,"line":448},[15293,15297],{"type":28,"tag":192,"props":15294,"children":15295},{"style":667},[15296],{"type":34,"value":5359},{"type":28,"tag":192,"props":15298,"children":15299},{"style":673},[15300],{"type":34,"value":5364},{"type":28,"tag":192,"props":15302,"children":15303},{"class":194,"line":456},[15304,15308,15312,15316,15320],{"type":28,"tag":192,"props":15305,"children":15306},{"style":209},[15307],{"type":34,"value":322},{"type":28,"tag":192,"props":15309,"children":15310},{"style":209},[15311],{"type":34,"value":688},{"type":28,"tag":192,"props":15313,"children":15314},{"style":325},[15315],{"type":34,"value":14691},{"type":28,"tag":192,"props":15317,"children":15318},{"style":226},[15319],{"type":34,"value":475},{"type":28,"tag":192,"props":15321,"children":15322},{"style":226},[15323],{"type":34,"value":229},{"type":28,"tag":192,"props":15325,"children":15326},{"class":194,"line":482},[15327,15331,15335,15339,15343,15347,15351,15356],{"type":28,"tag":192,"props":15328,"children":15329},{"style":247},[15330],{"type":34,"value":4327},{"type":28,"tag":192,"props":15332,"children":15333},{"style":226},[15334],{"type":34,"value":379},{"type":28,"tag":192,"props":15336,"children":15337},{"style":247},[15338],{"type":34,"value":2673},{"type":28,"tag":192,"props":15340,"children":15341},{"style":226},[15342],{"type":34,"value":379},{"type":28,"tag":192,"props":15344,"children":15345},{"style":325},[15346],{"type":34,"value":2682},{"type":28,"tag":192,"props":15348,"children":15349},{"style":226},[15350],{"type":34,"value":332},{"type":28,"tag":192,"props":15352,"children":15353},{"style":734},[15354],{"type":34,"value":15355},"\"Le lave-vaisselle nettoie.\"",{"type":28,"tag":192,"props":15357,"children":15358},{"style":226},[15359],{"type":34,"value":752},{"type":28,"tag":192,"props":15361,"children":15362},{"class":194,"line":499},[15363],{"type":28,"tag":192,"props":15364,"children":15365},{"style":226},[15366],{"type":34,"value":445},{"type":28,"tag":192,"props":15368,"children":15369},{"class":194,"line":507},[15370],{"type":28,"tag":192,"props":15371,"children":15372},{"style":226},[15373],{"type":34,"value":588},{"type":28,"tag":44,"props":15375,"children":15376},{},[15377],{"type":34,"value":15378},"Cette séparation rend le code plus flexible, plus modulaire et plus simple à tester.",{"type":28,"tag":83,"props":15380,"children":15381},{},[],{"type":28,"tag":120,"props":15383,"children":15385},{"cta":122,"href":123,"title":15384,"type":125},"Vous voulez acquérir le réflexe de découper une interface au bon endroit, sans y penser ?",[15386],{"type":28,"tag":44,"props":15387,"children":15388},{},[15389],{"type":34,"value":15390},"Sentir qu'une interface est trop large et savoir exactement où la scinder, ça ne s'apprend pas dans un article : ça se travaille sur votre vrai code. En mentoring 1:1, je relis vos abstractions avec vous, on refactore ensemble vos contrats les plus douloureux, et vous repartez avec le coup d'oeil qui vous fait éviter ces fourre-tout dès la conception.",{"type":28,"tag":29,"props":15392,"children":15394},{"id":15393},"les-erreurs-courantes-à-éviter",[15395],{"type":34,"value":15396},"Les erreurs courantes à éviter",{"type":28,"tag":44,"props":15398,"children":15399},{},[15400],{"type":34,"value":15401},"Même si le principe de séparation d’interface semble simple, il est courant de tomber dans certains pièges lors de son application. Voici quelques erreurs fréquentes à éviter pour que votre code reste propre, modulaire et facile à maintenir.",{"type":28,"tag":37,"props":15403,"children":15405},{"id":15404},"_1-créer-trop-dinterfaces-inutiles",[15406],{"type":34,"value":15407},"1. Créer trop d'interfaces inutiles",{"type":28,"tag":44,"props":15409,"children":15410},{},[15411],{"type":34,"value":15412},"L'erreur la plus fréquente, c'est de sur-appliquer ISP en créant des dizaines d'interfaces ultra-spécifiques. Le système devient fragmenté, illisible, et le pattern d'origine se perd. Cherchez l'équilibre : assez petites pour ne contenir que ce dont une classe a besoin, mais pas au point de devenir redondantes ou inutilisables.",{"type":28,"tag":44,"props":15414,"children":15415},{},[15416],{"type":28,"tag":55,"props":15417,"children":15418},{},[15419],{"type":34,"value":878},{"type":28,"tag":181,"props":15421,"children":15423},{"className":183,"code":15422,"language":185,"meta":8,"style":8},"public interface Travailler {\n    void ecrireCode();\n}\n\npublic interface ManagerProjet {\n    void organiserReunion();\n}\n\npublic interface SalarieEntreprise {\n    void calculerSalaire();\n}\n",[15424],{"type":28,"tag":188,"props":15425,"children":15426},{"__ignoreMap":8},[15427,15447,15463,15470,15477,15497,15513,15520,15527,15547,15562],{"type":28,"tag":192,"props":15428,"children":15429},{"class":194,"line":195},[15430,15434,15438,15443],{"type":28,"tag":192,"props":15431,"children":15432},{"style":209},[15433],{"type":34,"value":212},{"type":28,"tag":192,"props":15435,"children":15436},{"style":209},[15437],{"type":34,"value":5275},{"type":28,"tag":192,"props":15439,"children":15440},{"style":220},[15441],{"type":34,"value":15442}," Travailler",{"type":28,"tag":192,"props":15444,"children":15445},{"style":226},[15446],{"type":34,"value":229},{"type":28,"tag":192,"props":15448,"children":15449},{"class":194,"line":205},[15450,15454,15459],{"type":28,"tag":192,"props":15451,"children":15452},{"style":209},[15453],{"type":34,"value":5292},{"type":28,"tag":192,"props":15455,"children":15456},{"style":325},[15457],{"type":34,"value":15458}," ecrireCode",{"type":28,"tag":192,"props":15460,"children":15461},{"style":226},[15462],{"type":34,"value":1973},{"type":28,"tag":192,"props":15464,"children":15465},{"class":194,"line":232},[15466],{"type":28,"tag":192,"props":15467,"children":15468},{"style":226},[15469],{"type":34,"value":588},{"type":28,"tag":192,"props":15471,"children":15472},{"class":194,"line":258},[15473],{"type":28,"tag":192,"props":15474,"children":15475},{"emptyLinePlaceholder":13},[15476],{"type":34,"value":313},{"type":28,"tag":192,"props":15478,"children":15479},{"class":194,"line":280},[15480,15484,15488,15493],{"type":28,"tag":192,"props":15481,"children":15482},{"style":209},[15483],{"type":34,"value":212},{"type":28,"tag":192,"props":15485,"children":15486},{"style":209},[15487],{"type":34,"value":5275},{"type":28,"tag":192,"props":15489,"children":15490},{"style":220},[15491],{"type":34,"value":15492}," ManagerProjet",{"type":28,"tag":192,"props":15494,"children":15495},{"style":226},[15496],{"type":34,"value":229},{"type":28,"tag":192,"props":15498,"children":15499},{"class":194,"line":307},[15500,15504,15509],{"type":28,"tag":192,"props":15501,"children":15502},{"style":209},[15503],{"type":34,"value":5292},{"type":28,"tag":192,"props":15505,"children":15506},{"style":325},[15507],{"type":34,"value":15508}," organiserReunion",{"type":28,"tag":192,"props":15510,"children":15511},{"style":226},[15512],{"type":34,"value":1973},{"type":28,"tag":192,"props":15514,"children":15515},{"class":194,"line":316},[15516],{"type":28,"tag":192,"props":15517,"children":15518},{"style":226},[15519],{"type":34,"value":588},{"type":28,"tag":192,"props":15521,"children":15522},{"class":194,"line":367},[15523],{"type":28,"tag":192,"props":15524,"children":15525},{"emptyLinePlaceholder":13},[15526],{"type":34,"value":313},{"type":28,"tag":192,"props":15528,"children":15529},{"class":194,"line":401},[15530,15534,15538,15543],{"type":28,"tag":192,"props":15531,"children":15532},{"style":209},[15533],{"type":34,"value":212},{"type":28,"tag":192,"props":15535,"children":15536},{"style":209},[15537],{"type":34,"value":5275},{"type":28,"tag":192,"props":15539,"children":15540},{"style":220},[15541],{"type":34,"value":15542}," SalarieEntreprise",{"type":28,"tag":192,"props":15544,"children":15545},{"style":226},[15546],{"type":34,"value":229},{"type":28,"tag":192,"props":15548,"children":15549},{"class":194,"line":430},[15550,15554,15558],{"type":28,"tag":192,"props":15551,"children":15552},{"style":209},[15553],{"type":34,"value":5292},{"type":28,"tag":192,"props":15555,"children":15556},{"style":325},[15557],{"type":34,"value":13759},{"type":28,"tag":192,"props":15559,"children":15560},{"style":226},[15561],{"type":34,"value":1973},{"type":28,"tag":192,"props":15563,"children":15564},{"class":194,"line":439},[15565],{"type":28,"tag":192,"props":15566,"children":15567},{"style":226},[15568],{"type":34,"value":588},{"type":28,"tag":44,"props":15570,"children":15571},{},[15572],{"type":34,"value":15573},"Cet exemple montre des interfaces beaucoup trop spécifiques. Parfois, il est plus judicieux de regrouper certaines responsabilités sous une seule interface quand cela fait sens.",{"type":28,"tag":13274,"props":15575,"children":15576},{},[15577],{"type":28,"tag":44,"props":15578,"children":15579},{},[15580,15584],{"type":28,"tag":55,"props":15581,"children":15582},{},[15583],{"type":34,"value":13586},{"type":34,"value":15585}," : regrouper des comportements similaires sous une même interface quand le métier l'autorise garde le code simple et évite la sur-segmentation. C'est un équilibre que j'ai appris à trouver chez Agirc-Arrco et Canal+ : ni fragmentation excessive, ni interface \"dieu\".",{"type":28,"tag":37,"props":15587,"children":15589},{"id":15588},"_2-concevoir-des-interfaces-trop-larges",[15590],{"type":34,"value":15591},"2. Concevoir des interfaces trop larges",{"type":28,"tag":44,"props":15593,"children":15594},{},[15595],{"type":34,"value":15596},"L'autre extrême, c'est l'interface fourre-tout, l'inverse exact d'ISP. Une interface qui regroupe trop de responsabilités force les classes à implémenter des méthodes dont elles n'ont pas besoin. Couplage et complexité explosent pour rien.",{"type":28,"tag":44,"props":15598,"children":15599},{},[15600],{"type":28,"tag":55,"props":15601,"children":15602},{},[15603],{"type":34,"value":878},{"type":28,"tag":181,"props":15605,"children":15607},{"className":183,"code":15606,"language":185,"meta":8,"style":8},"public interface ServiceClient {\n    void traiterCommande();\n    void envoyerFacture();\n    void gererReclamations();\n    void realiserAudit();\n}\n",[15608],{"type":28,"tag":188,"props":15609,"children":15610},{"__ignoreMap":8},[15611,15631,15647,15663,15679,15695],{"type":28,"tag":192,"props":15612,"children":15613},{"class":194,"line":195},[15614,15618,15622,15627],{"type":28,"tag":192,"props":15615,"children":15616},{"style":209},[15617],{"type":34,"value":212},{"type":28,"tag":192,"props":15619,"children":15620},{"style":209},[15621],{"type":34,"value":5275},{"type":28,"tag":192,"props":15623,"children":15624},{"style":220},[15625],{"type":34,"value":15626}," ServiceClient",{"type":28,"tag":192,"props":15628,"children":15629},{"style":226},[15630],{"type":34,"value":229},{"type":28,"tag":192,"props":15632,"children":15633},{"class":194,"line":205},[15634,15638,15643],{"type":28,"tag":192,"props":15635,"children":15636},{"style":209},[15637],{"type":34,"value":5292},{"type":28,"tag":192,"props":15639,"children":15640},{"style":325},[15641],{"type":34,"value":15642}," traiterCommande",{"type":28,"tag":192,"props":15644,"children":15645},{"style":226},[15646],{"type":34,"value":1973},{"type":28,"tag":192,"props":15648,"children":15649},{"class":194,"line":232},[15650,15654,15659],{"type":28,"tag":192,"props":15651,"children":15652},{"style":209},[15653],{"type":34,"value":5292},{"type":28,"tag":192,"props":15655,"children":15656},{"style":325},[15657],{"type":34,"value":15658}," envoyerFacture",{"type":28,"tag":192,"props":15660,"children":15661},{"style":226},[15662],{"type":34,"value":1973},{"type":28,"tag":192,"props":15664,"children":15665},{"class":194,"line":258},[15666,15670,15675],{"type":28,"tag":192,"props":15667,"children":15668},{"style":209},[15669],{"type":34,"value":5292},{"type":28,"tag":192,"props":15671,"children":15672},{"style":325},[15673],{"type":34,"value":15674}," gererReclamations",{"type":28,"tag":192,"props":15676,"children":15677},{"style":226},[15678],{"type":34,"value":1973},{"type":28,"tag":192,"props":15680,"children":15681},{"class":194,"line":280},[15682,15686,15691],{"type":28,"tag":192,"props":15683,"children":15684},{"style":209},[15685],{"type":34,"value":5292},{"type":28,"tag":192,"props":15687,"children":15688},{"style":325},[15689],{"type":34,"value":15690}," realiserAudit",{"type":28,"tag":192,"props":15692,"children":15693},{"style":226},[15694],{"type":34,"value":1973},{"type":28,"tag":192,"props":15696,"children":15697},{"class":194,"line":307},[15698],{"type":28,"tag":192,"props":15699,"children":15700},{"style":226},[15701],{"type":34,"value":588},{"type":28,"tag":44,"props":15703,"children":15704},{},[15705,15707,15713],{"type":34,"value":15706},"Ici, une interface ",{"type":28,"tag":188,"props":15708,"children":15710},{"className":15709},[],[15711],{"type":34,"value":15712},"ServiceClient",{"type":34,"value":15714}," regroupe des fonctionnalités très différentes, forçant les classes qui l’implémentent à prendre en charge des tâches qui n'ont rien à voir entre elles.",{"type":28,"tag":37,"props":15716,"children":15718},{"id":15717},"_3-ne-pas-reconnaître-les-symptômes-dune-interface-trop-lourde",[15719],{"type":34,"value":15720},"3. Ne pas reconnaître les symptômes d’une interface trop lourde",{"type":28,"tag":44,"props":15722,"children":15723},{},[15724,15726,15731],{"type":34,"value":15725},"Si vous vous rendez compte que vous devez fréquemment passer des paramètres ",{"type":28,"tag":188,"props":15727,"children":15729},{"className":15728},[],[15730],{"type":34,"value":3229},{"type":34,"value":15732}," ou lever des exceptions pour des méthodes non implémentées, c’est un signe clair que votre interface est trop large. Une bonne interface ne devrait jamais forcer une classe à contourner des méthodes dont elle n’a pas besoin.",{"type":28,"tag":44,"props":15734,"children":15735},{},[15736],{"type":28,"tag":55,"props":15737,"children":15738},{},[15739],{"type":34,"value":15740},"Exemple :",{"type":28,"tag":181,"props":15742,"children":15744},{"className":183,"code":15743,"language":185,"meta":8,"style":8},"public class ServiceLivraison implements ServiceClient {\n    @Override\n    public void traiterCommande() {\n        // Code de traitement de commande\n    }\n\n    @Override\n    public void envoyerFacture() {\n        // Cette méthode n'est pas pertinente pour ServiceLivraison.\n        throw new UnsupportedOperationException(\"Méthode non supportée.\");\n    }\n\n    @Override\n    public void gererReclamations() {\n        // Code de gestion des réclamations\n    }\n\n    @Override\n    public void realiserAudit() {\n        // Non pertinent pour ServiceLivraison.\n        throw new UnsupportedOperationException(\"Méthode non supportée.\");\n    }\n}\n",[15745],{"type":28,"tag":188,"props":15746,"children":15747},{"__ignoreMap":8},[15748,15776,15787,15810,15818,15825,15832,15843,15866,15874,15904,15911,15918,15929,15952,15960,15967,15974,15985,16008,16016,16043,16050],{"type":28,"tag":192,"props":15749,"children":15750},{"class":194,"line":195},[15751,15755,15759,15764,15768,15772],{"type":28,"tag":192,"props":15752,"children":15753},{"style":209},[15754],{"type":34,"value":212},{"type":28,"tag":192,"props":15756,"children":15757},{"style":209},[15758],{"type":34,"value":217},{"type":28,"tag":192,"props":15760,"children":15761},{"style":220},[15762],{"type":34,"value":15763}," ServiceLivraison",{"type":28,"tag":192,"props":15765,"children":15766},{"style":209},[15767],{"type":34,"value":5343},{"type":28,"tag":192,"props":15769,"children":15770},{"style":220},[15771],{"type":34,"value":15626},{"type":28,"tag":192,"props":15773,"children":15774},{"style":226},[15775],{"type":34,"value":229},{"type":28,"tag":192,"props":15777,"children":15778},{"class":194,"line":205},[15779,15783],{"type":28,"tag":192,"props":15780,"children":15781},{"style":667},[15782],{"type":34,"value":5359},{"type":28,"tag":192,"props":15784,"children":15785},{"style":673},[15786],{"type":34,"value":5364},{"type":28,"tag":192,"props":15788,"children":15789},{"class":194,"line":232},[15790,15794,15798,15802,15806],{"type":28,"tag":192,"props":15791,"children":15792},{"style":209},[15793],{"type":34,"value":322},{"type":28,"tag":192,"props":15795,"children":15796},{"style":209},[15797],{"type":34,"value":688},{"type":28,"tag":192,"props":15799,"children":15800},{"style":325},[15801],{"type":34,"value":15642},{"type":28,"tag":192,"props":15803,"children":15804},{"style":226},[15805],{"type":34,"value":475},{"type":28,"tag":192,"props":15807,"children":15808},{"style":226},[15809],{"type":34,"value":229},{"type":28,"tag":192,"props":15811,"children":15812},{"class":194,"line":258},[15813],{"type":28,"tag":192,"props":15814,"children":15815},{"style":199},[15816],{"type":34,"value":15817},"        // Code de traitement de commande\n",{"type":28,"tag":192,"props":15819,"children":15820},{"class":194,"line":280},[15821],{"type":28,"tag":192,"props":15822,"children":15823},{"style":226},[15824],{"type":34,"value":445},{"type":28,"tag":192,"props":15826,"children":15827},{"class":194,"line":307},[15828],{"type":28,"tag":192,"props":15829,"children":15830},{"emptyLinePlaceholder":13},[15831],{"type":34,"value":313},{"type":28,"tag":192,"props":15833,"children":15834},{"class":194,"line":316},[15835,15839],{"type":28,"tag":192,"props":15836,"children":15837},{"style":667},[15838],{"type":34,"value":5359},{"type":28,"tag":192,"props":15840,"children":15841},{"style":673},[15842],{"type":34,"value":5364},{"type":28,"tag":192,"props":15844,"children":15845},{"class":194,"line":367},[15846,15850,15854,15858,15862],{"type":28,"tag":192,"props":15847,"children":15848},{"style":209},[15849],{"type":34,"value":322},{"type":28,"tag":192,"props":15851,"children":15852},{"style":209},[15853],{"type":34,"value":688},{"type":28,"tag":192,"props":15855,"children":15856},{"style":325},[15857],{"type":34,"value":15658},{"type":28,"tag":192,"props":15859,"children":15860},{"style":226},[15861],{"type":34,"value":475},{"type":28,"tag":192,"props":15863,"children":15864},{"style":226},[15865],{"type":34,"value":229},{"type":28,"tag":192,"props":15867,"children":15868},{"class":194,"line":401},[15869],{"type":28,"tag":192,"props":15870,"children":15871},{"style":199},[15872],{"type":34,"value":15873},"        // Cette méthode n'est pas pertinente pour ServiceLivraison.\n",{"type":28,"tag":192,"props":15875,"children":15876},{"class":194,"line":430},[15877,15882,15886,15891,15895,15900],{"type":28,"tag":192,"props":15878,"children":15879},{"style":209},[15880],{"type":34,"value":15881},"        throw",{"type":28,"tag":192,"props":15883,"children":15884},{"style":209},[15885],{"type":34,"value":723},{"type":28,"tag":192,"props":15887,"children":15888},{"style":325},[15889],{"type":34,"value":15890}," UnsupportedOperationException",{"type":28,"tag":192,"props":15892,"children":15893},{"style":226},[15894],{"type":34,"value":332},{"type":28,"tag":192,"props":15896,"children":15897},{"style":734},[15898],{"type":34,"value":15899},"\"Méthode non supportée.\"",{"type":28,"tag":192,"props":15901,"children":15902},{"style":226},[15903],{"type":34,"value":752},{"type":28,"tag":192,"props":15905,"children":15906},{"class":194,"line":439},[15907],{"type":28,"tag":192,"props":15908,"children":15909},{"style":226},[15910],{"type":34,"value":445},{"type":28,"tag":192,"props":15912,"children":15913},{"class":194,"line":448},[15914],{"type":28,"tag":192,"props":15915,"children":15916},{"emptyLinePlaceholder":13},[15917],{"type":34,"value":313},{"type":28,"tag":192,"props":15919,"children":15920},{"class":194,"line":456},[15921,15925],{"type":28,"tag":192,"props":15922,"children":15923},{"style":667},[15924],{"type":34,"value":5359},{"type":28,"tag":192,"props":15926,"children":15927},{"style":673},[15928],{"type":34,"value":5364},{"type":28,"tag":192,"props":15930,"children":15931},{"class":194,"line":482},[15932,15936,15940,15944,15948],{"type":28,"tag":192,"props":15933,"children":15934},{"style":209},[15935],{"type":34,"value":322},{"type":28,"tag":192,"props":15937,"children":15938},{"style":209},[15939],{"type":34,"value":688},{"type":28,"tag":192,"props":15941,"children":15942},{"style":325},[15943],{"type":34,"value":15674},{"type":28,"tag":192,"props":15945,"children":15946},{"style":226},[15947],{"type":34,"value":475},{"type":28,"tag":192,"props":15949,"children":15950},{"style":226},[15951],{"type":34,"value":229},{"type":28,"tag":192,"props":15953,"children":15954},{"class":194,"line":499},[15955],{"type":28,"tag":192,"props":15956,"children":15957},{"style":199},[15958],{"type":34,"value":15959},"        // Code de gestion des réclamations\n",{"type":28,"tag":192,"props":15961,"children":15962},{"class":194,"line":507},[15963],{"type":28,"tag":192,"props":15964,"children":15965},{"style":226},[15966],{"type":34,"value":445},{"type":28,"tag":192,"props":15968,"children":15969},{"class":194,"line":515},[15970],{"type":28,"tag":192,"props":15971,"children":15972},{"emptyLinePlaceholder":13},[15973],{"type":34,"value":313},{"type":28,"tag":192,"props":15975,"children":15976},{"class":194,"line":540},[15977,15981],{"type":28,"tag":192,"props":15978,"children":15979},{"style":667},[15980],{"type":34,"value":5359},{"type":28,"tag":192,"props":15982,"children":15983},{"style":673},[15984],{"type":34,"value":5364},{"type":28,"tag":192,"props":15986,"children":15987},{"class":194,"line":556},[15988,15992,15996,16000,16004],{"type":28,"tag":192,"props":15989,"children":15990},{"style":209},[15991],{"type":34,"value":322},{"type":28,"tag":192,"props":15993,"children":15994},{"style":209},[15995],{"type":34,"value":688},{"type":28,"tag":192,"props":15997,"children":15998},{"style":325},[15999],{"type":34,"value":15690},{"type":28,"tag":192,"props":16001,"children":16002},{"style":226},[16003],{"type":34,"value":475},{"type":28,"tag":192,"props":16005,"children":16006},{"style":226},[16007],{"type":34,"value":229},{"type":28,"tag":192,"props":16009,"children":16010},{"class":194,"line":564},[16011],{"type":28,"tag":192,"props":16012,"children":16013},{"style":199},[16014],{"type":34,"value":16015},"        // Non pertinent pour ServiceLivraison.\n",{"type":28,"tag":192,"props":16017,"children":16018},{"class":194,"line":573},[16019,16023,16027,16031,16035,16039],{"type":28,"tag":192,"props":16020,"children":16021},{"style":209},[16022],{"type":34,"value":15881},{"type":28,"tag":192,"props":16024,"children":16025},{"style":209},[16026],{"type":34,"value":723},{"type":28,"tag":192,"props":16028,"children":16029},{"style":325},[16030],{"type":34,"value":15890},{"type":28,"tag":192,"props":16032,"children":16033},{"style":226},[16034],{"type":34,"value":332},{"type":28,"tag":192,"props":16036,"children":16037},{"style":734},[16038],{"type":34,"value":15899},{"type":28,"tag":192,"props":16040,"children":16041},{"style":226},[16042],{"type":34,"value":752},{"type":28,"tag":192,"props":16044,"children":16045},{"class":194,"line":582},[16046],{"type":28,"tag":192,"props":16047,"children":16048},{"style":226},[16049],{"type":34,"value":445},{"type":28,"tag":192,"props":16051,"children":16052},{"class":194,"line":5580},[16053],{"type":28,"tag":192,"props":16054,"children":16055},{"style":226},[16056],{"type":34,"value":588},{"type":28,"tag":44,"props":16058,"children":16059},{},[16060,16061,16067],{"type":34,"value":4486},{"type":28,"tag":188,"props":16062,"children":16064},{"className":16063},[],[16065],{"type":34,"value":16066},"ServiceLivraison",{"type":34,"value":16068}," est obligée de gérer des méthodes inutiles en lançant des exceptions. Cela viole complètement ISP et rend le code plus difficile à maintenir.",{"type":28,"tag":37,"props":16070,"children":16072},{"id":16071},"_4-ne-pas-penser-aux-changements-futurs",[16073],{"type":34,"value":16074},"4. Ne pas penser aux changements futurs",{"type":28,"tag":44,"props":16076,"children":16077},{},[16078],{"type":34,"value":16079},"Concevoir des interfaces sans anticiper les évolutions du système est un piège classique. Ajouter une méthode à une interface large impose une modification à toutes les classes qui l'implémentent, y compris celles qui n'ont aucun usage de la nouvelle fonctionnalité. Des interfaces ciblées dès le départ évitent ce problème et rendent le code plus évolutif.",{"type":28,"tag":13274,"props":16081,"children":16082},{},[16083],{"type":28,"tag":44,"props":16084,"children":16085},{},[16086,16090],{"type":28,"tag":55,"props":16087,"children":16088},{},[16089],{"type":34,"value":13586},{"type":34,"value":16091}," : Lorsque vous ajoutez une nouvelle fonctionnalité, vérifiez si elle doit vraiment être implémentée par toutes les classes existantes. Si ce n'est pas le cas, il est probablement préférable de créer une nouvelle interface.",{"type":28,"tag":83,"props":16093,"children":16094},{},[],{"type":28,"tag":120,"props":16096,"children":16098},{"cta":1327,"href":1328,"title":16097,"type":1330},"Bien découper une interface n'est qu'une pratique sur 100",[16099],{"type":28,"tag":44,"props":16100,"children":16101},{},[16102],{"type":34,"value":16103},"Appliquer ISP proprement est un réflexe parmi tous ceux qui séparent un dev senior du reste. Le Craft Bundle réunit les 100 pratiques que j'applique au quotidien pour concevoir des abstractions justes et un code qui reste maintenable. Ce sont celles que l'IA ne vous apprendra jamais, parce qu'elle ne les a jamais vues tenir en production.",{"type":28,"tag":83,"props":16105,"children":16106},{},[],{"type":28,"tag":29,"props":16108,"children":16110},{"id":16109},"faq-sur-le-principe-isp-interface-segregation-principle",[16111],{"type":34,"value":16112},"FAQ sur le principe ISP (Interface Segregation Principle)",{"type":28,"tag":1347,"props":16114,"children":16115},{},[16116,16121],{"type":28,"tag":1351,"props":16117,"children":16118},{},[16119],{"type":34,"value":16120},"1. Qu’est-ce que le principe de séparation d’interface (ISP) en quelques mots ?",{"type":28,"tag":44,"props":16122,"children":16123},{},[16124],{"type":34,"value":16125},"Le principe de séparation d’interface (ISP) stipule qu’une interface ne doit pas forcer une classe à implémenter des méthodes dont elle n’a pas besoin. Cela signifie que chaque interface doit être spécialisée et conçue pour répondre à un rôle ou une responsabilité précise, plutôt que d’essayer de tout englober.",{"type":28,"tag":1347,"props":16127,"children":16128},{},[16129,16134],{"type":28,"tag":1351,"props":16130,"children":16131},{},[16132],{"type":34,"value":16133},"2. Pourquoi est-ce important de respecter ISP ?",{"type":28,"tag":44,"props":16135,"children":16136},{},[16137],{"type":34,"value":16138},"Respecter ISP améliore la maintenabilité, la flexibilité et la réutilisabilité de votre code. Si une interface est trop large, cela entraîne un couplage élevé entre les classes, rendant le code difficile à modifier et à tester. Avec ISP, chaque classe n’implémente que les fonctionnalités dont elle a besoin, ce qui rend votre système plus modulaire.",{"type":28,"tag":1347,"props":16140,"children":16141},{},[16142,16147],{"type":28,"tag":1351,"props":16143,"children":16144},{},[16145],{"type":34,"value":16146},"3. Comment puis-je savoir qu’une interface est trop large ?",{"type":28,"tag":44,"props":16148,"children":16149},{},[16150,16152,16157],{"type":34,"value":16151},"Si vous vous retrouvez à implémenter des méthodes dont votre classe n’a pas besoin ou à lever des exceptions du type ",{"type":28,"tag":188,"props":16153,"children":16155},{"className":16154},[],[16156],{"type":34,"value":14043},{"type":34,"value":16158},", c’est un signe que votre interface est trop large. De plus, si vous êtes obligé de modifier plusieurs classes à chaque fois que vous ajoutez ou modifiez une méthode dans une interface, cela signifie probablement que cette interface regroupe trop de responsabilités.",{"type":28,"tag":1347,"props":16160,"children":16161},{},[16162,16167],{"type":28,"tag":1351,"props":16163,"children":16164},{},[16165],{"type":34,"value":16166},"4. Combien d’interfaces devrais-je créer ?",{"type":28,"tag":44,"props":16168,"children":16169},{},[16170],{"type":34,"value":16171},"Il n’y a pas de nombre exact d’interfaces à créer. Le principe est de diviser les interfaces de manière à ce qu’elles soient aussi spécifiques que nécessaire, mais pas au point de devenir inutiles ou trop fragmentées. Le but est d’atteindre un équilibre entre la spécificité et la simplicité.",{"type":28,"tag":1347,"props":16173,"children":16174},{},[16175,16180],{"type":28,"tag":1351,"props":16176,"children":16177},{},[16178],{"type":34,"value":16179},"5. Quelles sont les différences entre ISP et le principe de responsabilité unique (SRP) ?",{"type":28,"tag":44,"props":16181,"children":16182},{},[16183,16185,16191],{"type":34,"value":16184},"ISP et SRP se ressemblent dans l’idée de limiter les responsabilités, mais ils s’appliquent à différents niveaux. SRP concerne le fait qu’une classe ne devrait avoir qu’une seule raison de changer, tandis qu’ISP se focalise sur le fait qu’une interface ne devrait contenir que des méthodes pertinentes pour les classes qui l’implémentent. Les deux principes se complètent : des interfaces bien segmentées facilitent l’application du ",{"type":28,"tag":103,"props":16186,"children":16188},{"href":16187},"/fr/architecture-craft/dependency-inversion-pratique",[16189],{"type":34,"value":16190},"Dependency Inversion Principle",{"type":34,"value":16192},", car les modules de haut niveau peuvent dépendre d’abstractions précises plutôt que de contrats fourre-tout.",{"type":28,"tag":1347,"props":16194,"children":16195},{},[16196,16201],{"type":28,"tag":1351,"props":16197,"children":16198},{},[16199],{"type":34,"value":16200},"6. Quel est le lien entre ISP et les autres principes SOLID ?",{"type":28,"tag":44,"props":16202,"children":16203},{},[16204],{"type":34,"value":16205},"ISP fait partie des cinq principes SOLID, qui sont conçus pour améliorer la qualité du code orienté objet. Il est étroitement lié au principe SRP, car ils cherchent tous deux à réduire la complexité du code en limitant les responsabilités. L’ISP aide aussi à réduire le couplage, ce qui est un objectif clé du principe de l’inversion des dépendances (DIP).",{"type":28,"tag":1347,"props":16207,"children":16208},{},[16209,16214],{"type":28,"tag":1351,"props":16210,"children":16211},{},[16212],{"type":34,"value":16213},"7. Quels sont les avantages d’ISP pour les tests unitaires ?",{"type":28,"tag":44,"props":16215,"children":16216},{},[16217],{"type":34,"value":16218},"En séparant les interfaces selon leurs responsabilités spécifiques, vous simplifiez les tests unitaires. Comme les classes n’implémentent que ce dont elles ont besoin, il est plus facile de simuler des comportements (via des mocks ou des stubs) et de tester chaque fonctionnalité de manière isolée, sans se soucier des autres méthodes inutiles.",{"type":28,"tag":1347,"props":16220,"children":16221},{},[16222,16227],{"type":28,"tag":1351,"props":16223,"children":16224},{},[16225],{"type":34,"value":16226},"8. Comment appliquer ISP dans des projets existants sans tout refactorer ?",{"type":28,"tag":44,"props":16228,"children":16229},{},[16230],{"type":34,"value":16231},"Vous pouvez appliquer ISP progressivement dans un projet existant. Commencez par identifier les interfaces trop larges qui causent le plus de problèmes, puis divisez-les en interfaces plus spécifiques. Vous pouvez également adopter ISP lors de la création de nouvelles fonctionnalités, sans forcément refactorer l’intégralité du projet d’un coup.",{"type":28,"tag":1347,"props":16233,"children":16234},{},[16235,16240],{"type":28,"tag":1351,"props":16236,"children":16237},{},[16238],{"type":34,"value":16239},"9. Peut-on respecter ISP dans des langages autres que Java ?",{"type":28,"tag":44,"props":16241,"children":16242},{},[16243],{"type":34,"value":16244},"Oui, ISP est un principe général du développement orienté objet, donc vous pouvez l’appliquer dans la plupart des langages orientés objet, comme C#, Python, ou même C++. Bien que l’implémentation diffère légèrement selon le langage, l’idée reste la même : garder les interfaces petites et spécifiques.",{"type":28,"tag":83,"props":16246,"children":16247},{},[],{"type":28,"tag":44,"props":16249,"children":16250},{},[16251,16253,16258],{"type":34,"value":16252},"En suivant ces conseils et en évitant les erreurs courantes, vous pourrez tirer le meilleur parti du ",{"type":28,"tag":55,"props":16254,"children":16255},{},[16256],{"type":34,"value":16257},"principe de séparation d'interface (ISP)",{"type":34,"value":16259}," et écrire un code modulaire, maintenable et facile à tester.",{"type":28,"tag":83,"props":16261,"children":16262},{},[],{"type":28,"tag":120,"props":16264,"children":16267},{"cta":16265,"href":1445,"title":16266,"type":1447},"Télécharger le diagnostic gratuit →","Ressource gratuite : 10 signaux que votre équipe tech est en danger",[16268],{"type":28,"tag":44,"props":16269,"children":16270},{},[16271],{"type":34,"value":16272},"10 signaux d'alarme pour identifier les problèmes systémiques cachés dans votre équipe avant qu'ils deviennent critiques. Auto-diagnostic inclus : 5 minutes pour savoir où vous en êtes.",{"type":28,"tag":1455,"props":16274,"children":16275},{},[16276],{"type":34,"value":1459},{"title":8,"searchDepth":205,"depth":205,"links":16278},[16279,16285,16290,16296],{"id":13517,"depth":205,"text":13520,"children":16280},[16281,16282,16283,16284],{"id":13539,"depth":232,"text":13542},{"id":13591,"depth":232,"text":13594},{"id":13624,"depth":232,"text":13627},{"id":13635,"depth":232,"text":13638},{"id":13662,"depth":205,"text":13665,"children":16286},[16287,16288,16289],{"id":13673,"depth":232,"text":13676},{"id":14048,"depth":232,"text":14051},{"id":14604,"depth":232,"text":14607},{"id":15393,"depth":205,"text":15396,"children":16291},[16292,16293,16294,16295],{"id":15404,"depth":232,"text":15407},{"id":15588,"depth":232,"text":15591},{"id":15717,"depth":232,"text":15720},{"id":16071,"depth":232,"text":16074},{"id":16109,"depth":205,"text":16112},"content:fr:architecture-craft:principe-isp-software-craftsmanship-exemples-java.md","fr/architecture-craft/principe-isp-software-craftsmanship-exemples-java.md","fr/architecture-craft/principe-isp-software-craftsmanship-exemples-java",{"_path":641,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":16301,"description":16302,"id":16303,"date":16304,"listed":13,"hidden":7,"nocomments":7,"categories":16305,"tags":16307,"cover":16309,"readingTime":16310,"body":16314,"_type":1471,"_id":20279,"_source":1473,"_file":20280,"_stem":20281,"_extension":1476},"Découvrir les frameworks de tests en Java, Types, exemples et guide complet","Découvrez pourquoi les frameworks de tests sont indispensables pour les développeurs Java. Explorez les types de tests, des exemples concrets avec...",44,"2024-03-14",[16306],"tests-automatises-et-software-craftsmanship",[16308,17],"Tests automatises","covers/articles/frameworks-de-tests.jpg",{"text":20,"minutes":16311,"time":16312,"words":16313},7.945,476700,1589,{"type":25,"children":16315,"toc":20271},[16316,16325,16330,16342,16354,16357,16366,16371,16383,16393,16398,16410,16420,16425,16435,16455,16473,16476,16485,16490,16500,16517,16523,16846,16859,16869,16894,16900,17334,17344,17356,17362,18126,18151,18154,18163,18168,18178,18187,18193,18503,18513,18522,18528,18815,18825,18834,18840,19392,19401,19411,19420,19426,19926,19929,19938,19943,19953,19998,20008,20064,20074,20104,20116,20126,20154,20165,20187,20196,20199,20208,20231,20244,20257,20267],{"type":28,"tag":37,"props":16317,"children":16319},{"id":16318},"découvrir-limportance-et-les-différents-types-de-frameworks-de-tests-pour-les-développeurs-de-logiciels",[16320],{"type":28,"tag":55,"props":16321,"children":16322},{},[16323],{"type":34,"value":16324},"Découvrir l'importance et les différents types de frameworks de tests pour les développeurs de logiciels",{"type":28,"tag":44,"props":16326,"children":16327},{},[16328],{"type":34,"value":16329},"Scénario familier : tout fonctionne, vous livrez, un bug inattendu surgit en prod. Frustrant, et évitable avec de meilleurs tests. Tester manuellement reste tenable sur un POC. Pas sur un projet qui grandit.",{"type":28,"tag":44,"props":16331,"children":16332},{},[16333,16335,16340],{"type":34,"value":16334},"D'où l'intérêt des ",{"type":28,"tag":55,"props":16336,"children":16337},{},[16338],{"type":34,"value":16339},"frameworks de tests",{"type":34,"value":16341},". Ils automatisent, réduisent les erreurs humaines, fluidifient le développement. En Java, l'écosystème est riche : unitaires, intégration, fonctionnels. Reste à choisir le bon outil et à l'utiliser correctement.",{"type":28,"tag":44,"props":16343,"children":16344},{},[16345,16347,16352],{"type":34,"value":16346},"L'article passe en revue ",{"type":28,"tag":55,"props":16348,"children":16349},{},[16350],{"type":34,"value":16351},"pourquoi",{"type":34,"value":16353}," les frameworks de tests sont indispensables, les principaux types de tests, et des exemples concrets en Java.",{"type":28,"tag":83,"props":16355,"children":16356},{},[],{"type":28,"tag":37,"props":16358,"children":16360},{"id":16359},"frameworks-de-tests-pourquoi-en-utiliser-un",[16361],{"type":28,"tag":55,"props":16362,"children":16363},{},[16364],{"type":34,"value":16365},"Frameworks de tests : Pourquoi en utiliser un ?",{"type":28,"tag":44,"props":16367,"children":16368},{},[16369],{"type":34,"value":16370},"Sans tests automatisés, chaque nouvelle fonctionnalité ou correction de bug doit être vérifiée à la main. Inefficace à petite échelle, ingérable dès que le projet se complexifie.",{"type":28,"tag":44,"props":16372,"children":16373},{},[16374,16376,16381],{"type":34,"value":16375},"Voici ",{"type":28,"tag":55,"props":16377,"children":16378},{},[16379],{"type":34,"value":16380},"trois raisons principales",{"type":34,"value":16382}," pour lesquelles l'utilisation d'un framework de tests est essentielle :",{"type":28,"tag":169,"props":16384,"children":16386},{"id":16385},"_1-automatisation-des-tests",[16387,16388],{"type":34,"value":621},{"type":28,"tag":55,"props":16389,"children":16390},{},[16391],{"type":34,"value":16392},"Automatisation des tests",{"type":28,"tag":44,"props":16394,"children":16395},{},[16396],{"type":34,"value":16397},"Un framework exécute automatiquement des dizaines voire des centaines de tests en quelques secondes. Fini le lancement manuel de l'application, les vérifications une par une, la prise de notes. Vous récupérez du temps pour écrire des fonctionnalités, et le code reste stable.",{"type":28,"tag":13274,"props":16399,"children":16400},{},[16401],{"type":28,"tag":44,"props":16402,"children":16403},{},[16404,16408],{"type":28,"tag":55,"props":16405,"children":16406},{},[16407],{"type":34,"value":1843},{"type":34,"value":16409}," : Intégrez les tests dans votre workflow de développement dès le début. Plus tôt vous automatisez les tests, plus vous réduisez les risques de bugs en production.",{"type":28,"tag":169,"props":16411,"children":16413},{"id":16412},"_2-détection-rapide-des-bugs",[16414,16415],{"type":34,"value":860},{"type":28,"tag":55,"props":16416,"children":16417},{},[16418],{"type":34,"value":16419},"Détection rapide des bugs",{"type":28,"tag":44,"props":16421,"children":16422},{},[16423],{"type":34,"value":16424},"Les tests automatisés attrapent les régressions au moment où elles apparaissent. Chaque modification risque de casser quelque chose ailleurs. Avec une suite de tests, vous le savez immédiatement, pas en prod trois semaines plus tard. Dans les DSI bancaires et assurance que j'ai accompagnées, l'absence de tests automatisés allonge le time-to-market de 30 à 50 %. Les équipes passent une part croissante de leur capacité à gérer des régressions au lieu de livrer.",{"type":28,"tag":169,"props":16426,"children":16428},{"id":16427},"_3-amélioration-de-la-qualité-du-code",[16429,16430],{"type":34,"value":1260},{"type":28,"tag":55,"props":16431,"children":16432},{},[16433],{"type":34,"value":16434},"Amélioration de la qualité du code",{"type":28,"tag":44,"props":16436,"children":16437},{},[16438,16440,16445,16447,16453],{"type":34,"value":16439},"Le fait d’écrire des tests pousse à mieux structurer et modulariser votre code. Un code facilement testable est souvent plus propre, plus clair et mieux organisé. Les frameworks de tests favorisent ainsi des pratiques de développement comme le ",{"type":28,"tag":55,"props":16441,"children":16442},{},[16443],{"type":34,"value":16444},"TDD (Test Driven Development)",{"type":34,"value":16446},", popularisé par Kent Beck dans son ouvrage \"Test-Driven Development by Example\", où vous écrivez d’abord vos tests avant d’implémenter la fonctionnalité. Pour aller plus loin sur la qualité, une ",{"type":28,"tag":103,"props":16448,"children":16450},{"href":16449},"/fr/dette-technique/definition-of-done-qualite",[16451],{"type":34,"value":16452},"Definition of Done",{"type":34,"value":16454}," solide exige des tests automatisés comme critère non-négociable.",{"type":28,"tag":13274,"props":16456,"children":16457},{},[16458],{"type":28,"tag":44,"props":16459,"children":16460},{},[16461,16465,16467,16471],{"type":28,"tag":55,"props":16462,"children":16463},{},[16464],{"type":34,"value":1843},{"type":34,"value":16466}," : Le ",{"type":28,"tag":55,"props":16468,"children":16469},{},[16470],{"type":34,"value":1891},{"type":34,"value":16472}," peut sembler contre-intuitif au début, mais il est très efficace à long terme. Essayez d’écrire un petit test avant d’écrire la fonctionnalité : vous verrez que ça force à réfléchir en profondeur sur le comportement attendu.",{"type":28,"tag":83,"props":16474,"children":16475},{},[],{"type":28,"tag":37,"props":16477,"children":16479},{"id":16478},"les-différents-types-de-frameworks-de-tests",[16480],{"type":28,"tag":55,"props":16481,"children":16482},{},[16483],{"type":34,"value":16484},"Les différents types de frameworks de tests",{"type":28,"tag":44,"props":16486,"children":16487},{},[16488],{"type":34,"value":16489},"Il existe plusieurs types de tests, chacun ayant un rôle spécifique dans le développement logiciel. En fonction de ce que vous souhaitez tester (une petite portion de code ou tout un système), vous choisirez un type de test particulier. Voici les principaux types de tests utilisés par les développeurs, ainsi que les frameworks correspondants pour chaque type.",{"type":28,"tag":169,"props":16491,"children":16493},{"id":16492},"_1-tests-unitaires",[16494,16495],{"type":34,"value":621},{"type":28,"tag":55,"props":16496,"children":16497},{},[16498],{"type":34,"value":16499},"Tests unitaires",{"type":28,"tag":44,"props":16501,"children":16502},{},[16503,16505,16509,16510,16515],{"type":34,"value":16504},"Les tests unitaires se concentrent sur de petites portions de votre code, généralement des fonctions ou des méthodes individuelles. L'idée est de s'assurer que chaque unité fonctionne correctement de manière isolée. En Java, ",{"type":28,"tag":55,"props":16506,"children":16507},{},[16508],{"type":34,"value":3602},{"type":34,"value":10377},{"type":28,"tag":55,"props":16511,"children":16512},{},[16513],{"type":34,"value":16514},"TestNG",{"type":34,"value":16516}," sont deux des frameworks les plus populaires pour effectuer des tests unitaires.",{"type":28,"tag":12775,"props":16518,"children":16520},{"id":16519},"exemple-de-test-unitaire-avec-junit",[16521],{"type":34,"value":16522},"Exemple de test unitaire avec JUnit :",{"type":28,"tag":181,"props":16524,"children":16526},{"className":183,"code":16525,"language":185,"meta":8,"style":8},"import org.junit.jupiter.api.Test;\nimport static org.junit.jupiter.api.Assertions.assertEquals;\n\npublic class CalculatriceTest {\n\n    @Test\n    public void testAddition() {\n        Calculatrice calc = new Calculatrice();\n        int resultat = calc.addition(2, 3);\n        assertEquals(5, resultat, \"L'addition de 2 et 3 devrait être 5\");\n    }\n}\n",[16527],{"type":28,"tag":188,"props":16528,"children":16529},{"__ignoreMap":8},[16530,16583,16644,16651,16671,16678,16689,16713,16742,16793,16832,16839],{"type":28,"tag":192,"props":16531,"children":16532},{"class":194,"line":195},[16533,16538,16543,16547,16552,16556,16561,16565,16570,16574,16579],{"type":28,"tag":192,"props":16534,"children":16535},{"style":209},[16536],{"type":34,"value":16537},"import",{"type":28,"tag":192,"props":16539,"children":16540},{"style":247},[16541],{"type":34,"value":16542}," org",{"type":28,"tag":192,"props":16544,"children":16545},{"style":226},[16546],{"type":34,"value":379},{"type":28,"tag":192,"props":16548,"children":16549},{"style":247},[16550],{"type":34,"value":16551},"junit",{"type":28,"tag":192,"props":16553,"children":16554},{"style":226},[16555],{"type":34,"value":379},{"type":28,"tag":192,"props":16557,"children":16558},{"style":247},[16559],{"type":34,"value":16560},"jupiter",{"type":28,"tag":192,"props":16562,"children":16563},{"style":226},[16564],{"type":34,"value":379},{"type":28,"tag":192,"props":16566,"children":16567},{"style":247},[16568],{"type":34,"value":16569},"api",{"type":28,"tag":192,"props":16571,"children":16572},{"style":226},[16573],{"type":34,"value":379},{"type":28,"tag":192,"props":16575,"children":16576},{"style":247},[16577],{"type":34,"value":16578},"Test",{"type":28,"tag":192,"props":16580,"children":16581},{"style":226},[16582],{"type":34,"value":255},{"type":28,"tag":192,"props":16584,"children":16585},{"class":194,"line":205},[16586,16590,16594,16598,16602,16606,16610,16614,16618,16622,16626,16631,16635,16640],{"type":28,"tag":192,"props":16587,"children":16588},{"style":209},[16589],{"type":34,"value":16537},{"type":28,"tag":192,"props":16591,"children":16592},{"style":209},[16593],{"type":34,"value":5862},{"type":28,"tag":192,"props":16595,"children":16596},{"style":247},[16597],{"type":34,"value":16542},{"type":28,"tag":192,"props":16599,"children":16600},{"style":226},[16601],{"type":34,"value":379},{"type":28,"tag":192,"props":16603,"children":16604},{"style":247},[16605],{"type":34,"value":16551},{"type":28,"tag":192,"props":16607,"children":16608},{"style":226},[16609],{"type":34,"value":379},{"type":28,"tag":192,"props":16611,"children":16612},{"style":247},[16613],{"type":34,"value":16560},{"type":28,"tag":192,"props":16615,"children":16616},{"style":226},[16617],{"type":34,"value":379},{"type":28,"tag":192,"props":16619,"children":16620},{"style":247},[16621],{"type":34,"value":16569},{"type":28,"tag":192,"props":16623,"children":16624},{"style":226},[16625],{"type":34,"value":379},{"type":28,"tag":192,"props":16627,"children":16628},{"style":247},[16629],{"type":34,"value":16630},"Assertions",{"type":28,"tag":192,"props":16632,"children":16633},{"style":226},[16634],{"type":34,"value":379},{"type":28,"tag":192,"props":16636,"children":16637},{"style":247},[16638],{"type":34,"value":16639},"assertEquals",{"type":28,"tag":192,"props":16641,"children":16642},{"style":226},[16643],{"type":34,"value":255},{"type":28,"tag":192,"props":16645,"children":16646},{"class":194,"line":232},[16647],{"type":28,"tag":192,"props":16648,"children":16649},{"emptyLinePlaceholder":13},[16650],{"type":34,"value":313},{"type":28,"tag":192,"props":16652,"children":16653},{"class":194,"line":258},[16654,16658,16662,16667],{"type":28,"tag":192,"props":16655,"children":16656},{"style":209},[16657],{"type":34,"value":212},{"type":28,"tag":192,"props":16659,"children":16660},{"style":209},[16661],{"type":34,"value":217},{"type":28,"tag":192,"props":16663,"children":16664},{"style":220},[16665],{"type":34,"value":16666}," CalculatriceTest",{"type":28,"tag":192,"props":16668,"children":16669},{"style":226},[16670],{"type":34,"value":229},{"type":28,"tag":192,"props":16672,"children":16673},{"class":194,"line":280},[16674],{"type":28,"tag":192,"props":16675,"children":16676},{"emptyLinePlaceholder":13},[16677],{"type":34,"value":313},{"type":28,"tag":192,"props":16679,"children":16680},{"class":194,"line":307},[16681,16685],{"type":28,"tag":192,"props":16682,"children":16683},{"style":667},[16684],{"type":34,"value":5359},{"type":28,"tag":192,"props":16686,"children":16687},{"style":673},[16688],{"type":34,"value":676},{"type":28,"tag":192,"props":16690,"children":16691},{"class":194,"line":316},[16692,16696,16700,16705,16709],{"type":28,"tag":192,"props":16693,"children":16694},{"style":209},[16695],{"type":34,"value":322},{"type":28,"tag":192,"props":16697,"children":16698},{"style":209},[16699],{"type":34,"value":688},{"type":28,"tag":192,"props":16701,"children":16702},{"style":325},[16703],{"type":34,"value":16704}," testAddition",{"type":28,"tag":192,"props":16706,"children":16707},{"style":226},[16708],{"type":34,"value":475},{"type":28,"tag":192,"props":16710,"children":16711},{"style":226},[16712],{"type":34,"value":229},{"type":28,"tag":192,"props":16714,"children":16715},{"class":194,"line":367},[16716,16721,16725,16729,16733,16738],{"type":28,"tag":192,"props":16717,"children":16718},{"style":241},[16719],{"type":34,"value":16720},"        Calculatrice",{"type":28,"tag":192,"props":16722,"children":16723},{"style":247},[16724],{"type":34,"value":1956},{"type":28,"tag":192,"props":16726,"children":16727},{"style":387},[16728],{"type":34,"value":390},{"type":28,"tag":192,"props":16730,"children":16731},{"style":209},[16732],{"type":34,"value":723},{"type":28,"tag":192,"props":16734,"children":16735},{"style":325},[16736],{"type":34,"value":16737}," Calculatrice",{"type":28,"tag":192,"props":16739,"children":16740},{"style":226},[16741],{"type":34,"value":1973},{"type":28,"tag":192,"props":16743,"children":16744},{"class":194,"line":401},[16745,16750,16755,16759,16763,16767,16772,16776,16780,16784,16789],{"type":28,"tag":192,"props":16746,"children":16747},{"style":209},[16748],{"type":34,"value":16749},"        int",{"type":28,"tag":192,"props":16751,"children":16752},{"style":247},[16753],{"type":34,"value":16754}," resultat ",{"type":28,"tag":192,"props":16756,"children":16757},{"style":387},[16758],{"type":34,"value":390},{"type":28,"tag":192,"props":16760,"children":16761},{"style":247},[16762],{"type":34,"value":2072},{"type":28,"tag":192,"props":16764,"children":16765},{"style":226},[16766],{"type":34,"value":379},{"type":28,"tag":192,"props":16768,"children":16769},{"style":325},[16770],{"type":34,"value":16771},"addition",{"type":28,"tag":192,"props":16773,"children":16774},{"style":226},[16775],{"type":34,"value":332},{"type":28,"tag":192,"props":16777,"children":16778},{"style":744},[16779],{"type":34,"value":2025},{"type":28,"tag":192,"props":16781,"children":16782},{"style":226},[16783],{"type":34,"value":347},{"type":28,"tag":192,"props":16785,"children":16786},{"style":744},[16787],{"type":34,"value":16788}," 3",{"type":28,"tag":192,"props":16790,"children":16791},{"style":226},[16792],{"type":34,"value":752},{"type":28,"tag":192,"props":16794,"children":16795},{"class":194,"line":430},[16796,16801,16805,16810,16814,16819,16823,16828],{"type":28,"tag":192,"props":16797,"children":16798},{"style":325},[16799],{"type":34,"value":16800},"        assertEquals",{"type":28,"tag":192,"props":16802,"children":16803},{"style":226},[16804],{"type":34,"value":332},{"type":28,"tag":192,"props":16806,"children":16807},{"style":744},[16808],{"type":34,"value":16809},"5",{"type":28,"tag":192,"props":16811,"children":16812},{"style":226},[16813],{"type":34,"value":347},{"type":28,"tag":192,"props":16815,"children":16816},{"style":247},[16817],{"type":34,"value":16818}," resultat",{"type":28,"tag":192,"props":16820,"children":16821},{"style":226},[16822],{"type":34,"value":347},{"type":28,"tag":192,"props":16824,"children":16825},{"style":734},[16826],{"type":34,"value":16827}," \"L'addition de 2 et 3 devrait être 5\"",{"type":28,"tag":192,"props":16829,"children":16830},{"style":226},[16831],{"type":34,"value":752},{"type":28,"tag":192,"props":16833,"children":16834},{"class":194,"line":439},[16835],{"type":28,"tag":192,"props":16836,"children":16837},{"style":226},[16838],{"type":34,"value":445},{"type":28,"tag":192,"props":16840,"children":16841},{"class":194,"line":448},[16842],{"type":28,"tag":192,"props":16843,"children":16844},{"style":226},[16845],{"type":34,"value":588},{"type":28,"tag":13274,"props":16847,"children":16848},{},[16849],{"type":28,"tag":44,"props":16850,"children":16851},{},[16852,16857],{"type":28,"tag":55,"props":16853,"children":16854},{},[16855],{"type":34,"value":16856},"ALERT",{"type":34,"value":16858}," : Il est crucial de tester toutes les branches de votre code, même celles qui semblent rarement utilisées. Par exemple, n'oubliez pas de tester les exceptions et les cas limites.",{"type":28,"tag":169,"props":16860,"children":16862},{"id":16861},"_2-tests-dintégration",[16863,16864],{"type":34,"value":860},{"type":28,"tag":55,"props":16865,"children":16866},{},[16867],{"type":34,"value":16868},"Tests d'intégration",{"type":28,"tag":44,"props":16870,"children":16871},{},[16872,16874,16880,16882,16887,16888,16893],{"type":34,"value":16873},"Les ",{"type":28,"tag":103,"props":16875,"children":16877},{"href":16876},"/fr/dette-technique/tests-integration-legacy-pieges",[16878],{"type":34,"value":16879},"tests d'intégration",{"type":34,"value":16881}," vérifient que différentes parties de votre application fonctionnent bien ensemble. Contrairement aux tests unitaires, qui se concentrent sur des morceaux isolés, les tests d'intégration s'assurent que les interactions entre modules sont correctes. Pour ce type de tests, vous pouvez utiliser des outils comme ",{"type":28,"tag":55,"props":16883,"children":16884},{},[16885],{"type":34,"value":16886},"Spring Test",{"type":34,"value":1865},{"type":28,"tag":55,"props":16889,"children":16890},{},[16891],{"type":34,"value":16892},"Arquillian",{"type":34,"value":379},{"type":28,"tag":12775,"props":16895,"children":16897},{"id":16896},"exemple-de-test-dintégration-avec-spring",[16898],{"type":34,"value":16899},"Exemple de test d'intégration avec Spring :",{"type":28,"tag":181,"props":16901,"children":16903},{"className":183,"code":16902,"language":185,"meta":8,"style":8},"import org.junit.jupiter.api.Test;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.boot.test.context.SpringBootTest;\n\n@SpringBootTest\npublic class ApplicationIntegrationTest {\n\n    @Autowired\n    private UserService userService;\n\n    @Test\n    public void testCreerUtilisateur() {\n        User user = new User(\"John\", \"Doe\");\n        User savedUser = userService.creerUtilisateur(user);\n        assertNotNull(savedUser.getId(), \"L'utilisateur devrait avoir un ID après l'enregistrement\");\n    }\n}\n",[16904],{"type":28,"tag":188,"props":16905,"children":16906},{"__ignoreMap":8},[16907,16954,17014,17072,17079,17091,17111,17118,17129,17150,17157,17168,17192,17238,17280,17320,17327],{"type":28,"tag":192,"props":16908,"children":16909},{"class":194,"line":195},[16910,16914,16918,16922,16926,16930,16934,16938,16942,16946,16950],{"type":28,"tag":192,"props":16911,"children":16912},{"style":209},[16913],{"type":34,"value":16537},{"type":28,"tag":192,"props":16915,"children":16916},{"style":247},[16917],{"type":34,"value":16542},{"type":28,"tag":192,"props":16919,"children":16920},{"style":226},[16921],{"type":34,"value":379},{"type":28,"tag":192,"props":16923,"children":16924},{"style":247},[16925],{"type":34,"value":16551},{"type":28,"tag":192,"props":16927,"children":16928},{"style":226},[16929],{"type":34,"value":379},{"type":28,"tag":192,"props":16931,"children":16932},{"style":247},[16933],{"type":34,"value":16560},{"type":28,"tag":192,"props":16935,"children":16936},{"style":226},[16937],{"type":34,"value":379},{"type":28,"tag":192,"props":16939,"children":16940},{"style":247},[16941],{"type":34,"value":16569},{"type":28,"tag":192,"props":16943,"children":16944},{"style":226},[16945],{"type":34,"value":379},{"type":28,"tag":192,"props":16947,"children":16948},{"style":247},[16949],{"type":34,"value":16578},{"type":28,"tag":192,"props":16951,"children":16952},{"style":226},[16953],{"type":34,"value":255},{"type":28,"tag":192,"props":16955,"children":16956},{"class":194,"line":205},[16957,16961,16965,16969,16974,16978,16983,16987,16992,16996,17001,17005,17010],{"type":28,"tag":192,"props":16958,"children":16959},{"style":209},[16960],{"type":34,"value":16537},{"type":28,"tag":192,"props":16962,"children":16963},{"style":247},[16964],{"type":34,"value":16542},{"type":28,"tag":192,"props":16966,"children":16967},{"style":226},[16968],{"type":34,"value":379},{"type":28,"tag":192,"props":16970,"children":16971},{"style":247},[16972],{"type":34,"value":16973},"springframework",{"type":28,"tag":192,"props":16975,"children":16976},{"style":226},[16977],{"type":34,"value":379},{"type":28,"tag":192,"props":16979,"children":16980},{"style":247},[16981],{"type":34,"value":16982},"beans",{"type":28,"tag":192,"props":16984,"children":16985},{"style":226},[16986],{"type":34,"value":379},{"type":28,"tag":192,"props":16988,"children":16989},{"style":247},[16990],{"type":34,"value":16991},"factory",{"type":28,"tag":192,"props":16993,"children":16994},{"style":226},[16995],{"type":34,"value":379},{"type":28,"tag":192,"props":16997,"children":16998},{"style":247},[16999],{"type":34,"value":17000},"annotation",{"type":28,"tag":192,"props":17002,"children":17003},{"style":226},[17004],{"type":34,"value":379},{"type":28,"tag":192,"props":17006,"children":17007},{"style":247},[17008],{"type":34,"value":17009},"Autowired",{"type":28,"tag":192,"props":17011,"children":17012},{"style":226},[17013],{"type":34,"value":255},{"type":28,"tag":192,"props":17015,"children":17016},{"class":194,"line":232},[17017,17021,17025,17029,17033,17037,17042,17046,17050,17054,17059,17063,17068],{"type":28,"tag":192,"props":17018,"children":17019},{"style":209},[17020],{"type":34,"value":16537},{"type":28,"tag":192,"props":17022,"children":17023},{"style":247},[17024],{"type":34,"value":16542},{"type":28,"tag":192,"props":17026,"children":17027},{"style":226},[17028],{"type":34,"value":379},{"type":28,"tag":192,"props":17030,"children":17031},{"style":247},[17032],{"type":34,"value":16973},{"type":28,"tag":192,"props":17034,"children":17035},{"style":226},[17036],{"type":34,"value":379},{"type":28,"tag":192,"props":17038,"children":17039},{"style":247},[17040],{"type":34,"value":17041},"boot",{"type":28,"tag":192,"props":17043,"children":17044},{"style":226},[17045],{"type":34,"value":379},{"type":28,"tag":192,"props":17047,"children":17048},{"style":247},[17049],{"type":34,"value":644},{"type":28,"tag":192,"props":17051,"children":17052},{"style":226},[17053],{"type":34,"value":379},{"type":28,"tag":192,"props":17055,"children":17056},{"style":247},[17057],{"type":34,"value":17058},"context",{"type":28,"tag":192,"props":17060,"children":17061},{"style":226},[17062],{"type":34,"value":379},{"type":28,"tag":192,"props":17064,"children":17065},{"style":247},[17066],{"type":34,"value":17067},"SpringBootTest",{"type":28,"tag":192,"props":17069,"children":17070},{"style":226},[17071],{"type":34,"value":255},{"type":28,"tag":192,"props":17073,"children":17074},{"class":194,"line":258},[17075],{"type":28,"tag":192,"props":17076,"children":17077},{"emptyLinePlaceholder":13},[17078],{"type":34,"value":313},{"type":28,"tag":192,"props":17080,"children":17081},{"class":194,"line":280},[17082,17086],{"type":28,"tag":192,"props":17083,"children":17084},{"style":667},[17085],{"type":34,"value":670},{"type":28,"tag":192,"props":17087,"children":17088},{"style":673},[17089],{"type":34,"value":17090},"SpringBootTest\n",{"type":28,"tag":192,"props":17092,"children":17093},{"class":194,"line":307},[17094,17098,17102,17107],{"type":28,"tag":192,"props":17095,"children":17096},{"style":209},[17097],{"type":34,"value":212},{"type":28,"tag":192,"props":17099,"children":17100},{"style":209},[17101],{"type":34,"value":217},{"type":28,"tag":192,"props":17103,"children":17104},{"style":220},[17105],{"type":34,"value":17106}," ApplicationIntegrationTest",{"type":28,"tag":192,"props":17108,"children":17109},{"style":226},[17110],{"type":34,"value":229},{"type":28,"tag":192,"props":17112,"children":17113},{"class":194,"line":316},[17114],{"type":28,"tag":192,"props":17115,"children":17116},{"emptyLinePlaceholder":13},[17117],{"type":34,"value":313},{"type":28,"tag":192,"props":17119,"children":17120},{"class":194,"line":367},[17121,17125],{"type":28,"tag":192,"props":17122,"children":17123},{"style":667},[17124],{"type":34,"value":5359},{"type":28,"tag":192,"props":17126,"children":17127},{"style":673},[17128],{"type":34,"value":12353},{"type":28,"tag":192,"props":17130,"children":17131},{"class":194,"line":401},[17132,17136,17141,17146],{"type":28,"tag":192,"props":17133,"children":17134},{"style":209},[17135],{"type":34,"value":238},{"type":28,"tag":192,"props":17137,"children":17138},{"style":241},[17139],{"type":34,"value":17140}," UserService",{"type":28,"tag":192,"props":17142,"children":17143},{"style":247},[17144],{"type":34,"value":17145}," userService",{"type":28,"tag":192,"props":17147,"children":17148},{"style":226},[17149],{"type":34,"value":255},{"type":28,"tag":192,"props":17151,"children":17152},{"class":194,"line":430},[17153],{"type":28,"tag":192,"props":17154,"children":17155},{"emptyLinePlaceholder":13},[17156],{"type":34,"value":313},{"type":28,"tag":192,"props":17158,"children":17159},{"class":194,"line":439},[17160,17164],{"type":28,"tag":192,"props":17161,"children":17162},{"style":667},[17163],{"type":34,"value":5359},{"type":28,"tag":192,"props":17165,"children":17166},{"style":673},[17167],{"type":34,"value":676},{"type":28,"tag":192,"props":17169,"children":17170},{"class":194,"line":448},[17171,17175,17179,17184,17188],{"type":28,"tag":192,"props":17172,"children":17173},{"style":209},[17174],{"type":34,"value":322},{"type":28,"tag":192,"props":17176,"children":17177},{"style":209},[17178],{"type":34,"value":688},{"type":28,"tag":192,"props":17180,"children":17181},{"style":325},[17182],{"type":34,"value":17183}," testCreerUtilisateur",{"type":28,"tag":192,"props":17185,"children":17186},{"style":226},[17187],{"type":34,"value":475},{"type":28,"tag":192,"props":17189,"children":17190},{"style":226},[17191],{"type":34,"value":229},{"type":28,"tag":192,"props":17193,"children":17194},{"class":194,"line":456},[17195,17200,17204,17208,17212,17216,17220,17225,17229,17234],{"type":28,"tag":192,"props":17196,"children":17197},{"style":241},[17198],{"type":34,"value":17199},"        User",{"type":28,"tag":192,"props":17201,"children":17202},{"style":247},[17203],{"type":34,"value":714},{"type":28,"tag":192,"props":17205,"children":17206},{"style":387},[17207],{"type":34,"value":390},{"type":28,"tag":192,"props":17209,"children":17210},{"style":209},[17211],{"type":34,"value":723},{"type":28,"tag":192,"props":17213,"children":17214},{"style":325},[17215],{"type":34,"value":223},{"type":28,"tag":192,"props":17217,"children":17218},{"style":226},[17219],{"type":34,"value":332},{"type":28,"tag":192,"props":17221,"children":17222},{"style":734},[17223],{"type":34,"value":17224},"\"John\"",{"type":28,"tag":192,"props":17226,"children":17227},{"style":226},[17228],{"type":34,"value":347},{"type":28,"tag":192,"props":17230,"children":17231},{"style":734},[17232],{"type":34,"value":17233}," \"Doe\"",{"type":28,"tag":192,"props":17235,"children":17236},{"style":226},[17237],{"type":34,"value":752},{"type":28,"tag":192,"props":17239,"children":17240},{"class":194,"line":482},[17241,17245,17250,17254,17258,17262,17267,17271,17276],{"type":28,"tag":192,"props":17242,"children":17243},{"style":241},[17244],{"type":34,"value":17199},{"type":28,"tag":192,"props":17246,"children":17247},{"style":247},[17248],{"type":34,"value":17249}," savedUser ",{"type":28,"tag":192,"props":17251,"children":17252},{"style":387},[17253],{"type":34,"value":390},{"type":28,"tag":192,"props":17255,"children":17256},{"style":247},[17257],{"type":34,"value":17145},{"type":28,"tag":192,"props":17259,"children":17260},{"style":226},[17261],{"type":34,"value":379},{"type":28,"tag":192,"props":17263,"children":17264},{"style":325},[17265],{"type":34,"value":17266},"creerUtilisateur",{"type":28,"tag":192,"props":17268,"children":17269},{"style":226},[17270],{"type":34,"value":332},{"type":28,"tag":192,"props":17272,"children":17273},{"style":247},[17274],{"type":34,"value":17275},"user",{"type":28,"tag":192,"props":17277,"children":17278},{"style":226},[17279],{"type":34,"value":752},{"type":28,"tag":192,"props":17281,"children":17282},{"class":194,"line":499},[17283,17288,17292,17297,17301,17306,17311,17316],{"type":28,"tag":192,"props":17284,"children":17285},{"style":325},[17286],{"type":34,"value":17287},"        assertNotNull",{"type":28,"tag":192,"props":17289,"children":17290},{"style":226},[17291],{"type":34,"value":332},{"type":28,"tag":192,"props":17293,"children":17294},{"style":247},[17295],{"type":34,"value":17296},"savedUser",{"type":28,"tag":192,"props":17298,"children":17299},{"style":226},[17300],{"type":34,"value":379},{"type":28,"tag":192,"props":17302,"children":17303},{"style":325},[17304],{"type":34,"value":17305},"getId",{"type":28,"tag":192,"props":17307,"children":17308},{"style":226},[17309],{"type":34,"value":17310},"(),",{"type":28,"tag":192,"props":17312,"children":17313},{"style":734},[17314],{"type":34,"value":17315}," \"L'utilisateur devrait avoir un ID après l'enregistrement\"",{"type":28,"tag":192,"props":17317,"children":17318},{"style":226},[17319],{"type":34,"value":752},{"type":28,"tag":192,"props":17321,"children":17322},{"class":194,"line":507},[17323],{"type":28,"tag":192,"props":17324,"children":17325},{"style":226},[17326],{"type":34,"value":445},{"type":28,"tag":192,"props":17328,"children":17329},{"class":194,"line":515},[17330],{"type":28,"tag":192,"props":17331,"children":17332},{"style":226},[17333],{"type":34,"value":588},{"type":28,"tag":169,"props":17335,"children":17337},{"id":17336},"_3-tests-fonctionnels-ou-end-to-end",[17338,17339],{"type":34,"value":1260},{"type":28,"tag":55,"props":17340,"children":17341},{},[17342],{"type":34,"value":17343},"Tests fonctionnels (ou end-to-end)",{"type":28,"tag":44,"props":17345,"children":17346},{},[17347,17349,17354],{"type":34,"value":17348},"Les tests fonctionnels, ou tests end-to-end, vérifient l'ensemble du système du point de vue de l'utilisateur. Ils simulent des scénarios d'utilisation complets pour s'assurer que l'application fonctionne comme prévu du début à la fin. ",{"type":28,"tag":55,"props":17350,"children":17351},{},[17352],{"type":34,"value":17353},"Selenium",{"type":34,"value":17355}," est souvent utilisé pour automatiser les tests fonctionnels des applications web.",{"type":28,"tag":12775,"props":17357,"children":17359},{"id":17358},"exemple-de-test-fonctionnel-avec-selenium",[17360],{"type":34,"value":17361},"Exemple de test fonctionnel avec Selenium :",{"type":28,"tag":181,"props":17363,"children":17365},{"className":183,"code":17364,"language":185,"meta":8,"style":8},"import org.openqa.selenium.WebDriver;\nimport org.openqa.selenium.chrome.ChromeDriver;\nimport org.openqa.selenium.By;\n\npublic class LoginTest {\n\n    public static void main(String[] args) {\n        // Configurer le WebDriver pour Chrome\n        System.setProperty(\"webdriver.chrome.driver\", \"path_to_chromedriver\");\n        WebDriver driver = new ChromeDriver();\n\n        // Ouvrir la page de login\n        driver.get(\"http://monapplication.com/login\");\n\n        // Entrer les informations d'identification et se connecter\n        driver.findElement(By.id(\"username\")).sendKeys(\"monNomUtilisateur\");\n        driver.findElement(By.id(\"password\")).sendKeys(\"monMotDePasse\");\n        driver.findElement(By.id(\"loginButton\")).click();\n\n        // Vérifier que la connexion a réussi\n        String pageTitre = driver.getTitle();\n        if(pageTitre.equals(\"Tableau de bord\")) {\n            System.out.println(\"Connexion réussie !\");\n        } else {\n            System.out.println(\"Échec de la connexion.\");\n        }\n\n        // Fermer le navigateur\n        driver.quit();\n    }\n}\n",[17366],{"type":28,"tag":188,"props":17367,"children":17368},{"__ignoreMap":8},[17369,17411,17460,17500,17507,17527,17534,17577,17585,17623,17653,17660,17668,17698,17705,17713,17778,17839,17892,17899,17907,17942,17983,18019,18034,18070,18077,18084,18092,18112,18119],{"type":28,"tag":192,"props":17370,"children":17371},{"class":194,"line":195},[17372,17376,17380,17384,17389,17393,17398,17402,17407],{"type":28,"tag":192,"props":17373,"children":17374},{"style":209},[17375],{"type":34,"value":16537},{"type":28,"tag":192,"props":17377,"children":17378},{"style":247},[17379],{"type":34,"value":16542},{"type":28,"tag":192,"props":17381,"children":17382},{"style":226},[17383],{"type":34,"value":379},{"type":28,"tag":192,"props":17385,"children":17386},{"style":247},[17387],{"type":34,"value":17388},"openqa",{"type":28,"tag":192,"props":17390,"children":17391},{"style":226},[17392],{"type":34,"value":379},{"type":28,"tag":192,"props":17394,"children":17395},{"style":247},[17396],{"type":34,"value":17397},"selenium",{"type":28,"tag":192,"props":17399,"children":17400},{"style":226},[17401],{"type":34,"value":379},{"type":28,"tag":192,"props":17403,"children":17404},{"style":247},[17405],{"type":34,"value":17406},"WebDriver",{"type":28,"tag":192,"props":17408,"children":17409},{"style":226},[17410],{"type":34,"value":255},{"type":28,"tag":192,"props":17412,"children":17413},{"class":194,"line":205},[17414,17418,17422,17426,17430,17434,17438,17442,17447,17451,17456],{"type":28,"tag":192,"props":17415,"children":17416},{"style":209},[17417],{"type":34,"value":16537},{"type":28,"tag":192,"props":17419,"children":17420},{"style":247},[17421],{"type":34,"value":16542},{"type":28,"tag":192,"props":17423,"children":17424},{"style":226},[17425],{"type":34,"value":379},{"type":28,"tag":192,"props":17427,"children":17428},{"style":247},[17429],{"type":34,"value":17388},{"type":28,"tag":192,"props":17431,"children":17432},{"style":226},[17433],{"type":34,"value":379},{"type":28,"tag":192,"props":17435,"children":17436},{"style":247},[17437],{"type":34,"value":17397},{"type":28,"tag":192,"props":17439,"children":17440},{"style":226},[17441],{"type":34,"value":379},{"type":28,"tag":192,"props":17443,"children":17444},{"style":247},[17445],{"type":34,"value":17446},"chrome",{"type":28,"tag":192,"props":17448,"children":17449},{"style":226},[17450],{"type":34,"value":379},{"type":28,"tag":192,"props":17452,"children":17453},{"style":247},[17454],{"type":34,"value":17455},"ChromeDriver",{"type":28,"tag":192,"props":17457,"children":17458},{"style":226},[17459],{"type":34,"value":255},{"type":28,"tag":192,"props":17461,"children":17462},{"class":194,"line":232},[17463,17467,17471,17475,17479,17483,17487,17491,17496],{"type":28,"tag":192,"props":17464,"children":17465},{"style":209},[17466],{"type":34,"value":16537},{"type":28,"tag":192,"props":17468,"children":17469},{"style":247},[17470],{"type":34,"value":16542},{"type":28,"tag":192,"props":17472,"children":17473},{"style":226},[17474],{"type":34,"value":379},{"type":28,"tag":192,"props":17476,"children":17477},{"style":247},[17478],{"type":34,"value":17388},{"type":28,"tag":192,"props":17480,"children":17481},{"style":226},[17482],{"type":34,"value":379},{"type":28,"tag":192,"props":17484,"children":17485},{"style":247},[17486],{"type":34,"value":17397},{"type":28,"tag":192,"props":17488,"children":17489},{"style":226},[17490],{"type":34,"value":379},{"type":28,"tag":192,"props":17492,"children":17493},{"style":247},[17494],{"type":34,"value":17495},"By",{"type":28,"tag":192,"props":17497,"children":17498},{"style":226},[17499],{"type":34,"value":255},{"type":28,"tag":192,"props":17501,"children":17502},{"class":194,"line":258},[17503],{"type":28,"tag":192,"props":17504,"children":17505},{"emptyLinePlaceholder":13},[17506],{"type":34,"value":313},{"type":28,"tag":192,"props":17508,"children":17509},{"class":194,"line":280},[17510,17514,17518,17523],{"type":28,"tag":192,"props":17511,"children":17512},{"style":209},[17513],{"type":34,"value":212},{"type":28,"tag":192,"props":17515,"children":17516},{"style":209},[17517],{"type":34,"value":217},{"type":28,"tag":192,"props":17519,"children":17520},{"style":220},[17521],{"type":34,"value":17522}," LoginTest",{"type":28,"tag":192,"props":17524,"children":17525},{"style":226},[17526],{"type":34,"value":229},{"type":28,"tag":192,"props":17528,"children":17529},{"class":194,"line":307},[17530],{"type":28,"tag":192,"props":17531,"children":17532},{"emptyLinePlaceholder":13},[17533],{"type":34,"value":313},{"type":28,"tag":192,"props":17535,"children":17536},{"class":194,"line":316},[17537,17541,17545,17549,17553,17557,17561,17565,17569,17573],{"type":28,"tag":192,"props":17538,"children":17539},{"style":209},[17540],{"type":34,"value":322},{"type":28,"tag":192,"props":17542,"children":17543},{"style":209},[17544],{"type":34,"value":5862},{"type":28,"tag":192,"props":17546,"children":17547},{"style":209},[17548],{"type":34,"value":688},{"type":28,"tag":192,"props":17550,"children":17551},{"style":325},[17552],{"type":34,"value":5871},{"type":28,"tag":192,"props":17554,"children":17555},{"style":226},[17556],{"type":34,"value":332},{"type":28,"tag":192,"props":17558,"children":17559},{"style":209},[17560],{"type":34,"value":337},{"type":28,"tag":192,"props":17562,"children":17563},{"style":226},[17564],{"type":34,"value":5884},{"type":28,"tag":192,"props":17566,"children":17567},{"style":340},[17568],{"type":34,"value":5889},{"type":28,"tag":192,"props":17570,"children":17571},{"style":226},[17572],{"type":34,"value":360},{"type":28,"tag":192,"props":17574,"children":17575},{"style":226},[17576],{"type":34,"value":229},{"type":28,"tag":192,"props":17578,"children":17579},{"class":194,"line":367},[17580],{"type":28,"tag":192,"props":17581,"children":17582},{"style":199},[17583],{"type":34,"value":17584},"        // Configurer le WebDriver pour Chrome\n",{"type":28,"tag":192,"props":17586,"children":17587},{"class":194,"line":401},[17588,17592,17596,17601,17605,17610,17614,17619],{"type":28,"tag":192,"props":17589,"children":17590},{"style":247},[17591],{"type":34,"value":4327},{"type":28,"tag":192,"props":17593,"children":17594},{"style":226},[17595],{"type":34,"value":379},{"type":28,"tag":192,"props":17597,"children":17598},{"style":325},[17599],{"type":34,"value":17600},"setProperty",{"type":28,"tag":192,"props":17602,"children":17603},{"style":226},[17604],{"type":34,"value":332},{"type":28,"tag":192,"props":17606,"children":17607},{"style":734},[17608],{"type":34,"value":17609},"\"webdriver.chrome.driver\"",{"type":28,"tag":192,"props":17611,"children":17612},{"style":226},[17613],{"type":34,"value":347},{"type":28,"tag":192,"props":17615,"children":17616},{"style":734},[17617],{"type":34,"value":17618}," \"path_to_chromedriver\"",{"type":28,"tag":192,"props":17620,"children":17621},{"style":226},[17622],{"type":34,"value":752},{"type":28,"tag":192,"props":17624,"children":17625},{"class":194,"line":430},[17626,17631,17636,17640,17644,17649],{"type":28,"tag":192,"props":17627,"children":17628},{"style":241},[17629],{"type":34,"value":17630},"        WebDriver",{"type":28,"tag":192,"props":17632,"children":17633},{"style":247},[17634],{"type":34,"value":17635}," driver ",{"type":28,"tag":192,"props":17637,"children":17638},{"style":387},[17639],{"type":34,"value":390},{"type":28,"tag":192,"props":17641,"children":17642},{"style":209},[17643],{"type":34,"value":723},{"type":28,"tag":192,"props":17645,"children":17646},{"style":325},[17647],{"type":34,"value":17648}," ChromeDriver",{"type":28,"tag":192,"props":17650,"children":17651},{"style":226},[17652],{"type":34,"value":1973},{"type":28,"tag":192,"props":17654,"children":17655},{"class":194,"line":439},[17656],{"type":28,"tag":192,"props":17657,"children":17658},{"emptyLinePlaceholder":13},[17659],{"type":34,"value":313},{"type":28,"tag":192,"props":17661,"children":17662},{"class":194,"line":448},[17663],{"type":28,"tag":192,"props":17664,"children":17665},{"style":199},[17666],{"type":34,"value":17667},"        // Ouvrir la page de login\n",{"type":28,"tag":192,"props":17669,"children":17670},{"class":194,"line":456},[17671,17676,17680,17685,17689,17694],{"type":28,"tag":192,"props":17672,"children":17673},{"style":247},[17674],{"type":34,"value":17675},"        driver",{"type":28,"tag":192,"props":17677,"children":17678},{"style":226},[17679],{"type":34,"value":379},{"type":28,"tag":192,"props":17681,"children":17682},{"style":325},[17683],{"type":34,"value":17684},"get",{"type":28,"tag":192,"props":17686,"children":17687},{"style":226},[17688],{"type":34,"value":332},{"type":28,"tag":192,"props":17690,"children":17691},{"style":734},[17692],{"type":34,"value":17693},"\"http://monapplication.com/login\"",{"type":28,"tag":192,"props":17695,"children":17696},{"style":226},[17697],{"type":34,"value":752},{"type":28,"tag":192,"props":17699,"children":17700},{"class":194,"line":482},[17701],{"type":28,"tag":192,"props":17702,"children":17703},{"emptyLinePlaceholder":13},[17704],{"type":34,"value":313},{"type":28,"tag":192,"props":17706,"children":17707},{"class":194,"line":499},[17708],{"type":28,"tag":192,"props":17709,"children":17710},{"style":199},[17711],{"type":34,"value":17712},"        // Entrer les informations d'identification et se connecter\n",{"type":28,"tag":192,"props":17714,"children":17715},{"class":194,"line":507},[17716,17720,17724,17729,17733,17737,17741,17746,17750,17755,17760,17765,17769,17774],{"type":28,"tag":192,"props":17717,"children":17718},{"style":247},[17719],{"type":34,"value":17675},{"type":28,"tag":192,"props":17721,"children":17722},{"style":226},[17723],{"type":34,"value":379},{"type":28,"tag":192,"props":17725,"children":17726},{"style":325},[17727],{"type":34,"value":17728},"findElement",{"type":28,"tag":192,"props":17730,"children":17731},{"style":226},[17732],{"type":34,"value":332},{"type":28,"tag":192,"props":17734,"children":17735},{"style":247},[17736],{"type":34,"value":17495},{"type":28,"tag":192,"props":17738,"children":17739},{"style":226},[17740],{"type":34,"value":379},{"type":28,"tag":192,"props":17742,"children":17743},{"style":325},[17744],{"type":34,"value":17745},"id",{"type":28,"tag":192,"props":17747,"children":17748},{"style":226},[17749],{"type":34,"value":332},{"type":28,"tag":192,"props":17751,"children":17752},{"style":734},[17753],{"type":34,"value":17754},"\"username\"",{"type":28,"tag":192,"props":17756,"children":17757},{"style":226},[17758],{"type":34,"value":17759},")).",{"type":28,"tag":192,"props":17761,"children":17762},{"style":325},[17763],{"type":34,"value":17764},"sendKeys",{"type":28,"tag":192,"props":17766,"children":17767},{"style":226},[17768],{"type":34,"value":332},{"type":28,"tag":192,"props":17770,"children":17771},{"style":734},[17772],{"type":34,"value":17773},"\"monNomUtilisateur\"",{"type":28,"tag":192,"props":17775,"children":17776},{"style":226},[17777],{"type":34,"value":752},{"type":28,"tag":192,"props":17779,"children":17780},{"class":194,"line":515},[17781,17785,17789,17793,17797,17801,17805,17809,17813,17818,17822,17826,17830,17835],{"type":28,"tag":192,"props":17782,"children":17783},{"style":247},[17784],{"type":34,"value":17675},{"type":28,"tag":192,"props":17786,"children":17787},{"style":226},[17788],{"type":34,"value":379},{"type":28,"tag":192,"props":17790,"children":17791},{"style":325},[17792],{"type":34,"value":17728},{"type":28,"tag":192,"props":17794,"children":17795},{"style":226},[17796],{"type":34,"value":332},{"type":28,"tag":192,"props":17798,"children":17799},{"style":247},[17800],{"type":34,"value":17495},{"type":28,"tag":192,"props":17802,"children":17803},{"style":226},[17804],{"type":34,"value":379},{"type":28,"tag":192,"props":17806,"children":17807},{"style":325},[17808],{"type":34,"value":17745},{"type":28,"tag":192,"props":17810,"children":17811},{"style":226},[17812],{"type":34,"value":332},{"type":28,"tag":192,"props":17814,"children":17815},{"style":734},[17816],{"type":34,"value":17817},"\"password\"",{"type":28,"tag":192,"props":17819,"children":17820},{"style":226},[17821],{"type":34,"value":17759},{"type":28,"tag":192,"props":17823,"children":17824},{"style":325},[17825],{"type":34,"value":17764},{"type":28,"tag":192,"props":17827,"children":17828},{"style":226},[17829],{"type":34,"value":332},{"type":28,"tag":192,"props":17831,"children":17832},{"style":734},[17833],{"type":34,"value":17834},"\"monMotDePasse\"",{"type":28,"tag":192,"props":17836,"children":17837},{"style":226},[17838],{"type":34,"value":752},{"type":28,"tag":192,"props":17840,"children":17841},{"class":194,"line":540},[17842,17846,17850,17854,17858,17862,17866,17870,17874,17879,17883,17888],{"type":28,"tag":192,"props":17843,"children":17844},{"style":247},[17845],{"type":34,"value":17675},{"type":28,"tag":192,"props":17847,"children":17848},{"style":226},[17849],{"type":34,"value":379},{"type":28,"tag":192,"props":17851,"children":17852},{"style":325},[17853],{"type":34,"value":17728},{"type":28,"tag":192,"props":17855,"children":17856},{"style":226},[17857],{"type":34,"value":332},{"type":28,"tag":192,"props":17859,"children":17860},{"style":247},[17861],{"type":34,"value":17495},{"type":28,"tag":192,"props":17863,"children":17864},{"style":226},[17865],{"type":34,"value":379},{"type":28,"tag":192,"props":17867,"children":17868},{"style":325},[17869],{"type":34,"value":17745},{"type":28,"tag":192,"props":17871,"children":17872},{"style":226},[17873],{"type":34,"value":332},{"type":28,"tag":192,"props":17875,"children":17876},{"style":734},[17877],{"type":34,"value":17878},"\"loginButton\"",{"type":28,"tag":192,"props":17880,"children":17881},{"style":226},[17882],{"type":34,"value":17759},{"type":28,"tag":192,"props":17884,"children":17885},{"style":325},[17886],{"type":34,"value":17887},"click",{"type":28,"tag":192,"props":17889,"children":17890},{"style":226},[17891],{"type":34,"value":1973},{"type":28,"tag":192,"props":17893,"children":17894},{"class":194,"line":556},[17895],{"type":28,"tag":192,"props":17896,"children":17897},{"emptyLinePlaceholder":13},[17898],{"type":34,"value":313},{"type":28,"tag":192,"props":17900,"children":17901},{"class":194,"line":564},[17902],{"type":28,"tag":192,"props":17903,"children":17904},{"style":199},[17905],{"type":34,"value":17906},"        // Vérifier que la connexion a réussi\n",{"type":28,"tag":192,"props":17908,"children":17909},{"class":194,"line":573},[17910,17915,17920,17924,17929,17933,17938],{"type":28,"tag":192,"props":17911,"children":17912},{"style":241},[17913],{"type":34,"value":17914},"        String",{"type":28,"tag":192,"props":17916,"children":17917},{"style":247},[17918],{"type":34,"value":17919}," pageTitre ",{"type":28,"tag":192,"props":17921,"children":17922},{"style":387},[17923],{"type":34,"value":390},{"type":28,"tag":192,"props":17925,"children":17926},{"style":247},[17927],{"type":34,"value":17928}," driver",{"type":28,"tag":192,"props":17930,"children":17931},{"style":226},[17932],{"type":34,"value":379},{"type":28,"tag":192,"props":17934,"children":17935},{"style":325},[17936],{"type":34,"value":17937},"getTitle",{"type":28,"tag":192,"props":17939,"children":17940},{"style":226},[17941],{"type":34,"value":1973},{"type":28,"tag":192,"props":17943,"children":17944},{"class":194,"line":582},[17945,17949,17953,17958,17962,17966,17970,17975,17979],{"type":28,"tag":192,"props":17946,"children":17947},{"style":209},[17948],{"type":34,"value":986},{"type":28,"tag":192,"props":17950,"children":17951},{"style":226},[17952],{"type":34,"value":332},{"type":28,"tag":192,"props":17954,"children":17955},{"style":247},[17956],{"type":34,"value":17957},"pageTitre",{"type":28,"tag":192,"props":17959,"children":17960},{"style":226},[17961],{"type":34,"value":379},{"type":28,"tag":192,"props":17963,"children":17964},{"style":325},[17965],{"type":34,"value":5034},{"type":28,"tag":192,"props":17967,"children":17968},{"style":226},[17969],{"type":34,"value":332},{"type":28,"tag":192,"props":17971,"children":17972},{"style":734},[17973],{"type":34,"value":17974},"\"Tableau de bord\"",{"type":28,"tag":192,"props":17976,"children":17977},{"style":226},[17978],{"type":34,"value":5048},{"type":28,"tag":192,"props":17980,"children":17981},{"style":226},[17982],{"type":34,"value":229},{"type":28,"tag":192,"props":17984,"children":17985},{"class":194,"line":5580},[17986,17990,17994,17998,18002,18006,18010,18015],{"type":28,"tag":192,"props":17987,"children":17988},{"style":247},[17989],{"type":34,"value":2664},{"type":28,"tag":192,"props":17991,"children":17992},{"style":226},[17993],{"type":34,"value":379},{"type":28,"tag":192,"props":17995,"children":17996},{"style":247},[17997],{"type":34,"value":2673},{"type":28,"tag":192,"props":17999,"children":18000},{"style":226},[18001],{"type":34,"value":379},{"type":28,"tag":192,"props":18003,"children":18004},{"style":325},[18005],{"type":34,"value":2682},{"type":28,"tag":192,"props":18007,"children":18008},{"style":226},[18009],{"type":34,"value":332},{"type":28,"tag":192,"props":18011,"children":18012},{"style":734},[18013],{"type":34,"value":18014},"\"Connexion réussie !\"",{"type":28,"tag":192,"props":18016,"children":18017},{"style":226},[18018],{"type":34,"value":752},{"type":28,"tag":192,"props":18020,"children":18021},{"class":194,"line":5600},[18022,18026,18030],{"type":28,"tag":192,"props":18023,"children":18024},{"style":226},[18025],{"type":34,"value":1076},{"type":28,"tag":192,"props":18027,"children":18028},{"style":209},[18029],{"type":34,"value":1081},{"type":28,"tag":192,"props":18031,"children":18032},{"style":226},[18033],{"type":34,"value":229},{"type":28,"tag":192,"props":18035,"children":18036},{"class":194,"line":5638},[18037,18041,18045,18049,18053,18057,18061,18066],{"type":28,"tag":192,"props":18038,"children":18039},{"style":247},[18040],{"type":34,"value":2664},{"type":28,"tag":192,"props":18042,"children":18043},{"style":226},[18044],{"type":34,"value":379},{"type":28,"tag":192,"props":18046,"children":18047},{"style":247},[18048],{"type":34,"value":2673},{"type":28,"tag":192,"props":18050,"children":18051},{"style":226},[18052],{"type":34,"value":379},{"type":28,"tag":192,"props":18054,"children":18055},{"style":325},[18056],{"type":34,"value":2682},{"type":28,"tag":192,"props":18058,"children":18059},{"style":226},[18060],{"type":34,"value":332},{"type":28,"tag":192,"props":18062,"children":18063},{"style":734},[18064],{"type":34,"value":18065},"\"Échec de la connexion.\"",{"type":28,"tag":192,"props":18067,"children":18068},{"style":226},[18069],{"type":34,"value":752},{"type":28,"tag":192,"props":18071,"children":18072},{"class":194,"line":5660},[18073],{"type":28,"tag":192,"props":18074,"children":18075},{"style":226},[18076],{"type":34,"value":1118},{"type":28,"tag":192,"props":18078,"children":18079},{"class":194,"line":5668},[18080],{"type":28,"tag":192,"props":18081,"children":18082},{"emptyLinePlaceholder":13},[18083],{"type":34,"value":313},{"type":28,"tag":192,"props":18085,"children":18086},{"class":194,"line":6718},[18087],{"type":28,"tag":192,"props":18088,"children":18089},{"style":199},[18090],{"type":34,"value":18091},"        // Fermer le navigateur\n",{"type":28,"tag":192,"props":18093,"children":18094},{"class":194,"line":6754},[18095,18099,18103,18108],{"type":28,"tag":192,"props":18096,"children":18097},{"style":247},[18098],{"type":34,"value":17675},{"type":28,"tag":192,"props":18100,"children":18101},{"style":226},[18102],{"type":34,"value":379},{"type":28,"tag":192,"props":18104,"children":18105},{"style":325},[18106],{"type":34,"value":18107},"quit",{"type":28,"tag":192,"props":18109,"children":18110},{"style":226},[18111],{"type":34,"value":1973},{"type":28,"tag":192,"props":18113,"children":18114},{"class":194,"line":6782},[18115],{"type":28,"tag":192,"props":18116,"children":18117},{"style":226},[18118],{"type":34,"value":445},{"type":28,"tag":192,"props":18120,"children":18121},{"class":194,"line":6814},[18122],{"type":28,"tag":192,"props":18123,"children":18124},{"style":226},[18125],{"type":34,"value":588},{"type":28,"tag":13274,"props":18127,"children":18128},{},[18129],{"type":28,"tag":44,"props":18130,"children":18131},{},[18132,18136,18138,18142,18144,18149],{"type":28,"tag":55,"props":18133,"children":18134},{},[18135],{"type":34,"value":1843},{"type":34,"value":18137}," : Lorsque vous utilisez ",{"type":28,"tag":55,"props":18139,"children":18140},{},[18141],{"type":34,"value":17353},{"type":34,"value":18143},", essayez d'exécuter vos tests sur plusieurs navigateurs pour vous assurer de la compatibilité de votre application. Utilisez des outils comme ",{"type":28,"tag":55,"props":18145,"children":18146},{},[18147],{"type":34,"value":18148},"BrowserStack",{"type":34,"value":18150}," pour tester sur différents environnements.",{"type":28,"tag":83,"props":18152,"children":18153},{},[],{"type":28,"tag":37,"props":18155,"children":18157},{"id":18156},"présentation-de-quelques-frameworks-populaires-en-java",[18158],{"type":28,"tag":55,"props":18159,"children":18160},{},[18161],{"type":34,"value":18162},"Présentation de quelques frameworks populaires en Java",{"type":28,"tag":44,"props":18164,"children":18165},{},[18166],{"type":34,"value":18167},"Voici une sélection de frameworks populaires que vous pouvez utiliser dans vos projets Java.",{"type":28,"tag":169,"props":18169,"children":18171},{"id":18170},"_1-junit-le-pilier-des-tests-unitaires",[18172,18173],{"type":34,"value":621},{"type":28,"tag":55,"props":18174,"children":18175},{},[18176],{"type":34,"value":18177},"JUnit : Le pilier des tests unitaires",{"type":28,"tag":44,"props":18179,"children":18180},{},[18181,18185],{"type":28,"tag":55,"props":18182,"children":18183},{},[18184],{"type":34,"value":3602},{"type":34,"value":18186}," est sans doute le framework de tests unitaires le plus populaire en Java. Il est léger, facile à utiliser et largement adopté dans l'industrie.",{"type":28,"tag":12775,"props":18188,"children":18190},{"id":18189},"exemple-simple-avec-junit-5",[18191],{"type":34,"value":18192},"Exemple simple avec JUnit 5 :",{"type":28,"tag":181,"props":18194,"children":18196},{"className":183,"code":18195,"language":185,"meta":8,"style":8},"import org.junit.jupiter.api.Test;\nimport static org.junit.jupiter.api.Assertions.*;\n\npublic class CalculatriceTest {\n\n    @Test\n    public void testMultiplication() {\n        Calculatrice calc = new Calculatrice();\n        int resultat = calc.multiplication(4, 5);\n        assertEquals(20, resultat, \"La multiplication de 4 par 5 devrait être 20\");\n    }\n}\n",[18197],{"type":28,"tag":188,"props":18198,"children":18199},{"__ignoreMap":8},[18200,18247,18307,18314,18333,18340,18351,18375,18402,18452,18489,18496],{"type":28,"tag":192,"props":18201,"children":18202},{"class":194,"line":195},[18203,18207,18211,18215,18219,18223,18227,18231,18235,18239,18243],{"type":28,"tag":192,"props":18204,"children":18205},{"style":209},[18206],{"type":34,"value":16537},{"type":28,"tag":192,"props":18208,"children":18209},{"style":247},[18210],{"type":34,"value":16542},{"type":28,"tag":192,"props":18212,"children":18213},{"style":226},[18214],{"type":34,"value":379},{"type":28,"tag":192,"props":18216,"children":18217},{"style":247},[18218],{"type":34,"value":16551},{"type":28,"tag":192,"props":18220,"children":18221},{"style":226},[18222],{"type":34,"value":379},{"type":28,"tag":192,"props":18224,"children":18225},{"style":247},[18226],{"type":34,"value":16560},{"type":28,"tag":192,"props":18228,"children":18229},{"style":226},[18230],{"type":34,"value":379},{"type":28,"tag":192,"props":18232,"children":18233},{"style":247},[18234],{"type":34,"value":16569},{"type":28,"tag":192,"props":18236,"children":18237},{"style":226},[18238],{"type":34,"value":379},{"type":28,"tag":192,"props":18240,"children":18241},{"style":247},[18242],{"type":34,"value":16578},{"type":28,"tag":192,"props":18244,"children":18245},{"style":226},[18246],{"type":34,"value":255},{"type":28,"tag":192,"props":18248,"children":18249},{"class":194,"line":205},[18250,18254,18258,18262,18266,18270,18274,18278,18282,18286,18290,18294,18298,18303],{"type":28,"tag":192,"props":18251,"children":18252},{"style":209},[18253],{"type":34,"value":16537},{"type":28,"tag":192,"props":18255,"children":18256},{"style":209},[18257],{"type":34,"value":5862},{"type":28,"tag":192,"props":18259,"children":18260},{"style":247},[18261],{"type":34,"value":16542},{"type":28,"tag":192,"props":18263,"children":18264},{"style":226},[18265],{"type":34,"value":379},{"type":28,"tag":192,"props":18267,"children":18268},{"style":247},[18269],{"type":34,"value":16551},{"type":28,"tag":192,"props":18271,"children":18272},{"style":226},[18273],{"type":34,"value":379},{"type":28,"tag":192,"props":18275,"children":18276},{"style":247},[18277],{"type":34,"value":16560},{"type":28,"tag":192,"props":18279,"children":18280},{"style":226},[18281],{"type":34,"value":379},{"type":28,"tag":192,"props":18283,"children":18284},{"style":247},[18285],{"type":34,"value":16569},{"type":28,"tag":192,"props":18287,"children":18288},{"style":226},[18289],{"type":34,"value":379},{"type":28,"tag":192,"props":18291,"children":18292},{"style":247},[18293],{"type":34,"value":16630},{"type":28,"tag":192,"props":18295,"children":18296},{"style":226},[18297],{"type":34,"value":379},{"type":28,"tag":192,"props":18299,"children":18301},{"style":18300},"--shiki-default:#C6D0F5;--shiki-dark:#79B8FF",[18302],{"type":34,"value":1102},{"type":28,"tag":192,"props":18304,"children":18305},{"style":226},[18306],{"type":34,"value":255},{"type":28,"tag":192,"props":18308,"children":18309},{"class":194,"line":232},[18310],{"type":28,"tag":192,"props":18311,"children":18312},{"emptyLinePlaceholder":13},[18313],{"type":34,"value":313},{"type":28,"tag":192,"props":18315,"children":18316},{"class":194,"line":258},[18317,18321,18325,18329],{"type":28,"tag":192,"props":18318,"children":18319},{"style":209},[18320],{"type":34,"value":212},{"type":28,"tag":192,"props":18322,"children":18323},{"style":209},[18324],{"type":34,"value":217},{"type":28,"tag":192,"props":18326,"children":18327},{"style":220},[18328],{"type":34,"value":16666},{"type":28,"tag":192,"props":18330,"children":18331},{"style":226},[18332],{"type":34,"value":229},{"type":28,"tag":192,"props":18334,"children":18335},{"class":194,"line":280},[18336],{"type":28,"tag":192,"props":18337,"children":18338},{"emptyLinePlaceholder":13},[18339],{"type":34,"value":313},{"type":28,"tag":192,"props":18341,"children":18342},{"class":194,"line":307},[18343,18347],{"type":28,"tag":192,"props":18344,"children":18345},{"style":667},[18346],{"type":34,"value":5359},{"type":28,"tag":192,"props":18348,"children":18349},{"style":673},[18350],{"type":34,"value":676},{"type":28,"tag":192,"props":18352,"children":18353},{"class":194,"line":316},[18354,18358,18362,18367,18371],{"type":28,"tag":192,"props":18355,"children":18356},{"style":209},[18357],{"type":34,"value":322},{"type":28,"tag":192,"props":18359,"children":18360},{"style":209},[18361],{"type":34,"value":688},{"type":28,"tag":192,"props":18363,"children":18364},{"style":325},[18365],{"type":34,"value":18366}," testMultiplication",{"type":28,"tag":192,"props":18368,"children":18369},{"style":226},[18370],{"type":34,"value":475},{"type":28,"tag":192,"props":18372,"children":18373},{"style":226},[18374],{"type":34,"value":229},{"type":28,"tag":192,"props":18376,"children":18377},{"class":194,"line":367},[18378,18382,18386,18390,18394,18398],{"type":28,"tag":192,"props":18379,"children":18380},{"style":241},[18381],{"type":34,"value":16720},{"type":28,"tag":192,"props":18383,"children":18384},{"style":247},[18385],{"type":34,"value":1956},{"type":28,"tag":192,"props":18387,"children":18388},{"style":387},[18389],{"type":34,"value":390},{"type":28,"tag":192,"props":18391,"children":18392},{"style":209},[18393],{"type":34,"value":723},{"type":28,"tag":192,"props":18395,"children":18396},{"style":325},[18397],{"type":34,"value":16737},{"type":28,"tag":192,"props":18399,"children":18400},{"style":226},[18401],{"type":34,"value":1973},{"type":28,"tag":192,"props":18403,"children":18404},{"class":194,"line":401},[18405,18409,18413,18417,18421,18425,18430,18434,18439,18443,18448],{"type":28,"tag":192,"props":18406,"children":18407},{"style":209},[18408],{"type":34,"value":16749},{"type":28,"tag":192,"props":18410,"children":18411},{"style":247},[18412],{"type":34,"value":16754},{"type":28,"tag":192,"props":18414,"children":18415},{"style":387},[18416],{"type":34,"value":390},{"type":28,"tag":192,"props":18418,"children":18419},{"style":247},[18420],{"type":34,"value":2072},{"type":28,"tag":192,"props":18422,"children":18423},{"style":226},[18424],{"type":34,"value":379},{"type":28,"tag":192,"props":18426,"children":18427},{"style":325},[18428],{"type":34,"value":18429},"multiplication",{"type":28,"tag":192,"props":18431,"children":18432},{"style":226},[18433],{"type":34,"value":332},{"type":28,"tag":192,"props":18435,"children":18436},{"style":744},[18437],{"type":34,"value":18438},"4",{"type":28,"tag":192,"props":18440,"children":18441},{"style":226},[18442],{"type":34,"value":347},{"type":28,"tag":192,"props":18444,"children":18445},{"style":744},[18446],{"type":34,"value":18447}," 5",{"type":28,"tag":192,"props":18449,"children":18450},{"style":226},[18451],{"type":34,"value":752},{"type":28,"tag":192,"props":18453,"children":18454},{"class":194,"line":430},[18455,18459,18463,18468,18472,18476,18480,18485],{"type":28,"tag":192,"props":18456,"children":18457},{"style":325},[18458],{"type":34,"value":16800},{"type":28,"tag":192,"props":18460,"children":18461},{"style":226},[18462],{"type":34,"value":332},{"type":28,"tag":192,"props":18464,"children":18465},{"style":744},[18466],{"type":34,"value":18467},"20",{"type":28,"tag":192,"props":18469,"children":18470},{"style":226},[18471],{"type":34,"value":347},{"type":28,"tag":192,"props":18473,"children":18474},{"style":247},[18475],{"type":34,"value":16818},{"type":28,"tag":192,"props":18477,"children":18478},{"style":226},[18479],{"type":34,"value":347},{"type":28,"tag":192,"props":18481,"children":18482},{"style":734},[18483],{"type":34,"value":18484}," \"La multiplication de 4 par 5 devrait être 20\"",{"type":28,"tag":192,"props":18486,"children":18487},{"style":226},[18488],{"type":34,"value":752},{"type":28,"tag":192,"props":18490,"children":18491},{"class":194,"line":439},[18492],{"type":28,"tag":192,"props":18493,"children":18494},{"style":226},[18495],{"type":34,"value":445},{"type":28,"tag":192,"props":18497,"children":18498},{"class":194,"line":448},[18499],{"type":28,"tag":192,"props":18500,"children":18501},{"style":226},[18502],{"type":34,"value":588},{"type":28,"tag":169,"props":18504,"children":18506},{"id":18505},"_2-testng-flexibilité-et-fonctionnalités-avancées",[18507,18508],{"type":34,"value":860},{"type":28,"tag":55,"props":18509,"children":18510},{},[18511],{"type":34,"value":18512},"TestNG : Flexibilité et fonctionnalités avancées",{"type":28,"tag":44,"props":18514,"children":18515},{},[18516,18520],{"type":28,"tag":55,"props":18517,"children":18518},{},[18519],{"type":34,"value":16514},{"type":34,"value":18521}," est un autre framework de tests unitaires, mais il offre des fonctionnalités supplémentaires par rapport à JUnit.",{"type":28,"tag":12775,"props":18523,"children":18525},{"id":18524},"exemple-de-test-avec-testng",[18526],{"type":34,"value":18527},"Exemple de test avec TestNG :",{"type":28,"tag":181,"props":18529,"children":18531},{"className":183,"code":18530,"language":185,"meta":8,"style":8},"import org.testng.annotations.Test;\nimport static org.testng.Assert.assertEquals;\n\npublic class CalculatriceTest {\n\n    @Test\n    public void testSoustraction() {\n        Calculatrice calc = new Calculatrice();\n        int resultat = calc.soustraction(10, 3);\n        assertEquals(7, resultat, \"La soustraction de 10 et 3 devrait être 7\");\n    }\n}\n",[18532],{"type":28,"tag":188,"props":18533,"children":18534},{"__ignoreMap":8},[18535,18576,18620,18627,18646,18653,18664,18688,18715,18764,18801,18808],{"type":28,"tag":192,"props":18536,"children":18537},{"class":194,"line":195},[18538,18542,18546,18550,18555,18559,18564,18568,18572],{"type":28,"tag":192,"props":18539,"children":18540},{"style":209},[18541],{"type":34,"value":16537},{"type":28,"tag":192,"props":18543,"children":18544},{"style":247},[18545],{"type":34,"value":16542},{"type":28,"tag":192,"props":18547,"children":18548},{"style":226},[18549],{"type":34,"value":379},{"type":28,"tag":192,"props":18551,"children":18552},{"style":247},[18553],{"type":34,"value":18554},"testng",{"type":28,"tag":192,"props":18556,"children":18557},{"style":226},[18558],{"type":34,"value":379},{"type":28,"tag":192,"props":18560,"children":18561},{"style":247},[18562],{"type":34,"value":18563},"annotations",{"type":28,"tag":192,"props":18565,"children":18566},{"style":226},[18567],{"type":34,"value":379},{"type":28,"tag":192,"props":18569,"children":18570},{"style":247},[18571],{"type":34,"value":16578},{"type":28,"tag":192,"props":18573,"children":18574},{"style":226},[18575],{"type":34,"value":255},{"type":28,"tag":192,"props":18577,"children":18578},{"class":194,"line":205},[18579,18583,18587,18591,18595,18599,18603,18608,18612,18616],{"type":28,"tag":192,"props":18580,"children":18581},{"style":209},[18582],{"type":34,"value":16537},{"type":28,"tag":192,"props":18584,"children":18585},{"style":209},[18586],{"type":34,"value":5862},{"type":28,"tag":192,"props":18588,"children":18589},{"style":247},[18590],{"type":34,"value":16542},{"type":28,"tag":192,"props":18592,"children":18593},{"style":226},[18594],{"type":34,"value":379},{"type":28,"tag":192,"props":18596,"children":18597},{"style":247},[18598],{"type":34,"value":18554},{"type":28,"tag":192,"props":18600,"children":18601},{"style":226},[18602],{"type":34,"value":379},{"type":28,"tag":192,"props":18604,"children":18605},{"style":247},[18606],{"type":34,"value":18607},"Assert",{"type":28,"tag":192,"props":18609,"children":18610},{"style":226},[18611],{"type":34,"value":379},{"type":28,"tag":192,"props":18613,"children":18614},{"style":247},[18615],{"type":34,"value":16639},{"type":28,"tag":192,"props":18617,"children":18618},{"style":226},[18619],{"type":34,"value":255},{"type":28,"tag":192,"props":18621,"children":18622},{"class":194,"line":232},[18623],{"type":28,"tag":192,"props":18624,"children":18625},{"emptyLinePlaceholder":13},[18626],{"type":34,"value":313},{"type":28,"tag":192,"props":18628,"children":18629},{"class":194,"line":258},[18630,18634,18638,18642],{"type":28,"tag":192,"props":18631,"children":18632},{"style":209},[18633],{"type":34,"value":212},{"type":28,"tag":192,"props":18635,"children":18636},{"style":209},[18637],{"type":34,"value":217},{"type":28,"tag":192,"props":18639,"children":18640},{"style":220},[18641],{"type":34,"value":16666},{"type":28,"tag":192,"props":18643,"children":18644},{"style":226},[18645],{"type":34,"value":229},{"type":28,"tag":192,"props":18647,"children":18648},{"class":194,"line":280},[18649],{"type":28,"tag":192,"props":18650,"children":18651},{"emptyLinePlaceholder":13},[18652],{"type":34,"value":313},{"type":28,"tag":192,"props":18654,"children":18655},{"class":194,"line":307},[18656,18660],{"type":28,"tag":192,"props":18657,"children":18658},{"style":667},[18659],{"type":34,"value":5359},{"type":28,"tag":192,"props":18661,"children":18662},{"style":673},[18663],{"type":34,"value":676},{"type":28,"tag":192,"props":18665,"children":18666},{"class":194,"line":316},[18667,18671,18675,18680,18684],{"type":28,"tag":192,"props":18668,"children":18669},{"style":209},[18670],{"type":34,"value":322},{"type":28,"tag":192,"props":18672,"children":18673},{"style":209},[18674],{"type":34,"value":688},{"type":28,"tag":192,"props":18676,"children":18677},{"style":325},[18678],{"type":34,"value":18679}," testSoustraction",{"type":28,"tag":192,"props":18681,"children":18682},{"style":226},[18683],{"type":34,"value":475},{"type":28,"tag":192,"props":18685,"children":18686},{"style":226},[18687],{"type":34,"value":229},{"type":28,"tag":192,"props":18689,"children":18690},{"class":194,"line":367},[18691,18695,18699,18703,18707,18711],{"type":28,"tag":192,"props":18692,"children":18693},{"style":241},[18694],{"type":34,"value":16720},{"type":28,"tag":192,"props":18696,"children":18697},{"style":247},[18698],{"type":34,"value":1956},{"type":28,"tag":192,"props":18700,"children":18701},{"style":387},[18702],{"type":34,"value":390},{"type":28,"tag":192,"props":18704,"children":18705},{"style":209},[18706],{"type":34,"value":723},{"type":28,"tag":192,"props":18708,"children":18709},{"style":325},[18710],{"type":34,"value":16737},{"type":28,"tag":192,"props":18712,"children":18713},{"style":226},[18714],{"type":34,"value":1973},{"type":28,"tag":192,"props":18716,"children":18717},{"class":194,"line":401},[18718,18722,18726,18730,18734,18738,18743,18747,18752,18756,18760],{"type":28,"tag":192,"props":18719,"children":18720},{"style":209},[18721],{"type":34,"value":16749},{"type":28,"tag":192,"props":18723,"children":18724},{"style":247},[18725],{"type":34,"value":16754},{"type":28,"tag":192,"props":18727,"children":18728},{"style":387},[18729],{"type":34,"value":390},{"type":28,"tag":192,"props":18731,"children":18732},{"style":247},[18733],{"type":34,"value":2072},{"type":28,"tag":192,"props":18735,"children":18736},{"style":226},[18737],{"type":34,"value":379},{"type":28,"tag":192,"props":18739,"children":18740},{"style":325},[18741],{"type":34,"value":18742},"soustraction",{"type":28,"tag":192,"props":18744,"children":18745},{"style":226},[18746],{"type":34,"value":332},{"type":28,"tag":192,"props":18748,"children":18749},{"style":744},[18750],{"type":34,"value":18751},"10",{"type":28,"tag":192,"props":18753,"children":18754},{"style":226},[18755],{"type":34,"value":347},{"type":28,"tag":192,"props":18757,"children":18758},{"style":744},[18759],{"type":34,"value":16788},{"type":28,"tag":192,"props":18761,"children":18762},{"style":226},[18763],{"type":34,"value":752},{"type":28,"tag":192,"props":18765,"children":18766},{"class":194,"line":430},[18767,18771,18775,18780,18784,18788,18792,18797],{"type":28,"tag":192,"props":18768,"children":18769},{"style":325},[18770],{"type":34,"value":16800},{"type":28,"tag":192,"props":18772,"children":18773},{"style":226},[18774],{"type":34,"value":332},{"type":28,"tag":192,"props":18776,"children":18777},{"style":744},[18778],{"type":34,"value":18779},"7",{"type":28,"tag":192,"props":18781,"children":18782},{"style":226},[18783],{"type":34,"value":347},{"type":28,"tag":192,"props":18785,"children":18786},{"style":247},[18787],{"type":34,"value":16818},{"type":28,"tag":192,"props":18789,"children":18790},{"style":226},[18791],{"type":34,"value":347},{"type":28,"tag":192,"props":18793,"children":18794},{"style":734},[18795],{"type":34,"value":18796}," \"La soustraction de 10 et 3 devrait être 7\"",{"type":28,"tag":192,"props":18798,"children":18799},{"style":226},[18800],{"type":34,"value":752},{"type":28,"tag":192,"props":18802,"children":18803},{"class":194,"line":439},[18804],{"type":28,"tag":192,"props":18805,"children":18806},{"style":226},[18807],{"type":34,"value":445},{"type":28,"tag":192,"props":18809,"children":18810},{"class":194,"line":448},[18811],{"type":28,"tag":192,"props":18812,"children":18813},{"style":226},[18814],{"type":34,"value":588},{"type":28,"tag":169,"props":18816,"children":18818},{"id":18817},"_3-mockito-pour-des-tests-unitaires-et-dintégration-avec-des-mocks",[18819,18820],{"type":34,"value":1260},{"type":28,"tag":55,"props":18821,"children":18822},{},[18823],{"type":34,"value":18824},"Mockito : Pour des tests unitaires et d'intégration avec des mocks",{"type":28,"tag":44,"props":18826,"children":18827},{},[18828,18832],{"type":28,"tag":55,"props":18829,"children":18830},{},[18831],{"type":34,"value":3612},{"type":34,"value":18833}," est un framework spécialisé dans les tests unitaires qui nécessitent de simuler le comportement de certains objets.",{"type":28,"tag":12775,"props":18835,"children":18837},{"id":18836},"exemple-de-test-avec-mockito",[18838],{"type":34,"value":18839},"Exemple de test avec Mockito :",{"type":28,"tag":181,"props":18841,"children":18843},{"className":183,"code":18842,"language":185,"meta":8,"style":8},"import org.junit.jupiter.api.Test;\nimport static org.mockito.Mockito.*;\nimport static org.junit.jupiter.api.Assertions.*;\n\npublic class ServiceTest {\n    \n    @Test\n    public void testServiceAvecMock() {\n        // Mock d'une dépendance\n        UserRepository userRepository = mock(UserRepository.class);\n        when(userRepository.findUserById(1)).thenReturn(new User(\"John\", \"Doe\"));\n\n        UserService userService = new UserService(userRepository);\n        User user = userService.getUser(1);\n\n        // Vérification\n        assertEquals(\"John\", user.getFirstName(), \"Le prénom devrait être John\");\n        verify(userRepository).findUserById(1);  // Vérifie que la méthode a bien été appelée\n    }\n}\n",[18844],{"type":28,"tag":188,"props":18845,"children":18846},{"__ignoreMap":8},[18847,18894,18938,18997,19004,19024,19031,19042,19066,19074,19116,19192,19199,19236,19276,19283,19291,19336,19378,19385],{"type":28,"tag":192,"props":18848,"children":18849},{"class":194,"line":195},[18850,18854,18858,18862,18866,18870,18874,18878,18882,18886,18890],{"type":28,"tag":192,"props":18851,"children":18852},{"style":209},[18853],{"type":34,"value":16537},{"type":28,"tag":192,"props":18855,"children":18856},{"style":247},[18857],{"type":34,"value":16542},{"type":28,"tag":192,"props":18859,"children":18860},{"style":226},[18861],{"type":34,"value":379},{"type":28,"tag":192,"props":18863,"children":18864},{"style":247},[18865],{"type":34,"value":16551},{"type":28,"tag":192,"props":18867,"children":18868},{"style":226},[18869],{"type":34,"value":379},{"type":28,"tag":192,"props":18871,"children":18872},{"style":247},[18873],{"type":34,"value":16560},{"type":28,"tag":192,"props":18875,"children":18876},{"style":226},[18877],{"type":34,"value":379},{"type":28,"tag":192,"props":18879,"children":18880},{"style":247},[18881],{"type":34,"value":16569},{"type":28,"tag":192,"props":18883,"children":18884},{"style":226},[18885],{"type":34,"value":379},{"type":28,"tag":192,"props":18887,"children":18888},{"style":247},[18889],{"type":34,"value":16578},{"type":28,"tag":192,"props":18891,"children":18892},{"style":226},[18893],{"type":34,"value":255},{"type":28,"tag":192,"props":18895,"children":18896},{"class":194,"line":205},[18897,18901,18905,18909,18913,18918,18922,18926,18930,18934],{"type":28,"tag":192,"props":18898,"children":18899},{"style":209},[18900],{"type":34,"value":16537},{"type":28,"tag":192,"props":18902,"children":18903},{"style":209},[18904],{"type":34,"value":5862},{"type":28,"tag":192,"props":18906,"children":18907},{"style":247},[18908],{"type":34,"value":16542},{"type":28,"tag":192,"props":18910,"children":18911},{"style":226},[18912],{"type":34,"value":379},{"type":28,"tag":192,"props":18914,"children":18915},{"style":247},[18916],{"type":34,"value":18917},"mockito",{"type":28,"tag":192,"props":18919,"children":18920},{"style":226},[18921],{"type":34,"value":379},{"type":28,"tag":192,"props":18923,"children":18924},{"style":247},[18925],{"type":34,"value":3612},{"type":28,"tag":192,"props":18927,"children":18928},{"style":226},[18929],{"type":34,"value":379},{"type":28,"tag":192,"props":18931,"children":18932},{"style":18300},[18933],{"type":34,"value":1102},{"type":28,"tag":192,"props":18935,"children":18936},{"style":226},[18937],{"type":34,"value":255},{"type":28,"tag":192,"props":18939,"children":18940},{"class":194,"line":232},[18941,18945,18949,18953,18957,18961,18965,18969,18973,18977,18981,18985,18989,18993],{"type":28,"tag":192,"props":18942,"children":18943},{"style":209},[18944],{"type":34,"value":16537},{"type":28,"tag":192,"props":18946,"children":18947},{"style":209},[18948],{"type":34,"value":5862},{"type":28,"tag":192,"props":18950,"children":18951},{"style":247},[18952],{"type":34,"value":16542},{"type":28,"tag":192,"props":18954,"children":18955},{"style":226},[18956],{"type":34,"value":379},{"type":28,"tag":192,"props":18958,"children":18959},{"style":247},[18960],{"type":34,"value":16551},{"type":28,"tag":192,"props":18962,"children":18963},{"style":226},[18964],{"type":34,"value":379},{"type":28,"tag":192,"props":18966,"children":18967},{"style":247},[18968],{"type":34,"value":16560},{"type":28,"tag":192,"props":18970,"children":18971},{"style":226},[18972],{"type":34,"value":379},{"type":28,"tag":192,"props":18974,"children":18975},{"style":247},[18976],{"type":34,"value":16569},{"type":28,"tag":192,"props":18978,"children":18979},{"style":226},[18980],{"type":34,"value":379},{"type":28,"tag":192,"props":18982,"children":18983},{"style":247},[18984],{"type":34,"value":16630},{"type":28,"tag":192,"props":18986,"children":18987},{"style":226},[18988],{"type":34,"value":379},{"type":28,"tag":192,"props":18990,"children":18991},{"style":18300},[18992],{"type":34,"value":1102},{"type":28,"tag":192,"props":18994,"children":18995},{"style":226},[18996],{"type":34,"value":255},{"type":28,"tag":192,"props":18998,"children":18999},{"class":194,"line":258},[19000],{"type":28,"tag":192,"props":19001,"children":19002},{"emptyLinePlaceholder":13},[19003],{"type":34,"value":313},{"type":28,"tag":192,"props":19005,"children":19006},{"class":194,"line":280},[19007,19011,19015,19020],{"type":28,"tag":192,"props":19008,"children":19009},{"style":209},[19010],{"type":34,"value":212},{"type":28,"tag":192,"props":19012,"children":19013},{"style":209},[19014],{"type":34,"value":217},{"type":28,"tag":192,"props":19016,"children":19017},{"style":220},[19018],{"type":34,"value":19019}," ServiceTest",{"type":28,"tag":192,"props":19021,"children":19022},{"style":226},[19023],{"type":34,"value":229},{"type":28,"tag":192,"props":19025,"children":19026},{"class":194,"line":307},[19027],{"type":28,"tag":192,"props":19028,"children":19029},{"style":247},[19030],{"type":34,"value":570},{"type":28,"tag":192,"props":19032,"children":19033},{"class":194,"line":316},[19034,19038],{"type":28,"tag":192,"props":19035,"children":19036},{"style":667},[19037],{"type":34,"value":5359},{"type":28,"tag":192,"props":19039,"children":19040},{"style":673},[19041],{"type":34,"value":676},{"type":28,"tag":192,"props":19043,"children":19044},{"class":194,"line":367},[19045,19049,19053,19058,19062],{"type":28,"tag":192,"props":19046,"children":19047},{"style":209},[19048],{"type":34,"value":322},{"type":28,"tag":192,"props":19050,"children":19051},{"style":209},[19052],{"type":34,"value":688},{"type":28,"tag":192,"props":19054,"children":19055},{"style":325},[19056],{"type":34,"value":19057}," testServiceAvecMock",{"type":28,"tag":192,"props":19059,"children":19060},{"style":226},[19061],{"type":34,"value":475},{"type":28,"tag":192,"props":19063,"children":19064},{"style":226},[19065],{"type":34,"value":229},{"type":28,"tag":192,"props":19067,"children":19068},{"class":194,"line":401},[19069],{"type":28,"tag":192,"props":19070,"children":19071},{"style":199},[19072],{"type":34,"value":19073},"        // Mock d'une dépendance\n",{"type":28,"tag":192,"props":19075,"children":19076},{"class":194,"line":430},[19077,19082,19087,19091,19095,19099,19104,19108,19112],{"type":28,"tag":192,"props":19078,"children":19079},{"style":241},[19080],{"type":34,"value":19081},"        UserRepository",{"type":28,"tag":192,"props":19083,"children":19084},{"style":247},[19085],{"type":34,"value":19086}," userRepository ",{"type":28,"tag":192,"props":19088,"children":19089},{"style":387},[19090],{"type":34,"value":390},{"type":28,"tag":192,"props":19092,"children":19093},{"style":325},[19094],{"type":34,"value":3678},{"type":28,"tag":192,"props":19096,"children":19097},{"style":226},[19098],{"type":34,"value":332},{"type":28,"tag":192,"props":19100,"children":19101},{"style":247},[19102],{"type":34,"value":19103},"UserRepository",{"type":28,"tag":192,"props":19105,"children":19106},{"style":226},[19107],{"type":34,"value":379},{"type":28,"tag":192,"props":19109,"children":19110},{"style":247},[19111],{"type":34,"value":3696},{"type":28,"tag":192,"props":19113,"children":19114},{"style":226},[19115],{"type":34,"value":752},{"type":28,"tag":192,"props":19117,"children":19118},{"class":194,"line":439},[19119,19124,19128,19133,19137,19142,19146,19151,19155,19159,19163,19168,19172,19176,19180,19184,19188],{"type":28,"tag":192,"props":19120,"children":19121},{"style":325},[19122],{"type":34,"value":19123},"        when",{"type":28,"tag":192,"props":19125,"children":19126},{"style":226},[19127],{"type":34,"value":332},{"type":28,"tag":192,"props":19129,"children":19130},{"style":247},[19131],{"type":34,"value":19132},"userRepository",{"type":28,"tag":192,"props":19134,"children":19135},{"style":226},[19136],{"type":34,"value":379},{"type":28,"tag":192,"props":19138,"children":19139},{"style":325},[19140],{"type":34,"value":19141},"findUserById",{"type":28,"tag":192,"props":19143,"children":19144},{"style":226},[19145],{"type":34,"value":332},{"type":28,"tag":192,"props":19147,"children":19148},{"style":744},[19149],{"type":34,"value":19150},"1",{"type":28,"tag":192,"props":19152,"children":19153},{"style":226},[19154],{"type":34,"value":17759},{"type":28,"tag":192,"props":19156,"children":19157},{"style":325},[19158],{"type":34,"value":3736},{"type":28,"tag":192,"props":19160,"children":19161},{"style":226},[19162],{"type":34,"value":332},{"type":28,"tag":192,"props":19164,"children":19165},{"style":209},[19166],{"type":34,"value":19167},"new",{"type":28,"tag":192,"props":19169,"children":19170},{"style":325},[19171],{"type":34,"value":223},{"type":28,"tag":192,"props":19173,"children":19174},{"style":226},[19175],{"type":34,"value":332},{"type":28,"tag":192,"props":19177,"children":19178},{"style":734},[19179],{"type":34,"value":17224},{"type":28,"tag":192,"props":19181,"children":19182},{"style":226},[19183],{"type":34,"value":347},{"type":28,"tag":192,"props":19185,"children":19186},{"style":734},[19187],{"type":34,"value":17233},{"type":28,"tag":192,"props":19189,"children":19190},{"style":226},[19191],{"type":34,"value":3176},{"type":28,"tag":192,"props":19193,"children":19194},{"class":194,"line":448},[19195],{"type":28,"tag":192,"props":19196,"children":19197},{"emptyLinePlaceholder":13},[19198],{"type":34,"value":313},{"type":28,"tag":192,"props":19200,"children":19201},{"class":194,"line":456},[19202,19207,19212,19216,19220,19224,19228,19232],{"type":28,"tag":192,"props":19203,"children":19204},{"style":241},[19205],{"type":34,"value":19206},"        UserService",{"type":28,"tag":192,"props":19208,"children":19209},{"style":247},[19210],{"type":34,"value":19211}," userService ",{"type":28,"tag":192,"props":19213,"children":19214},{"style":387},[19215],{"type":34,"value":390},{"type":28,"tag":192,"props":19217,"children":19218},{"style":209},[19219],{"type":34,"value":723},{"type":28,"tag":192,"props":19221,"children":19222},{"style":325},[19223],{"type":34,"value":17140},{"type":28,"tag":192,"props":19225,"children":19226},{"style":226},[19227],{"type":34,"value":332},{"type":28,"tag":192,"props":19229,"children":19230},{"style":247},[19231],{"type":34,"value":19132},{"type":28,"tag":192,"props":19233,"children":19234},{"style":226},[19235],{"type":34,"value":752},{"type":28,"tag":192,"props":19237,"children":19238},{"class":194,"line":482},[19239,19243,19247,19251,19255,19259,19264,19268,19272],{"type":28,"tag":192,"props":19240,"children":19241},{"style":241},[19242],{"type":34,"value":17199},{"type":28,"tag":192,"props":19244,"children":19245},{"style":247},[19246],{"type":34,"value":714},{"type":28,"tag":192,"props":19248,"children":19249},{"style":387},[19250],{"type":34,"value":390},{"type":28,"tag":192,"props":19252,"children":19253},{"style":247},[19254],{"type":34,"value":17145},{"type":28,"tag":192,"props":19256,"children":19257},{"style":226},[19258],{"type":34,"value":379},{"type":28,"tag":192,"props":19260,"children":19261},{"style":325},[19262],{"type":34,"value":19263},"getUser",{"type":28,"tag":192,"props":19265,"children":19266},{"style":226},[19267],{"type":34,"value":332},{"type":28,"tag":192,"props":19269,"children":19270},{"style":744},[19271],{"type":34,"value":19150},{"type":28,"tag":192,"props":19273,"children":19274},{"style":226},[19275],{"type":34,"value":752},{"type":28,"tag":192,"props":19277,"children":19278},{"class":194,"line":499},[19279],{"type":28,"tag":192,"props":19280,"children":19281},{"emptyLinePlaceholder":13},[19282],{"type":34,"value":313},{"type":28,"tag":192,"props":19284,"children":19285},{"class":194,"line":507},[19286],{"type":28,"tag":192,"props":19287,"children":19288},{"style":199},[19289],{"type":34,"value":19290},"        // Vérification\n",{"type":28,"tag":192,"props":19292,"children":19293},{"class":194,"line":515},[19294,19298,19302,19306,19310,19314,19318,19323,19327,19332],{"type":28,"tag":192,"props":19295,"children":19296},{"style":325},[19297],{"type":34,"value":16800},{"type":28,"tag":192,"props":19299,"children":19300},{"style":226},[19301],{"type":34,"value":332},{"type":28,"tag":192,"props":19303,"children":19304},{"style":734},[19305],{"type":34,"value":17224},{"type":28,"tag":192,"props":19307,"children":19308},{"style":226},[19309],{"type":34,"value":347},{"type":28,"tag":192,"props":19311,"children":19312},{"style":247},[19313],{"type":34,"value":777},{"type":28,"tag":192,"props":19315,"children":19316},{"style":226},[19317],{"type":34,"value":379},{"type":28,"tag":192,"props":19319,"children":19320},{"style":325},[19321],{"type":34,"value":19322},"getFirstName",{"type":28,"tag":192,"props":19324,"children":19325},{"style":226},[19326],{"type":34,"value":17310},{"type":28,"tag":192,"props":19328,"children":19329},{"style":734},[19330],{"type":34,"value":19331}," \"Le prénom devrait être John\"",{"type":28,"tag":192,"props":19333,"children":19334},{"style":226},[19335],{"type":34,"value":752},{"type":28,"tag":192,"props":19337,"children":19338},{"class":194,"line":540},[19339,19344,19348,19352,19356,19360,19364,19368,19373],{"type":28,"tag":192,"props":19340,"children":19341},{"style":325},[19342],{"type":34,"value":19343},"        verify",{"type":28,"tag":192,"props":19345,"children":19346},{"style":226},[19347],{"type":34,"value":332},{"type":28,"tag":192,"props":19349,"children":19350},{"style":247},[19351],{"type":34,"value":19132},{"type":28,"tag":192,"props":19353,"children":19354},{"style":226},[19355],{"type":34,"value":1798},{"type":28,"tag":192,"props":19357,"children":19358},{"style":325},[19359],{"type":34,"value":19141},{"type":28,"tag":192,"props":19361,"children":19362},{"style":226},[19363],{"type":34,"value":332},{"type":28,"tag":192,"props":19365,"children":19366},{"style":744},[19367],{"type":34,"value":19150},{"type":28,"tag":192,"props":19369,"children":19370},{"style":226},[19371],{"type":34,"value":19372},");",{"type":28,"tag":192,"props":19374,"children":19375},{"style":199},[19376],{"type":34,"value":19377},"  // Vérifie que la méthode a bien été appelée\n",{"type":28,"tag":192,"props":19379,"children":19380},{"class":194,"line":556},[19381],{"type":28,"tag":192,"props":19382,"children":19383},{"style":226},[19384],{"type":34,"value":445},{"type":28,"tag":192,"props":19386,"children":19387},{"class":194,"line":564},[19388],{"type":28,"tag":192,"props":19389,"children":19390},{"style":226},[19391],{"type":34,"value":588},{"type":28,"tag":120,"props":19393,"children":19395},{"cta":122,"href":123,"title":19394,"type":125},"Vous voulez écrire des tests qui attrapent vraiment les régressions ?",[19396],{"type":28,"tag":44,"props":19397,"children":19398},{},[19399],{"type":34,"value":19400},"Choisir JUnit ou Mockito, c'est une chose. Écrire des tests qui documentent l'intention, isolent les bonnes dépendances et restent lisibles dans six mois, ça se travaille. En mentoring 1:1, on relit votre code de test ensemble, je vous montre comment structurer vos suites pour qu'elles vous protègent au lieu de vous freiner. Vous gagnez le réflexe de tester juste, pas plus.",{"type":28,"tag":169,"props":19402,"children":19404},{"id":19403},"_4-selenium-automatisation-des-tests-fonctionnels",[19405,19406],{"type":34,"value":1283},{"type":28,"tag":55,"props":19407,"children":19408},{},[19409],{"type":34,"value":19410},"Selenium : Automatisation des tests fonctionnels",{"type":28,"tag":44,"props":19412,"children":19413},{},[19414,19418],{"type":28,"tag":55,"props":19415,"children":19416},{},[19417],{"type":34,"value":17353},{"type":34,"value":19419}," est le framework de référence pour les tests fonctionnels, spécialement pour les applications web.",{"type":28,"tag":12775,"props":19421,"children":19423},{"id":19422},"exemple-de-test-fonctionnel-avec-selenium-java",[19424],{"type":34,"value":19425},"Exemple de test fonctionnel avec Selenium (Java) :",{"type":28,"tag":181,"props":19427,"children":19429},{"className":183,"code":19428,"language":185,"meta":8,"style":8},"import org.openqa.selenium.By;\nimport org.openqa.selenium.WebDriver;\nimport org.openqa.selenium.chrome.ChromeDriver;\n\npublic class TestFonctionnel {\n\n    public static void main(String[] args) {\n        // Configuration du WebDriver pour Chrome\n        System.setProperty(\"webdriver.chrome.driver\", \"path_to_chromedriver\");\n        WebDriver driver = new ChromeDriver();\n\n        // Ouvrir la page d'accueil\n        driver.get(\"http://monapplication.com\");\n\n        // Vérification du titre de la page\n        String titre = driver.getTitle();\n        if(titre.equals(\"Accueil - Mon Application\")) {\n            System.out.println(\"Page d'accueil chargée correctement !\");\n        }\n\n        // Fermer le navigateur\n        driver.quit();\n    }\n}\n",[19430],{"type":28,"tag":188,"props":19431,"children":19432},{"__ignoreMap":8},[19433,19472,19511,19558,19565,19585,19592,19635,19643,19678,19705,19712,19720,19748,19755,19763,19795,19836,19872,19879,19886,19893,19912,19919],{"type":28,"tag":192,"props":19434,"children":19435},{"class":194,"line":195},[19436,19440,19444,19448,19452,19456,19460,19464,19468],{"type":28,"tag":192,"props":19437,"children":19438},{"style":209},[19439],{"type":34,"value":16537},{"type":28,"tag":192,"props":19441,"children":19442},{"style":247},[19443],{"type":34,"value":16542},{"type":28,"tag":192,"props":19445,"children":19446},{"style":226},[19447],{"type":34,"value":379},{"type":28,"tag":192,"props":19449,"children":19450},{"style":247},[19451],{"type":34,"value":17388},{"type":28,"tag":192,"props":19453,"children":19454},{"style":226},[19455],{"type":34,"value":379},{"type":28,"tag":192,"props":19457,"children":19458},{"style":247},[19459],{"type":34,"value":17397},{"type":28,"tag":192,"props":19461,"children":19462},{"style":226},[19463],{"type":34,"value":379},{"type":28,"tag":192,"props":19465,"children":19466},{"style":247},[19467],{"type":34,"value":17495},{"type":28,"tag":192,"props":19469,"children":19470},{"style":226},[19471],{"type":34,"value":255},{"type":28,"tag":192,"props":19473,"children":19474},{"class":194,"line":205},[19475,19479,19483,19487,19491,19495,19499,19503,19507],{"type":28,"tag":192,"props":19476,"children":19477},{"style":209},[19478],{"type":34,"value":16537},{"type":28,"tag":192,"props":19480,"children":19481},{"style":247},[19482],{"type":34,"value":16542},{"type":28,"tag":192,"props":19484,"children":19485},{"style":226},[19486],{"type":34,"value":379},{"type":28,"tag":192,"props":19488,"children":19489},{"style":247},[19490],{"type":34,"value":17388},{"type":28,"tag":192,"props":19492,"children":19493},{"style":226},[19494],{"type":34,"value":379},{"type":28,"tag":192,"props":19496,"children":19497},{"style":247},[19498],{"type":34,"value":17397},{"type":28,"tag":192,"props":19500,"children":19501},{"style":226},[19502],{"type":34,"value":379},{"type":28,"tag":192,"props":19504,"children":19505},{"style":247},[19506],{"type":34,"value":17406},{"type":28,"tag":192,"props":19508,"children":19509},{"style":226},[19510],{"type":34,"value":255},{"type":28,"tag":192,"props":19512,"children":19513},{"class":194,"line":232},[19514,19518,19522,19526,19530,19534,19538,19542,19546,19550,19554],{"type":28,"tag":192,"props":19515,"children":19516},{"style":209},[19517],{"type":34,"value":16537},{"type":28,"tag":192,"props":19519,"children":19520},{"style":247},[19521],{"type":34,"value":16542},{"type":28,"tag":192,"props":19523,"children":19524},{"style":226},[19525],{"type":34,"value":379},{"type":28,"tag":192,"props":19527,"children":19528},{"style":247},[19529],{"type":34,"value":17388},{"type":28,"tag":192,"props":19531,"children":19532},{"style":226},[19533],{"type":34,"value":379},{"type":28,"tag":192,"props":19535,"children":19536},{"style":247},[19537],{"type":34,"value":17397},{"type":28,"tag":192,"props":19539,"children":19540},{"style":226},[19541],{"type":34,"value":379},{"type":28,"tag":192,"props":19543,"children":19544},{"style":247},[19545],{"type":34,"value":17446},{"type":28,"tag":192,"props":19547,"children":19548},{"style":226},[19549],{"type":34,"value":379},{"type":28,"tag":192,"props":19551,"children":19552},{"style":247},[19553],{"type":34,"value":17455},{"type":28,"tag":192,"props":19555,"children":19556},{"style":226},[19557],{"type":34,"value":255},{"type":28,"tag":192,"props":19559,"children":19560},{"class":194,"line":258},[19561],{"type":28,"tag":192,"props":19562,"children":19563},{"emptyLinePlaceholder":13},[19564],{"type":34,"value":313},{"type":28,"tag":192,"props":19566,"children":19567},{"class":194,"line":280},[19568,19572,19576,19581],{"type":28,"tag":192,"props":19569,"children":19570},{"style":209},[19571],{"type":34,"value":212},{"type":28,"tag":192,"props":19573,"children":19574},{"style":209},[19575],{"type":34,"value":217},{"type":28,"tag":192,"props":19577,"children":19578},{"style":220},[19579],{"type":34,"value":19580}," TestFonctionnel",{"type":28,"tag":192,"props":19582,"children":19583},{"style":226},[19584],{"type":34,"value":229},{"type":28,"tag":192,"props":19586,"children":19587},{"class":194,"line":307},[19588],{"type":28,"tag":192,"props":19589,"children":19590},{"emptyLinePlaceholder":13},[19591],{"type":34,"value":313},{"type":28,"tag":192,"props":19593,"children":19594},{"class":194,"line":316},[19595,19599,19603,19607,19611,19615,19619,19623,19627,19631],{"type":28,"tag":192,"props":19596,"children":19597},{"style":209},[19598],{"type":34,"value":322},{"type":28,"tag":192,"props":19600,"children":19601},{"style":209},[19602],{"type":34,"value":5862},{"type":28,"tag":192,"props":19604,"children":19605},{"style":209},[19606],{"type":34,"value":688},{"type":28,"tag":192,"props":19608,"children":19609},{"style":325},[19610],{"type":34,"value":5871},{"type":28,"tag":192,"props":19612,"children":19613},{"style":226},[19614],{"type":34,"value":332},{"type":28,"tag":192,"props":19616,"children":19617},{"style":209},[19618],{"type":34,"value":337},{"type":28,"tag":192,"props":19620,"children":19621},{"style":226},[19622],{"type":34,"value":5884},{"type":28,"tag":192,"props":19624,"children":19625},{"style":340},[19626],{"type":34,"value":5889},{"type":28,"tag":192,"props":19628,"children":19629},{"style":226},[19630],{"type":34,"value":360},{"type":28,"tag":192,"props":19632,"children":19633},{"style":226},[19634],{"type":34,"value":229},{"type":28,"tag":192,"props":19636,"children":19637},{"class":194,"line":367},[19638],{"type":28,"tag":192,"props":19639,"children":19640},{"style":199},[19641],{"type":34,"value":19642},"        // Configuration du WebDriver pour Chrome\n",{"type":28,"tag":192,"props":19644,"children":19645},{"class":194,"line":401},[19646,19650,19654,19658,19662,19666,19670,19674],{"type":28,"tag":192,"props":19647,"children":19648},{"style":247},[19649],{"type":34,"value":4327},{"type":28,"tag":192,"props":19651,"children":19652},{"style":226},[19653],{"type":34,"value":379},{"type":28,"tag":192,"props":19655,"children":19656},{"style":325},[19657],{"type":34,"value":17600},{"type":28,"tag":192,"props":19659,"children":19660},{"style":226},[19661],{"type":34,"value":332},{"type":28,"tag":192,"props":19663,"children":19664},{"style":734},[19665],{"type":34,"value":17609},{"type":28,"tag":192,"props":19667,"children":19668},{"style":226},[19669],{"type":34,"value":347},{"type":28,"tag":192,"props":19671,"children":19672},{"style":734},[19673],{"type":34,"value":17618},{"type":28,"tag":192,"props":19675,"children":19676},{"style":226},[19677],{"type":34,"value":752},{"type":28,"tag":192,"props":19679,"children":19680},{"class":194,"line":430},[19681,19685,19689,19693,19697,19701],{"type":28,"tag":192,"props":19682,"children":19683},{"style":241},[19684],{"type":34,"value":17630},{"type":28,"tag":192,"props":19686,"children":19687},{"style":247},[19688],{"type":34,"value":17635},{"type":28,"tag":192,"props":19690,"children":19691},{"style":387},[19692],{"type":34,"value":390},{"type":28,"tag":192,"props":19694,"children":19695},{"style":209},[19696],{"type":34,"value":723},{"type":28,"tag":192,"props":19698,"children":19699},{"style":325},[19700],{"type":34,"value":17648},{"type":28,"tag":192,"props":19702,"children":19703},{"style":226},[19704],{"type":34,"value":1973},{"type":28,"tag":192,"props":19706,"children":19707},{"class":194,"line":439},[19708],{"type":28,"tag":192,"props":19709,"children":19710},{"emptyLinePlaceholder":13},[19711],{"type":34,"value":313},{"type":28,"tag":192,"props":19713,"children":19714},{"class":194,"line":448},[19715],{"type":28,"tag":192,"props":19716,"children":19717},{"style":199},[19718],{"type":34,"value":19719},"        // Ouvrir la page d'accueil\n",{"type":28,"tag":192,"props":19721,"children":19722},{"class":194,"line":456},[19723,19727,19731,19735,19739,19744],{"type":28,"tag":192,"props":19724,"children":19725},{"style":247},[19726],{"type":34,"value":17675},{"type":28,"tag":192,"props":19728,"children":19729},{"style":226},[19730],{"type":34,"value":379},{"type":28,"tag":192,"props":19732,"children":19733},{"style":325},[19734],{"type":34,"value":17684},{"type":28,"tag":192,"props":19736,"children":19737},{"style":226},[19738],{"type":34,"value":332},{"type":28,"tag":192,"props":19740,"children":19741},{"style":734},[19742],{"type":34,"value":19743},"\"http://monapplication.com\"",{"type":28,"tag":192,"props":19745,"children":19746},{"style":226},[19747],{"type":34,"value":752},{"type":28,"tag":192,"props":19749,"children":19750},{"class":194,"line":482},[19751],{"type":28,"tag":192,"props":19752,"children":19753},{"emptyLinePlaceholder":13},[19754],{"type":34,"value":313},{"type":28,"tag":192,"props":19756,"children":19757},{"class":194,"line":499},[19758],{"type":28,"tag":192,"props":19759,"children":19760},{"style":199},[19761],{"type":34,"value":19762},"        // Vérification du titre de la page\n",{"type":28,"tag":192,"props":19764,"children":19765},{"class":194,"line":507},[19766,19770,19775,19779,19783,19787,19791],{"type":28,"tag":192,"props":19767,"children":19768},{"style":241},[19769],{"type":34,"value":17914},{"type":28,"tag":192,"props":19771,"children":19772},{"style":247},[19773],{"type":34,"value":19774}," titre ",{"type":28,"tag":192,"props":19776,"children":19777},{"style":387},[19778],{"type":34,"value":390},{"type":28,"tag":192,"props":19780,"children":19781},{"style":247},[19782],{"type":34,"value":17928},{"type":28,"tag":192,"props":19784,"children":19785},{"style":226},[19786],{"type":34,"value":379},{"type":28,"tag":192,"props":19788,"children":19789},{"style":325},[19790],{"type":34,"value":17937},{"type":28,"tag":192,"props":19792,"children":19793},{"style":226},[19794],{"type":34,"value":1973},{"type":28,"tag":192,"props":19796,"children":19797},{"class":194,"line":515},[19798,19802,19806,19811,19815,19819,19823,19828,19832],{"type":28,"tag":192,"props":19799,"children":19800},{"style":209},[19801],{"type":34,"value":986},{"type":28,"tag":192,"props":19803,"children":19804},{"style":226},[19805],{"type":34,"value":332},{"type":28,"tag":192,"props":19807,"children":19808},{"style":247},[19809],{"type":34,"value":19810},"titre",{"type":28,"tag":192,"props":19812,"children":19813},{"style":226},[19814],{"type":34,"value":379},{"type":28,"tag":192,"props":19816,"children":19817},{"style":325},[19818],{"type":34,"value":5034},{"type":28,"tag":192,"props":19820,"children":19821},{"style":226},[19822],{"type":34,"value":332},{"type":28,"tag":192,"props":19824,"children":19825},{"style":734},[19826],{"type":34,"value":19827},"\"Accueil - Mon Application\"",{"type":28,"tag":192,"props":19829,"children":19830},{"style":226},[19831],{"type":34,"value":5048},{"type":28,"tag":192,"props":19833,"children":19834},{"style":226},[19835],{"type":34,"value":229},{"type":28,"tag":192,"props":19837,"children":19838},{"class":194,"line":540},[19839,19843,19847,19851,19855,19859,19863,19868],{"type":28,"tag":192,"props":19840,"children":19841},{"style":247},[19842],{"type":34,"value":2664},{"type":28,"tag":192,"props":19844,"children":19845},{"style":226},[19846],{"type":34,"value":379},{"type":28,"tag":192,"props":19848,"children":19849},{"style":247},[19850],{"type":34,"value":2673},{"type":28,"tag":192,"props":19852,"children":19853},{"style":226},[19854],{"type":34,"value":379},{"type":28,"tag":192,"props":19856,"children":19857},{"style":325},[19858],{"type":34,"value":2682},{"type":28,"tag":192,"props":19860,"children":19861},{"style":226},[19862],{"type":34,"value":332},{"type":28,"tag":192,"props":19864,"children":19865},{"style":734},[19866],{"type":34,"value":19867},"\"Page d'accueil chargée correctement !\"",{"type":28,"tag":192,"props":19869,"children":19870},{"style":226},[19871],{"type":34,"value":752},{"type":28,"tag":192,"props":19873,"children":19874},{"class":194,"line":556},[19875],{"type":28,"tag":192,"props":19876,"children":19877},{"style":226},[19878],{"type":34,"value":1118},{"type":28,"tag":192,"props":19880,"children":19881},{"class":194,"line":564},[19882],{"type":28,"tag":192,"props":19883,"children":19884},{"emptyLinePlaceholder":13},[19885],{"type":34,"value":313},{"type":28,"tag":192,"props":19887,"children":19888},{"class":194,"line":573},[19889],{"type":28,"tag":192,"props":19890,"children":19891},{"style":199},[19892],{"type":34,"value":18091},{"type":28,"tag":192,"props":19894,"children":19895},{"class":194,"line":582},[19896,19900,19904,19908],{"type":28,"tag":192,"props":19897,"children":19898},{"style":247},[19899],{"type":34,"value":17675},{"type":28,"tag":192,"props":19901,"children":19902},{"style":226},[19903],{"type":34,"value":379},{"type":28,"tag":192,"props":19905,"children":19906},{"style":325},[19907],{"type":34,"value":18107},{"type":28,"tag":192,"props":19909,"children":19910},{"style":226},[19911],{"type":34,"value":1973},{"type":28,"tag":192,"props":19913,"children":19914},{"class":194,"line":5580},[19915],{"type":28,"tag":192,"props":19916,"children":19917},{"style":226},[19918],{"type":34,"value":445},{"type":28,"tag":192,"props":19920,"children":19921},{"class":194,"line":5600},[19922],{"type":28,"tag":192,"props":19923,"children":19924},{"style":226},[19925],{"type":34,"value":588},{"type":28,"tag":83,"props":19927,"children":19928},{},[],{"type":28,"tag":37,"props":19930,"children":19932},{"id":19931},"comment-choisir-le-bon-framework-pour-votre-projet",[19933],{"type":28,"tag":55,"props":19934,"children":19935},{},[19936],{"type":34,"value":19937},"Comment choisir le bon framework pour votre projet ?",{"type":28,"tag":44,"props":19939,"children":19940},{},[19941],{"type":34,"value":19942},"Le choix du framework dépend de plusieurs facteurs :",{"type":28,"tag":169,"props":19944,"children":19946},{"id":19945},"_1-type-de-projet-et-complexité",[19947,19948],{"type":34,"value":621},{"type":28,"tag":55,"props":19949,"children":19950},{},[19951],{"type":34,"value":19952},"Type de projet et complexité",{"type":28,"tag":144,"props":19954,"children":19955},{},[19956,19977],{"type":28,"tag":148,"props":19957,"children":19958},{},[19959,19964,19966,19970,19971,19975],{"type":28,"tag":55,"props":19960,"children":19961},{},[19962],{"type":34,"value":19963},"Projets simples ou modérés",{"type":34,"value":19965}," : ",{"type":28,"tag":55,"props":19967,"children":19968},{},[19969],{"type":34,"value":3602},{"type":34,"value":1865},{"type":28,"tag":55,"props":19972,"children":19973},{},[19974],{"type":34,"value":16514},{"type":34,"value":19976}," pour des tests unitaires.",{"type":28,"tag":148,"props":19978,"children":19979},{},[19980,19985,19986,19990,19992,19996],{"type":28,"tag":55,"props":19981,"children":19982},{},[19983],{"type":34,"value":19984},"Projets complexes",{"type":34,"value":19965},{"type":28,"tag":55,"props":19987,"children":19988},{},[19989],{"type":34,"value":3612},{"type":34,"value":19991}," pour tester des interactions complexes, ",{"type":28,"tag":55,"props":19993,"children":19994},{},[19995],{"type":34,"value":16886},{"type":34,"value":19997}," pour des tests d'intégration.",{"type":28,"tag":169,"props":19999,"children":20001},{"id":20000},"_2-nature-des-tests",[20002,20003],{"type":34,"value":860},{"type":28,"tag":55,"props":20004,"children":20005},{},[20006],{"type":34,"value":20007},"Nature des tests",{"type":28,"tag":144,"props":20009,"children":20010},{},[20011,20030,20049],{"type":28,"tag":148,"props":20012,"children":20013},{},[20014,20019,20020,20024,20025,20029],{"type":28,"tag":55,"props":20015,"children":20016},{},[20017],{"type":34,"value":20018},"Unitaires",{"type":34,"value":19965},{"type":28,"tag":55,"props":20021,"children":20022},{},[20023],{"type":34,"value":3602},{"type":34,"value":1865},{"type":28,"tag":55,"props":20026,"children":20027},{},[20028],{"type":34,"value":16514},{"type":34,"value":379},{"type":28,"tag":148,"props":20031,"children":20032},{},[20033,20038,20039,20043,20044,20048],{"type":28,"tag":55,"props":20034,"children":20035},{},[20036],{"type":34,"value":20037},"Intégration",{"type":34,"value":19965},{"type":28,"tag":55,"props":20040,"children":20041},{},[20042],{"type":34,"value":16886},{"type":34,"value":1865},{"type":28,"tag":55,"props":20045,"children":20046},{},[20047],{"type":34,"value":16892},{"type":34,"value":379},{"type":28,"tag":148,"props":20050,"children":20051},{},[20052,20057,20058,20062],{"type":28,"tag":55,"props":20053,"children":20054},{},[20055],{"type":34,"value":20056},"End-to-end",{"type":34,"value":19965},{"type":28,"tag":55,"props":20059,"children":20060},{},[20061],{"type":34,"value":17353},{"type":34,"value":20063}," pour automatiser les tests fonctionnels.",{"type":28,"tag":169,"props":20065,"children":20067},{"id":20066},"_3-facilité-dutilisation-et-dapprentissage",[20068,20069],{"type":34,"value":1260},{"type":28,"tag":55,"props":20070,"children":20071},{},[20072],{"type":34,"value":20073},"Facilité d'utilisation et d'apprentissage",{"type":28,"tag":144,"props":20075,"children":20076},{},[20077,20086,20095],{"type":28,"tag":148,"props":20078,"children":20079},{},[20080,20084],{"type":28,"tag":55,"props":20081,"children":20082},{},[20083],{"type":34,"value":3602},{"type":34,"value":20085}," pour la simplicité.",{"type":28,"tag":148,"props":20087,"children":20088},{},[20089,20093],{"type":28,"tag":55,"props":20090,"children":20091},{},[20092],{"type":34,"value":16514},{"type":34,"value":20094}," pour des besoins plus avancés.",{"type":28,"tag":148,"props":20096,"children":20097},{},[20098,20102],{"type":28,"tag":55,"props":20099,"children":20100},{},[20101],{"type":34,"value":3612},{"type":34,"value":20103}," pour simuler des dépendances.",{"type":28,"tag":13274,"props":20105,"children":20106},{},[20107],{"type":28,"tag":44,"props":20108,"children":20109},{},[20110,20114],{"type":28,"tag":55,"props":20111,"children":20112},{},[20113],{"type":34,"value":1843},{"type":34,"value":20115}," : Choisissez un framework que vous et votre équipe êtes prêts à apprendre et à maintenir. Il vaut mieux maîtriser un framework simple que d'utiliser un outil avancé de manière incorrecte.",{"type":28,"tag":169,"props":20117,"children":20119},{"id":20118},"_4-compatibilité-avec-votre-environnement",[20120,20121],{"type":34,"value":1283},{"type":28,"tag":55,"props":20122,"children":20123},{},[20124],{"type":34,"value":20125},"Compatibilité avec votre environnement",{"type":28,"tag":144,"props":20127,"children":20128},{},[20129,20145],{"type":28,"tag":148,"props":20130,"children":20131},{},[20132,20137,20138,20143],{"type":28,"tag":55,"props":20133,"children":20134},{},[20135],{"type":34,"value":20136},"Maven",{"type":34,"value":1865},{"type":28,"tag":55,"props":20139,"children":20140},{},[20141],{"type":34,"value":20142},"Gradle",{"type":34,"value":20144}," fonctionnent bien avec JUnit, TestNG et Mockito.",{"type":28,"tag":148,"props":20146,"children":20147},{},[20148,20152],{"type":28,"tag":55,"props":20149,"children":20150},{},[20151],{"type":34,"value":17353},{"type":34,"value":20153}," pour des tests multiplateformes.",{"type":28,"tag":169,"props":20155,"children":20157},{"id":20156},"_5-écosystème-et-support-communautaire",[20158,20160],{"type":34,"value":20159},"5. ",{"type":28,"tag":55,"props":20161,"children":20162},{},[20163],{"type":34,"value":20164},"Écosystème et support communautaire",{"type":28,"tag":144,"props":20166,"children":20167},{},[20168],{"type":28,"tag":148,"props":20169,"children":20170},{},[20171,20175,20177,20181,20182,20186],{"type":28,"tag":55,"props":20172,"children":20173},{},[20174],{"type":34,"value":3602},{"type":34,"value":20176}," bénéficie d'une large communauté, tout comme ",{"type":28,"tag":55,"props":20178,"children":20179},{},[20180],{"type":34,"value":3612},{"type":34,"value":10377},{"type":28,"tag":55,"props":20183,"children":20184},{},[20185],{"type":34,"value":17353},{"type":34,"value":379},{"type":28,"tag":120,"props":20188,"children":20190},{"cta":1327,"href":1328,"title":20189,"type":1330},"Bien tester n'est qu'une des 100 pratiques qui font le code propre",[20191],{"type":28,"tag":44,"props":20192,"children":20193},{},[20194],{"type":34,"value":20195},"Cet article vous montre comment choisir et utiliser un framework de tests. Mais bien tester n'est qu'un maillon : le Craft Bundle réunit les 100 pratiques craft que j'applique pour coder propre, de la conception des tests au découpage des modules. Ce sont les pratiques que l'IA ne vous apprendra jamais, parce qu'elle ne les a jamais vues tenir un projet sur la durée.",{"type":28,"tag":83,"props":20197,"children":20198},{},[],{"type":28,"tag":37,"props":20200,"children":20202},{"id":20201},"faq",[20203],{"type":28,"tag":55,"props":20204,"children":20205},{},[20206],{"type":34,"value":20207},"FAQ",{"type":28,"tag":1347,"props":20209,"children":20210},{},[20211,20216],{"type":28,"tag":1351,"props":20212,"children":20213},{},[20214],{"type":34,"value":20215},"1. Quelle est la différence entre JUnit et TestNG ?",{"type":28,"tag":44,"props":20217,"children":20218},{},[20219,20223,20225,20229],{"type":28,"tag":55,"props":20220,"children":20221},{},[20222],{"type":34,"value":3602},{"type":34,"value":20224}," est plus basique et plus largement adopté. ",{"type":28,"tag":55,"props":20226,"children":20227},{},[20228],{"type":34,"value":16514},{"type":34,"value":20230}," offre des fonctionnalités avancées : tests parallèles, groupes de tests, dépendances entre tests. Si vous démarrez sur un projet standard, JUnit suffit. TestNG devient pertinent quand vous avez besoin de parallélisation fine ou de scénarios de tests complexes.",{"type":28,"tag":1347,"props":20232,"children":20233},{},[20234,20239],{"type":28,"tag":1351,"props":20235,"children":20236},{},[20237],{"type":34,"value":20238},"2. Quand utiliser Mockito ?",{"type":28,"tag":44,"props":20240,"children":20241},{},[20242],{"type":34,"value":20243},"Quand vous voulez tester une unité en isolation alors qu'elle dépend d'objets coûteux ou non déterministes (DB, services externes, horloge système). Mockito vous permet de simuler ces dépendances et de contrôler leur comportement.",{"type":28,"tag":1347,"props":20245,"children":20246},{},[20247,20252],{"type":28,"tag":1351,"props":20248,"children":20249},{},[20250],{"type":34,"value":20251},"3. Selenium fonctionne-t-il uniquement sur des applications web ?",{"type":28,"tag":44,"props":20253,"children":20254},{},[20255],{"type":34,"value":20256},"Oui. Selenium pilote un navigateur via WebDriver. Pour des applications desktop ou mobiles, regardez plutôt Appium (mobile) ou TestFX/Sikuli (desktop).",{"type":28,"tag":120,"props":20258,"children":20261},{"cta":20259,"href":1445,"title":20260,"type":1447},"Télécharger le guide gratuit →","Ressource gratuite : De 6 semaines à 8 jours de lead time en 90 jours",[20262],{"type":28,"tag":44,"props":20263,"children":20264},{},[20265],{"type":34,"value":20266},"Le framework 4 phases appliqué dans 12 équipes engineering. Une bonne couverture de tests est la fondation d'un lead time court : découvrez comment réduire le vôtre de 50%.",{"type":28,"tag":1455,"props":20268,"children":20269},{},[20270],{"type":34,"value":1459},{"title":8,"searchDepth":205,"depth":205,"links":20272},[20273,20274,20275,20276,20277,20278],{"id":16318,"depth":232,"text":16324},{"id":16359,"depth":232,"text":16365},{"id":16478,"depth":232,"text":16484},{"id":18156,"depth":232,"text":18162},{"id":19931,"depth":232,"text":19937},{"id":20201,"depth":232,"text":20207},"content:fr:dette-technique:decouvrir-frameworks-tests-java.md","fr/dette-technique/decouvrir-frameworks-tests-java.md","fr/dette-technique/decouvrir-frameworks-tests-java",{"_path":4058,"_dir":3980,"_draft":7,"_partial":7,"_locale":8,"title":20283,"description":20284,"id":20285,"date":20286,"listed":13,"nocomments":7,"hidden":7,"categories":20287,"tags":20288,"cover":20289,"readingTime":20290,"body":20295,"_type":1471,"_id":24402,"_source":1473,"_file":24403,"_stem":24404,"_extension":1476},"Principe de substitution de Liskov (LSP), Comprendre et appliquer avec des exemples Java","Découvrez le principe de substitution de Liskov (LSP) avec des exemples concrets en Java. Apprenez à respecter ce principe clé des SOLID pour des conceptions orientées objet robustes.",38,"2024-02-06",[1484],[1486,1487],"covers/articles/principe-lsp.jpg",{"text":20291,"minutes":20292,"time":20293,"words":20294},"10 min read",9.835,590100,1967,{"type":25,"children":20296,"toc":24386},[20297,20303,20313,20324,20329,20332,20338,20343,20349,20354,20360,20408,20414,20425,20428,20437,20443,20462,20474,20893,20905,20918,21241,21275,21281,21292,21716,21722,21756,21782,21785,21791,21809,21815,21834,21851,21856,21867,22276,22288,22300,22578,22624,22630,22649,23232,23237,23262,23268,23299,23305,23317,23323,23839,23845,24180,24183,24189,24194,24200,24218,24224,24242,24245,24254,24257,24263,24276,24289,24320,24333,24346,24359,24372,24375,24382],{"type":28,"tag":29,"props":20298,"children":20300},{"id":20299},"principe-de-liskov-substitution-lsp-pour-les-développeurs-de-logiciels",[20301],{"type":34,"value":20302},"Principe de Liskov Substitution (LSP) pour les développeurs de logiciels",{"type":28,"tag":44,"props":20304,"children":20305},{},[20306,20308],{"type":34,"value":20307},"L'équipe code une hiérarchie d'objets, tout marche. Puis arrive une sous-classe qui ajoute \"juste\" une fonctionnalité, et le comportement attendu de l'application casse en silence, parfois en production seulement, des semaines plus tard. La question revient toujours : ",{"type":28,"tag":63,"props":20309,"children":20310},{},[20311],{"type":34,"value":20312},"l'héritage a-t-il vraiment été le bon outil ?",{"type":28,"tag":44,"props":20314,"children":20315},{},[20316,20318,20322],{"type":34,"value":20317},"Le principe de substitution de Liskov (LSP), formulé par Barbara Liskov en 1987, attaque exactement ce scénario. Quatrième des cinq ",{"type":28,"tag":103,"props":20319,"children":20320},{"href":3979},[20321],{"type":34,"value":13398},{"type":34,"value":20323},", il s'assure qu'une sous-classe respecte le contrat implicite de sa classe parente : condition non négociable pour qu'un code orienté objet reste flexible et maintenable.",{"type":28,"tag":44,"props":20325,"children":20326},{},[20327],{"type":34,"value":20328},"Cet article explique ce que recouvre vraiment LSP, pourquoi il est central dans la conception de logiciels robustes, et comment l'appliquer concrètement avec des exemples Java.",{"type":28,"tag":83,"props":20330,"children":20331},{},[],{"type":28,"tag":29,"props":20333,"children":20335},{"id":20334},"quest-ce-que-le-principe-de-substitution-de-liskov-lsp",[20336],{"type":34,"value":20337},"Qu’est-ce que le principe de substitution de Liskov (LSP) ?",{"type":28,"tag":44,"props":20339,"children":20340},{},[20341],{"type":34,"value":20342},"Le principe de substitution de Liskov (LSP), introduit par Barbara Liskov en 1987, est l’un des cinq principes SOLID utilisés en programmation orientée objet. Ce principe stipule qu’une sous-classe doit pouvoir être substituée à sa classe parente sans que cela ne modifie le comportement attendu du programme. En d’autres termes, si vous utilisez une classe de base dans votre code, vous devriez pouvoir la remplacer par n’importe quelle sous-classe sans avoir à ajuster le code existant.",{"type":28,"tag":169,"props":20344,"children":20346},{"id":20345},"en-termes-simples-voici-ce-que-cela-signifie",[20347],{"type":34,"value":20348},"En termes simples, voici ce que cela signifie :",{"type":28,"tag":44,"props":20350,"children":20351},{},[20352],{"type":34,"value":20353},"Si une classe B hérite de la classe A, alors B doit pouvoir être utilisée partout où A est acceptée. Les objets de B doivent se comporter de manière cohérente avec les attentes établies par la classe A.",{"type":28,"tag":12775,"props":20355,"children":20357},{"id":20356},"exemple-classique-pour-mieux-comprendre",[20358],{"type":34,"value":20359},"Exemple classique pour mieux comprendre :",{"type":28,"tag":44,"props":20361,"children":20362},{},[20363,20365,20371,20373,20378,20379,20385,20387,20392,20394,20399,20401,20406],{"type":34,"value":20364},"Imaginez que vous développez une application qui manipule des formes géométriques. Vous avez une classe de base ",{"type":28,"tag":188,"props":20366,"children":20368},{"className":20367},[],[20369],{"type":34,"value":20370},"Forme",{"type":34,"value":20372},", et deux sous-classes : ",{"type":28,"tag":188,"props":20374,"children":20376},{"className":20375},[],[20377],{"type":34,"value":6208},{"type":34,"value":10377},{"type":28,"tag":188,"props":20380,"children":20382},{"className":20381},[],[20383],{"type":34,"value":20384},"Carré",{"type":34,"value":20386},". Comme vous le savez, un carré est un cas particulier de rectangle où tous les côtés sont égaux. Cependant, si vous créez une sous-classe ",{"type":28,"tag":188,"props":20388,"children":20390},{"className":20389},[],[20391],{"type":34,"value":20384},{"type":34,"value":20393}," qui redéfinit le comportement de ",{"type":28,"tag":188,"props":20395,"children":20397},{"className":20396},[],[20398],{"type":34,"value":6208},{"type":34,"value":20400},", vous risquez de casser la logique qui fonctionne parfaitement pour la classe ",{"type":28,"tag":188,"props":20402,"children":20404},{"className":20403},[],[20405],{"type":34,"value":6208},{"type":34,"value":20407},". Cela brise le LSP.",{"type":28,"tag":37,"props":20409,"children":20411},{"id":20410},"pourquoi-ce-principe-est-il-important",[20412],{"type":34,"value":20413},"Pourquoi ce principe est-il important ?",{"type":28,"tag":44,"props":20415,"children":20416},{},[20417,20419,20423],{"type":34,"value":20418},"Une violation de LSP rend le code dur à comprendre, dur à maintenir, et surtout dur à tester. Quand une sous-classe redéfinit en douce une méthode de sa classe parente, vous obtenez des bugs cachés et un comportement imprévisible. Sur mes missions, ces violations se manifestent presque toujours par des bugs en production difficiles à reproduire : cycles de correction qui s'allongent, coûts de maintenance qui dérapent. C'est précisément pour cette raison que le ",{"type":28,"tag":103,"props":20420,"children":20421},{"href":16187},[20422],{"type":34,"value":16190},{"type":34,"value":20424}," impose de dépendre d'abstractions : une interface fige un contrat que toutes les implémentations doivent respecter, ce qui supprime à la racine la possibilité d'une violation LSP.",{"type":28,"tag":83,"props":20426,"children":20427},{},[],{"type":28,"tag":120,"props":20429,"children":20431},{"cta":122,"href":123,"title":20430,"type":125},"Vous voulez sentir quand un héritage va casser un contrat avant de l'écrire ?",[20432],{"type":28,"tag":44,"props":20433,"children":20434},{},[20435],{"type":34,"value":20436},"Repérer une sous-classe qui trahit sa classe parente, ça ne s'apprend pas en lisant la définition du LSP : ça se travaille sur du vrai code. En mentoring 1:1, je relis vos hiérarchies d'objets avec vous, je vous montre où le contrat se fissure et comment choisir entre héritage, composition ou interface. Vous repartez avec le réflexe de conception, pas juste la théorie.",{"type":28,"tag":29,"props":20438,"children":20440},{"id":20439},"exemple-pratique-briser-le-lsp-ce-quil-ne-faut-pas-faire",[20441],{"type":34,"value":20442},"Exemple pratique - Briser le LSP : Ce qu’il ne faut pas faire",{"type":28,"tag":44,"props":20444,"children":20445},{},[20446,20448,20453,20455,20460],{"type":34,"value":20447},"Prenons l'exemple classique du ",{"type":28,"tag":188,"props":20449,"children":20451},{"className":20450},[],[20452],{"type":34,"value":6208},{"type":34,"value":20454}," et du ",{"type":28,"tag":188,"props":20456,"children":20458},{"className":20457},[],[20459],{"type":34,"value":20384},{"type":34,"value":20461}," en Java pour illustrer une violation du principe de substitution de Liskov (LSP).",{"type":28,"tag":169,"props":20463,"children":20465},{"id":20464},"classe-rectangle",[20466,20468,20473],{"type":34,"value":20467},"Classe ",{"type":28,"tag":188,"props":20469,"children":20471},{"className":20470},[],[20472],{"type":34,"value":6208},{"type":34,"value":5685},{"type":28,"tag":181,"props":20475,"children":20477},{"className":183,"code":20476,"language":185,"meta":8,"style":8},"public class Rectangle {\n    protected int largeur;\n    protected int hauteur;\n\n    public Rectangle(int largeur, int hauteur) {\n        this.largeur = largeur;\n        this.hauteur = hauteur;\n    }\n\n    public void setLargeur(int largeur) {\n        this.largeur = largeur;\n    }\n\n    public void setHauteur(int hauteur) {\n        this.hauteur = hauteur;\n    }\n\n    public int calculerAire() {\n        return this.largeur * this.hauteur;\n    }\n}\n",[20478],{"type":28,"tag":188,"props":20479,"children":20480},{"__ignoreMap":8},[20481,20500,20520,20540,20547,20590,20618,20646,20653,20660,20696,20723,20730,20737,20773,20800,20807,20814,20838,20879,20886],{"type":28,"tag":192,"props":20482,"children":20483},{"class":194,"line":195},[20484,20488,20492,20496],{"type":28,"tag":192,"props":20485,"children":20486},{"style":209},[20487],{"type":34,"value":212},{"type":28,"tag":192,"props":20489,"children":20490},{"style":209},[20491],{"type":34,"value":217},{"type":28,"tag":192,"props":20493,"children":20494},{"style":220},[20495],{"type":34,"value":6265},{"type":28,"tag":192,"props":20497,"children":20498},{"style":226},[20499],{"type":34,"value":229},{"type":28,"tag":192,"props":20501,"children":20502},{"class":194,"line":205},[20503,20507,20511,20516],{"type":28,"tag":192,"props":20504,"children":20505},{"style":209},[20506],{"type":34,"value":6277},{"type":28,"tag":192,"props":20508,"children":20509},{"style":209},[20510],{"type":34,"value":268},{"type":28,"tag":192,"props":20512,"children":20513},{"style":247},[20514],{"type":34,"value":20515}," largeur",{"type":28,"tag":192,"props":20517,"children":20518},{"style":226},[20519],{"type":34,"value":255},{"type":28,"tag":192,"props":20521,"children":20522},{"class":194,"line":232},[20523,20527,20531,20536],{"type":28,"tag":192,"props":20524,"children":20525},{"style":209},[20526],{"type":34,"value":6277},{"type":28,"tag":192,"props":20528,"children":20529},{"style":209},[20530],{"type":34,"value":268},{"type":28,"tag":192,"props":20532,"children":20533},{"style":247},[20534],{"type":34,"value":20535}," hauteur",{"type":28,"tag":192,"props":20537,"children":20538},{"style":226},[20539],{"type":34,"value":255},{"type":28,"tag":192,"props":20541,"children":20542},{"class":194,"line":258},[20543],{"type":28,"tag":192,"props":20544,"children":20545},{"emptyLinePlaceholder":13},[20546],{"type":34,"value":313},{"type":28,"tag":192,"props":20548,"children":20549},{"class":194,"line":280},[20550,20554,20558,20562,20566,20570,20574,20578,20582,20586],{"type":28,"tag":192,"props":20551,"children":20552},{"style":209},[20553],{"type":34,"value":322},{"type":28,"tag":192,"props":20555,"children":20556},{"style":325},[20557],{"type":34,"value":6265},{"type":28,"tag":192,"props":20559,"children":20560},{"style":226},[20561],{"type":34,"value":332},{"type":28,"tag":192,"props":20563,"children":20564},{"style":209},[20565],{"type":34,"value":938},{"type":28,"tag":192,"props":20567,"children":20568},{"style":340},[20569],{"type":34,"value":20515},{"type":28,"tag":192,"props":20571,"children":20572},{"style":226},[20573],{"type":34,"value":347},{"type":28,"tag":192,"props":20575,"children":20576},{"style":209},[20577],{"type":34,"value":268},{"type":28,"tag":192,"props":20579,"children":20580},{"style":340},[20581],{"type":34,"value":20535},{"type":28,"tag":192,"props":20583,"children":20584},{"style":226},[20585],{"type":34,"value":360},{"type":28,"tag":192,"props":20587,"children":20588},{"style":226},[20589],{"type":34,"value":229},{"type":28,"tag":192,"props":20591,"children":20592},{"class":194,"line":307},[20593,20597,20601,20606,20610,20614],{"type":28,"tag":192,"props":20594,"children":20595},{"style":371},[20596],{"type":34,"value":374},{"type":28,"tag":192,"props":20598,"children":20599},{"style":226},[20600],{"type":34,"value":379},{"type":28,"tag":192,"props":20602,"children":20603},{"style":247},[20604],{"type":34,"value":20605},"largeur ",{"type":28,"tag":192,"props":20607,"children":20608},{"style":387},[20609],{"type":34,"value":390},{"type":28,"tag":192,"props":20611,"children":20612},{"style":247},[20613],{"type":34,"value":20515},{"type":28,"tag":192,"props":20615,"children":20616},{"style":226},[20617],{"type":34,"value":255},{"type":28,"tag":192,"props":20619,"children":20620},{"class":194,"line":316},[20621,20625,20629,20634,20638,20642],{"type":28,"tag":192,"props":20622,"children":20623},{"style":371},[20624],{"type":34,"value":374},{"type":28,"tag":192,"props":20626,"children":20627},{"style":226},[20628],{"type":34,"value":379},{"type":28,"tag":192,"props":20630,"children":20631},{"style":247},[20632],{"type":34,"value":20633},"hauteur ",{"type":28,"tag":192,"props":20635,"children":20636},{"style":387},[20637],{"type":34,"value":390},{"type":28,"tag":192,"props":20639,"children":20640},{"style":247},[20641],{"type":34,"value":20535},{"type":28,"tag":192,"props":20643,"children":20644},{"style":226},[20645],{"type":34,"value":255},{"type":28,"tag":192,"props":20647,"children":20648},{"class":194,"line":367},[20649],{"type":28,"tag":192,"props":20650,"children":20651},{"style":226},[20652],{"type":34,"value":445},{"type":28,"tag":192,"props":20654,"children":20655},{"class":194,"line":401},[20656],{"type":28,"tag":192,"props":20657,"children":20658},{"emptyLinePlaceholder":13},[20659],{"type":34,"value":313},{"type":28,"tag":192,"props":20661,"children":20662},{"class":194,"line":430},[20663,20667,20671,20676,20680,20684,20688,20692],{"type":28,"tag":192,"props":20664,"children":20665},{"style":209},[20666],{"type":34,"value":322},{"type":28,"tag":192,"props":20668,"children":20669},{"style":209},[20670],{"type":34,"value":688},{"type":28,"tag":192,"props":20672,"children":20673},{"style":325},[20674],{"type":34,"value":20675}," setLargeur",{"type":28,"tag":192,"props":20677,"children":20678},{"style":226},[20679],{"type":34,"value":332},{"type":28,"tag":192,"props":20681,"children":20682},{"style":209},[20683],{"type":34,"value":938},{"type":28,"tag":192,"props":20685,"children":20686},{"style":340},[20687],{"type":34,"value":20515},{"type":28,"tag":192,"props":20689,"children":20690},{"style":226},[20691],{"type":34,"value":360},{"type":28,"tag":192,"props":20693,"children":20694},{"style":226},[20695],{"type":34,"value":229},{"type":28,"tag":192,"props":20697,"children":20698},{"class":194,"line":439},[20699,20703,20707,20711,20715,20719],{"type":28,"tag":192,"props":20700,"children":20701},{"style":371},[20702],{"type":34,"value":374},{"type":28,"tag":192,"props":20704,"children":20705},{"style":226},[20706],{"type":34,"value":379},{"type":28,"tag":192,"props":20708,"children":20709},{"style":247},[20710],{"type":34,"value":20605},{"type":28,"tag":192,"props":20712,"children":20713},{"style":387},[20714],{"type":34,"value":390},{"type":28,"tag":192,"props":20716,"children":20717},{"style":247},[20718],{"type":34,"value":20515},{"type":28,"tag":192,"props":20720,"children":20721},{"style":226},[20722],{"type":34,"value":255},{"type":28,"tag":192,"props":20724,"children":20725},{"class":194,"line":448},[20726],{"type":28,"tag":192,"props":20727,"children":20728},{"style":226},[20729],{"type":34,"value":445},{"type":28,"tag":192,"props":20731,"children":20732},{"class":194,"line":456},[20733],{"type":28,"tag":192,"props":20734,"children":20735},{"emptyLinePlaceholder":13},[20736],{"type":34,"value":313},{"type":28,"tag":192,"props":20738,"children":20739},{"class":194,"line":482},[20740,20744,20748,20753,20757,20761,20765,20769],{"type":28,"tag":192,"props":20741,"children":20742},{"style":209},[20743],{"type":34,"value":322},{"type":28,"tag":192,"props":20745,"children":20746},{"style":209},[20747],{"type":34,"value":688},{"type":28,"tag":192,"props":20749,"children":20750},{"style":325},[20751],{"type":34,"value":20752}," setHauteur",{"type":28,"tag":192,"props":20754,"children":20755},{"style":226},[20756],{"type":34,"value":332},{"type":28,"tag":192,"props":20758,"children":20759},{"style":209},[20760],{"type":34,"value":938},{"type":28,"tag":192,"props":20762,"children":20763},{"style":340},[20764],{"type":34,"value":20535},{"type":28,"tag":192,"props":20766,"children":20767},{"style":226},[20768],{"type":34,"value":360},{"type":28,"tag":192,"props":20770,"children":20771},{"style":226},[20772],{"type":34,"value":229},{"type":28,"tag":192,"props":20774,"children":20775},{"class":194,"line":499},[20776,20780,20784,20788,20792,20796],{"type":28,"tag":192,"props":20777,"children":20778},{"style":371},[20779],{"type":34,"value":374},{"type":28,"tag":192,"props":20781,"children":20782},{"style":226},[20783],{"type":34,"value":379},{"type":28,"tag":192,"props":20785,"children":20786},{"style":247},[20787],{"type":34,"value":20633},{"type":28,"tag":192,"props":20789,"children":20790},{"style":387},[20791],{"type":34,"value":390},{"type":28,"tag":192,"props":20793,"children":20794},{"style":247},[20795],{"type":34,"value":20535},{"type":28,"tag":192,"props":20797,"children":20798},{"style":226},[20799],{"type":34,"value":255},{"type":28,"tag":192,"props":20801,"children":20802},{"class":194,"line":507},[20803],{"type":28,"tag":192,"props":20804,"children":20805},{"style":226},[20806],{"type":34,"value":445},{"type":28,"tag":192,"props":20808,"children":20809},{"class":194,"line":515},[20810],{"type":28,"tag":192,"props":20811,"children":20812},{"emptyLinePlaceholder":13},[20813],{"type":34,"value":313},{"type":28,"tag":192,"props":20815,"children":20816},{"class":194,"line":540},[20817,20821,20825,20830,20834],{"type":28,"tag":192,"props":20818,"children":20819},{"style":209},[20820],{"type":34,"value":322},{"type":28,"tag":192,"props":20822,"children":20823},{"style":209},[20824],{"type":34,"value":268},{"type":28,"tag":192,"props":20826,"children":20827},{"style":325},[20828],{"type":34,"value":20829}," calculerAire",{"type":28,"tag":192,"props":20831,"children":20832},{"style":226},[20833],{"type":34,"value":475},{"type":28,"tag":192,"props":20835,"children":20836},{"style":226},[20837],{"type":34,"value":229},{"type":28,"tag":192,"props":20839,"children":20840},{"class":194,"line":556},[20841,20845,20850,20854,20858,20862,20866,20870,20875],{"type":28,"tag":192,"props":20842,"children":20843},{"style":209},[20844],{"type":34,"value":488},{"type":28,"tag":192,"props":20846,"children":20847},{"style":371},[20848],{"type":34,"value":20849}," this",{"type":28,"tag":192,"props":20851,"children":20852},{"style":226},[20853],{"type":34,"value":379},{"type":28,"tag":192,"props":20855,"children":20856},{"style":247},[20857],{"type":34,"value":20605},{"type":28,"tag":192,"props":20859,"children":20860},{"style":387},[20861],{"type":34,"value":1102},{"type":28,"tag":192,"props":20863,"children":20864},{"style":371},[20865],{"type":34,"value":20849},{"type":28,"tag":192,"props":20867,"children":20868},{"style":226},[20869],{"type":34,"value":379},{"type":28,"tag":192,"props":20871,"children":20872},{"style":247},[20873],{"type":34,"value":20874},"hauteur",{"type":28,"tag":192,"props":20876,"children":20877},{"style":226},[20878],{"type":34,"value":255},{"type":28,"tag":192,"props":20880,"children":20881},{"class":194,"line":564},[20882],{"type":28,"tag":192,"props":20883,"children":20884},{"style":226},[20885],{"type":34,"value":445},{"type":28,"tag":192,"props":20887,"children":20888},{"class":194,"line":573},[20889],{"type":28,"tag":192,"props":20890,"children":20891},{"style":226},[20892],{"type":34,"value":588},{"type":28,"tag":44,"props":20894,"children":20895},{},[20896,20898,20903],{"type":34,"value":20897},"Ici, la classe ",{"type":28,"tag":188,"props":20899,"children":20901},{"className":20900},[],[20902],{"type":34,"value":6208},{"type":34,"value":20904}," fonctionne normalement. Elle a des méthodes pour définir la largeur et la hauteur, et pour calculer l'aire.",{"type":28,"tag":169,"props":20906,"children":20908},{"id":20907},"sous-classe-carre",[20909,20911,20917],{"type":34,"value":20910},"Sous-classe ",{"type":28,"tag":188,"props":20912,"children":20914},{"className":20913},[],[20915],{"type":34,"value":20916},"Carre",{"type":34,"value":5685},{"type":28,"tag":181,"props":20919,"children":20921},{"className":183,"code":20920,"language":185,"meta":8,"style":8},"public class Carre extends Rectangle {\n\n    public Carre(int taille) {\n        super(taille, taille);\n    }\n\n    @Override\n    public void setLargeur(int taille) {\n        this.largeur = this.hauteur = taille;\n    }\n\n    @Override\n    public void setHauteur(int taille) {\n        this.largeur = this.hauteur = taille;\n    }\n}\n",[20922],{"type":28,"tag":188,"props":20923,"children":20924},{"__ignoreMap":8},[20925,20953,20960,20992,21021,21028,21035,21046,21081,21124,21131,21138,21149,21184,21227,21234],{"type":28,"tag":192,"props":20926,"children":20927},{"class":194,"line":195},[20928,20932,20936,20941,20945,20949],{"type":28,"tag":192,"props":20929,"children":20930},{"style":209},[20931],{"type":34,"value":212},{"type":28,"tag":192,"props":20933,"children":20934},{"style":209},[20935],{"type":34,"value":217},{"type":28,"tag":192,"props":20937,"children":20938},{"style":220},[20939],{"type":34,"value":20940}," Carre",{"type":28,"tag":192,"props":20942,"children":20943},{"style":209},[20944],{"type":34,"value":6577},{"type":28,"tag":192,"props":20946,"children":20947},{"style":220},[20948],{"type":34,"value":6265},{"type":28,"tag":192,"props":20950,"children":20951},{"style":226},[20952],{"type":34,"value":229},{"type":28,"tag":192,"props":20954,"children":20955},{"class":194,"line":205},[20956],{"type":28,"tag":192,"props":20957,"children":20958},{"emptyLinePlaceholder":13},[20959],{"type":34,"value":313},{"type":28,"tag":192,"props":20961,"children":20962},{"class":194,"line":232},[20963,20967,20971,20975,20979,20984,20988],{"type":28,"tag":192,"props":20964,"children":20965},{"style":209},[20966],{"type":34,"value":322},{"type":28,"tag":192,"props":20968,"children":20969},{"style":325},[20970],{"type":34,"value":20940},{"type":28,"tag":192,"props":20972,"children":20973},{"style":226},[20974],{"type":34,"value":332},{"type":28,"tag":192,"props":20976,"children":20977},{"style":209},[20978],{"type":34,"value":938},{"type":28,"tag":192,"props":20980,"children":20981},{"style":340},[20982],{"type":34,"value":20983}," taille",{"type":28,"tag":192,"props":20985,"children":20986},{"style":226},[20987],{"type":34,"value":360},{"type":28,"tag":192,"props":20989,"children":20990},{"style":226},[20991],{"type":34,"value":229},{"type":28,"tag":192,"props":20993,"children":20994},{"class":194,"line":258},[20995,21000,21004,21009,21013,21017],{"type":28,"tag":192,"props":20996,"children":20997},{"style":18300},[20998],{"type":34,"value":20999},"        super",{"type":28,"tag":192,"props":21001,"children":21002},{"style":226},[21003],{"type":34,"value":332},{"type":28,"tag":192,"props":21005,"children":21006},{"style":247},[21007],{"type":34,"value":21008},"taille",{"type":28,"tag":192,"props":21010,"children":21011},{"style":226},[21012],{"type":34,"value":347},{"type":28,"tag":192,"props":21014,"children":21015},{"style":247},[21016],{"type":34,"value":20983},{"type":28,"tag":192,"props":21018,"children":21019},{"style":226},[21020],{"type":34,"value":752},{"type":28,"tag":192,"props":21022,"children":21023},{"class":194,"line":280},[21024],{"type":28,"tag":192,"props":21025,"children":21026},{"style":226},[21027],{"type":34,"value":445},{"type":28,"tag":192,"props":21029,"children":21030},{"class":194,"line":307},[21031],{"type":28,"tag":192,"props":21032,"children":21033},{"emptyLinePlaceholder":13},[21034],{"type":34,"value":313},{"type":28,"tag":192,"props":21036,"children":21037},{"class":194,"line":316},[21038,21042],{"type":28,"tag":192,"props":21039,"children":21040},{"style":667},[21041],{"type":34,"value":5359},{"type":28,"tag":192,"props":21043,"children":21044},{"style":673},[21045],{"type":34,"value":5364},{"type":28,"tag":192,"props":21047,"children":21048},{"class":194,"line":367},[21049,21053,21057,21061,21065,21069,21073,21077],{"type":28,"tag":192,"props":21050,"children":21051},{"style":209},[21052],{"type":34,"value":322},{"type":28,"tag":192,"props":21054,"children":21055},{"style":209},[21056],{"type":34,"value":688},{"type":28,"tag":192,"props":21058,"children":21059},{"style":325},[21060],{"type":34,"value":20675},{"type":28,"tag":192,"props":21062,"children":21063},{"style":226},[21064],{"type":34,"value":332},{"type":28,"tag":192,"props":21066,"children":21067},{"style":209},[21068],{"type":34,"value":938},{"type":28,"tag":192,"props":21070,"children":21071},{"style":340},[21072],{"type":34,"value":20983},{"type":28,"tag":192,"props":21074,"children":21075},{"style":226},[21076],{"type":34,"value":360},{"type":28,"tag":192,"props":21078,"children":21079},{"style":226},[21080],{"type":34,"value":229},{"type":28,"tag":192,"props":21082,"children":21083},{"class":194,"line":401},[21084,21088,21092,21096,21100,21104,21108,21112,21116,21120],{"type":28,"tag":192,"props":21085,"children":21086},{"style":371},[21087],{"type":34,"value":374},{"type":28,"tag":192,"props":21089,"children":21090},{"style":226},[21091],{"type":34,"value":379},{"type":28,"tag":192,"props":21093,"children":21094},{"style":247},[21095],{"type":34,"value":20605},{"type":28,"tag":192,"props":21097,"children":21098},{"style":387},[21099],{"type":34,"value":390},{"type":28,"tag":192,"props":21101,"children":21102},{"style":371},[21103],{"type":34,"value":20849},{"type":28,"tag":192,"props":21105,"children":21106},{"style":226},[21107],{"type":34,"value":379},{"type":28,"tag":192,"props":21109,"children":21110},{"style":247},[21111],{"type":34,"value":20633},{"type":28,"tag":192,"props":21113,"children":21114},{"style":387},[21115],{"type":34,"value":390},{"type":28,"tag":192,"props":21117,"children":21118},{"style":247},[21119],{"type":34,"value":20983},{"type":28,"tag":192,"props":21121,"children":21122},{"style":226},[21123],{"type":34,"value":255},{"type":28,"tag":192,"props":21125,"children":21126},{"class":194,"line":430},[21127],{"type":28,"tag":192,"props":21128,"children":21129},{"style":226},[21130],{"type":34,"value":445},{"type":28,"tag":192,"props":21132,"children":21133},{"class":194,"line":439},[21134],{"type":28,"tag":192,"props":21135,"children":21136},{"emptyLinePlaceholder":13},[21137],{"type":34,"value":313},{"type":28,"tag":192,"props":21139,"children":21140},{"class":194,"line":448},[21141,21145],{"type":28,"tag":192,"props":21142,"children":21143},{"style":667},[21144],{"type":34,"value":5359},{"type":28,"tag":192,"props":21146,"children":21147},{"style":673},[21148],{"type":34,"value":5364},{"type":28,"tag":192,"props":21150,"children":21151},{"class":194,"line":456},[21152,21156,21160,21164,21168,21172,21176,21180],{"type":28,"tag":192,"props":21153,"children":21154},{"style":209},[21155],{"type":34,"value":322},{"type":28,"tag":192,"props":21157,"children":21158},{"style":209},[21159],{"type":34,"value":688},{"type":28,"tag":192,"props":21161,"children":21162},{"style":325},[21163],{"type":34,"value":20752},{"type":28,"tag":192,"props":21165,"children":21166},{"style":226},[21167],{"type":34,"value":332},{"type":28,"tag":192,"props":21169,"children":21170},{"style":209},[21171],{"type":34,"value":938},{"type":28,"tag":192,"props":21173,"children":21174},{"style":340},[21175],{"type":34,"value":20983},{"type":28,"tag":192,"props":21177,"children":21178},{"style":226},[21179],{"type":34,"value":360},{"type":28,"tag":192,"props":21181,"children":21182},{"style":226},[21183],{"type":34,"value":229},{"type":28,"tag":192,"props":21185,"children":21186},{"class":194,"line":482},[21187,21191,21195,21199,21203,21207,21211,21215,21219,21223],{"type":28,"tag":192,"props":21188,"children":21189},{"style":371},[21190],{"type":34,"value":374},{"type":28,"tag":192,"props":21192,"children":21193},{"style":226},[21194],{"type":34,"value":379},{"type":28,"tag":192,"props":21196,"children":21197},{"style":247},[21198],{"type":34,"value":20605},{"type":28,"tag":192,"props":21200,"children":21201},{"style":387},[21202],{"type":34,"value":390},{"type":28,"tag":192,"props":21204,"children":21205},{"style":371},[21206],{"type":34,"value":20849},{"type":28,"tag":192,"props":21208,"children":21209},{"style":226},[21210],{"type":34,"value":379},{"type":28,"tag":192,"props":21212,"children":21213},{"style":247},[21214],{"type":34,"value":20633},{"type":28,"tag":192,"props":21216,"children":21217},{"style":387},[21218],{"type":34,"value":390},{"type":28,"tag":192,"props":21220,"children":21221},{"style":247},[21222],{"type":34,"value":20983},{"type":28,"tag":192,"props":21224,"children":21225},{"style":226},[21226],{"type":34,"value":255},{"type":28,"tag":192,"props":21228,"children":21229},{"class":194,"line":499},[21230],{"type":28,"tag":192,"props":21231,"children":21232},{"style":226},[21233],{"type":34,"value":445},{"type":28,"tag":192,"props":21235,"children":21236},{"class":194,"line":507},[21237],{"type":28,"tag":192,"props":21238,"children":21239},{"style":226},[21240],{"type":34,"value":588},{"type":28,"tag":44,"props":21242,"children":21243},{},[21244,21246,21251,21253,21258,21260,21266,21267,21273],{"type":34,"value":21245},"Dans cet exemple, nous avons une classe ",{"type":28,"tag":188,"props":21247,"children":21249},{"className":21248},[],[21250],{"type":34,"value":20916},{"type":34,"value":21252}," qui hérite de ",{"type":28,"tag":188,"props":21254,"children":21256},{"className":21255},[],[21257],{"type":34,"value":6208},{"type":34,"value":21259},". Un carré étant un cas particulier de rectangle où tous les côtés sont égaux, nous avons redéfini les méthodes ",{"type":28,"tag":188,"props":21261,"children":21263},{"className":21262},[],[21264],{"type":34,"value":21265},"setLargeur",{"type":34,"value":10377},{"type":28,"tag":188,"props":21268,"children":21270},{"className":21269},[],[21271],{"type":34,"value":21272},"setHauteur",{"type":34,"value":21274}," pour toujours appliquer la même valeur à la largeur et à la hauteur.",{"type":28,"tag":169,"props":21276,"children":21278},{"id":21277},"problème-avec-le-lsp",[21279],{"type":34,"value":21280},"Problème avec le LSP",{"type":28,"tag":44,"props":21282,"children":21283},{},[21284,21286,21291],{"type":34,"value":21285},"Maintenant, utilisons ces classes dans un programme. Supposons que nous ayons une méthode qui teste les objets ",{"type":28,"tag":188,"props":21287,"children":21289},{"className":21288},[],[21290],{"type":34,"value":6208},{"type":34,"value":5685},{"type":28,"tag":181,"props":21293,"children":21295},{"className":183,"code":21294,"language":185,"meta":8,"style":8},"public class Main {\n\n    public static void testerRectangle(Rectangle rect) {\n        rect.setLargeur(5);\n        rect.setHauteur(10);\n        int aire = rect.calculerAire();\n        System.out.println(\"Aire attendue : 50, Aire calculée : \" + aire);\n    }\n\n    public static void main(String[] args) {\n        // Test avec un Rectangle\n        Rectangle rect = new Rectangle(2, 3);\n        testerRectangle(rect);\n\n        // Test avec un Carre\n        Carre carre = new Carre(5);\n        testerRectangle(carre);\n    }\n}\n",[21296],{"type":28,"tag":188,"props":21297,"children":21298},{"__ignoreMap":8},[21299,21318,21325,21366,21394,21421,21454,21499,21506,21513,21556,21564,21609,21630,21637,21645,21682,21702,21709],{"type":28,"tag":192,"props":21300,"children":21301},{"class":194,"line":195},[21302,21306,21310,21314],{"type":28,"tag":192,"props":21303,"children":21304},{"style":209},[21305],{"type":34,"value":212},{"type":28,"tag":192,"props":21307,"children":21308},{"style":209},[21309],{"type":34,"value":217},{"type":28,"tag":192,"props":21311,"children":21312},{"style":220},[21313],{"type":34,"value":5846},{"type":28,"tag":192,"props":21315,"children":21316},{"style":226},[21317],{"type":34,"value":229},{"type":28,"tag":192,"props":21319,"children":21320},{"class":194,"line":205},[21321],{"type":28,"tag":192,"props":21322,"children":21323},{"emptyLinePlaceholder":13},[21324],{"type":34,"value":313},{"type":28,"tag":192,"props":21326,"children":21327},{"class":194,"line":232},[21328,21332,21336,21340,21345,21349,21353,21358,21362],{"type":28,"tag":192,"props":21329,"children":21330},{"style":209},[21331],{"type":34,"value":322},{"type":28,"tag":192,"props":21333,"children":21334},{"style":209},[21335],{"type":34,"value":5862},{"type":28,"tag":192,"props":21337,"children":21338},{"style":209},[21339],{"type":34,"value":688},{"type":28,"tag":192,"props":21341,"children":21342},{"style":325},[21343],{"type":34,"value":21344}," testerRectangle",{"type":28,"tag":192,"props":21346,"children":21347},{"style":226},[21348],{"type":34,"value":332},{"type":28,"tag":192,"props":21350,"children":21351},{"style":241},[21352],{"type":34,"value":6208},{"type":28,"tag":192,"props":21354,"children":21355},{"style":340},[21356],{"type":34,"value":21357}," rect",{"type":28,"tag":192,"props":21359,"children":21360},{"style":226},[21361],{"type":34,"value":360},{"type":28,"tag":192,"props":21363,"children":21364},{"style":226},[21365],{"type":34,"value":229},{"type":28,"tag":192,"props":21367,"children":21368},{"class":194,"line":258},[21369,21374,21378,21382,21386,21390],{"type":28,"tag":192,"props":21370,"children":21371},{"style":247},[21372],{"type":34,"value":21373},"        rect",{"type":28,"tag":192,"props":21375,"children":21376},{"style":226},[21377],{"type":34,"value":379},{"type":28,"tag":192,"props":21379,"children":21380},{"style":325},[21381],{"type":34,"value":21265},{"type":28,"tag":192,"props":21383,"children":21384},{"style":226},[21385],{"type":34,"value":332},{"type":28,"tag":192,"props":21387,"children":21388},{"style":744},[21389],{"type":34,"value":16809},{"type":28,"tag":192,"props":21391,"children":21392},{"style":226},[21393],{"type":34,"value":752},{"type":28,"tag":192,"props":21395,"children":21396},{"class":194,"line":280},[21397,21401,21405,21409,21413,21417],{"type":28,"tag":192,"props":21398,"children":21399},{"style":247},[21400],{"type":34,"value":21373},{"type":28,"tag":192,"props":21402,"children":21403},{"style":226},[21404],{"type":34,"value":379},{"type":28,"tag":192,"props":21406,"children":21407},{"style":325},[21408],{"type":34,"value":21272},{"type":28,"tag":192,"props":21410,"children":21411},{"style":226},[21412],{"type":34,"value":332},{"type":28,"tag":192,"props":21414,"children":21415},{"style":744},[21416],{"type":34,"value":18751},{"type":28,"tag":192,"props":21418,"children":21419},{"style":226},[21420],{"type":34,"value":752},{"type":28,"tag":192,"props":21422,"children":21423},{"class":194,"line":307},[21424,21428,21433,21437,21441,21445,21450],{"type":28,"tag":192,"props":21425,"children":21426},{"style":209},[21427],{"type":34,"value":16749},{"type":28,"tag":192,"props":21429,"children":21430},{"style":247},[21431],{"type":34,"value":21432}," aire ",{"type":28,"tag":192,"props":21434,"children":21435},{"style":387},[21436],{"type":34,"value":390},{"type":28,"tag":192,"props":21438,"children":21439},{"style":247},[21440],{"type":34,"value":21357},{"type":28,"tag":192,"props":21442,"children":21443},{"style":226},[21444],{"type":34,"value":379},{"type":28,"tag":192,"props":21446,"children":21447},{"style":325},[21448],{"type":34,"value":21449},"calculerAire",{"type":28,"tag":192,"props":21451,"children":21452},{"style":226},[21453],{"type":34,"value":1973},{"type":28,"tag":192,"props":21455,"children":21456},{"class":194,"line":316},[21457,21461,21465,21469,21473,21477,21481,21486,21490,21495],{"type":28,"tag":192,"props":21458,"children":21459},{"style":247},[21460],{"type":34,"value":4327},{"type":28,"tag":192,"props":21462,"children":21463},{"style":226},[21464],{"type":34,"value":379},{"type":28,"tag":192,"props":21466,"children":21467},{"style":247},[21468],{"type":34,"value":2673},{"type":28,"tag":192,"props":21470,"children":21471},{"style":226},[21472],{"type":34,"value":379},{"type":28,"tag":192,"props":21474,"children":21475},{"style":325},[21476],{"type":34,"value":2682},{"type":28,"tag":192,"props":21478,"children":21479},{"style":226},[21480],{"type":34,"value":332},{"type":28,"tag":192,"props":21482,"children":21483},{"style":734},[21484],{"type":34,"value":21485},"\"Aire attendue : 50, Aire calculée : \"",{"type":28,"tag":192,"props":21487,"children":21488},{"style":387},[21489],{"type":34,"value":2696},{"type":28,"tag":192,"props":21491,"children":21492},{"style":247},[21493],{"type":34,"value":21494}," aire",{"type":28,"tag":192,"props":21496,"children":21497},{"style":226},[21498],{"type":34,"value":752},{"type":28,"tag":192,"props":21500,"children":21501},{"class":194,"line":367},[21502],{"type":28,"tag":192,"props":21503,"children":21504},{"style":226},[21505],{"type":34,"value":445},{"type":28,"tag":192,"props":21507,"children":21508},{"class":194,"line":401},[21509],{"type":28,"tag":192,"props":21510,"children":21511},{"emptyLinePlaceholder":13},[21512],{"type":34,"value":313},{"type":28,"tag":192,"props":21514,"children":21515},{"class":194,"line":430},[21516,21520,21524,21528,21532,21536,21540,21544,21548,21552],{"type":28,"tag":192,"props":21517,"children":21518},{"style":209},[21519],{"type":34,"value":322},{"type":28,"tag":192,"props":21521,"children":21522},{"style":209},[21523],{"type":34,"value":5862},{"type":28,"tag":192,"props":21525,"children":21526},{"style":209},[21527],{"type":34,"value":688},{"type":28,"tag":192,"props":21529,"children":21530},{"style":325},[21531],{"type":34,"value":5871},{"type":28,"tag":192,"props":21533,"children":21534},{"style":226},[21535],{"type":34,"value":332},{"type":28,"tag":192,"props":21537,"children":21538},{"style":209},[21539],{"type":34,"value":337},{"type":28,"tag":192,"props":21541,"children":21542},{"style":226},[21543],{"type":34,"value":5884},{"type":28,"tag":192,"props":21545,"children":21546},{"style":340},[21547],{"type":34,"value":5889},{"type":28,"tag":192,"props":21549,"children":21550},{"style":226},[21551],{"type":34,"value":360},{"type":28,"tag":192,"props":21553,"children":21554},{"style":226},[21555],{"type":34,"value":229},{"type":28,"tag":192,"props":21557,"children":21558},{"class":194,"line":439},[21559],{"type":28,"tag":192,"props":21560,"children":21561},{"style":199},[21562],{"type":34,"value":21563},"        // Test avec un Rectangle\n",{"type":28,"tag":192,"props":21565,"children":21566},{"class":194,"line":448},[21567,21572,21577,21581,21585,21589,21593,21597,21601,21605],{"type":28,"tag":192,"props":21568,"children":21569},{"style":241},[21570],{"type":34,"value":21571},"        Rectangle",{"type":28,"tag":192,"props":21573,"children":21574},{"style":247},[21575],{"type":34,"value":21576}," rect ",{"type":28,"tag":192,"props":21578,"children":21579},{"style":387},[21580],{"type":34,"value":390},{"type":28,"tag":192,"props":21582,"children":21583},{"style":209},[21584],{"type":34,"value":723},{"type":28,"tag":192,"props":21586,"children":21587},{"style":325},[21588],{"type":34,"value":6265},{"type":28,"tag":192,"props":21590,"children":21591},{"style":226},[21592],{"type":34,"value":332},{"type":28,"tag":192,"props":21594,"children":21595},{"style":744},[21596],{"type":34,"value":2025},{"type":28,"tag":192,"props":21598,"children":21599},{"style":226},[21600],{"type":34,"value":347},{"type":28,"tag":192,"props":21602,"children":21603},{"style":744},[21604],{"type":34,"value":16788},{"type":28,"tag":192,"props":21606,"children":21607},{"style":226},[21608],{"type":34,"value":752},{"type":28,"tag":192,"props":21610,"children":21611},{"class":194,"line":456},[21612,21617,21621,21626],{"type":28,"tag":192,"props":21613,"children":21614},{"style":325},[21615],{"type":34,"value":21616},"        testerRectangle",{"type":28,"tag":192,"props":21618,"children":21619},{"style":226},[21620],{"type":34,"value":332},{"type":28,"tag":192,"props":21622,"children":21623},{"style":247},[21624],{"type":34,"value":21625},"rect",{"type":28,"tag":192,"props":21627,"children":21628},{"style":226},[21629],{"type":34,"value":752},{"type":28,"tag":192,"props":21631,"children":21632},{"class":194,"line":482},[21633],{"type":28,"tag":192,"props":21634,"children":21635},{"emptyLinePlaceholder":13},[21636],{"type":34,"value":313},{"type":28,"tag":192,"props":21638,"children":21639},{"class":194,"line":499},[21640],{"type":28,"tag":192,"props":21641,"children":21642},{"style":199},[21643],{"type":34,"value":21644},"        // Test avec un Carre\n",{"type":28,"tag":192,"props":21646,"children":21647},{"class":194,"line":507},[21648,21653,21658,21662,21666,21670,21674,21678],{"type":28,"tag":192,"props":21649,"children":21650},{"style":241},[21651],{"type":34,"value":21652},"        Carre",{"type":28,"tag":192,"props":21654,"children":21655},{"style":247},[21656],{"type":34,"value":21657}," carre ",{"type":28,"tag":192,"props":21659,"children":21660},{"style":387},[21661],{"type":34,"value":390},{"type":28,"tag":192,"props":21663,"children":21664},{"style":209},[21665],{"type":34,"value":723},{"type":28,"tag":192,"props":21667,"children":21668},{"style":325},[21669],{"type":34,"value":20940},{"type":28,"tag":192,"props":21671,"children":21672},{"style":226},[21673],{"type":34,"value":332},{"type":28,"tag":192,"props":21675,"children":21676},{"style":744},[21677],{"type":34,"value":16809},{"type":28,"tag":192,"props":21679,"children":21680},{"style":226},[21681],{"type":34,"value":752},{"type":28,"tag":192,"props":21683,"children":21684},{"class":194,"line":515},[21685,21689,21693,21698],{"type":28,"tag":192,"props":21686,"children":21687},{"style":325},[21688],{"type":34,"value":21616},{"type":28,"tag":192,"props":21690,"children":21691},{"style":226},[21692],{"type":34,"value":332},{"type":28,"tag":192,"props":21694,"children":21695},{"style":247},[21696],{"type":34,"value":21697},"carre",{"type":28,"tag":192,"props":21699,"children":21700},{"style":226},[21701],{"type":34,"value":752},{"type":28,"tag":192,"props":21703,"children":21704},{"class":194,"line":540},[21705],{"type":28,"tag":192,"props":21706,"children":21707},{"style":226},[21708],{"type":34,"value":445},{"type":28,"tag":192,"props":21710,"children":21711},{"class":194,"line":556},[21712],{"type":28,"tag":192,"props":21713,"children":21714},{"style":226},[21715],{"type":34,"value":588},{"type":28,"tag":169,"props":21717,"children":21719},{"id":21718},"résultat",[21720],{"type":34,"value":21721},"Résultat :",{"type":28,"tag":144,"props":21723,"children":21724},{},[21725,21737],{"type":28,"tag":148,"props":21726,"children":21727},{},[21728,21730,21735],{"type":34,"value":21729},"Avec l'objet ",{"type":28,"tag":188,"props":21731,"children":21733},{"className":21732},[],[21734],{"type":34,"value":6208},{"type":34,"value":21736},", tout fonctionne comme prévu. L'aire calculée sera de 50 (5 * 10).",{"type":28,"tag":148,"props":21738,"children":21739},{},[21740,21741,21746,21748,21754],{"type":34,"value":21729},{"type":28,"tag":188,"props":21742,"children":21744},{"className":21743},[],[21745],{"type":34,"value":20916},{"type":34,"value":21747},", cependant, le calcul ne donnera pas le résultat attendu. En appelant ",{"type":28,"tag":188,"props":21749,"children":21751},{"className":21750},[],[21752],{"type":34,"value":21753},"setHauteur(10)",{"type":34,"value":21755},", nous changeons aussi la largeur à 10, et l'aire calculée sera 100 au lieu de 50.",{"type":28,"tag":44,"props":21757,"children":21758},{},[21759,21761,21766,21768,21773,21775,21780],{"type":34,"value":21760},"Ce comportement brise le LSP, car la classe ",{"type":28,"tag":188,"props":21762,"children":21764},{"className":21763},[],[21765],{"type":34,"value":20916},{"type":34,"value":21767}," ne respecte pas les attentes fixées par ",{"type":28,"tag":188,"props":21769,"children":21771},{"className":21770},[],[21772],{"type":34,"value":6208},{"type":34,"value":21774},". Cela peut causer des bugs ou des comportements inattendus dans les programmes qui s’attendent à ce qu’un ",{"type":28,"tag":188,"props":21776,"children":21778},{"className":21777},[],[21779],{"type":34,"value":6208},{"type":34,"value":21781}," fonctionne d’une certaine manière.",{"type":28,"tag":83,"props":21783,"children":21784},{},[],{"type":28,"tag":29,"props":21786,"children":21788},{"id":21787},"exemple-correct-respecter-le-lsp-ce-quil-faut-faire",[21789],{"type":34,"value":21790},"Exemple correct - Respecter le LSP : Ce qu’il faut faire",{"type":28,"tag":44,"props":21792,"children":21793},{},[21794,21796,21801,21802,21807],{"type":34,"value":21795},"Pour respecter le principe de substitution de Liskov, nous devons nous assurer que les sous-classes n'altèrent pas le comportement attendu de la classe de base. Dans le cas du ",{"type":28,"tag":188,"props":21797,"children":21799},{"className":21798},[],[21800],{"type":34,"value":6208},{"type":34,"value":20454},{"type":28,"tag":188,"props":21803,"children":21805},{"className":21804},[],[21806],{"type":34,"value":20916},{"type":34,"value":21808},", le problème vient du fait que le carré redéfinit la manière dont les dimensions sont définies, brisant ainsi le comportement du rectangle.",{"type":28,"tag":169,"props":21810,"children":21812},{"id":21811},"solution-séparer-les-concepts",[21813],{"type":34,"value":21814},"Solution : Séparer les concepts",{"type":28,"tag":44,"props":21816,"children":21817},{},[21818,21820,21825,21827,21832],{"type":34,"value":21819},"Une solution consiste à ne pas faire de ",{"type":28,"tag":188,"props":21821,"children":21823},{"className":21822},[],[21824],{"type":34,"value":20916},{"type":34,"value":21826}," une sous-classe de ",{"type":28,"tag":188,"props":21828,"children":21830},{"className":21829},[],[21831],{"type":34,"value":6208},{"type":34,"value":21833},". Bien que mathématiquement, un carré soit un type particulier de rectangle, en termes de conception orientée objet, il est souvent préférable de modéliser ces concepts de manière distincte pour éviter de briser le LSP.",{"type":28,"tag":169,"props":21835,"children":21837},{"id":21836},"nouvelle-conception-classes-indépendantes-rectangle-et-carre",[21838,21840,21845,21846],{"type":34,"value":21839},"Nouvelle conception : Classes indépendantes ",{"type":28,"tag":188,"props":21841,"children":21843},{"className":21842},[],[21844],{"type":34,"value":6208},{"type":34,"value":10377},{"type":28,"tag":188,"props":21847,"children":21849},{"className":21848},[],[21850],{"type":34,"value":20916},{"type":28,"tag":44,"props":21852,"children":21853},{},[21854],{"type":34,"value":21855},"Voici comment nous pourrions concevoir cela correctement :",{"type":28,"tag":169,"props":21857,"children":21859},{"id":21858},"classe-rectangle-1",[21860,21861,21866],{"type":34,"value":20467},{"type":28,"tag":188,"props":21862,"children":21864},{"className":21863},[],[21865],{"type":34,"value":6208},{"type":34,"value":5685},{"type":28,"tag":181,"props":21868,"children":21869},{"className":183,"code":20476,"language":185,"meta":8,"style":8},[21870],{"type":28,"tag":188,"props":21871,"children":21872},{"__ignoreMap":8},[21873,21892,21911,21930,21937,21980,22007,22034,22041,22048,22083,22110,22117,22124,22159,22186,22193,22200,22223,22262,22269],{"type":28,"tag":192,"props":21874,"children":21875},{"class":194,"line":195},[21876,21880,21884,21888],{"type":28,"tag":192,"props":21877,"children":21878},{"style":209},[21879],{"type":34,"value":212},{"type":28,"tag":192,"props":21881,"children":21882},{"style":209},[21883],{"type":34,"value":217},{"type":28,"tag":192,"props":21885,"children":21886},{"style":220},[21887],{"type":34,"value":6265},{"type":28,"tag":192,"props":21889,"children":21890},{"style":226},[21891],{"type":34,"value":229},{"type":28,"tag":192,"props":21893,"children":21894},{"class":194,"line":205},[21895,21899,21903,21907],{"type":28,"tag":192,"props":21896,"children":21897},{"style":209},[21898],{"type":34,"value":6277},{"type":28,"tag":192,"props":21900,"children":21901},{"style":209},[21902],{"type":34,"value":268},{"type":28,"tag":192,"props":21904,"children":21905},{"style":247},[21906],{"type":34,"value":20515},{"type":28,"tag":192,"props":21908,"children":21909},{"style":226},[21910],{"type":34,"value":255},{"type":28,"tag":192,"props":21912,"children":21913},{"class":194,"line":232},[21914,21918,21922,21926],{"type":28,"tag":192,"props":21915,"children":21916},{"style":209},[21917],{"type":34,"value":6277},{"type":28,"tag":192,"props":21919,"children":21920},{"style":209},[21921],{"type":34,"value":268},{"type":28,"tag":192,"props":21923,"children":21924},{"style":247},[21925],{"type":34,"value":20535},{"type":28,"tag":192,"props":21927,"children":21928},{"style":226},[21929],{"type":34,"value":255},{"type":28,"tag":192,"props":21931,"children":21932},{"class":194,"line":258},[21933],{"type":28,"tag":192,"props":21934,"children":21935},{"emptyLinePlaceholder":13},[21936],{"type":34,"value":313},{"type":28,"tag":192,"props":21938,"children":21939},{"class":194,"line":280},[21940,21944,21948,21952,21956,21960,21964,21968,21972,21976],{"type":28,"tag":192,"props":21941,"children":21942},{"style":209},[21943],{"type":34,"value":322},{"type":28,"tag":192,"props":21945,"children":21946},{"style":325},[21947],{"type":34,"value":6265},{"type":28,"tag":192,"props":21949,"children":21950},{"style":226},[21951],{"type":34,"value":332},{"type":28,"tag":192,"props":21953,"children":21954},{"style":209},[21955],{"type":34,"value":938},{"type":28,"tag":192,"props":21957,"children":21958},{"style":340},[21959],{"type":34,"value":20515},{"type":28,"tag":192,"props":21961,"children":21962},{"style":226},[21963],{"type":34,"value":347},{"type":28,"tag":192,"props":21965,"children":21966},{"style":209},[21967],{"type":34,"value":268},{"type":28,"tag":192,"props":21969,"children":21970},{"style":340},[21971],{"type":34,"value":20535},{"type":28,"tag":192,"props":21973,"children":21974},{"style":226},[21975],{"type":34,"value":360},{"type":28,"tag":192,"props":21977,"children":21978},{"style":226},[21979],{"type":34,"value":229},{"type":28,"tag":192,"props":21981,"children":21982},{"class":194,"line":307},[21983,21987,21991,21995,21999,22003],{"type":28,"tag":192,"props":21984,"children":21985},{"style":371},[21986],{"type":34,"value":374},{"type":28,"tag":192,"props":21988,"children":21989},{"style":226},[21990],{"type":34,"value":379},{"type":28,"tag":192,"props":21992,"children":21993},{"style":247},[21994],{"type":34,"value":20605},{"type":28,"tag":192,"props":21996,"children":21997},{"style":387},[21998],{"type":34,"value":390},{"type":28,"tag":192,"props":22000,"children":22001},{"style":247},[22002],{"type":34,"value":20515},{"type":28,"tag":192,"props":22004,"children":22005},{"style":226},[22006],{"type":34,"value":255},{"type":28,"tag":192,"props":22008,"children":22009},{"class":194,"line":316},[22010,22014,22018,22022,22026,22030],{"type":28,"tag":192,"props":22011,"children":22012},{"style":371},[22013],{"type":34,"value":374},{"type":28,"tag":192,"props":22015,"children":22016},{"style":226},[22017],{"type":34,"value":379},{"type":28,"tag":192,"props":22019,"children":22020},{"style":247},[22021],{"type":34,"value":20633},{"type":28,"tag":192,"props":22023,"children":22024},{"style":387},[22025],{"type":34,"value":390},{"type":28,"tag":192,"props":22027,"children":22028},{"style":247},[22029],{"type":34,"value":20535},{"type":28,"tag":192,"props":22031,"children":22032},{"style":226},[22033],{"type":34,"value":255},{"type":28,"tag":192,"props":22035,"children":22036},{"class":194,"line":367},[22037],{"type":28,"tag":192,"props":22038,"children":22039},{"style":226},[22040],{"type":34,"value":445},{"type":28,"tag":192,"props":22042,"children":22043},{"class":194,"line":401},[22044],{"type":28,"tag":192,"props":22045,"children":22046},{"emptyLinePlaceholder":13},[22047],{"type":34,"value":313},{"type":28,"tag":192,"props":22049,"children":22050},{"class":194,"line":430},[22051,22055,22059,22063,22067,22071,22075,22079],{"type":28,"tag":192,"props":22052,"children":22053},{"style":209},[22054],{"type":34,"value":322},{"type":28,"tag":192,"props":22056,"children":22057},{"style":209},[22058],{"type":34,"value":688},{"type":28,"tag":192,"props":22060,"children":22061},{"style":325},[22062],{"type":34,"value":20675},{"type":28,"tag":192,"props":22064,"children":22065},{"style":226},[22066],{"type":34,"value":332},{"type":28,"tag":192,"props":22068,"children":22069},{"style":209},[22070],{"type":34,"value":938},{"type":28,"tag":192,"props":22072,"children":22073},{"style":340},[22074],{"type":34,"value":20515},{"type":28,"tag":192,"props":22076,"children":22077},{"style":226},[22078],{"type":34,"value":360},{"type":28,"tag":192,"props":22080,"children":22081},{"style":226},[22082],{"type":34,"value":229},{"type":28,"tag":192,"props":22084,"children":22085},{"class":194,"line":439},[22086,22090,22094,22098,22102,22106],{"type":28,"tag":192,"props":22087,"children":22088},{"style":371},[22089],{"type":34,"value":374},{"type":28,"tag":192,"props":22091,"children":22092},{"style":226},[22093],{"type":34,"value":379},{"type":28,"tag":192,"props":22095,"children":22096},{"style":247},[22097],{"type":34,"value":20605},{"type":28,"tag":192,"props":22099,"children":22100},{"style":387},[22101],{"type":34,"value":390},{"type":28,"tag":192,"props":22103,"children":22104},{"style":247},[22105],{"type":34,"value":20515},{"type":28,"tag":192,"props":22107,"children":22108},{"style":226},[22109],{"type":34,"value":255},{"type":28,"tag":192,"props":22111,"children":22112},{"class":194,"line":448},[22113],{"type":28,"tag":192,"props":22114,"children":22115},{"style":226},[22116],{"type":34,"value":445},{"type":28,"tag":192,"props":22118,"children":22119},{"class":194,"line":456},[22120],{"type":28,"tag":192,"props":22121,"children":22122},{"emptyLinePlaceholder":13},[22123],{"type":34,"value":313},{"type":28,"tag":192,"props":22125,"children":22126},{"class":194,"line":482},[22127,22131,22135,22139,22143,22147,22151,22155],{"type":28,"tag":192,"props":22128,"children":22129},{"style":209},[22130],{"type":34,"value":322},{"type":28,"tag":192,"props":22132,"children":22133},{"style":209},[22134],{"type":34,"value":688},{"type":28,"tag":192,"props":22136,"children":22137},{"style":325},[22138],{"type":34,"value":20752},{"type":28,"tag":192,"props":22140,"children":22141},{"style":226},[22142],{"type":34,"value":332},{"type":28,"tag":192,"props":22144,"children":22145},{"style":209},[22146],{"type":34,"value":938},{"type":28,"tag":192,"props":22148,"children":22149},{"style":340},[22150],{"type":34,"value":20535},{"type":28,"tag":192,"props":22152,"children":22153},{"style":226},[22154],{"type":34,"value":360},{"type":28,"tag":192,"props":22156,"children":22157},{"style":226},[22158],{"type":34,"value":229},{"type":28,"tag":192,"props":22160,"children":22161},{"class":194,"line":499},[22162,22166,22170,22174,22178,22182],{"type":28,"tag":192,"props":22163,"children":22164},{"style":371},[22165],{"type":34,"value":374},{"type":28,"tag":192,"props":22167,"children":22168},{"style":226},[22169],{"type":34,"value":379},{"type":28,"tag":192,"props":22171,"children":22172},{"style":247},[22173],{"type":34,"value":20633},{"type":28,"tag":192,"props":22175,"children":22176},{"style":387},[22177],{"type":34,"value":390},{"type":28,"tag":192,"props":22179,"children":22180},{"style":247},[22181],{"type":34,"value":20535},{"type":28,"tag":192,"props":22183,"children":22184},{"style":226},[22185],{"type":34,"value":255},{"type":28,"tag":192,"props":22187,"children":22188},{"class":194,"line":507},[22189],{"type":28,"tag":192,"props":22190,"children":22191},{"style":226},[22192],{"type":34,"value":445},{"type":28,"tag":192,"props":22194,"children":22195},{"class":194,"line":515},[22196],{"type":28,"tag":192,"props":22197,"children":22198},{"emptyLinePlaceholder":13},[22199],{"type":34,"value":313},{"type":28,"tag":192,"props":22201,"children":22202},{"class":194,"line":540},[22203,22207,22211,22215,22219],{"type":28,"tag":192,"props":22204,"children":22205},{"style":209},[22206],{"type":34,"value":322},{"type":28,"tag":192,"props":22208,"children":22209},{"style":209},[22210],{"type":34,"value":268},{"type":28,"tag":192,"props":22212,"children":22213},{"style":325},[22214],{"type":34,"value":20829},{"type":28,"tag":192,"props":22216,"children":22217},{"style":226},[22218],{"type":34,"value":475},{"type":28,"tag":192,"props":22220,"children":22221},{"style":226},[22222],{"type":34,"value":229},{"type":28,"tag":192,"props":22224,"children":22225},{"class":194,"line":556},[22226,22230,22234,22238,22242,22246,22250,22254,22258],{"type":28,"tag":192,"props":22227,"children":22228},{"style":209},[22229],{"type":34,"value":488},{"type":28,"tag":192,"props":22231,"children":22232},{"style":371},[22233],{"type":34,"value":20849},{"type":28,"tag":192,"props":22235,"children":22236},{"style":226},[22237],{"type":34,"value":379},{"type":28,"tag":192,"props":22239,"children":22240},{"style":247},[22241],{"type":34,"value":20605},{"type":28,"tag":192,"props":22243,"children":22244},{"style":387},[22245],{"type":34,"value":1102},{"type":28,"tag":192,"props":22247,"children":22248},{"style":371},[22249],{"type":34,"value":20849},{"type":28,"tag":192,"props":22251,"children":22252},{"style":226},[22253],{"type":34,"value":379},{"type":28,"tag":192,"props":22255,"children":22256},{"style":247},[22257],{"type":34,"value":20874},{"type":28,"tag":192,"props":22259,"children":22260},{"style":226},[22261],{"type":34,"value":255},{"type":28,"tag":192,"props":22263,"children":22264},{"class":194,"line":564},[22265],{"type":28,"tag":192,"props":22266,"children":22267},{"style":226},[22268],{"type":34,"value":445},{"type":28,"tag":192,"props":22270,"children":22271},{"class":194,"line":573},[22272],{"type":28,"tag":192,"props":22273,"children":22274},{"style":226},[22275],{"type":34,"value":588},{"type":28,"tag":44,"props":22277,"children":22278},{},[22279,22281,22286],{"type":34,"value":22280},"La classe ",{"type":28,"tag":188,"props":22282,"children":22284},{"className":22283},[],[22285],{"type":34,"value":6208},{"type":34,"value":22287}," reste inchangée.",{"type":28,"tag":169,"props":22289,"children":22291},{"id":22290},"classe-carre-indépendante",[22292,22293,22298],{"type":34,"value":20467},{"type":28,"tag":188,"props":22294,"children":22296},{"className":22295},[],[22297],{"type":34,"value":20916},{"type":34,"value":22299}," (indépendante) :",{"type":28,"tag":181,"props":22301,"children":22303},{"className":183,"code":22302,"language":185,"meta":8,"style":8},"public class Carre {\n    private int taille;\n\n    public Carre(int taille) {\n        this.taille = taille;\n    }\n\n    public void setTaille(int taille) {\n        this.taille = taille;\n    }\n\n    public int calculerAire() {\n        return this.taille * this.taille;\n    }\n}\n",[22304],{"type":28,"tag":188,"props":22305,"children":22306},{"__ignoreMap":8},[22307,22326,22345,22352,22383,22411,22418,22425,22461,22488,22495,22502,22525,22564,22571],{"type":28,"tag":192,"props":22308,"children":22309},{"class":194,"line":195},[22310,22314,22318,22322],{"type":28,"tag":192,"props":22311,"children":22312},{"style":209},[22313],{"type":34,"value":212},{"type":28,"tag":192,"props":22315,"children":22316},{"style":209},[22317],{"type":34,"value":217},{"type":28,"tag":192,"props":22319,"children":22320},{"style":220},[22321],{"type":34,"value":20940},{"type":28,"tag":192,"props":22323,"children":22324},{"style":226},[22325],{"type":34,"value":229},{"type":28,"tag":192,"props":22327,"children":22328},{"class":194,"line":205},[22329,22333,22337,22341],{"type":28,"tag":192,"props":22330,"children":22331},{"style":209},[22332],{"type":34,"value":238},{"type":28,"tag":192,"props":22334,"children":22335},{"style":209},[22336],{"type":34,"value":268},{"type":28,"tag":192,"props":22338,"children":22339},{"style":247},[22340],{"type":34,"value":20983},{"type":28,"tag":192,"props":22342,"children":22343},{"style":226},[22344],{"type":34,"value":255},{"type":28,"tag":192,"props":22346,"children":22347},{"class":194,"line":232},[22348],{"type":28,"tag":192,"props":22349,"children":22350},{"emptyLinePlaceholder":13},[22351],{"type":34,"value":313},{"type":28,"tag":192,"props":22353,"children":22354},{"class":194,"line":258},[22355,22359,22363,22367,22371,22375,22379],{"type":28,"tag":192,"props":22356,"children":22357},{"style":209},[22358],{"type":34,"value":322},{"type":28,"tag":192,"props":22360,"children":22361},{"style":325},[22362],{"type":34,"value":20940},{"type":28,"tag":192,"props":22364,"children":22365},{"style":226},[22366],{"type":34,"value":332},{"type":28,"tag":192,"props":22368,"children":22369},{"style":209},[22370],{"type":34,"value":938},{"type":28,"tag":192,"props":22372,"children":22373},{"style":340},[22374],{"type":34,"value":20983},{"type":28,"tag":192,"props":22376,"children":22377},{"style":226},[22378],{"type":34,"value":360},{"type":28,"tag":192,"props":22380,"children":22381},{"style":226},[22382],{"type":34,"value":229},{"type":28,"tag":192,"props":22384,"children":22385},{"class":194,"line":280},[22386,22390,22394,22399,22403,22407],{"type":28,"tag":192,"props":22387,"children":22388},{"style":371},[22389],{"type":34,"value":374},{"type":28,"tag":192,"props":22391,"children":22392},{"style":226},[22393],{"type":34,"value":379},{"type":28,"tag":192,"props":22395,"children":22396},{"style":247},[22397],{"type":34,"value":22398},"taille ",{"type":28,"tag":192,"props":22400,"children":22401},{"style":387},[22402],{"type":34,"value":390},{"type":28,"tag":192,"props":22404,"children":22405},{"style":247},[22406],{"type":34,"value":20983},{"type":28,"tag":192,"props":22408,"children":22409},{"style":226},[22410],{"type":34,"value":255},{"type":28,"tag":192,"props":22412,"children":22413},{"class":194,"line":307},[22414],{"type":28,"tag":192,"props":22415,"children":22416},{"style":226},[22417],{"type":34,"value":445},{"type":28,"tag":192,"props":22419,"children":22420},{"class":194,"line":316},[22421],{"type":28,"tag":192,"props":22422,"children":22423},{"emptyLinePlaceholder":13},[22424],{"type":34,"value":313},{"type":28,"tag":192,"props":22426,"children":22427},{"class":194,"line":367},[22428,22432,22436,22441,22445,22449,22453,22457],{"type":28,"tag":192,"props":22429,"children":22430},{"style":209},[22431],{"type":34,"value":322},{"type":28,"tag":192,"props":22433,"children":22434},{"style":209},[22435],{"type":34,"value":688},{"type":28,"tag":192,"props":22437,"children":22438},{"style":325},[22439],{"type":34,"value":22440}," setTaille",{"type":28,"tag":192,"props":22442,"children":22443},{"style":226},[22444],{"type":34,"value":332},{"type":28,"tag":192,"props":22446,"children":22447},{"style":209},[22448],{"type":34,"value":938},{"type":28,"tag":192,"props":22450,"children":22451},{"style":340},[22452],{"type":34,"value":20983},{"type":28,"tag":192,"props":22454,"children":22455},{"style":226},[22456],{"type":34,"value":360},{"type":28,"tag":192,"props":22458,"children":22459},{"style":226},[22460],{"type":34,"value":229},{"type":28,"tag":192,"props":22462,"children":22463},{"class":194,"line":401},[22464,22468,22472,22476,22480,22484],{"type":28,"tag":192,"props":22465,"children":22466},{"style":371},[22467],{"type":34,"value":374},{"type":28,"tag":192,"props":22469,"children":22470},{"style":226},[22471],{"type":34,"value":379},{"type":28,"tag":192,"props":22473,"children":22474},{"style":247},[22475],{"type":34,"value":22398},{"type":28,"tag":192,"props":22477,"children":22478},{"style":387},[22479],{"type":34,"value":390},{"type":28,"tag":192,"props":22481,"children":22482},{"style":247},[22483],{"type":34,"value":20983},{"type":28,"tag":192,"props":22485,"children":22486},{"style":226},[22487],{"type":34,"value":255},{"type":28,"tag":192,"props":22489,"children":22490},{"class":194,"line":430},[22491],{"type":28,"tag":192,"props":22492,"children":22493},{"style":226},[22494],{"type":34,"value":445},{"type":28,"tag":192,"props":22496,"children":22497},{"class":194,"line":439},[22498],{"type":28,"tag":192,"props":22499,"children":22500},{"emptyLinePlaceholder":13},[22501],{"type":34,"value":313},{"type":28,"tag":192,"props":22503,"children":22504},{"class":194,"line":448},[22505,22509,22513,22517,22521],{"type":28,"tag":192,"props":22506,"children":22507},{"style":209},[22508],{"type":34,"value":322},{"type":28,"tag":192,"props":22510,"children":22511},{"style":209},[22512],{"type":34,"value":268},{"type":28,"tag":192,"props":22514,"children":22515},{"style":325},[22516],{"type":34,"value":20829},{"type":28,"tag":192,"props":22518,"children":22519},{"style":226},[22520],{"type":34,"value":475},{"type":28,"tag":192,"props":22522,"children":22523},{"style":226},[22524],{"type":34,"value":229},{"type":28,"tag":192,"props":22526,"children":22527},{"class":194,"line":456},[22528,22532,22536,22540,22544,22548,22552,22556,22560],{"type":28,"tag":192,"props":22529,"children":22530},{"style":209},[22531],{"type":34,"value":488},{"type":28,"tag":192,"props":22533,"children":22534},{"style":371},[22535],{"type":34,"value":20849},{"type":28,"tag":192,"props":22537,"children":22538},{"style":226},[22539],{"type":34,"value":379},{"type":28,"tag":192,"props":22541,"children":22542},{"style":247},[22543],{"type":34,"value":22398},{"type":28,"tag":192,"props":22545,"children":22546},{"style":387},[22547],{"type":34,"value":1102},{"type":28,"tag":192,"props":22549,"children":22550},{"style":371},[22551],{"type":34,"value":20849},{"type":28,"tag":192,"props":22553,"children":22554},{"style":226},[22555],{"type":34,"value":379},{"type":28,"tag":192,"props":22557,"children":22558},{"style":247},[22559],{"type":34,"value":21008},{"type":28,"tag":192,"props":22561,"children":22562},{"style":226},[22563],{"type":34,"value":255},{"type":28,"tag":192,"props":22565,"children":22566},{"class":194,"line":482},[22567],{"type":28,"tag":192,"props":22568,"children":22569},{"style":226},[22570],{"type":34,"value":445},{"type":28,"tag":192,"props":22572,"children":22573},{"class":194,"line":499},[22574],{"type":28,"tag":192,"props":22575,"children":22576},{"style":226},[22577],{"type":34,"value":588},{"type":28,"tag":44,"props":22579,"children":22580},{},[22581,22583,22588,22590,22595,22597,22602,22604,22609,22611,22616,22618,22623],{"type":34,"value":22582},"Dans cette version, ",{"type":28,"tag":188,"props":22584,"children":22586},{"className":22585},[],[22587],{"type":34,"value":20916},{"type":34,"value":22589}," n’hérite plus de ",{"type":28,"tag":188,"props":22591,"children":22593},{"className":22592},[],[22594],{"type":34,"value":6208},{"type":34,"value":22596},". Nous avons ainsi une classe ",{"type":28,"tag":188,"props":22598,"children":22600},{"className":22599},[],[22601],{"type":34,"value":20916},{"type":34,"value":22603}," totalement indépendante qui suit ses propres règles et n'interfère pas avec les attentes définies pour un ",{"type":28,"tag":188,"props":22605,"children":22607},{"className":22606},[],[22608],{"type":34,"value":6208},{"type":34,"value":22610},". Le carré a une seule dimension (",{"type":28,"tag":188,"props":22612,"children":22614},{"className":22613},[],[22615],{"type":34,"value":21008},{"type":34,"value":22617},"), et son comportement est cohérent avec son concept sans violer les principes de la classe ",{"type":28,"tag":188,"props":22619,"children":22621},{"className":22620},[],[22622],{"type":34,"value":6208},{"type":34,"value":379},{"type":28,"tag":169,"props":22625,"children":22627},{"id":22626},"modification-du-programme-de-test",[22628],{"type":34,"value":22629},"Modification du programme de test :",{"type":28,"tag":44,"props":22631,"children":22632},{},[22633,22635,22640,22642,22647],{"type":34,"value":22634},"Puisque ",{"type":28,"tag":188,"props":22636,"children":22638},{"className":22637},[],[22639],{"type":34,"value":20916},{"type":34,"value":22641}," n’est plus une sous-classe de ",{"type":28,"tag":188,"props":22643,"children":22645},{"className":22644},[],[22646],{"type":34,"value":6208},{"type":34,"value":22648},", nous devons légèrement modifier notre méthode de test pour respecter cette nouvelle structure.",{"type":28,"tag":181,"props":22650,"children":22652},{"className":183,"code":22651,"language":185,"meta":8,"style":8},"public class Main {\n\n    public static void testerRectangle(Rectangle rect) {\n        rect.setLargeur(5);\n        rect.setHauteur(10);\n        int aire = rect.calculerAire();\n        System.out.println(\"Aire attendue (Rectangle) : 50, Aire calculée : \" + aire);\n    }\n\n    public static void testerCarre(Carre carre) {\n        carre.setTaille(5);\n        int aire = carre.calculerAire();\n        System.out.println(\"Aire attendue (Carre) : 25, Aire calculée : \" + aire);\n    }\n\n    public static void main(String[] args) {\n        // Test avec un Rectangle\n        Rectangle rect = new Rectangle(2, 3);\n        testerRectangle(rect);\n\n        // Test avec un Carre\n        Carre carre = new Carre(5);\n\n\n        testerCarre(carre);\n    }\n}\n",[22653],{"type":28,"tag":188,"props":22654,"children":22655},{"__ignoreMap":8},[22656,22675,22682,22721,22748,22775,22806,22850,22857,22864,22905,22934,22965,23009,23016,23023,23066,23073,23116,23135,23142,23149,23184,23191,23198,23218,23225],{"type":28,"tag":192,"props":22657,"children":22658},{"class":194,"line":195},[22659,22663,22667,22671],{"type":28,"tag":192,"props":22660,"children":22661},{"style":209},[22662],{"type":34,"value":212},{"type":28,"tag":192,"props":22664,"children":22665},{"style":209},[22666],{"type":34,"value":217},{"type":28,"tag":192,"props":22668,"children":22669},{"style":220},[22670],{"type":34,"value":5846},{"type":28,"tag":192,"props":22672,"children":22673},{"style":226},[22674],{"type":34,"value":229},{"type":28,"tag":192,"props":22676,"children":22677},{"class":194,"line":205},[22678],{"type":28,"tag":192,"props":22679,"children":22680},{"emptyLinePlaceholder":13},[22681],{"type":34,"value":313},{"type":28,"tag":192,"props":22683,"children":22684},{"class":194,"line":232},[22685,22689,22693,22697,22701,22705,22709,22713,22717],{"type":28,"tag":192,"props":22686,"children":22687},{"style":209},[22688],{"type":34,"value":322},{"type":28,"tag":192,"props":22690,"children":22691},{"style":209},[22692],{"type":34,"value":5862},{"type":28,"tag":192,"props":22694,"children":22695},{"style":209},[22696],{"type":34,"value":688},{"type":28,"tag":192,"props":22698,"children":22699},{"style":325},[22700],{"type":34,"value":21344},{"type":28,"tag":192,"props":22702,"children":22703},{"style":226},[22704],{"type":34,"value":332},{"type":28,"tag":192,"props":22706,"children":22707},{"style":241},[22708],{"type":34,"value":6208},{"type":28,"tag":192,"props":22710,"children":22711},{"style":340},[22712],{"type":34,"value":21357},{"type":28,"tag":192,"props":22714,"children":22715},{"style":226},[22716],{"type":34,"value":360},{"type":28,"tag":192,"props":22718,"children":22719},{"style":226},[22720],{"type":34,"value":229},{"type":28,"tag":192,"props":22722,"children":22723},{"class":194,"line":258},[22724,22728,22732,22736,22740,22744],{"type":28,"tag":192,"props":22725,"children":22726},{"style":247},[22727],{"type":34,"value":21373},{"type":28,"tag":192,"props":22729,"children":22730},{"style":226},[22731],{"type":34,"value":379},{"type":28,"tag":192,"props":22733,"children":22734},{"style":325},[22735],{"type":34,"value":21265},{"type":28,"tag":192,"props":22737,"children":22738},{"style":226},[22739],{"type":34,"value":332},{"type":28,"tag":192,"props":22741,"children":22742},{"style":744},[22743],{"type":34,"value":16809},{"type":28,"tag":192,"props":22745,"children":22746},{"style":226},[22747],{"type":34,"value":752},{"type":28,"tag":192,"props":22749,"children":22750},{"class":194,"line":280},[22751,22755,22759,22763,22767,22771],{"type":28,"tag":192,"props":22752,"children":22753},{"style":247},[22754],{"type":34,"value":21373},{"type":28,"tag":192,"props":22756,"children":22757},{"style":226},[22758],{"type":34,"value":379},{"type":28,"tag":192,"props":22760,"children":22761},{"style":325},[22762],{"type":34,"value":21272},{"type":28,"tag":192,"props":22764,"children":22765},{"style":226},[22766],{"type":34,"value":332},{"type":28,"tag":192,"props":22768,"children":22769},{"style":744},[22770],{"type":34,"value":18751},{"type":28,"tag":192,"props":22772,"children":22773},{"style":226},[22774],{"type":34,"value":752},{"type":28,"tag":192,"props":22776,"children":22777},{"class":194,"line":307},[22778,22782,22786,22790,22794,22798,22802],{"type":28,"tag":192,"props":22779,"children":22780},{"style":209},[22781],{"type":34,"value":16749},{"type":28,"tag":192,"props":22783,"children":22784},{"style":247},[22785],{"type":34,"value":21432},{"type":28,"tag":192,"props":22787,"children":22788},{"style":387},[22789],{"type":34,"value":390},{"type":28,"tag":192,"props":22791,"children":22792},{"style":247},[22793],{"type":34,"value":21357},{"type":28,"tag":192,"props":22795,"children":22796},{"style":226},[22797],{"type":34,"value":379},{"type":28,"tag":192,"props":22799,"children":22800},{"style":325},[22801],{"type":34,"value":21449},{"type":28,"tag":192,"props":22803,"children":22804},{"style":226},[22805],{"type":34,"value":1973},{"type":28,"tag":192,"props":22807,"children":22808},{"class":194,"line":316},[22809,22813,22817,22821,22825,22829,22833,22838,22842,22846],{"type":28,"tag":192,"props":22810,"children":22811},{"style":247},[22812],{"type":34,"value":4327},{"type":28,"tag":192,"props":22814,"children":22815},{"style":226},[22816],{"type":34,"value":379},{"type":28,"tag":192,"props":22818,"children":22819},{"style":247},[22820],{"type":34,"value":2673},{"type":28,"tag":192,"props":22822,"children":22823},{"style":226},[22824],{"type":34,"value":379},{"type":28,"tag":192,"props":22826,"children":22827},{"style":325},[22828],{"type":34,"value":2682},{"type":28,"tag":192,"props":22830,"children":22831},{"style":226},[22832],{"type":34,"value":332},{"type":28,"tag":192,"props":22834,"children":22835},{"style":734},[22836],{"type":34,"value":22837},"\"Aire attendue (Rectangle) : 50, Aire calculée : \"",{"type":28,"tag":192,"props":22839,"children":22840},{"style":387},[22841],{"type":34,"value":2696},{"type":28,"tag":192,"props":22843,"children":22844},{"style":247},[22845],{"type":34,"value":21494},{"type":28,"tag":192,"props":22847,"children":22848},{"style":226},[22849],{"type":34,"value":752},{"type":28,"tag":192,"props":22851,"children":22852},{"class":194,"line":367},[22853],{"type":28,"tag":192,"props":22854,"children":22855},{"style":226},[22856],{"type":34,"value":445},{"type":28,"tag":192,"props":22858,"children":22859},{"class":194,"line":401},[22860],{"type":28,"tag":192,"props":22861,"children":22862},{"emptyLinePlaceholder":13},[22863],{"type":34,"value":313},{"type":28,"tag":192,"props":22865,"children":22866},{"class":194,"line":430},[22867,22871,22875,22879,22884,22888,22892,22897,22901],{"type":28,"tag":192,"props":22868,"children":22869},{"style":209},[22870],{"type":34,"value":322},{"type":28,"tag":192,"props":22872,"children":22873},{"style":209},[22874],{"type":34,"value":5862},{"type":28,"tag":192,"props":22876,"children":22877},{"style":209},[22878],{"type":34,"value":688},{"type":28,"tag":192,"props":22880,"children":22881},{"style":325},[22882],{"type":34,"value":22883}," testerCarre",{"type":28,"tag":192,"props":22885,"children":22886},{"style":226},[22887],{"type":34,"value":332},{"type":28,"tag":192,"props":22889,"children":22890},{"style":241},[22891],{"type":34,"value":20916},{"type":28,"tag":192,"props":22893,"children":22894},{"style":340},[22895],{"type":34,"value":22896}," carre",{"type":28,"tag":192,"props":22898,"children":22899},{"style":226},[22900],{"type":34,"value":360},{"type":28,"tag":192,"props":22902,"children":22903},{"style":226},[22904],{"type":34,"value":229},{"type":28,"tag":192,"props":22906,"children":22907},{"class":194,"line":439},[22908,22913,22917,22922,22926,22930],{"type":28,"tag":192,"props":22909,"children":22910},{"style":247},[22911],{"type":34,"value":22912},"        carre",{"type":28,"tag":192,"props":22914,"children":22915},{"style":226},[22916],{"type":34,"value":379},{"type":28,"tag":192,"props":22918,"children":22919},{"style":325},[22920],{"type":34,"value":22921},"setTaille",{"type":28,"tag":192,"props":22923,"children":22924},{"style":226},[22925],{"type":34,"value":332},{"type":28,"tag":192,"props":22927,"children":22928},{"style":744},[22929],{"type":34,"value":16809},{"type":28,"tag":192,"props":22931,"children":22932},{"style":226},[22933],{"type":34,"value":752},{"type":28,"tag":192,"props":22935,"children":22936},{"class":194,"line":448},[22937,22941,22945,22949,22953,22957,22961],{"type":28,"tag":192,"props":22938,"children":22939},{"style":209},[22940],{"type":34,"value":16749},{"type":28,"tag":192,"props":22942,"children":22943},{"style":247},[22944],{"type":34,"value":21432},{"type":28,"tag":192,"props":22946,"children":22947},{"style":387},[22948],{"type":34,"value":390},{"type":28,"tag":192,"props":22950,"children":22951},{"style":247},[22952],{"type":34,"value":22896},{"type":28,"tag":192,"props":22954,"children":22955},{"style":226},[22956],{"type":34,"value":379},{"type":28,"tag":192,"props":22958,"children":22959},{"style":325},[22960],{"type":34,"value":21449},{"type":28,"tag":192,"props":22962,"children":22963},{"style":226},[22964],{"type":34,"value":1973},{"type":28,"tag":192,"props":22966,"children":22967},{"class":194,"line":456},[22968,22972,22976,22980,22984,22988,22992,22997,23001,23005],{"type":28,"tag":192,"props":22969,"children":22970},{"style":247},[22971],{"type":34,"value":4327},{"type":28,"tag":192,"props":22973,"children":22974},{"style":226},[22975],{"type":34,"value":379},{"type":28,"tag":192,"props":22977,"children":22978},{"style":247},[22979],{"type":34,"value":2673},{"type":28,"tag":192,"props":22981,"children":22982},{"style":226},[22983],{"type":34,"value":379},{"type":28,"tag":192,"props":22985,"children":22986},{"style":325},[22987],{"type":34,"value":2682},{"type":28,"tag":192,"props":22989,"children":22990},{"style":226},[22991],{"type":34,"value":332},{"type":28,"tag":192,"props":22993,"children":22994},{"style":734},[22995],{"type":34,"value":22996},"\"Aire attendue (Carre) : 25, Aire calculée : \"",{"type":28,"tag":192,"props":22998,"children":22999},{"style":387},[23000],{"type":34,"value":2696},{"type":28,"tag":192,"props":23002,"children":23003},{"style":247},[23004],{"type":34,"value":21494},{"type":28,"tag":192,"props":23006,"children":23007},{"style":226},[23008],{"type":34,"value":752},{"type":28,"tag":192,"props":23010,"children":23011},{"class":194,"line":482},[23012],{"type":28,"tag":192,"props":23013,"children":23014},{"style":226},[23015],{"type":34,"value":445},{"type":28,"tag":192,"props":23017,"children":23018},{"class":194,"line":499},[23019],{"type":28,"tag":192,"props":23020,"children":23021},{"emptyLinePlaceholder":13},[23022],{"type":34,"value":313},{"type":28,"tag":192,"props":23024,"children":23025},{"class":194,"line":507},[23026,23030,23034,23038,23042,23046,23050,23054,23058,23062],{"type":28,"tag":192,"props":23027,"children":23028},{"style":209},[23029],{"type":34,"value":322},{"type":28,"tag":192,"props":23031,"children":23032},{"style":209},[23033],{"type":34,"value":5862},{"type":28,"tag":192,"props":23035,"children":23036},{"style":209},[23037],{"type":34,"value":688},{"type":28,"tag":192,"props":23039,"children":23040},{"style":325},[23041],{"type":34,"value":5871},{"type":28,"tag":192,"props":23043,"children":23044},{"style":226},[23045],{"type":34,"value":332},{"type":28,"tag":192,"props":23047,"children":23048},{"style":209},[23049],{"type":34,"value":337},{"type":28,"tag":192,"props":23051,"children":23052},{"style":226},[23053],{"type":34,"value":5884},{"type":28,"tag":192,"props":23055,"children":23056},{"style":340},[23057],{"type":34,"value":5889},{"type":28,"tag":192,"props":23059,"children":23060},{"style":226},[23061],{"type":34,"value":360},{"type":28,"tag":192,"props":23063,"children":23064},{"style":226},[23065],{"type":34,"value":229},{"type":28,"tag":192,"props":23067,"children":23068},{"class":194,"line":515},[23069],{"type":28,"tag":192,"props":23070,"children":23071},{"style":199},[23072],{"type":34,"value":21563},{"type":28,"tag":192,"props":23074,"children":23075},{"class":194,"line":540},[23076,23080,23084,23088,23092,23096,23100,23104,23108,23112],{"type":28,"tag":192,"props":23077,"children":23078},{"style":241},[23079],{"type":34,"value":21571},{"type":28,"tag":192,"props":23081,"children":23082},{"style":247},[23083],{"type":34,"value":21576},{"type":28,"tag":192,"props":23085,"children":23086},{"style":387},[23087],{"type":34,"value":390},{"type":28,"tag":192,"props":23089,"children":23090},{"style":209},[23091],{"type":34,"value":723},{"type":28,"tag":192,"props":23093,"children":23094},{"style":325},[23095],{"type":34,"value":6265},{"type":28,"tag":192,"props":23097,"children":23098},{"style":226},[23099],{"type":34,"value":332},{"type":28,"tag":192,"props":23101,"children":23102},{"style":744},[23103],{"type":34,"value":2025},{"type":28,"tag":192,"props":23105,"children":23106},{"style":226},[23107],{"type":34,"value":347},{"type":28,"tag":192,"props":23109,"children":23110},{"style":744},[23111],{"type":34,"value":16788},{"type":28,"tag":192,"props":23113,"children":23114},{"style":226},[23115],{"type":34,"value":752},{"type":28,"tag":192,"props":23117,"children":23118},{"class":194,"line":556},[23119,23123,23127,23131],{"type":28,"tag":192,"props":23120,"children":23121},{"style":325},[23122],{"type":34,"value":21616},{"type":28,"tag":192,"props":23124,"children":23125},{"style":226},[23126],{"type":34,"value":332},{"type":28,"tag":192,"props":23128,"children":23129},{"style":247},[23130],{"type":34,"value":21625},{"type":28,"tag":192,"props":23132,"children":23133},{"style":226},[23134],{"type":34,"value":752},{"type":28,"tag":192,"props":23136,"children":23137},{"class":194,"line":564},[23138],{"type":28,"tag":192,"props":23139,"children":23140},{"emptyLinePlaceholder":13},[23141],{"type":34,"value":313},{"type":28,"tag":192,"props":23143,"children":23144},{"class":194,"line":573},[23145],{"type":28,"tag":192,"props":23146,"children":23147},{"style":199},[23148],{"type":34,"value":21644},{"type":28,"tag":192,"props":23150,"children":23151},{"class":194,"line":582},[23152,23156,23160,23164,23168,23172,23176,23180],{"type":28,"tag":192,"props":23153,"children":23154},{"style":241},[23155],{"type":34,"value":21652},{"type":28,"tag":192,"props":23157,"children":23158},{"style":247},[23159],{"type":34,"value":21657},{"type":28,"tag":192,"props":23161,"children":23162},{"style":387},[23163],{"type":34,"value":390},{"type":28,"tag":192,"props":23165,"children":23166},{"style":209},[23167],{"type":34,"value":723},{"type":28,"tag":192,"props":23169,"children":23170},{"style":325},[23171],{"type":34,"value":20940},{"type":28,"tag":192,"props":23173,"children":23174},{"style":226},[23175],{"type":34,"value":332},{"type":28,"tag":192,"props":23177,"children":23178},{"style":744},[23179],{"type":34,"value":16809},{"type":28,"tag":192,"props":23181,"children":23182},{"style":226},[23183],{"type":34,"value":752},{"type":28,"tag":192,"props":23185,"children":23186},{"class":194,"line":5580},[23187],{"type":28,"tag":192,"props":23188,"children":23189},{"emptyLinePlaceholder":13},[23190],{"type":34,"value":313},{"type":28,"tag":192,"props":23192,"children":23193},{"class":194,"line":5600},[23194],{"type":28,"tag":192,"props":23195,"children":23196},{"emptyLinePlaceholder":13},[23197],{"type":34,"value":313},{"type":28,"tag":192,"props":23199,"children":23200},{"class":194,"line":5638},[23201,23206,23210,23214],{"type":28,"tag":192,"props":23202,"children":23203},{"style":325},[23204],{"type":34,"value":23205},"        testerCarre",{"type":28,"tag":192,"props":23207,"children":23208},{"style":226},[23209],{"type":34,"value":332},{"type":28,"tag":192,"props":23211,"children":23212},{"style":247},[23213],{"type":34,"value":21697},{"type":28,"tag":192,"props":23215,"children":23216},{"style":226},[23217],{"type":34,"value":752},{"type":28,"tag":192,"props":23219,"children":23220},{"class":194,"line":5660},[23221],{"type":28,"tag":192,"props":23222,"children":23223},{"style":226},[23224],{"type":34,"value":445},{"type":28,"tag":192,"props":23226,"children":23227},{"class":194,"line":5668},[23228],{"type":28,"tag":192,"props":23229,"children":23230},{"style":226},[23231],{"type":34,"value":588},{"type":28,"tag":169,"props":23233,"children":23235},{"id":23234},"résultat-1",[23236],{"type":34,"value":21721},{"type":28,"tag":144,"props":23238,"children":23239},{},[23240,23251],{"type":28,"tag":148,"props":23241,"children":23242},{},[23243,23244,23249],{"type":34,"value":1636},{"type":28,"tag":188,"props":23245,"children":23247},{"className":23246},[],[23248],{"type":34,"value":6208},{"type":34,"value":23250}," fonctionne comme prévu : l'aire est de 50.",{"type":28,"tag":148,"props":23252,"children":23253},{},[23254,23255,23260],{"type":34,"value":1636},{"type":28,"tag":188,"props":23256,"children":23258},{"className":23257},[],[23259],{"type":34,"value":20916},{"type":34,"value":23261}," fonctionne également correctement : l'aire est de 25 (5 * 5), et le comportement est bien conforme aux attentes.",{"type":28,"tag":37,"props":23263,"children":23265},{"id":23264},"pourquoi-cela-respecte-t-il-le-lsp",[23266],{"type":34,"value":23267},"Pourquoi cela respecte-t-il le LSP ?",{"type":28,"tag":44,"props":23269,"children":23270},{},[23271,23273,23278,23279,23284,23286,23291,23292,23297],{"type":34,"value":23272},"Dans cette solution, nous avons séparé les deux concepts (",{"type":28,"tag":188,"props":23274,"children":23276},{"className":23275},[],[23277],{"type":34,"value":6208},{"type":34,"value":10377},{"type":28,"tag":188,"props":23280,"children":23282},{"className":23281},[],[23283],{"type":34,"value":20916},{"type":34,"value":23285},") afin que chaque classe respecte ses propres contraintes. Le LSP est respecté car les objets ",{"type":28,"tag":188,"props":23287,"children":23289},{"className":23288},[],[23290],{"type":34,"value":6208},{"type":34,"value":10377},{"type":28,"tag":188,"props":23293,"children":23295},{"className":23294},[],[23296],{"type":34,"value":20916},{"type":34,"value":23298}," ne sont plus liés par une relation d’héritage qui pourrait potentiellement briser les attentes du programme.",{"type":28,"tag":37,"props":23300,"children":23302},{"id":23301},"autre-approche-utiliser-une-interface-commune",[23303],{"type":34,"value":23304},"Autre approche : utiliser une interface commune",{"type":28,"tag":44,"props":23306,"children":23307},{},[23308,23310,23315],{"type":34,"value":23309},"Si vous souhaitez toujours utiliser l’héritage ou l’interchangeabilité, une meilleure approche serait d’introduire une interface commune ",{"type":28,"tag":188,"props":23311,"children":23313},{"className":23312},[],[23314],{"type":34,"value":20370},{"type":34,"value":23316}," que les deux classes pourraient implémenter. Ainsi, elles partageraient des comportements communs tout en ayant leurs propres implémentations spécifiques.",{"type":28,"tag":169,"props":23318,"children":23320},{"id":23319},"exemple-avec-une-interface-commune",[23321],{"type":34,"value":23322},"Exemple avec une interface commune",{"type":28,"tag":181,"props":23324,"children":23326},{"className":183,"code":23325,"language":185,"meta":8,"style":8},"public interface Forme {\n    int calculerAire();\n}\n\npublic class Rectangle implements Forme {\n    private int largeur;\n    private int hauteur;\n\n    public Rectangle(int largeur, int hauteur) {\n        this.largeur = largeur;\n        this.hauteur = hauteur;\n    }\n\n    @Override\n    public int calculerAire() {\n        return largeur * hauteur;\n    }\n}\n\npublic class Carre implements Forme {\n    private int taille;\n\n    public Carre(int taille) {\n        this.taille = taille;\n    }\n\n    @Override\n    public int calculerAire() {\n        return taille * taille;\n    }\n}\n",[23327],{"type":28,"tag":188,"props":23328,"children":23329},{"__ignoreMap":8},[23330,23350,23366,23373,23380,23407,23426,23445,23452,23495,23522,23549,23556,23563,23574,23597,23621,23628,23635,23642,23669,23688,23695,23726,23753,23760,23767,23778,23801,23825,23832],{"type":28,"tag":192,"props":23331,"children":23332},{"class":194,"line":195},[23333,23337,23341,23346],{"type":28,"tag":192,"props":23334,"children":23335},{"style":209},[23336],{"type":34,"value":212},{"type":28,"tag":192,"props":23338,"children":23339},{"style":209},[23340],{"type":34,"value":5275},{"type":28,"tag":192,"props":23342,"children":23343},{"style":220},[23344],{"type":34,"value":23345}," Forme",{"type":28,"tag":192,"props":23347,"children":23348},{"style":226},[23349],{"type":34,"value":229},{"type":28,"tag":192,"props":23351,"children":23352},{"class":194,"line":205},[23353,23358,23362],{"type":28,"tag":192,"props":23354,"children":23355},{"style":209},[23356],{"type":34,"value":23357},"    int",{"type":28,"tag":192,"props":23359,"children":23360},{"style":325},[23361],{"type":34,"value":20829},{"type":28,"tag":192,"props":23363,"children":23364},{"style":226},[23365],{"type":34,"value":1973},{"type":28,"tag":192,"props":23367,"children":23368},{"class":194,"line":232},[23369],{"type":28,"tag":192,"props":23370,"children":23371},{"style":226},[23372],{"type":34,"value":588},{"type":28,"tag":192,"props":23374,"children":23375},{"class":194,"line":258},[23376],{"type":28,"tag":192,"props":23377,"children":23378},{"emptyLinePlaceholder":13},[23379],{"type":34,"value":313},{"type":28,"tag":192,"props":23381,"children":23382},{"class":194,"line":280},[23383,23387,23391,23395,23399,23403],{"type":28,"tag":192,"props":23384,"children":23385},{"style":209},[23386],{"type":34,"value":212},{"type":28,"tag":192,"props":23388,"children":23389},{"style":209},[23390],{"type":34,"value":217},{"type":28,"tag":192,"props":23392,"children":23393},{"style":220},[23394],{"type":34,"value":6265},{"type":28,"tag":192,"props":23396,"children":23397},{"style":209},[23398],{"type":34,"value":5343},{"type":28,"tag":192,"props":23400,"children":23401},{"style":220},[23402],{"type":34,"value":23345},{"type":28,"tag":192,"props":23404,"children":23405},{"style":226},[23406],{"type":34,"value":229},{"type":28,"tag":192,"props":23408,"children":23409},{"class":194,"line":307},[23410,23414,23418,23422],{"type":28,"tag":192,"props":23411,"children":23412},{"style":209},[23413],{"type":34,"value":238},{"type":28,"tag":192,"props":23415,"children":23416},{"style":209},[23417],{"type":34,"value":268},{"type":28,"tag":192,"props":23419,"children":23420},{"style":247},[23421],{"type":34,"value":20515},{"type":28,"tag":192,"props":23423,"children":23424},{"style":226},[23425],{"type":34,"value":255},{"type":28,"tag":192,"props":23427,"children":23428},{"class":194,"line":316},[23429,23433,23437,23441],{"type":28,"tag":192,"props":23430,"children":23431},{"style":209},[23432],{"type":34,"value":238},{"type":28,"tag":192,"props":23434,"children":23435},{"style":209},[23436],{"type":34,"value":268},{"type":28,"tag":192,"props":23438,"children":23439},{"style":247},[23440],{"type":34,"value":20535},{"type":28,"tag":192,"props":23442,"children":23443},{"style":226},[23444],{"type":34,"value":255},{"type":28,"tag":192,"props":23446,"children":23447},{"class":194,"line":367},[23448],{"type":28,"tag":192,"props":23449,"children":23450},{"emptyLinePlaceholder":13},[23451],{"type":34,"value":313},{"type":28,"tag":192,"props":23453,"children":23454},{"class":194,"line":401},[23455,23459,23463,23467,23471,23475,23479,23483,23487,23491],{"type":28,"tag":192,"props":23456,"children":23457},{"style":209},[23458],{"type":34,"value":322},{"type":28,"tag":192,"props":23460,"children":23461},{"style":325},[23462],{"type":34,"value":6265},{"type":28,"tag":192,"props":23464,"children":23465},{"style":226},[23466],{"type":34,"value":332},{"type":28,"tag":192,"props":23468,"children":23469},{"style":209},[23470],{"type":34,"value":938},{"type":28,"tag":192,"props":23472,"children":23473},{"style":340},[23474],{"type":34,"value":20515},{"type":28,"tag":192,"props":23476,"children":23477},{"style":226},[23478],{"type":34,"value":347},{"type":28,"tag":192,"props":23480,"children":23481},{"style":209},[23482],{"type":34,"value":268},{"type":28,"tag":192,"props":23484,"children":23485},{"style":340},[23486],{"type":34,"value":20535},{"type":28,"tag":192,"props":23488,"children":23489},{"style":226},[23490],{"type":34,"value":360},{"type":28,"tag":192,"props":23492,"children":23493},{"style":226},[23494],{"type":34,"value":229},{"type":28,"tag":192,"props":23496,"children":23497},{"class":194,"line":430},[23498,23502,23506,23510,23514,23518],{"type":28,"tag":192,"props":23499,"children":23500},{"style":371},[23501],{"type":34,"value":374},{"type":28,"tag":192,"props":23503,"children":23504},{"style":226},[23505],{"type":34,"value":379},{"type":28,"tag":192,"props":23507,"children":23508},{"style":247},[23509],{"type":34,"value":20605},{"type":28,"tag":192,"props":23511,"children":23512},{"style":387},[23513],{"type":34,"value":390},{"type":28,"tag":192,"props":23515,"children":23516},{"style":247},[23517],{"type":34,"value":20515},{"type":28,"tag":192,"props":23519,"children":23520},{"style":226},[23521],{"type":34,"value":255},{"type":28,"tag":192,"props":23523,"children":23524},{"class":194,"line":439},[23525,23529,23533,23537,23541,23545],{"type":28,"tag":192,"props":23526,"children":23527},{"style":371},[23528],{"type":34,"value":374},{"type":28,"tag":192,"props":23530,"children":23531},{"style":226},[23532],{"type":34,"value":379},{"type":28,"tag":192,"props":23534,"children":23535},{"style":247},[23536],{"type":34,"value":20633},{"type":28,"tag":192,"props":23538,"children":23539},{"style":387},[23540],{"type":34,"value":390},{"type":28,"tag":192,"props":23542,"children":23543},{"style":247},[23544],{"type":34,"value":20535},{"type":28,"tag":192,"props":23546,"children":23547},{"style":226},[23548],{"type":34,"value":255},{"type":28,"tag":192,"props":23550,"children":23551},{"class":194,"line":448},[23552],{"type":28,"tag":192,"props":23553,"children":23554},{"style":226},[23555],{"type":34,"value":445},{"type":28,"tag":192,"props":23557,"children":23558},{"class":194,"line":456},[23559],{"type":28,"tag":192,"props":23560,"children":23561},{"emptyLinePlaceholder":13},[23562],{"type":34,"value":313},{"type":28,"tag":192,"props":23564,"children":23565},{"class":194,"line":482},[23566,23570],{"type":28,"tag":192,"props":23567,"children":23568},{"style":667},[23569],{"type":34,"value":5359},{"type":28,"tag":192,"props":23571,"children":23572},{"style":673},[23573],{"type":34,"value":5364},{"type":28,"tag":192,"props":23575,"children":23576},{"class":194,"line":499},[23577,23581,23585,23589,23593],{"type":28,"tag":192,"props":23578,"children":23579},{"style":209},[23580],{"type":34,"value":322},{"type":28,"tag":192,"props":23582,"children":23583},{"style":209},[23584],{"type":34,"value":268},{"type":28,"tag":192,"props":23586,"children":23587},{"style":325},[23588],{"type":34,"value":20829},{"type":28,"tag":192,"props":23590,"children":23591},{"style":226},[23592],{"type":34,"value":475},{"type":28,"tag":192,"props":23594,"children":23595},{"style":226},[23596],{"type":34,"value":229},{"type":28,"tag":192,"props":23598,"children":23599},{"class":194,"line":507},[23600,23604,23609,23613,23617],{"type":28,"tag":192,"props":23601,"children":23602},{"style":209},[23603],{"type":34,"value":488},{"type":28,"tag":192,"props":23605,"children":23606},{"style":247},[23607],{"type":34,"value":23608}," largeur ",{"type":28,"tag":192,"props":23610,"children":23611},{"style":387},[23612],{"type":34,"value":1102},{"type":28,"tag":192,"props":23614,"children":23615},{"style":247},[23616],{"type":34,"value":20535},{"type":28,"tag":192,"props":23618,"children":23619},{"style":226},[23620],{"type":34,"value":255},{"type":28,"tag":192,"props":23622,"children":23623},{"class":194,"line":515},[23624],{"type":28,"tag":192,"props":23625,"children":23626},{"style":226},[23627],{"type":34,"value":445},{"type":28,"tag":192,"props":23629,"children":23630},{"class":194,"line":540},[23631],{"type":28,"tag":192,"props":23632,"children":23633},{"style":226},[23634],{"type":34,"value":588},{"type":28,"tag":192,"props":23636,"children":23637},{"class":194,"line":556},[23638],{"type":28,"tag":192,"props":23639,"children":23640},{"emptyLinePlaceholder":13},[23641],{"type":34,"value":313},{"type":28,"tag":192,"props":23643,"children":23644},{"class":194,"line":564},[23645,23649,23653,23657,23661,23665],{"type":28,"tag":192,"props":23646,"children":23647},{"style":209},[23648],{"type":34,"value":212},{"type":28,"tag":192,"props":23650,"children":23651},{"style":209},[23652],{"type":34,"value":217},{"type":28,"tag":192,"props":23654,"children":23655},{"style":220},[23656],{"type":34,"value":20940},{"type":28,"tag":192,"props":23658,"children":23659},{"style":209},[23660],{"type":34,"value":5343},{"type":28,"tag":192,"props":23662,"children":23663},{"style":220},[23664],{"type":34,"value":23345},{"type":28,"tag":192,"props":23666,"children":23667},{"style":226},[23668],{"type":34,"value":229},{"type":28,"tag":192,"props":23670,"children":23671},{"class":194,"line":573},[23672,23676,23680,23684],{"type":28,"tag":192,"props":23673,"children":23674},{"style":209},[23675],{"type":34,"value":238},{"type":28,"tag":192,"props":23677,"children":23678},{"style":209},[23679],{"type":34,"value":268},{"type":28,"tag":192,"props":23681,"children":23682},{"style":247},[23683],{"type":34,"value":20983},{"type":28,"tag":192,"props":23685,"children":23686},{"style":226},[23687],{"type":34,"value":255},{"type":28,"tag":192,"props":23689,"children":23690},{"class":194,"line":582},[23691],{"type":28,"tag":192,"props":23692,"children":23693},{"emptyLinePlaceholder":13},[23694],{"type":34,"value":313},{"type":28,"tag":192,"props":23696,"children":23697},{"class":194,"line":5580},[23698,23702,23706,23710,23714,23718,23722],{"type":28,"tag":192,"props":23699,"children":23700},{"style":209},[23701],{"type":34,"value":322},{"type":28,"tag":192,"props":23703,"children":23704},{"style":325},[23705],{"type":34,"value":20940},{"type":28,"tag":192,"props":23707,"children":23708},{"style":226},[23709],{"type":34,"value":332},{"type":28,"tag":192,"props":23711,"children":23712},{"style":209},[23713],{"type":34,"value":938},{"type":28,"tag":192,"props":23715,"children":23716},{"style":340},[23717],{"type":34,"value":20983},{"type":28,"tag":192,"props":23719,"children":23720},{"style":226},[23721],{"type":34,"value":360},{"type":28,"tag":192,"props":23723,"children":23724},{"style":226},[23725],{"type":34,"value":229},{"type":28,"tag":192,"props":23727,"children":23728},{"class":194,"line":5600},[23729,23733,23737,23741,23745,23749],{"type":28,"tag":192,"props":23730,"children":23731},{"style":371},[23732],{"type":34,"value":374},{"type":28,"tag":192,"props":23734,"children":23735},{"style":226},[23736],{"type":34,"value":379},{"type":28,"tag":192,"props":23738,"children":23739},{"style":247},[23740],{"type":34,"value":22398},{"type":28,"tag":192,"props":23742,"children":23743},{"style":387},[23744],{"type":34,"value":390},{"type":28,"tag":192,"props":23746,"children":23747},{"style":247},[23748],{"type":34,"value":20983},{"type":28,"tag":192,"props":23750,"children":23751},{"style":226},[23752],{"type":34,"value":255},{"type":28,"tag":192,"props":23754,"children":23755},{"class":194,"line":5638},[23756],{"type":28,"tag":192,"props":23757,"children":23758},{"style":226},[23759],{"type":34,"value":445},{"type":28,"tag":192,"props":23761,"children":23762},{"class":194,"line":5660},[23763],{"type":28,"tag":192,"props":23764,"children":23765},{"emptyLinePlaceholder":13},[23766],{"type":34,"value":313},{"type":28,"tag":192,"props":23768,"children":23769},{"class":194,"line":5668},[23770,23774],{"type":28,"tag":192,"props":23771,"children":23772},{"style":667},[23773],{"type":34,"value":5359},{"type":28,"tag":192,"props":23775,"children":23776},{"style":673},[23777],{"type":34,"value":5364},{"type":28,"tag":192,"props":23779,"children":23780},{"class":194,"line":6718},[23781,23785,23789,23793,23797],{"type":28,"tag":192,"props":23782,"children":23783},{"style":209},[23784],{"type":34,"value":322},{"type":28,"tag":192,"props":23786,"children":23787},{"style":209},[23788],{"type":34,"value":268},{"type":28,"tag":192,"props":23790,"children":23791},{"style":325},[23792],{"type":34,"value":20829},{"type":28,"tag":192,"props":23794,"children":23795},{"style":226},[23796],{"type":34,"value":475},{"type":28,"tag":192,"props":23798,"children":23799},{"style":226},[23800],{"type":34,"value":229},{"type":28,"tag":192,"props":23802,"children":23803},{"class":194,"line":6754},[23804,23808,23813,23817,23821],{"type":28,"tag":192,"props":23805,"children":23806},{"style":209},[23807],{"type":34,"value":488},{"type":28,"tag":192,"props":23809,"children":23810},{"style":247},[23811],{"type":34,"value":23812}," taille ",{"type":28,"tag":192,"props":23814,"children":23815},{"style":387},[23816],{"type":34,"value":1102},{"type":28,"tag":192,"props":23818,"children":23819},{"style":247},[23820],{"type":34,"value":20983},{"type":28,"tag":192,"props":23822,"children":23823},{"style":226},[23824],{"type":34,"value":255},{"type":28,"tag":192,"props":23826,"children":23827},{"class":194,"line":6782},[23828],{"type":28,"tag":192,"props":23829,"children":23830},{"style":226},[23831],{"type":34,"value":445},{"type":28,"tag":192,"props":23833,"children":23834},{"class":194,"line":6814},[23835],{"type":28,"tag":192,"props":23836,"children":23837},{"style":226},[23838],{"type":34,"value":588},{"type":28,"tag":169,"props":23840,"children":23842},{"id":23841},"exemple-dutilisation",[23843],{"type":34,"value":23844},"Exemple d'utilisation :",{"type":28,"tag":181,"props":23846,"children":23848},{"className":183,"code":23847,"language":185,"meta":8,"style":8},"public class Main {\n\n    public static void afficherAire(Forme forme) {\n        System.out.println(\"Aire calculée : \" + forme.calculerAire());\n    }\n\n    public static void main(String[] args) {\n        Forme rectangle = new Rectangle(5, 10);\n        Forme carre = new Carre(5);\n\n        afficherAire(rectangle);  // Aire calculée : 50\n        afficherAire(carre);      // Aire calculée : 25\n    }\n}\n",[23849],{"type":28,"tag":188,"props":23850,"children":23851},{"__ignoreMap":8},[23852,23871,23878,23919,23971,23978,23985,24028,24074,24109,24116,24142,24166,24173],{"type":28,"tag":192,"props":23853,"children":23854},{"class":194,"line":195},[23855,23859,23863,23867],{"type":28,"tag":192,"props":23856,"children":23857},{"style":209},[23858],{"type":34,"value":212},{"type":28,"tag":192,"props":23860,"children":23861},{"style":209},[23862],{"type":34,"value":217},{"type":28,"tag":192,"props":23864,"children":23865},{"style":220},[23866],{"type":34,"value":5846},{"type":28,"tag":192,"props":23868,"children":23869},{"style":226},[23870],{"type":34,"value":229},{"type":28,"tag":192,"props":23872,"children":23873},{"class":194,"line":205},[23874],{"type":28,"tag":192,"props":23875,"children":23876},{"emptyLinePlaceholder":13},[23877],{"type":34,"value":313},{"type":28,"tag":192,"props":23879,"children":23880},{"class":194,"line":232},[23881,23885,23889,23893,23898,23902,23906,23911,23915],{"type":28,"tag":192,"props":23882,"children":23883},{"style":209},[23884],{"type":34,"value":322},{"type":28,"tag":192,"props":23886,"children":23887},{"style":209},[23888],{"type":34,"value":5862},{"type":28,"tag":192,"props":23890,"children":23891},{"style":209},[23892],{"type":34,"value":688},{"type":28,"tag":192,"props":23894,"children":23895},{"style":325},[23896],{"type":34,"value":23897}," afficherAire",{"type":28,"tag":192,"props":23899,"children":23900},{"style":226},[23901],{"type":34,"value":332},{"type":28,"tag":192,"props":23903,"children":23904},{"style":241},[23905],{"type":34,"value":20370},{"type":28,"tag":192,"props":23907,"children":23908},{"style":340},[23909],{"type":34,"value":23910}," forme",{"type":28,"tag":192,"props":23912,"children":23913},{"style":226},[23914],{"type":34,"value":360},{"type":28,"tag":192,"props":23916,"children":23917},{"style":226},[23918],{"type":34,"value":229},{"type":28,"tag":192,"props":23920,"children":23921},{"class":194,"line":258},[23922,23926,23930,23934,23938,23942,23946,23951,23955,23959,23963,23967],{"type":28,"tag":192,"props":23923,"children":23924},{"style":247},[23925],{"type":34,"value":4327},{"type":28,"tag":192,"props":23927,"children":23928},{"style":226},[23929],{"type":34,"value":379},{"type":28,"tag":192,"props":23931,"children":23932},{"style":247},[23933],{"type":34,"value":2673},{"type":28,"tag":192,"props":23935,"children":23936},{"style":226},[23937],{"type":34,"value":379},{"type":28,"tag":192,"props":23939,"children":23940},{"style":325},[23941],{"type":34,"value":2682},{"type":28,"tag":192,"props":23943,"children":23944},{"style":226},[23945],{"type":34,"value":332},{"type":28,"tag":192,"props":23947,"children":23948},{"style":734},[23949],{"type":34,"value":23950},"\"Aire calculée : \"",{"type":28,"tag":192,"props":23952,"children":23953},{"style":387},[23954],{"type":34,"value":2696},{"type":28,"tag":192,"props":23956,"children":23957},{"style":247},[23958],{"type":34,"value":23910},{"type":28,"tag":192,"props":23960,"children":23961},{"style":226},[23962],{"type":34,"value":379},{"type":28,"tag":192,"props":23964,"children":23965},{"style":325},[23966],{"type":34,"value":21449},{"type":28,"tag":192,"props":23968,"children":23969},{"style":226},[23970],{"type":34,"value":791},{"type":28,"tag":192,"props":23972,"children":23973},{"class":194,"line":280},[23974],{"type":28,"tag":192,"props":23975,"children":23976},{"style":226},[23977],{"type":34,"value":445},{"type":28,"tag":192,"props":23979,"children":23980},{"class":194,"line":307},[23981],{"type":28,"tag":192,"props":23982,"children":23983},{"emptyLinePlaceholder":13},[23984],{"type":34,"value":313},{"type":28,"tag":192,"props":23986,"children":23987},{"class":194,"line":316},[23988,23992,23996,24000,24004,24008,24012,24016,24020,24024],{"type":28,"tag":192,"props":23989,"children":23990},{"style":209},[23991],{"type":34,"value":322},{"type":28,"tag":192,"props":23993,"children":23994},{"style":209},[23995],{"type":34,"value":5862},{"type":28,"tag":192,"props":23997,"children":23998},{"style":209},[23999],{"type":34,"value":688},{"type":28,"tag":192,"props":24001,"children":24002},{"style":325},[24003],{"type":34,"value":5871},{"type":28,"tag":192,"props":24005,"children":24006},{"style":226},[24007],{"type":34,"value":332},{"type":28,"tag":192,"props":24009,"children":24010},{"style":209},[24011],{"type":34,"value":337},{"type":28,"tag":192,"props":24013,"children":24014},{"style":226},[24015],{"type":34,"value":5884},{"type":28,"tag":192,"props":24017,"children":24018},{"style":340},[24019],{"type":34,"value":5889},{"type":28,"tag":192,"props":24021,"children":24022},{"style":226},[24023],{"type":34,"value":360},{"type":28,"tag":192,"props":24025,"children":24026},{"style":226},[24027],{"type":34,"value":229},{"type":28,"tag":192,"props":24029,"children":24030},{"class":194,"line":367},[24031,24036,24041,24045,24049,24053,24057,24061,24065,24070],{"type":28,"tag":192,"props":24032,"children":24033},{"style":241},[24034],{"type":34,"value":24035},"        Forme",{"type":28,"tag":192,"props":24037,"children":24038},{"style":247},[24039],{"type":34,"value":24040}," rectangle ",{"type":28,"tag":192,"props":24042,"children":24043},{"style":387},[24044],{"type":34,"value":390},{"type":28,"tag":192,"props":24046,"children":24047},{"style":209},[24048],{"type":34,"value":723},{"type":28,"tag":192,"props":24050,"children":24051},{"style":325},[24052],{"type":34,"value":6265},{"type":28,"tag":192,"props":24054,"children":24055},{"style":226},[24056],{"type":34,"value":332},{"type":28,"tag":192,"props":24058,"children":24059},{"style":744},[24060],{"type":34,"value":16809},{"type":28,"tag":192,"props":24062,"children":24063},{"style":226},[24064],{"type":34,"value":347},{"type":28,"tag":192,"props":24066,"children":24067},{"style":744},[24068],{"type":34,"value":24069}," 10",{"type":28,"tag":192,"props":24071,"children":24072},{"style":226},[24073],{"type":34,"value":752},{"type":28,"tag":192,"props":24075,"children":24076},{"class":194,"line":401},[24077,24081,24085,24089,24093,24097,24101,24105],{"type":28,"tag":192,"props":24078,"children":24079},{"style":241},[24080],{"type":34,"value":24035},{"type":28,"tag":192,"props":24082,"children":24083},{"style":247},[24084],{"type":34,"value":21657},{"type":28,"tag":192,"props":24086,"children":24087},{"style":387},[24088],{"type":34,"value":390},{"type":28,"tag":192,"props":24090,"children":24091},{"style":209},[24092],{"type":34,"value":723},{"type":28,"tag":192,"props":24094,"children":24095},{"style":325},[24096],{"type":34,"value":20940},{"type":28,"tag":192,"props":24098,"children":24099},{"style":226},[24100],{"type":34,"value":332},{"type":28,"tag":192,"props":24102,"children":24103},{"style":744},[24104],{"type":34,"value":16809},{"type":28,"tag":192,"props":24106,"children":24107},{"style":226},[24108],{"type":34,"value":752},{"type":28,"tag":192,"props":24110,"children":24111},{"class":194,"line":430},[24112],{"type":28,"tag":192,"props":24113,"children":24114},{"emptyLinePlaceholder":13},[24115],{"type":34,"value":313},{"type":28,"tag":192,"props":24117,"children":24118},{"class":194,"line":439},[24119,24124,24128,24133,24137],{"type":28,"tag":192,"props":24120,"children":24121},{"style":325},[24122],{"type":34,"value":24123},"        afficherAire",{"type":28,"tag":192,"props":24125,"children":24126},{"style":226},[24127],{"type":34,"value":332},{"type":28,"tag":192,"props":24129,"children":24130},{"style":247},[24131],{"type":34,"value":24132},"rectangle",{"type":28,"tag":192,"props":24134,"children":24135},{"style":226},[24136],{"type":34,"value":19372},{"type":28,"tag":192,"props":24138,"children":24139},{"style":199},[24140],{"type":34,"value":24141},"  // Aire calculée : 50\n",{"type":28,"tag":192,"props":24143,"children":24144},{"class":194,"line":448},[24145,24149,24153,24157,24161],{"type":28,"tag":192,"props":24146,"children":24147},{"style":325},[24148],{"type":34,"value":24123},{"type":28,"tag":192,"props":24150,"children":24151},{"style":226},[24152],{"type":34,"value":332},{"type":28,"tag":192,"props":24154,"children":24155},{"style":247},[24156],{"type":34,"value":21697},{"type":28,"tag":192,"props":24158,"children":24159},{"style":226},[24160],{"type":34,"value":19372},{"type":28,"tag":192,"props":24162,"children":24163},{"style":199},[24164],{"type":34,"value":24165},"      // Aire calculée : 25\n",{"type":28,"tag":192,"props":24167,"children":24168},{"class":194,"line":456},[24169],{"type":28,"tag":192,"props":24170,"children":24171},{"style":226},[24172],{"type":34,"value":445},{"type":28,"tag":192,"props":24174,"children":24175},{"class":194,"line":482},[24176],{"type":28,"tag":192,"props":24177,"children":24178},{"style":226},[24179],{"type":34,"value":588},{"type":28,"tag":83,"props":24181,"children":24182},{},[],{"type":28,"tag":29,"props":24184,"children":24186},{"id":24185},"conclusion-et-conseils-pratiques",[24187],{"type":34,"value":24188},"Conclusion et conseils pratiques",{"type":28,"tag":44,"props":24190,"children":24191},{},[24192],{"type":34,"value":24193},"Le principe de substitution de Liskov est fondamental pour qu'une hiérarchie d'objets se comporte comme prévu. Le respecter rend votre code extensible et prévient les erreurs liées aux comportements inattendus des sous-classes.",{"type":28,"tag":37,"props":24195,"children":24197},{"id":24196},"récapitulatif-des-points-clés",[24198],{"type":34,"value":24199},"Récapitulatif des points clés :",{"type":28,"tag":144,"props":24201,"children":24202},{},[24203,24208,24213],{"type":28,"tag":148,"props":24204,"children":24205},{},[24206],{"type":34,"value":24207},"Le LSP exige que les sous-classes puissent être utilisées de manière interchangeable avec les classes parentes sans modifier le comportement attendu.",{"type":28,"tag":148,"props":24209,"children":24210},{},[24211],{"type":34,"value":24212},"Une sous-classe qui modifie les règles d'une classe parente brise le LSP.",{"type":28,"tag":148,"props":24214,"children":24215},{},[24216],{"type":34,"value":24217},"Il est parfois préférable d’utiliser des interfaces ou la composition pour éviter les problèmes d’héritage tout en respectant le LSP.",{"type":28,"tag":37,"props":24219,"children":24221},{"id":24220},"conseils-pratiques",[24222],{"type":34,"value":24223},"Conseils pratiques :",{"type":28,"tag":144,"props":24225,"children":24226},{},[24227,24232,24237],{"type":28,"tag":148,"props":24228,"children":24229},{},[24230],{"type":34,"value":24231},"Testez régulièrement votre code pour vérifier que les sous-classes respectent bien le comportement des classes parentes.",{"type":28,"tag":148,"props":24233,"children":24234},{},[24235],{"type":34,"value":24236},"Utilisez des interfaces ou la composition lorsque cela est possible, surtout si vous constatez que l’héritage ne correspond pas bien à votre modèle d’objet.",{"type":28,"tag":148,"props":24238,"children":24239},{},[24240],{"type":34,"value":24241},"Appliquez le LSP avec souplesse, en l’adaptant à vos besoins de conception, mais gardez en tête son importance pour éviter des bugs difficiles à identifier.",{"type":28,"tag":83,"props":24243,"children":24244},{},[],{"type":28,"tag":120,"props":24246,"children":24248},{"cta":1327,"href":1328,"title":24247,"type":1330},"Le LSP n'est qu'une pratique parmi 100 pour concevoir une hiérarchie qui tient",[24249],{"type":28,"tag":44,"props":24250,"children":24251},{},[24252],{"type":34,"value":24253},"Cet article décortique une seule règle de conception : qu'une sous-classe respecte le contrat de sa parente. Le Craft Bundle réunit les 100 pratiques que j'applique au quotidien pour modéliser des objets propres, du choix entre héritage et composition jusqu'aux tests qui attrapent une violation de contrat. Ce sont les réflexes que l'IA ne vous apprendra jamais, parce qu'elle ne les a jamais vus tenir en production.",{"type":28,"tag":83,"props":24255,"children":24256},{},[],{"type":28,"tag":29,"props":24258,"children":24260},{"id":24259},"faq-sur-le-principe-de-substitution-de-liskov-lsp",[24261],{"type":34,"value":24262},"FAQ sur le principe de substitution de Liskov (LSP)",{"type":28,"tag":1347,"props":24264,"children":24265},{},[24266,24271],{"type":28,"tag":1351,"props":24267,"children":24268},{},[24269],{"type":34,"value":24270},"1. Qu’est-ce que le LSP exactement ?",{"type":28,"tag":44,"props":24272,"children":24273},{},[24274],{"type":34,"value":24275},"Le principe de substitution de Liskov (LSP) stipule qu’une sous-classe doit pouvoir remplacer sa classe parente sans altérer le comportement du programme. Si vous utilisez une instance d’une sous-classe à la place d’une classe de base, le programme ne doit pas avoir de comportements inattendus ou incorrects.",{"type":28,"tag":1347,"props":24277,"children":24278},{},[24279,24284],{"type":28,"tag":1351,"props":24280,"children":24281},{},[24282],{"type":34,"value":24283},"2. Pourquoi est-ce que je dois respecter le LSP ?",{"type":28,"tag":44,"props":24285,"children":24286},{},[24287],{"type":34,"value":24288},"Le LSP garantit l'extensibilité et la maintenabilité de votre code. Sans lui, les sous-classes introduisent des comportements indésirables ou imprévisibles, ce qui complique la détection des bugs et alourdit la maintenance.",{"type":28,"tag":1347,"props":24290,"children":24291},{},[24292,24297,24302],{"type":28,"tag":1351,"props":24293,"children":24294},{},[24295],{"type":34,"value":24296},"3. Quels sont les signes indiquant que mon code ne respecte pas le LSP ?",{"type":28,"tag":44,"props":24298,"children":24299},{},[24300],{"type":34,"value":24301},"Voici quelques indices de violation du LSP :",{"type":28,"tag":144,"props":24303,"children":24304},{},[24305,24310,24315],{"type":28,"tag":148,"props":24306,"children":24307},{},[24308],{"type":34,"value":24309},"Ta sous-classe modifie ou redéfinit des méthodes de la classe parente de manière inattendue.",{"type":28,"tag":148,"props":24311,"children":24312},{},[24313],{"type":34,"value":24314},"Vous devez modifier le code existant lorsque vous ajoutez une nouvelle sous-classe.",{"type":28,"tag":148,"props":24316,"children":24317},{},[24318],{"type":34,"value":24319},"La sous-classe ne respecte pas les propriétés définies par la classe parente.",{"type":28,"tag":1347,"props":24321,"children":24322},{},[24323,24328],{"type":28,"tag":1351,"props":24324,"children":24325},{},[24326],{"type":34,"value":24327},"4. Quelle est la différence entre l’héritage classique et l’application du LSP ?",{"type":28,"tag":44,"props":24329,"children":24330},{},[24331],{"type":34,"value":24332},"L'héritage donne à une classe la capacité de réutiliser le code d'une autre. Le LSP va plus loin : il impose que la sous-classe maintienne le comportement logique attendu de la classe parente, sans en modifier les règles.",{"type":28,"tag":1347,"props":24334,"children":24335},{},[24336,24341],{"type":28,"tag":1351,"props":24337,"children":24338},{},[24339],{"type":34,"value":24340},"5. Est-ce que le LSP est toujours applicable ?",{"type":28,"tag":44,"props":24342,"children":24343},{},[24344],{"type":34,"value":24345},"Non, le LSP est un principe de conception qui doit être appliqué lorsqu’il est pertinent. Dans certains cas, éviter des hiérarchies complexes en utilisant la composition ou des interfaces peut être une meilleure approche.",{"type":28,"tag":1347,"props":24347,"children":24348},{},[24349,24354],{"type":28,"tag":1351,"props":24350,"children":24351},{},[24352],{"type":34,"value":24353},"6. Comment tester si mon code respecte le LSP ?",{"type":28,"tag":44,"props":24355,"children":24356},{},[24357],{"type":34,"value":24358},"Une manière de tester est de vérifier que vous pouvez utiliser une instance de la sous-classe à la place de la classe parente sans modifier le comportement du programme. Si des ajustements sont nécessaires, il est probable que le LSP soit violé.",{"type":28,"tag":1347,"props":24360,"children":24361},{},[24362,24367],{"type":28,"tag":1351,"props":24363,"children":24364},{},[24365],{"type":34,"value":24366},"7. Quelles sont les alternatives si je n’arrive pas à respecter le LSP dans mon code ?",{"type":28,"tag":44,"props":24368,"children":24369},{},[24370],{"type":34,"value":24371},"Si vous avez des difficultés à respecter le LSP, il peut être préférable de repenser la conception. Utiliser des interfaces, la composition plutôt que l’héritage, ou des classes abstraites peut aider à structurer votre code sans violer ce principe.",{"type":28,"tag":83,"props":24373,"children":24374},{},[],{"type":28,"tag":120,"props":24376,"children":24377},{"cta":16265,"href":1445,"title":16266,"type":1447},[24378],{"type":28,"tag":44,"props":24379,"children":24380},{},[24381],{"type":34,"value":16272},{"type":28,"tag":1455,"props":24383,"children":24384},{},[24385],{"type":34,"value":1459},{"title":8,"searchDepth":205,"depth":205,"links":24387},[24388,24389,24392,24393,24397,24401],{"id":20299,"depth":205,"text":20302},{"id":20334,"depth":205,"text":20337,"children":24390},[24391],{"id":20410,"depth":232,"text":20413},{"id":20439,"depth":205,"text":20442},{"id":21787,"depth":205,"text":21790,"children":24394},[24395,24396],{"id":23264,"depth":232,"text":23267},{"id":23301,"depth":232,"text":23304},{"id":24185,"depth":205,"text":24188,"children":24398},[24399,24400],{"id":24196,"depth":232,"text":24199},{"id":24220,"depth":232,"text":24223},{"id":24259,"depth":205,"text":24262},"content:fr:architecture-craft:principe-substitution-liskov-lsp-java.md","fr/architecture-craft/principe-substitution-liskov-lsp-java.md","fr/architecture-craft/principe-substitution-liskov-lsp-java",{"_path":4047,"_dir":3980,"_draft":7,"_partial":7,"_locale":8,"title":24406,"description":24407,"id":24408,"date":24409,"listed":13,"nocomments":7,"hidden":7,"categories":24410,"tags":24411,"cover":24412,"readingTime":24413,"body":24417,"_type":1471,"_id":26526,"_source":1473,"_file":26527,"_stem":26528,"_extension":1476},"Principe OCP en Software Craftsmanship, Guide Complet et Exemples Java","Découvrez comment appliquer le principe OCP (Open/Closed Principle) en Software Craftsmanship. Apprenez avec des exemples concrets en Java à rendre...",42,"2024-01-31",[1484],[1486,1487],"covers/articles/principe-ocp.jpg",{"text":1490,"minutes":24414,"time":24415,"words":24416},8.565,513900,1713,{"type":25,"children":24418,"toc":26512},[24419,24425,24430,24442,24453,24456,24462,24485,24490,24503,24508,24514,24535,24929,24941,24965,24970,24976,24981,25517,25536,25651,25656,25664,25667,25676,25682,25709,25742,25750,25768,25771,25777,25782,25788,25793,25798,26293,26305,26313,26316,26322,26327,26371,26384,26397,26400,26406,26411,26428,26437,26440,26446,26459,26472,26485,26498,26501,26508],{"type":28,"tag":29,"props":24420,"children":24422},{"id":24421},"introduction",[24423],{"type":34,"value":24424},"Introduction",{"type":28,"tag":44,"props":24426,"children":24427},{},[24428],{"type":34,"value":24429},"Modifier un morceau de code et casser au passage une fonctionnalité qui marchait : la scène se répète dans toutes les équipes que j'audite. Chaque changement déclenche une cascade de régressions imprévues. La cause profonde est presque toujours la même : le code n'a pas été conçu pour être étendu sans être modifié.",{"type":28,"tag":44,"props":24431,"children":24432},{},[24433,24435,24440],{"type":34,"value":24434},"Le principe OCP (Open/Closed Principle) attaque ce problème de front. Sur des dizaines de missions, j'ai vu le même pattern : à chaque nouvelle règle métier, on retouche du code existant, on casse des tests, la vélocité s'effondre. OCP coupe ce cycle. Le principe, formulé par Bertrand Meyer dans ",{"type":28,"tag":63,"props":24436,"children":24437},{},[24438],{"type":34,"value":24439},"Object-Oriented Software Construction",{"type":34,"value":24441}," (1988) puis repris par Robert C. Martin parmi les SOLID, pose qu'une fois écrit, un module doit être ouvert aux extensions mais fermé aux modifications.",{"type":28,"tag":44,"props":24443,"children":24444},{},[24445,24447,24451],{"type":34,"value":24446},"Cet article explique ce que recouvre vraiment OCP, son rôle en ",{"type":28,"tag":103,"props":24448,"children":24449},{"href":1478},[24450],{"type":34,"value":1522},{"type":34,"value":24452},", et comment l'appliquer dans des projets Java. Exemples de code à l'appui, avec les pièges classiques à éviter.",{"type":28,"tag":83,"props":24454,"children":24455},{},[],{"type":28,"tag":29,"props":24457,"children":24459},{"id":24458},"quest-ce-que-le-principe-ocp-openclosed-principle",[24460],{"type":34,"value":24461},"Qu’est-ce que le Principe OCP (Open/Closed Principle) ?",{"type":28,"tag":44,"props":24463,"children":24464},{},[24465,24467,24471,24473,24478,24479,24484],{"type":34,"value":24466},"Le principe OCP fait partie des cinq ",{"type":28,"tag":103,"props":24468,"children":24469},{"href":3979},[24470],{"type":34,"value":13398},{"type":34,"value":24472},", qui sont des règles fondamentales pour concevoir du code propre, maintenable et évolutif. OCP signifie \"Ouvert/Fermé\", en référence à l'idée que les entités (classes, modules, fonctions) doivent être ",{"type":28,"tag":55,"props":24474,"children":24475},{},[24476],{"type":34,"value":24477},"ouvertes à l’extension",{"type":34,"value":4899},{"type":28,"tag":55,"props":24480,"children":24481},{},[24482],{"type":34,"value":24483},"fermées à la modification",{"type":34,"value":379},{"type":28,"tag":44,"props":24486,"children":24487},{},[24488],{"type":34,"value":24489},"En d’autres termes, une fois qu’une classe ou un module est en production, vous ne devriez pas avoir à le modifier pour ajouter de nouvelles fonctionnalités. Cela peut sembler contradictoire au début : comment peut-on ajouter de nouvelles fonctionnalités sans toucher au code existant ? La réponse réside dans la conception du code dès le départ. Au lieu de modifier le comportement d'une classe, vous devez la rendre extensible via des interfaces, des abstractions ou des classes dérivées.",{"type":28,"tag":1841,"props":24491,"children":24492},{"type":1843},[24493],{"type":28,"tag":44,"props":24494,"children":24495},{},[24496,24501],{"type":28,"tag":55,"props":24497,"children":24498},{},[24499],{"type":34,"value":24500},"Anticipez les axes d'extension qui ont déjà été identifiés",{"type":34,"value":24502}," par le métier (nouveaux types, nouvelles règles connues). Inutile d'abstraire à l'aveugle, c'est du YAGNI. OCP s'applique là où le changement est probable, pas partout.",{"type":28,"tag":44,"props":24504,"children":24505},{},[24506],{"type":34,"value":24507},"Prenons un exemple concret pour illustrer cela.",{"type":28,"tag":37,"props":24509,"children":24511},{"id":24510},"exemple-1-cas-classique-sans-ocp",[24512],{"type":34,"value":24513},"Exemple 1 : Cas classique sans OCP",{"type":28,"tag":44,"props":24515,"children":24516},{},[24517,24519,24525,24527,24533],{"type":34,"value":24518},"Imaginons que vous développez une application qui calcule les salaires d'employés. Vous avez une classe ",{"type":28,"tag":188,"props":24520,"children":24522},{"className":24521},[],[24523],{"type":34,"value":24524},"Employee",{"type":34,"value":24526}," avec une méthode ",{"type":28,"tag":188,"props":24528,"children":24530},{"className":24529},[],[24531],{"type":34,"value":24532},"calculateSalary()",{"type":34,"value":24534}," qui calcule le salaire en fonction du type d'employé.",{"type":28,"tag":181,"props":24536,"children":24538},{"className":183,"code":24537,"language":185,"meta":8,"style":8},"class Employee {\n    private String type;\n    private double baseSalary;\n\n    public Employee(String type, double baseSalary) {\n        this.type = type;\n        this.baseSalary = baseSalary;\n    }\n\n    public double calculateSalary() {\n        if (type.equals(\"Manager\")) {\n            return baseSalary * 2;\n        } else if (type.equals(\"Developer\")) {\n            return baseSalary * 1.5;\n        } else {\n            return baseSalary;\n        }\n    }\n}\n",[24539],{"type":28,"tag":188,"props":24540,"children":24541},{"__ignoreMap":8},[24542,24558,24577,24597,24604,24647,24675,24703,24710,24717,24741,24781,24806,24854,24878,24893,24908,24915,24922],{"type":28,"tag":192,"props":24543,"children":24544},{"class":194,"line":195},[24545,24549,24554],{"type":28,"tag":192,"props":24546,"children":24547},{"style":209},[24548],{"type":34,"value":3696},{"type":28,"tag":192,"props":24550,"children":24551},{"style":220},[24552],{"type":34,"value":24553}," Employee",{"type":28,"tag":192,"props":24555,"children":24556},{"style":226},[24557],{"type":34,"value":229},{"type":28,"tag":192,"props":24559,"children":24560},{"class":194,"line":205},[24561,24565,24569,24573],{"type":28,"tag":192,"props":24562,"children":24563},{"style":209},[24564],{"type":34,"value":238},{"type":28,"tag":192,"props":24566,"children":24567},{"style":241},[24568],{"type":34,"value":244},{"type":28,"tag":192,"props":24570,"children":24571},{"style":247},[24572],{"type":34,"value":5001},{"type":28,"tag":192,"props":24574,"children":24575},{"style":226},[24576],{"type":34,"value":255},{"type":28,"tag":192,"props":24578,"children":24579},{"class":194,"line":232},[24580,24584,24588,24593],{"type":28,"tag":192,"props":24581,"children":24582},{"style":209},[24583],{"type":34,"value":238},{"type":28,"tag":192,"props":24585,"children":24586},{"style":209},[24587],{"type":34,"value":1703},{"type":28,"tag":192,"props":24589,"children":24590},{"style":247},[24591],{"type":34,"value":24592}," baseSalary",{"type":28,"tag":192,"props":24594,"children":24595},{"style":226},[24596],{"type":34,"value":255},{"type":28,"tag":192,"props":24598,"children":24599},{"class":194,"line":258},[24600],{"type":28,"tag":192,"props":24601,"children":24602},{"emptyLinePlaceholder":13},[24603],{"type":34,"value":313},{"type":28,"tag":192,"props":24605,"children":24606},{"class":194,"line":280},[24607,24611,24615,24619,24623,24627,24631,24635,24639,24643],{"type":28,"tag":192,"props":24608,"children":24609},{"style":209},[24610],{"type":34,"value":322},{"type":28,"tag":192,"props":24612,"children":24613},{"style":325},[24614],{"type":34,"value":24553},{"type":28,"tag":192,"props":24616,"children":24617},{"style":226},[24618],{"type":34,"value":332},{"type":28,"tag":192,"props":24620,"children":24621},{"style":241},[24622],{"type":34,"value":337},{"type":28,"tag":192,"props":24624,"children":24625},{"style":340},[24626],{"type":34,"value":5001},{"type":28,"tag":192,"props":24628,"children":24629},{"style":226},[24630],{"type":34,"value":347},{"type":28,"tag":192,"props":24632,"children":24633},{"style":209},[24634],{"type":34,"value":1703},{"type":28,"tag":192,"props":24636,"children":24637},{"style":340},[24638],{"type":34,"value":24592},{"type":28,"tag":192,"props":24640,"children":24641},{"style":226},[24642],{"type":34,"value":360},{"type":28,"tag":192,"props":24644,"children":24645},{"style":226},[24646],{"type":34,"value":229},{"type":28,"tag":192,"props":24648,"children":24649},{"class":194,"line":307},[24650,24654,24658,24663,24667,24671],{"type":28,"tag":192,"props":24651,"children":24652},{"style":371},[24653],{"type":34,"value":374},{"type":28,"tag":192,"props":24655,"children":24656},{"style":226},[24657],{"type":34,"value":379},{"type":28,"tag":192,"props":24659,"children":24660},{"style":247},[24661],{"type":34,"value":24662},"type ",{"type":28,"tag":192,"props":24664,"children":24665},{"style":387},[24666],{"type":34,"value":390},{"type":28,"tag":192,"props":24668,"children":24669},{"style":247},[24670],{"type":34,"value":5001},{"type":28,"tag":192,"props":24672,"children":24673},{"style":226},[24674],{"type":34,"value":255},{"type":28,"tag":192,"props":24676,"children":24677},{"class":194,"line":316},[24678,24682,24686,24691,24695,24699],{"type":28,"tag":192,"props":24679,"children":24680},{"style":371},[24681],{"type":34,"value":374},{"type":28,"tag":192,"props":24683,"children":24684},{"style":226},[24685],{"type":34,"value":379},{"type":28,"tag":192,"props":24687,"children":24688},{"style":247},[24689],{"type":34,"value":24690},"baseSalary ",{"type":28,"tag":192,"props":24692,"children":24693},{"style":387},[24694],{"type":34,"value":390},{"type":28,"tag":192,"props":24696,"children":24697},{"style":247},[24698],{"type":34,"value":24592},{"type":28,"tag":192,"props":24700,"children":24701},{"style":226},[24702],{"type":34,"value":255},{"type":28,"tag":192,"props":24704,"children":24705},{"class":194,"line":367},[24706],{"type":28,"tag":192,"props":24707,"children":24708},{"style":226},[24709],{"type":34,"value":445},{"type":28,"tag":192,"props":24711,"children":24712},{"class":194,"line":401},[24713],{"type":28,"tag":192,"props":24714,"children":24715},{"emptyLinePlaceholder":13},[24716],{"type":34,"value":313},{"type":28,"tag":192,"props":24718,"children":24719},{"class":194,"line":430},[24720,24724,24728,24733,24737],{"type":28,"tag":192,"props":24721,"children":24722},{"style":209},[24723],{"type":34,"value":322},{"type":28,"tag":192,"props":24725,"children":24726},{"style":209},[24727],{"type":34,"value":1703},{"type":28,"tag":192,"props":24729,"children":24730},{"style":325},[24731],{"type":34,"value":24732}," calculateSalary",{"type":28,"tag":192,"props":24734,"children":24735},{"style":226},[24736],{"type":34,"value":475},{"type":28,"tag":192,"props":24738,"children":24739},{"style":226},[24740],{"type":34,"value":229},{"type":28,"tag":192,"props":24742,"children":24743},{"class":194,"line":439},[24744,24748,24752,24756,24760,24764,24768,24773,24777],{"type":28,"tag":192,"props":24745,"children":24746},{"style":209},[24747],{"type":34,"value":986},{"type":28,"tag":192,"props":24749,"children":24750},{"style":226},[24751],{"type":34,"value":991},{"type":28,"tag":192,"props":24753,"children":24754},{"style":247},[24755],{"type":34,"value":5025},{"type":28,"tag":192,"props":24757,"children":24758},{"style":226},[24759],{"type":34,"value":379},{"type":28,"tag":192,"props":24761,"children":24762},{"style":325},[24763],{"type":34,"value":5034},{"type":28,"tag":192,"props":24765,"children":24766},{"style":226},[24767],{"type":34,"value":332},{"type":28,"tag":192,"props":24769,"children":24770},{"style":734},[24771],{"type":34,"value":24772},"\"Manager\"",{"type":28,"tag":192,"props":24774,"children":24775},{"style":226},[24776],{"type":34,"value":5048},{"type":28,"tag":192,"props":24778,"children":24779},{"style":226},[24780],{"type":34,"value":229},{"type":28,"tag":192,"props":24782,"children":24783},{"class":194,"line":448},[24784,24788,24793,24797,24802],{"type":28,"tag":192,"props":24785,"children":24786},{"style":209},[24787],{"type":34,"value":1012},{"type":28,"tag":192,"props":24789,"children":24790},{"style":247},[24791],{"type":34,"value":24792}," baseSalary ",{"type":28,"tag":192,"props":24794,"children":24795},{"style":387},[24796],{"type":34,"value":1102},{"type":28,"tag":192,"props":24798,"children":24799},{"style":744},[24800],{"type":34,"value":24801}," 2",{"type":28,"tag":192,"props":24803,"children":24804},{"style":226},[24805],{"type":34,"value":255},{"type":28,"tag":192,"props":24807,"children":24808},{"class":194,"line":456},[24809,24813,24817,24821,24825,24829,24833,24837,24841,24846,24850],{"type":28,"tag":192,"props":24810,"children":24811},{"style":226},[24812],{"type":34,"value":1076},{"type":28,"tag":192,"props":24814,"children":24815},{"style":209},[24816],{"type":34,"value":1081},{"type":28,"tag":192,"props":24818,"children":24819},{"style":209},[24820],{"type":34,"value":5112},{"type":28,"tag":192,"props":24822,"children":24823},{"style":226},[24824],{"type":34,"value":991},{"type":28,"tag":192,"props":24826,"children":24827},{"style":247},[24828],{"type":34,"value":5025},{"type":28,"tag":192,"props":24830,"children":24831},{"style":226},[24832],{"type":34,"value":379},{"type":28,"tag":192,"props":24834,"children":24835},{"style":325},[24836],{"type":34,"value":5034},{"type":28,"tag":192,"props":24838,"children":24839},{"style":226},[24840],{"type":34,"value":332},{"type":28,"tag":192,"props":24842,"children":24843},{"style":734},[24844],{"type":34,"value":24845},"\"Developer\"",{"type":28,"tag":192,"props":24847,"children":24848},{"style":226},[24849],{"type":34,"value":5048},{"type":28,"tag":192,"props":24851,"children":24852},{"style":226},[24853],{"type":34,"value":229},{"type":28,"tag":192,"props":24855,"children":24856},{"class":194,"line":482},[24857,24861,24865,24869,24874],{"type":28,"tag":192,"props":24858,"children":24859},{"style":209},[24860],{"type":34,"value":1012},{"type":28,"tag":192,"props":24862,"children":24863},{"style":247},[24864],{"type":34,"value":24792},{"type":28,"tag":192,"props":24866,"children":24867},{"style":387},[24868],{"type":34,"value":1102},{"type":28,"tag":192,"props":24870,"children":24871},{"style":744},[24872],{"type":34,"value":24873}," 1.5",{"type":28,"tag":192,"props":24875,"children":24876},{"style":226},[24877],{"type":34,"value":255},{"type":28,"tag":192,"props":24879,"children":24880},{"class":194,"line":499},[24881,24885,24889],{"type":28,"tag":192,"props":24882,"children":24883},{"style":226},[24884],{"type":34,"value":1076},{"type":28,"tag":192,"props":24886,"children":24887},{"style":209},[24888],{"type":34,"value":1081},{"type":28,"tag":192,"props":24890,"children":24891},{"style":226},[24892],{"type":34,"value":229},{"type":28,"tag":192,"props":24894,"children":24895},{"class":194,"line":507},[24896,24900,24904],{"type":28,"tag":192,"props":24897,"children":24898},{"style":209},[24899],{"type":34,"value":1012},{"type":28,"tag":192,"props":24901,"children":24902},{"style":247},[24903],{"type":34,"value":24592},{"type":28,"tag":192,"props":24905,"children":24906},{"style":226},[24907],{"type":34,"value":255},{"type":28,"tag":192,"props":24909,"children":24910},{"class":194,"line":515},[24911],{"type":28,"tag":192,"props":24912,"children":24913},{"style":226},[24914],{"type":34,"value":1118},{"type":28,"tag":192,"props":24916,"children":24917},{"class":194,"line":540},[24918],{"type":28,"tag":192,"props":24919,"children":24920},{"style":226},[24921],{"type":34,"value":445},{"type":28,"tag":192,"props":24923,"children":24924},{"class":194,"line":556},[24925],{"type":28,"tag":192,"props":24926,"children":24927},{"style":226},[24928],{"type":34,"value":588},{"type":28,"tag":44,"props":24930,"children":24931},{},[24932,24934,24939],{"type":34,"value":24933},"À première vue, ce code semble fonctionnel. Mais que se passe-t-il si vous devez ajouter un nouveau type d'employé, par exemple, un \"Designer\" avec un salaire différent ? Vous devrez modifier la méthode ",{"type":28,"tag":188,"props":24935,"children":24937},{"className":24936},[],[24938],{"type":34,"value":24532},{"type":34,"value":24940}," et ajouter une nouvelle condition. Plus le nombre de types d'employés augmente, plus la méthode devient complexe et sujette aux erreurs.",{"type":28,"tag":1841,"props":24942,"children":24944},{"type":24943},"WARNING",[24945],{"type":28,"tag":44,"props":24946,"children":24947},{},[24948,24950,24956,24957,24963],{"type":34,"value":24949},"** Plus votre code est rempli de conditions (comme les ",{"type":28,"tag":188,"props":24951,"children":24953},{"className":24952},[],[24954],{"type":34,"value":24955},"if",{"type":34,"value":10377},{"type":28,"tag":188,"props":24958,"children":24960},{"className":24959},[],[24961],{"type":34,"value":24962},"else",{"type":34,"value":24964}," ici), plus il devient fragile. Chaque modification future peut casser une partie existante.",{"type":28,"tag":44,"props":24966,"children":24967},{},[24968],{"type":34,"value":24969},"Ce design viole le principe OCP car à chaque nouvelle fonctionnalité (nouveau type d'employé), vous devez modifier la classe existante. Cela rend le code plus difficile à maintenir et à tester.",{"type":28,"tag":37,"props":24971,"children":24973},{"id":24972},"exemple-2-application-du-principe-ocp-avec-des-interfaces",[24974],{"type":34,"value":24975},"Exemple 2 : Application du principe OCP avec des interfaces",{"type":28,"tag":44,"props":24977,"children":24978},{},[24979],{"type":34,"value":24980},"Voyons maintenant comment nous pourrions refactorer ce code pour respecter le principe OCP. La clé ici est de rendre le comportement de calcul extensible, sans avoir à modifier la classe existante. Nous pouvons utiliser des interfaces ou des classes abstraites pour séparer le calcul des salaires en fonction des types d’employés.",{"type":28,"tag":181,"props":24982,"children":24984},{"className":183,"code":24983,"language":185,"meta":8,"style":8},"interface SalaryCalculator {\n    double calculateSalary(double baseSalary);\n}\n\nclass ManagerSalaryCalculator implements SalaryCalculator {\n    @Override\n    public double calculateSalary(double baseSalary) {\n        return baseSalary * 2;\n    }\n}\n\nclass DeveloperSalaryCalculator implements SalaryCalculator {\n    @Override\n    public double calculateSalary(double baseSalary) {\n        return baseSalary * 1.5;\n    }\n}\n\nclass Employee {\n    private double baseSalary;\n    private SalaryCalculator salaryCalculator;\n\n    public Employee(double baseSalary, SalaryCalculator salaryCalculator) {\n        this.baseSalary = baseSalary;\n        this.salaryCalculator = salaryCalculator;\n    }\n\n    public double calculateSalary() {\n        return salaryCalculator.calculateSalary(baseSalary);\n    }\n}\n",[24985],{"type":28,"tag":188,"props":24986,"children":24987},{"__ignoreMap":8},[24988,25004,25032,25039,25046,25070,25081,25116,25139,25146,25153,25160,25184,25195,25230,25253,25260,25267,25274,25289,25308,25328,25335,25378,25405,25433,25440,25447,25470,25503,25510],{"type":28,"tag":192,"props":24989,"children":24990},{"class":194,"line":195},[24991,24995,25000],{"type":28,"tag":192,"props":24992,"children":24993},{"style":209},[24994],{"type":34,"value":10793},{"type":28,"tag":192,"props":24996,"children":24997},{"style":220},[24998],{"type":34,"value":24999}," SalaryCalculator",{"type":28,"tag":192,"props":25001,"children":25002},{"style":226},[25003],{"type":34,"value":229},{"type":28,"tag":192,"props":25005,"children":25006},{"class":194,"line":205},[25007,25011,25015,25019,25024,25028],{"type":28,"tag":192,"props":25008,"children":25009},{"style":209},[25010],{"type":34,"value":2195},{"type":28,"tag":192,"props":25012,"children":25013},{"style":325},[25014],{"type":34,"value":24732},{"type":28,"tag":192,"props":25016,"children":25017},{"style":226},[25018],{"type":34,"value":332},{"type":28,"tag":192,"props":25020,"children":25021},{"style":209},[25022],{"type":34,"value":25023},"double",{"type":28,"tag":192,"props":25025,"children":25026},{"style":340},[25027],{"type":34,"value":24592},{"type":28,"tag":192,"props":25029,"children":25030},{"style":226},[25031],{"type":34,"value":752},{"type":28,"tag":192,"props":25033,"children":25034},{"class":194,"line":232},[25035],{"type":28,"tag":192,"props":25036,"children":25037},{"style":226},[25038],{"type":34,"value":588},{"type":28,"tag":192,"props":25040,"children":25041},{"class":194,"line":258},[25042],{"type":28,"tag":192,"props":25043,"children":25044},{"emptyLinePlaceholder":13},[25045],{"type":34,"value":313},{"type":28,"tag":192,"props":25047,"children":25048},{"class":194,"line":280},[25049,25053,25058,25062,25066],{"type":28,"tag":192,"props":25050,"children":25051},{"style":209},[25052],{"type":34,"value":3696},{"type":28,"tag":192,"props":25054,"children":25055},{"style":220},[25056],{"type":34,"value":25057}," ManagerSalaryCalculator",{"type":28,"tag":192,"props":25059,"children":25060},{"style":209},[25061],{"type":34,"value":5343},{"type":28,"tag":192,"props":25063,"children":25064},{"style":220},[25065],{"type":34,"value":24999},{"type":28,"tag":192,"props":25067,"children":25068},{"style":226},[25069],{"type":34,"value":229},{"type":28,"tag":192,"props":25071,"children":25072},{"class":194,"line":307},[25073,25077],{"type":28,"tag":192,"props":25074,"children":25075},{"style":667},[25076],{"type":34,"value":5359},{"type":28,"tag":192,"props":25078,"children":25079},{"style":673},[25080],{"type":34,"value":5364},{"type":28,"tag":192,"props":25082,"children":25083},{"class":194,"line":316},[25084,25088,25092,25096,25100,25104,25108,25112],{"type":28,"tag":192,"props":25085,"children":25086},{"style":209},[25087],{"type":34,"value":322},{"type":28,"tag":192,"props":25089,"children":25090},{"style":209},[25091],{"type":34,"value":1703},{"type":28,"tag":192,"props":25093,"children":25094},{"style":325},[25095],{"type":34,"value":24732},{"type":28,"tag":192,"props":25097,"children":25098},{"style":226},[25099],{"type":34,"value":332},{"type":28,"tag":192,"props":25101,"children":25102},{"style":209},[25103],{"type":34,"value":25023},{"type":28,"tag":192,"props":25105,"children":25106},{"style":340},[25107],{"type":34,"value":24592},{"type":28,"tag":192,"props":25109,"children":25110},{"style":226},[25111],{"type":34,"value":360},{"type":28,"tag":192,"props":25113,"children":25114},{"style":226},[25115],{"type":34,"value":229},{"type":28,"tag":192,"props":25117,"children":25118},{"class":194,"line":367},[25119,25123,25127,25131,25135],{"type":28,"tag":192,"props":25120,"children":25121},{"style":209},[25122],{"type":34,"value":488},{"type":28,"tag":192,"props":25124,"children":25125},{"style":247},[25126],{"type":34,"value":24792},{"type":28,"tag":192,"props":25128,"children":25129},{"style":387},[25130],{"type":34,"value":1102},{"type":28,"tag":192,"props":25132,"children":25133},{"style":744},[25134],{"type":34,"value":24801},{"type":28,"tag":192,"props":25136,"children":25137},{"style":226},[25138],{"type":34,"value":255},{"type":28,"tag":192,"props":25140,"children":25141},{"class":194,"line":401},[25142],{"type":28,"tag":192,"props":25143,"children":25144},{"style":226},[25145],{"type":34,"value":445},{"type":28,"tag":192,"props":25147,"children":25148},{"class":194,"line":430},[25149],{"type":28,"tag":192,"props":25150,"children":25151},{"style":226},[25152],{"type":34,"value":588},{"type":28,"tag":192,"props":25154,"children":25155},{"class":194,"line":439},[25156],{"type":28,"tag":192,"props":25157,"children":25158},{"emptyLinePlaceholder":13},[25159],{"type":34,"value":313},{"type":28,"tag":192,"props":25161,"children":25162},{"class":194,"line":448},[25163,25167,25172,25176,25180],{"type":28,"tag":192,"props":25164,"children":25165},{"style":209},[25166],{"type":34,"value":3696},{"type":28,"tag":192,"props":25168,"children":25169},{"style":220},[25170],{"type":34,"value":25171}," DeveloperSalaryCalculator",{"type":28,"tag":192,"props":25173,"children":25174},{"style":209},[25175],{"type":34,"value":5343},{"type":28,"tag":192,"props":25177,"children":25178},{"style":220},[25179],{"type":34,"value":24999},{"type":28,"tag":192,"props":25181,"children":25182},{"style":226},[25183],{"type":34,"value":229},{"type":28,"tag":192,"props":25185,"children":25186},{"class":194,"line":456},[25187,25191],{"type":28,"tag":192,"props":25188,"children":25189},{"style":667},[25190],{"type":34,"value":5359},{"type":28,"tag":192,"props":25192,"children":25193},{"style":673},[25194],{"type":34,"value":5364},{"type":28,"tag":192,"props":25196,"children":25197},{"class":194,"line":482},[25198,25202,25206,25210,25214,25218,25222,25226],{"type":28,"tag":192,"props":25199,"children":25200},{"style":209},[25201],{"type":34,"value":322},{"type":28,"tag":192,"props":25203,"children":25204},{"style":209},[25205],{"type":34,"value":1703},{"type":28,"tag":192,"props":25207,"children":25208},{"style":325},[25209],{"type":34,"value":24732},{"type":28,"tag":192,"props":25211,"children":25212},{"style":226},[25213],{"type":34,"value":332},{"type":28,"tag":192,"props":25215,"children":25216},{"style":209},[25217],{"type":34,"value":25023},{"type":28,"tag":192,"props":25219,"children":25220},{"style":340},[25221],{"type":34,"value":24592},{"type":28,"tag":192,"props":25223,"children":25224},{"style":226},[25225],{"type":34,"value":360},{"type":28,"tag":192,"props":25227,"children":25228},{"style":226},[25229],{"type":34,"value":229},{"type":28,"tag":192,"props":25231,"children":25232},{"class":194,"line":499},[25233,25237,25241,25245,25249],{"type":28,"tag":192,"props":25234,"children":25235},{"style":209},[25236],{"type":34,"value":488},{"type":28,"tag":192,"props":25238,"children":25239},{"style":247},[25240],{"type":34,"value":24792},{"type":28,"tag":192,"props":25242,"children":25243},{"style":387},[25244],{"type":34,"value":1102},{"type":28,"tag":192,"props":25246,"children":25247},{"style":744},[25248],{"type":34,"value":24873},{"type":28,"tag":192,"props":25250,"children":25251},{"style":226},[25252],{"type":34,"value":255},{"type":28,"tag":192,"props":25254,"children":25255},{"class":194,"line":507},[25256],{"type":28,"tag":192,"props":25257,"children":25258},{"style":226},[25259],{"type":34,"value":445},{"type":28,"tag":192,"props":25261,"children":25262},{"class":194,"line":515},[25263],{"type":28,"tag":192,"props":25264,"children":25265},{"style":226},[25266],{"type":34,"value":588},{"type":28,"tag":192,"props":25268,"children":25269},{"class":194,"line":540},[25270],{"type":28,"tag":192,"props":25271,"children":25272},{"emptyLinePlaceholder":13},[25273],{"type":34,"value":313},{"type":28,"tag":192,"props":25275,"children":25276},{"class":194,"line":556},[25277,25281,25285],{"type":28,"tag":192,"props":25278,"children":25279},{"style":209},[25280],{"type":34,"value":3696},{"type":28,"tag":192,"props":25282,"children":25283},{"style":220},[25284],{"type":34,"value":24553},{"type":28,"tag":192,"props":25286,"children":25287},{"style":226},[25288],{"type":34,"value":229},{"type":28,"tag":192,"props":25290,"children":25291},{"class":194,"line":564},[25292,25296,25300,25304],{"type":28,"tag":192,"props":25293,"children":25294},{"style":209},[25295],{"type":34,"value":238},{"type":28,"tag":192,"props":25297,"children":25298},{"style":209},[25299],{"type":34,"value":1703},{"type":28,"tag":192,"props":25301,"children":25302},{"style":247},[25303],{"type":34,"value":24592},{"type":28,"tag":192,"props":25305,"children":25306},{"style":226},[25307],{"type":34,"value":255},{"type":28,"tag":192,"props":25309,"children":25310},{"class":194,"line":573},[25311,25315,25319,25324],{"type":28,"tag":192,"props":25312,"children":25313},{"style":209},[25314],{"type":34,"value":238},{"type":28,"tag":192,"props":25316,"children":25317},{"style":241},[25318],{"type":34,"value":24999},{"type":28,"tag":192,"props":25320,"children":25321},{"style":247},[25322],{"type":34,"value":25323}," salaryCalculator",{"type":28,"tag":192,"props":25325,"children":25326},{"style":226},[25327],{"type":34,"value":255},{"type":28,"tag":192,"props":25329,"children":25330},{"class":194,"line":582},[25331],{"type":28,"tag":192,"props":25332,"children":25333},{"emptyLinePlaceholder":13},[25334],{"type":34,"value":313},{"type":28,"tag":192,"props":25336,"children":25337},{"class":194,"line":5580},[25338,25342,25346,25350,25354,25358,25362,25366,25370,25374],{"type":28,"tag":192,"props":25339,"children":25340},{"style":209},[25341],{"type":34,"value":322},{"type":28,"tag":192,"props":25343,"children":25344},{"style":325},[25345],{"type":34,"value":24553},{"type":28,"tag":192,"props":25347,"children":25348},{"style":226},[25349],{"type":34,"value":332},{"type":28,"tag":192,"props":25351,"children":25352},{"style":209},[25353],{"type":34,"value":25023},{"type":28,"tag":192,"props":25355,"children":25356},{"style":340},[25357],{"type":34,"value":24592},{"type":28,"tag":192,"props":25359,"children":25360},{"style":226},[25361],{"type":34,"value":347},{"type":28,"tag":192,"props":25363,"children":25364},{"style":241},[25365],{"type":34,"value":24999},{"type":28,"tag":192,"props":25367,"children":25368},{"style":340},[25369],{"type":34,"value":25323},{"type":28,"tag":192,"props":25371,"children":25372},{"style":226},[25373],{"type":34,"value":360},{"type":28,"tag":192,"props":25375,"children":25376},{"style":226},[25377],{"type":34,"value":229},{"type":28,"tag":192,"props":25379,"children":25380},{"class":194,"line":5600},[25381,25385,25389,25393,25397,25401],{"type":28,"tag":192,"props":25382,"children":25383},{"style":371},[25384],{"type":34,"value":374},{"type":28,"tag":192,"props":25386,"children":25387},{"style":226},[25388],{"type":34,"value":379},{"type":28,"tag":192,"props":25390,"children":25391},{"style":247},[25392],{"type":34,"value":24690},{"type":28,"tag":192,"props":25394,"children":25395},{"style":387},[25396],{"type":34,"value":390},{"type":28,"tag":192,"props":25398,"children":25399},{"style":247},[25400],{"type":34,"value":24592},{"type":28,"tag":192,"props":25402,"children":25403},{"style":226},[25404],{"type":34,"value":255},{"type":28,"tag":192,"props":25406,"children":25407},{"class":194,"line":5638},[25408,25412,25416,25421,25425,25429],{"type":28,"tag":192,"props":25409,"children":25410},{"style":371},[25411],{"type":34,"value":374},{"type":28,"tag":192,"props":25413,"children":25414},{"style":226},[25415],{"type":34,"value":379},{"type":28,"tag":192,"props":25417,"children":25418},{"style":247},[25419],{"type":34,"value":25420},"salaryCalculator ",{"type":28,"tag":192,"props":25422,"children":25423},{"style":387},[25424],{"type":34,"value":390},{"type":28,"tag":192,"props":25426,"children":25427},{"style":247},[25428],{"type":34,"value":25323},{"type":28,"tag":192,"props":25430,"children":25431},{"style":226},[25432],{"type":34,"value":255},{"type":28,"tag":192,"props":25434,"children":25435},{"class":194,"line":5660},[25436],{"type":28,"tag":192,"props":25437,"children":25438},{"style":226},[25439],{"type":34,"value":445},{"type":28,"tag":192,"props":25441,"children":25442},{"class":194,"line":5668},[25443],{"type":28,"tag":192,"props":25444,"children":25445},{"emptyLinePlaceholder":13},[25446],{"type":34,"value":313},{"type":28,"tag":192,"props":25448,"children":25449},{"class":194,"line":6718},[25450,25454,25458,25462,25466],{"type":28,"tag":192,"props":25451,"children":25452},{"style":209},[25453],{"type":34,"value":322},{"type":28,"tag":192,"props":25455,"children":25456},{"style":209},[25457],{"type":34,"value":1703},{"type":28,"tag":192,"props":25459,"children":25460},{"style":325},[25461],{"type":34,"value":24732},{"type":28,"tag":192,"props":25463,"children":25464},{"style":226},[25465],{"type":34,"value":475},{"type":28,"tag":192,"props":25467,"children":25468},{"style":226},[25469],{"type":34,"value":229},{"type":28,"tag":192,"props":25471,"children":25472},{"class":194,"line":6754},[25473,25477,25481,25485,25490,25494,25499],{"type":28,"tag":192,"props":25474,"children":25475},{"style":209},[25476],{"type":34,"value":488},{"type":28,"tag":192,"props":25478,"children":25479},{"style":247},[25480],{"type":34,"value":25323},{"type":28,"tag":192,"props":25482,"children":25483},{"style":226},[25484],{"type":34,"value":379},{"type":28,"tag":192,"props":25486,"children":25487},{"style":325},[25488],{"type":34,"value":25489},"calculateSalary",{"type":28,"tag":192,"props":25491,"children":25492},{"style":226},[25493],{"type":34,"value":332},{"type":28,"tag":192,"props":25495,"children":25496},{"style":247},[25497],{"type":34,"value":25498},"baseSalary",{"type":28,"tag":192,"props":25500,"children":25501},{"style":226},[25502],{"type":34,"value":752},{"type":28,"tag":192,"props":25504,"children":25505},{"class":194,"line":6782},[25506],{"type":28,"tag":192,"props":25507,"children":25508},{"style":226},[25509],{"type":34,"value":445},{"type":28,"tag":192,"props":25511,"children":25512},{"class":194,"line":6814},[25513],{"type":28,"tag":192,"props":25514,"children":25515},{"style":226},[25516],{"type":34,"value":588},{"type":28,"tag":44,"props":25518,"children":25519},{},[25520,25522,25527,25529,25535],{"type":34,"value":25521},"Avec ce design, si vous avez besoin d’ajouter un nouveau type d’employé, par exemple un \"Designer\", vous n’avez plus à toucher à la classe ",{"type":28,"tag":188,"props":25523,"children":25525},{"className":25524},[],[25526],{"type":34,"value":24524},{"type":34,"value":25528},". Vous créez simplement une nouvelle classe qui implémente ",{"type":28,"tag":188,"props":25530,"children":25532},{"className":25531},[],[25533],{"type":34,"value":25534},"SalaryCalculator",{"type":34,"value":5685},{"type":28,"tag":181,"props":25537,"children":25539},{"className":183,"code":25538,"language":185,"meta":8,"style":8},"class DesignerSalaryCalculator implements SalaryCalculator {\n    @Override\n    public double calculateSalary(double baseSalary) {\n        return baseSalary * 1.8;\n    }\n}\n",[25540],{"type":28,"tag":188,"props":25541,"children":25542},{"__ignoreMap":8},[25543,25567,25578,25613,25637,25644],{"type":28,"tag":192,"props":25544,"children":25545},{"class":194,"line":195},[25546,25550,25555,25559,25563],{"type":28,"tag":192,"props":25547,"children":25548},{"style":209},[25549],{"type":34,"value":3696},{"type":28,"tag":192,"props":25551,"children":25552},{"style":220},[25553],{"type":34,"value":25554}," DesignerSalaryCalculator",{"type":28,"tag":192,"props":25556,"children":25557},{"style":209},[25558],{"type":34,"value":5343},{"type":28,"tag":192,"props":25560,"children":25561},{"style":220},[25562],{"type":34,"value":24999},{"type":28,"tag":192,"props":25564,"children":25565},{"style":226},[25566],{"type":34,"value":229},{"type":28,"tag":192,"props":25568,"children":25569},{"class":194,"line":205},[25570,25574],{"type":28,"tag":192,"props":25571,"children":25572},{"style":667},[25573],{"type":34,"value":5359},{"type":28,"tag":192,"props":25575,"children":25576},{"style":673},[25577],{"type":34,"value":5364},{"type":28,"tag":192,"props":25579,"children":25580},{"class":194,"line":232},[25581,25585,25589,25593,25597,25601,25605,25609],{"type":28,"tag":192,"props":25582,"children":25583},{"style":209},[25584],{"type":34,"value":322},{"type":28,"tag":192,"props":25586,"children":25587},{"style":209},[25588],{"type":34,"value":1703},{"type":28,"tag":192,"props":25590,"children":25591},{"style":325},[25592],{"type":34,"value":24732},{"type":28,"tag":192,"props":25594,"children":25595},{"style":226},[25596],{"type":34,"value":332},{"type":28,"tag":192,"props":25598,"children":25599},{"style":209},[25600],{"type":34,"value":25023},{"type":28,"tag":192,"props":25602,"children":25603},{"style":340},[25604],{"type":34,"value":24592},{"type":28,"tag":192,"props":25606,"children":25607},{"style":226},[25608],{"type":34,"value":360},{"type":28,"tag":192,"props":25610,"children":25611},{"style":226},[25612],{"type":34,"value":229},{"type":28,"tag":192,"props":25614,"children":25615},{"class":194,"line":258},[25616,25620,25624,25628,25633],{"type":28,"tag":192,"props":25617,"children":25618},{"style":209},[25619],{"type":34,"value":488},{"type":28,"tag":192,"props":25621,"children":25622},{"style":247},[25623],{"type":34,"value":24792},{"type":28,"tag":192,"props":25625,"children":25626},{"style":387},[25627],{"type":34,"value":1102},{"type":28,"tag":192,"props":25629,"children":25630},{"style":744},[25631],{"type":34,"value":25632}," 1.8",{"type":28,"tag":192,"props":25634,"children":25635},{"style":226},[25636],{"type":34,"value":255},{"type":28,"tag":192,"props":25638,"children":25639},{"class":194,"line":280},[25640],{"type":28,"tag":192,"props":25641,"children":25642},{"style":226},[25643],{"type":34,"value":445},{"type":28,"tag":192,"props":25645,"children":25646},{"class":194,"line":307},[25647],{"type":28,"tag":192,"props":25648,"children":25649},{"style":226},[25650],{"type":34,"value":588},{"type":28,"tag":44,"props":25652,"children":25653},{},[25654],{"type":34,"value":25655},"L'ajout d'un nouveau type d'employé devient alors une extension naturelle, sans modification du code existant. C'est exactement ce que vise OCP : un code flexible et modulaire qui évite les modifications sources de bugs.",{"type":28,"tag":1841,"props":25657,"children":25658},{"type":1843},[25659],{"type":28,"tag":44,"props":25660,"children":25661},{},[25662],{"type":34,"value":25663},"** Quand vous concevez votre code avec OCP, réfléchissez toujours en termes d'extension future. Posez-vous la question : \"Si je devais ajouter une nouvelle fonctionnalité, est-ce que je serais obligé de modifier le code existant ?\"",{"type":28,"tag":83,"props":25665,"children":25666},{},[],{"type":28,"tag":120,"props":25668,"children":25670},{"cta":122,"href":123,"title":25669,"type":125},"Vous voulez concevoir vos classes pour les étendre sans jamais les rouvrir ?",[25671],{"type":28,"tag":44,"props":25672,"children":25673},{},[25674],{"type":34,"value":25675},"Choisir le bon axe d'abstraction, savoir quand une interface vaut mieux qu'un if, sentir quand l'extension dérape en sur-ingénierie : ça ne s'apprend pas dans un article, ça se travaille. En mentoring 1:1, je relis votre code avec vous et on retravaille vos points d'extension ensemble, jusqu'à ce que le réflexe devienne le vôtre.",{"type":28,"tag":29,"props":25677,"children":25679},{"id":25678},"pourquoi-ocp-est-essentiel-dans-le-software-craftsmanship",[25680],{"type":34,"value":25681},"Pourquoi OCP est essentiel dans le Software Craftsmanship",{"type":28,"tag":44,"props":25683,"children":25684},{},[25685,25687,25694,25696,25701,25702,25707],{"type":34,"value":25686},"Le principe OCP ne se limite pas seulement à écrire du code plus propre. Il est au cœur de ce qu'on appelle le ",{"type":28,"tag":55,"props":25688,"children":25689},{},[25690],{"type":28,"tag":103,"props":25691,"children":25692},{"href":1478},[25693],{"type":34,"value":1522},{"type":34,"value":25695},", un mouvement qui prône l’écriture de code non seulement fonctionnel, mais aussi ",{"type":28,"tag":55,"props":25697,"children":25698},{},[25699],{"type":34,"value":25700},"élégant",{"type":34,"value":10377},{"type":28,"tag":55,"props":25703,"children":25704},{},[25705],{"type":34,"value":25706},"maintenable",{"type":34,"value":25708},". Respecter le principe OCP vous aide à :",{"type":28,"tag":1644,"props":25710,"children":25711},{},[25712,25722,25732],{"type":28,"tag":148,"props":25713,"children":25714},{},[25715,25720],{"type":28,"tag":55,"props":25716,"children":25717},{},[25718],{"type":34,"value":25719},"Réduire les risques de régressions",{"type":34,"value":25721}," : ne pas toucher au code existant signifie ne pas casser ce qui est déjà testé. Sur mes missions en grandes DSI, ce point se traduit directement par moins d'incidents de production et des releases plus fréquentes.",{"type":28,"tag":148,"props":25723,"children":25724},{},[25725,25730],{"type":28,"tag":55,"props":25726,"children":25727},{},[25728],{"type":34,"value":25729},"Faciliter les extensions",{"type":34,"value":25731}," : ajouter une nouvelle fonctionnalité devient une opération chirurgicale, sans avoir à plonger dans des classes complexes pour y greffer une modification.",{"type":28,"tag":148,"props":25733,"children":25734},{},[25735,25740],{"type":28,"tag":55,"props":25736,"children":25737},{},[25738],{"type":34,"value":25739},"Améliorer la collaboration en équipe",{"type":34,"value":25741}," : un code modulaire et bien structuré se laisse étendre par d'autres développeurs sans qu'ils craignent de casser des fonctionnalités voisines.",{"type":28,"tag":1841,"props":25743,"children":25744},{"type":24943},[25745],{"type":28,"tag":44,"props":25746,"children":25747},{},[25748],{"type":34,"value":25749},"** Un code qui ne suit pas OCP est souvent source de conflits lors du travail en équipe. Si plusieurs développeurs doivent modifier la même classe, des erreurs sont inévitables.",{"type":28,"tag":44,"props":25751,"children":25752},{},[25753,25755,25759,25761,25766],{"type":34,"value":25754},"Dans le contexte du ",{"type":28,"tag":103,"props":25756,"children":25757},{"href":1478},[25758],{"type":34,"value":1522},{"type":34,"value":25760},", suivre OCP revient à ",{"type":28,"tag":55,"props":25762,"children":25763},{},[25764],{"type":34,"value":25765},"prendre soin de son code",{"type":34,"value":25767}," sur le long terme. Vous étendez plutôt que de patcher, et vous arrêtez de courir après les bugs nés des modifications du code existant.",{"type":28,"tag":83,"props":25769,"children":25770},{},[],{"type":28,"tag":29,"props":25772,"children":25774},{"id":25773},"comment-appliquer-ocp-dans-vos-projets-java",[25775],{"type":34,"value":25776},"Comment appliquer OCP dans vos projets Java",{"type":28,"tag":44,"props":25778,"children":25779},{},[25780],{"type":34,"value":25781},"Au-delà des interfaces déjà vues, deux autres mécanismes Java permettent d'appliquer OCP en pratique : les classes abstraites et le pattern Strategy.",{"type":28,"tag":37,"props":25783,"children":25785},{"id":25784},"exemple-3-utilisation-de-classes-abstraites-pour-respecter-ocp",[25786],{"type":34,"value":25787},"Exemple 3 : Utilisation de classes abstraites pour respecter OCP",{"type":28,"tag":44,"props":25789,"children":25790},{},[25791],{"type":34,"value":25792},"Une autre manière courante de respecter OCP consiste à passer par des classes abstraites. Elles définissent un comportement commun partagé entre plusieurs sous-classes, tout en laissant à ces dernières la liberté de redéfinir certains points.",{"type":28,"tag":44,"props":25794,"children":25795},{},[25796],{"type":34,"value":25797},"Prenons l'exemple précédent de calcul des salaires. Voici comment vous pourriez utiliser des classes abstraites pour atteindre un résultat similaire tout en respectant OCP :",{"type":28,"tag":181,"props":25799,"children":25801},{"className":183,"code":25800,"language":185,"meta":8,"style":8},"abstract class Employee {\n    protected double baseSalary;\n\n    public Employee(double baseSalary) {\n        this.baseSalary = baseSalary;\n    }\n\n    // Méthode abstraite que chaque sous-classe implémentera\n    public abstract double calculateSalary();\n}\n\nclass Manager extends Employee {\n    public Manager(double baseSalary) {\n        super(baseSalary);\n    }\n\n    @Override\n    public double calculateSalary() {\n        return baseSalary * 2;\n    }\n}\n\nclass Developer extends Employee {\n    public Developer(double baseSalary) {\n        super(baseSalary);\n    }\n\n    @Override\n    public double calculateSalary() {\n        return baseSalary * 1.5;\n    }\n}\n",[25802],{"type":28,"tag":188,"props":25803,"children":25804},{"__ignoreMap":8},[25805,25825,25844,25851,25882,25909,25916,25923,25931,25955,25962,25969,25992,26023,26042,26049,26056,26067,26090,26113,26120,26127,26134,26158,26189,26208,26215,26222,26233,26256,26279,26286],{"type":28,"tag":192,"props":25806,"children":25807},{"class":194,"line":195},[25808,25813,25817,25821],{"type":28,"tag":192,"props":25809,"children":25810},{"style":209},[25811],{"type":34,"value":25812},"abstract",{"type":28,"tag":192,"props":25814,"children":25815},{"style":209},[25816],{"type":34,"value":217},{"type":28,"tag":192,"props":25818,"children":25819},{"style":220},[25820],{"type":34,"value":24553},{"type":28,"tag":192,"props":25822,"children":25823},{"style":226},[25824],{"type":34,"value":229},{"type":28,"tag":192,"props":25826,"children":25827},{"class":194,"line":205},[25828,25832,25836,25840],{"type":28,"tag":192,"props":25829,"children":25830},{"style":209},[25831],{"type":34,"value":6277},{"type":28,"tag":192,"props":25833,"children":25834},{"style":209},[25835],{"type":34,"value":1703},{"type":28,"tag":192,"props":25837,"children":25838},{"style":247},[25839],{"type":34,"value":24592},{"type":28,"tag":192,"props":25841,"children":25842},{"style":226},[25843],{"type":34,"value":255},{"type":28,"tag":192,"props":25845,"children":25846},{"class":194,"line":232},[25847],{"type":28,"tag":192,"props":25848,"children":25849},{"emptyLinePlaceholder":13},[25850],{"type":34,"value":313},{"type":28,"tag":192,"props":25852,"children":25853},{"class":194,"line":258},[25854,25858,25862,25866,25870,25874,25878],{"type":28,"tag":192,"props":25855,"children":25856},{"style":209},[25857],{"type":34,"value":322},{"type":28,"tag":192,"props":25859,"children":25860},{"style":325},[25861],{"type":34,"value":24553},{"type":28,"tag":192,"props":25863,"children":25864},{"style":226},[25865],{"type":34,"value":332},{"type":28,"tag":192,"props":25867,"children":25868},{"style":209},[25869],{"type":34,"value":25023},{"type":28,"tag":192,"props":25871,"children":25872},{"style":340},[25873],{"type":34,"value":24592},{"type":28,"tag":192,"props":25875,"children":25876},{"style":226},[25877],{"type":34,"value":360},{"type":28,"tag":192,"props":25879,"children":25880},{"style":226},[25881],{"type":34,"value":229},{"type":28,"tag":192,"props":25883,"children":25884},{"class":194,"line":280},[25885,25889,25893,25897,25901,25905],{"type":28,"tag":192,"props":25886,"children":25887},{"style":371},[25888],{"type":34,"value":374},{"type":28,"tag":192,"props":25890,"children":25891},{"style":226},[25892],{"type":34,"value":379},{"type":28,"tag":192,"props":25894,"children":25895},{"style":247},[25896],{"type":34,"value":24690},{"type":28,"tag":192,"props":25898,"children":25899},{"style":387},[25900],{"type":34,"value":390},{"type":28,"tag":192,"props":25902,"children":25903},{"style":247},[25904],{"type":34,"value":24592},{"type":28,"tag":192,"props":25906,"children":25907},{"style":226},[25908],{"type":34,"value":255},{"type":28,"tag":192,"props":25910,"children":25911},{"class":194,"line":307},[25912],{"type":28,"tag":192,"props":25913,"children":25914},{"style":226},[25915],{"type":34,"value":445},{"type":28,"tag":192,"props":25917,"children":25918},{"class":194,"line":316},[25919],{"type":28,"tag":192,"props":25920,"children":25921},{"emptyLinePlaceholder":13},[25922],{"type":34,"value":313},{"type":28,"tag":192,"props":25924,"children":25925},{"class":194,"line":367},[25926],{"type":28,"tag":192,"props":25927,"children":25928},{"style":199},[25929],{"type":34,"value":25930},"    // Méthode abstraite que chaque sous-classe implémentera\n",{"type":28,"tag":192,"props":25932,"children":25933},{"class":194,"line":401},[25934,25938,25943,25947,25951],{"type":28,"tag":192,"props":25935,"children":25936},{"style":209},[25937],{"type":34,"value":322},{"type":28,"tag":192,"props":25939,"children":25940},{"style":209},[25941],{"type":34,"value":25942}," abstract",{"type":28,"tag":192,"props":25944,"children":25945},{"style":209},[25946],{"type":34,"value":1703},{"type":28,"tag":192,"props":25948,"children":25949},{"style":325},[25950],{"type":34,"value":24732},{"type":28,"tag":192,"props":25952,"children":25953},{"style":226},[25954],{"type":34,"value":1973},{"type":28,"tag":192,"props":25956,"children":25957},{"class":194,"line":430},[25958],{"type":28,"tag":192,"props":25959,"children":25960},{"style":226},[25961],{"type":34,"value":588},{"type":28,"tag":192,"props":25963,"children":25964},{"class":194,"line":439},[25965],{"type":28,"tag":192,"props":25966,"children":25967},{"emptyLinePlaceholder":13},[25968],{"type":34,"value":313},{"type":28,"tag":192,"props":25970,"children":25971},{"class":194,"line":448},[25972,25976,25980,25984,25988],{"type":28,"tag":192,"props":25973,"children":25974},{"style":209},[25975],{"type":34,"value":3696},{"type":28,"tag":192,"props":25977,"children":25978},{"style":220},[25979],{"type":34,"value":14135},{"type":28,"tag":192,"props":25981,"children":25982},{"style":209},[25983],{"type":34,"value":6577},{"type":28,"tag":192,"props":25985,"children":25986},{"style":220},[25987],{"type":34,"value":24553},{"type":28,"tag":192,"props":25989,"children":25990},{"style":226},[25991],{"type":34,"value":229},{"type":28,"tag":192,"props":25993,"children":25994},{"class":194,"line":456},[25995,25999,26003,26007,26011,26015,26019],{"type":28,"tag":192,"props":25996,"children":25997},{"style":209},[25998],{"type":34,"value":322},{"type":28,"tag":192,"props":26000,"children":26001},{"style":325},[26002],{"type":34,"value":14135},{"type":28,"tag":192,"props":26004,"children":26005},{"style":226},[26006],{"type":34,"value":332},{"type":28,"tag":192,"props":26008,"children":26009},{"style":209},[26010],{"type":34,"value":25023},{"type":28,"tag":192,"props":26012,"children":26013},{"style":340},[26014],{"type":34,"value":24592},{"type":28,"tag":192,"props":26016,"children":26017},{"style":226},[26018],{"type":34,"value":360},{"type":28,"tag":192,"props":26020,"children":26021},{"style":226},[26022],{"type":34,"value":229},{"type":28,"tag":192,"props":26024,"children":26025},{"class":194,"line":482},[26026,26030,26034,26038],{"type":28,"tag":192,"props":26027,"children":26028},{"style":18300},[26029],{"type":34,"value":20999},{"type":28,"tag":192,"props":26031,"children":26032},{"style":226},[26033],{"type":34,"value":332},{"type":28,"tag":192,"props":26035,"children":26036},{"style":247},[26037],{"type":34,"value":25498},{"type":28,"tag":192,"props":26039,"children":26040},{"style":226},[26041],{"type":34,"value":752},{"type":28,"tag":192,"props":26043,"children":26044},{"class":194,"line":499},[26045],{"type":28,"tag":192,"props":26046,"children":26047},{"style":226},[26048],{"type":34,"value":445},{"type":28,"tag":192,"props":26050,"children":26051},{"class":194,"line":507},[26052],{"type":28,"tag":192,"props":26053,"children":26054},{"emptyLinePlaceholder":13},[26055],{"type":34,"value":313},{"type":28,"tag":192,"props":26057,"children":26058},{"class":194,"line":515},[26059,26063],{"type":28,"tag":192,"props":26060,"children":26061},{"style":667},[26062],{"type":34,"value":5359},{"type":28,"tag":192,"props":26064,"children":26065},{"style":673},[26066],{"type":34,"value":5364},{"type":28,"tag":192,"props":26068,"children":26069},{"class":194,"line":540},[26070,26074,26078,26082,26086],{"type":28,"tag":192,"props":26071,"children":26072},{"style":209},[26073],{"type":34,"value":322},{"type":28,"tag":192,"props":26075,"children":26076},{"style":209},[26077],{"type":34,"value":1703},{"type":28,"tag":192,"props":26079,"children":26080},{"style":325},[26081],{"type":34,"value":24732},{"type":28,"tag":192,"props":26083,"children":26084},{"style":226},[26085],{"type":34,"value":475},{"type":28,"tag":192,"props":26087,"children":26088},{"style":226},[26089],{"type":34,"value":229},{"type":28,"tag":192,"props":26091,"children":26092},{"class":194,"line":556},[26093,26097,26101,26105,26109],{"type":28,"tag":192,"props":26094,"children":26095},{"style":209},[26096],{"type":34,"value":488},{"type":28,"tag":192,"props":26098,"children":26099},{"style":247},[26100],{"type":34,"value":24792},{"type":28,"tag":192,"props":26102,"children":26103},{"style":387},[26104],{"type":34,"value":1102},{"type":28,"tag":192,"props":26106,"children":26107},{"style":744},[26108],{"type":34,"value":24801},{"type":28,"tag":192,"props":26110,"children":26111},{"style":226},[26112],{"type":34,"value":255},{"type":28,"tag":192,"props":26114,"children":26115},{"class":194,"line":564},[26116],{"type":28,"tag":192,"props":26117,"children":26118},{"style":226},[26119],{"type":34,"value":445},{"type":28,"tag":192,"props":26121,"children":26122},{"class":194,"line":573},[26123],{"type":28,"tag":192,"props":26124,"children":26125},{"style":226},[26126],{"type":34,"value":588},{"type":28,"tag":192,"props":26128,"children":26129},{"class":194,"line":582},[26130],{"type":28,"tag":192,"props":26131,"children":26132},{"emptyLinePlaceholder":13},[26133],{"type":34,"value":313},{"type":28,"tag":192,"props":26135,"children":26136},{"class":194,"line":5580},[26137,26141,26146,26150,26154],{"type":28,"tag":192,"props":26138,"children":26139},{"style":209},[26140],{"type":34,"value":3696},{"type":28,"tag":192,"props":26142,"children":26143},{"style":220},[26144],{"type":34,"value":26145}," Developer",{"type":28,"tag":192,"props":26147,"children":26148},{"style":209},[26149],{"type":34,"value":6577},{"type":28,"tag":192,"props":26151,"children":26152},{"style":220},[26153],{"type":34,"value":24553},{"type":28,"tag":192,"props":26155,"children":26156},{"style":226},[26157],{"type":34,"value":229},{"type":28,"tag":192,"props":26159,"children":26160},{"class":194,"line":5600},[26161,26165,26169,26173,26177,26181,26185],{"type":28,"tag":192,"props":26162,"children":26163},{"style":209},[26164],{"type":34,"value":322},{"type":28,"tag":192,"props":26166,"children":26167},{"style":325},[26168],{"type":34,"value":26145},{"type":28,"tag":192,"props":26170,"children":26171},{"style":226},[26172],{"type":34,"value":332},{"type":28,"tag":192,"props":26174,"children":26175},{"style":209},[26176],{"type":34,"value":25023},{"type":28,"tag":192,"props":26178,"children":26179},{"style":340},[26180],{"type":34,"value":24592},{"type":28,"tag":192,"props":26182,"children":26183},{"style":226},[26184],{"type":34,"value":360},{"type":28,"tag":192,"props":26186,"children":26187},{"style":226},[26188],{"type":34,"value":229},{"type":28,"tag":192,"props":26190,"children":26191},{"class":194,"line":5638},[26192,26196,26200,26204],{"type":28,"tag":192,"props":26193,"children":26194},{"style":18300},[26195],{"type":34,"value":20999},{"type":28,"tag":192,"props":26197,"children":26198},{"style":226},[26199],{"type":34,"value":332},{"type":28,"tag":192,"props":26201,"children":26202},{"style":247},[26203],{"type":34,"value":25498},{"type":28,"tag":192,"props":26205,"children":26206},{"style":226},[26207],{"type":34,"value":752},{"type":28,"tag":192,"props":26209,"children":26210},{"class":194,"line":5660},[26211],{"type":28,"tag":192,"props":26212,"children":26213},{"style":226},[26214],{"type":34,"value":445},{"type":28,"tag":192,"props":26216,"children":26217},{"class":194,"line":5668},[26218],{"type":28,"tag":192,"props":26219,"children":26220},{"emptyLinePlaceholder":13},[26221],{"type":34,"value":313},{"type":28,"tag":192,"props":26223,"children":26224},{"class":194,"line":6718},[26225,26229],{"type":28,"tag":192,"props":26226,"children":26227},{"style":667},[26228],{"type":34,"value":5359},{"type":28,"tag":192,"props":26230,"children":26231},{"style":673},[26232],{"type":34,"value":5364},{"type":28,"tag":192,"props":26234,"children":26235},{"class":194,"line":6754},[26236,26240,26244,26248,26252],{"type":28,"tag":192,"props":26237,"children":26238},{"style":209},[26239],{"type":34,"value":322},{"type":28,"tag":192,"props":26241,"children":26242},{"style":209},[26243],{"type":34,"value":1703},{"type":28,"tag":192,"props":26245,"children":26246},{"style":325},[26247],{"type":34,"value":24732},{"type":28,"tag":192,"props":26249,"children":26250},{"style":226},[26251],{"type":34,"value":475},{"type":28,"tag":192,"props":26253,"children":26254},{"style":226},[26255],{"type":34,"value":229},{"type":28,"tag":192,"props":26257,"children":26258},{"class":194,"line":6782},[26259,26263,26267,26271,26275],{"type":28,"tag":192,"props":26260,"children":26261},{"style":209},[26262],{"type":34,"value":488},{"type":28,"tag":192,"props":26264,"children":26265},{"style":247},[26266],{"type":34,"value":24792},{"type":28,"tag":192,"props":26268,"children":26269},{"style":387},[26270],{"type":34,"value":1102},{"type":28,"tag":192,"props":26272,"children":26273},{"style":744},[26274],{"type":34,"value":24873},{"type":28,"tag":192,"props":26276,"children":26277},{"style":226},[26278],{"type":34,"value":255},{"type":28,"tag":192,"props":26280,"children":26281},{"class":194,"line":6814},[26282],{"type":28,"tag":192,"props":26283,"children":26284},{"style":226},[26285],{"type":34,"value":445},{"type":28,"tag":192,"props":26287,"children":26288},{"class":194,"line":6822},[26289],{"type":28,"tag":192,"props":26290,"children":26291},{"style":226},[26292],{"type":34,"value":588},{"type":28,"tag":44,"props":26294,"children":26295},{},[26296,26298,26303],{"type":34,"value":26297},"Avec cette approche, la classe ",{"type":28,"tag":188,"props":26299,"children":26301},{"className":26300},[],[26302],{"type":34,"value":24524},{"type":34,"value":26304}," pose un cadre général pour tous les types d'employés ; chaque sous-classe prend en charge l'implémentation spécifique du calcul des salaires. Étendre le système revient à ajouter une nouvelle sous-classe : le code existant reste intact.",{"type":28,"tag":1841,"props":26306,"children":26307},{"type":1843},[26308],{"type":28,"tag":44,"props":26309,"children":26310},{},[26311],{"type":34,"value":26312},"** Les classes abstraites sont très utiles pour éviter la duplication de code commun tout en respectant OCP.",{"type":28,"tag":83,"props":26314,"children":26315},{},[],{"type":28,"tag":29,"props":26317,"children":26319},{"id":26318},"les-pièges-courants-et-comment-les-éviter",[26320],{"type":34,"value":26321},"Les pièges courants et comment les éviter",{"type":28,"tag":44,"props":26323,"children":26324},{},[26325],{"type":34,"value":26326},"OCP a l'air simple sur le papier. L'appliquer sans déraper l'est moins. Trois erreurs reviennent constamment :",{"type":28,"tag":1644,"props":26328,"children":26329},{},[26330,26354],{"type":28,"tag":148,"props":26331,"children":26332},{},[26333,26338,26340,26345,26347,26352],{"type":28,"tag":55,"props":26334,"children":26335},{},[26336],{"type":34,"value":26337},"Complexité inutile",{"type":34,"value":26339}," : OCP doit rendre le code ",{"type":28,"tag":55,"props":26341,"children":26342},{},[26343],{"type":34,"value":26344},"extensible",{"type":34,"value":26346},", pas ",{"type":28,"tag":55,"props":26348,"children":26349},{},[26350],{"type":34,"value":26351},"complexe",{"type":34,"value":26353},". Empiler des couches d'abstraction ou des hiérarchies d'héritage juste pour cocher la case OCP alourdit le code sans bénéfice. Appliquez le principe là où il a un sens, pas partout.",{"type":28,"tag":148,"props":26355,"children":26356},{},[26357,26362,26364,26369],{"type":28,"tag":55,"props":26358,"children":26359},{},[26360],{"type":34,"value":26361},"Abus d'héritage",{"type":34,"value":26363}," : créer de longues chaînes d'héritage au nom d'OCP est un classique. L'héritage rend pourtant le code rigide. Dans la plupart des cas, ",{"type":28,"tag":55,"props":26365,"children":26366},{},[26367],{"type":34,"value":26368},"la composition",{"type":34,"value":26370}," (utiliser des objets plutôt que des sous-classes) donne un résultat plus flexible.",{"type":28,"tag":1841,"props":26372,"children":26373},{"type":1843},[26374],{"type":28,"tag":44,"props":26375,"children":26376},{},[26377,26382],{"type":28,"tag":55,"props":26378,"children":26379},{},[26380],{"type":34,"value":26381},"Entre héritage et composition, préférez la composition.",{"type":34,"value":26383}," Vous obtenez des modules plus flexibles et plus réutilisables.",{"type":28,"tag":1644,"props":26385,"children":26386},{"start":232},[26387],{"type":28,"tag":148,"props":26388,"children":26389},{},[26390,26395],{"type":28,"tag":55,"props":26391,"children":26392},{},[26393],{"type":34,"value":26394},"Modifier le code existant alors qu'on pourrait l'éviter",{"type":34,"value":26396}," : la tentation d'aller patcher une classe pour répondre à un nouveau besoin est forte. Si vous le faites souvent, le design initial manque de flexibilité, c'est lui qu'il faut revoir.",{"type":28,"tag":83,"props":26398,"children":26399},{},[],{"type":28,"tag":29,"props":26401,"children":26403},{"id":26402},"conclusion-rendre-votre-code-plus-flexible-avec-ocp",[26404],{"type":34,"value":26405},"Conclusion : Rendre votre code plus flexible avec OCP",{"type":28,"tag":44,"props":26407,"children":26408},{},[26409],{"type":34,"value":26410},"OCP est un levier puissant pour concevoir un code extensible, robuste et maintenable. Limiter les modifications du code existant réduit le risque d'erreur et fluidifie l'ajout de fonctionnalités.",{"type":28,"tag":44,"props":26412,"children":26413},{},[26414,26416,26420,26422,26426],{"type":34,"value":26415},"Interfaces, classes abstraites ou composition : peu importe l'outil, OCP donne à vos applications la marge d'adaptation aux changements futurs. En ",{"type":28,"tag":103,"props":26417,"children":26418},{"href":1478},[26419],{"type":34,"value":1522},{"type":34,"value":26421},", respecter ce principe signale un engagement clair : écrire du code qui fonctionne ",{"type":28,"tag":63,"props":26423,"children":26424},{},[26425],{"type":34,"value":4152},{"type":34,"value":26427}," qui évolue avec élégance.",{"type":28,"tag":120,"props":26429,"children":26431},{"cta":1327,"href":1328,"title":26430,"type":1330},"OCP n'est qu'une pratique parmi les 100 que j'applique pour coder propre",[26432],{"type":28,"tag":44,"props":26433,"children":26434},{},[26435],{"type":34,"value":26436},"Cet article détaille une seule pratique : concevoir pour l'extension plutôt que pour la modification. Le Craft Bundle réunit les 100 pratiques craft que j'applique au quotidien pour écrire du code maintenable, du choix de l'abstraction au découpage des responsabilités. Ce sont celles que l'IA ne vous apprendra jamais, parce qu'elle ne les a jamais vues tenir en production sur le long terme.",{"type":28,"tag":83,"props":26438,"children":26439},{},[],{"type":28,"tag":29,"props":26441,"children":26443},{"id":26442},"faq-réponses-aux-questions-fréquentes",[26444],{"type":34,"value":26445},"FAQ : Réponses aux questions fréquentes",{"type":28,"tag":1347,"props":26447,"children":26448},{},[26449,26454],{"type":28,"tag":1351,"props":26450,"children":26451},{},[26452],{"type":34,"value":26453},"1. Comment savoir si j’applique correctement le principe OCP ?",{"type":28,"tag":44,"props":26455,"children":26456},{},[26457],{"type":34,"value":26458},"Si vous pouvez ajouter de nouvelles fonctionnalités à votre code sans toucher au code existant, vous êtes probablement sur la bonne voie. Utilisez des abstractions comme les interfaces et les classes abstraites pour séparer les comportements.",{"type":28,"tag":1347,"props":26460,"children":26461},{},[26462,26467],{"type":28,"tag":1351,"props":26463,"children":26464},{},[26465],{"type":34,"value":26466},"2. Est-ce que suivre OCP rend le code plus compliqué ?",{"type":28,"tag":44,"props":26468,"children":26469},{},[26470],{"type":34,"value":26471},"Cela dépend de la manière dont vous l’implémentez. Si vous ajoutez trop de couches d’abstraction, cela peut effectivement compliquer les choses. L’objectif est de trouver un équilibre où votre code reste compréhensible tout en étant extensible.",{"type":28,"tag":1347,"props":26473,"children":26474},{},[26475,26480],{"type":28,"tag":1351,"props":26476,"children":26477},{},[26478],{"type":34,"value":26479},"3. Que faire si j’ai déjà du code qui ne respecte pas OCP ?",{"type":28,"tag":44,"props":26481,"children":26482},{},[26483],{"type":34,"value":26484},"Vous pouvez refactorer progressivement votre code en identifiant les parties les plus susceptibles de changer, puis en les isolant à l’aide d’abstractions. Refactoriser petit à petit permet d’améliorer le code sans introduire trop de risques.",{"type":28,"tag":1347,"props":26486,"children":26487},{},[26488,26493],{"type":28,"tag":1351,"props":26489,"children":26490},{},[26491],{"type":34,"value":26492},"4. OCP est-il toujours applicable ?",{"type":28,"tag":44,"props":26494,"children":26495},{},[26496],{"type":34,"value":26497},"Non, parfois, il n’est pas nécessaire d’appliquer OCP, surtout si vous travaillez sur une petite partie du code qui ne changera probablement jamais. Le principe doit être appliqué là où il est pertinent, c’est-à-dire là où il y a un potentiel de changement ou d’extension.",{"type":28,"tag":83,"props":26499,"children":26500},{},[],{"type":28,"tag":120,"props":26502,"children":26503},{"cta":16265,"href":1445,"title":16266,"type":1447},[26504],{"type":28,"tag":44,"props":26505,"children":26506},{},[26507],{"type":34,"value":16272},{"type":28,"tag":1455,"props":26509,"children":26510},{},[26511],{"type":34,"value":1459},{"title":8,"searchDepth":205,"depth":205,"links":26513},[26514,26515,26519,26520,26523,26524,26525],{"id":24421,"depth":205,"text":24424},{"id":24458,"depth":205,"text":24461,"children":26516},[26517,26518],{"id":24510,"depth":232,"text":24513},{"id":24972,"depth":232,"text":24975},{"id":25678,"depth":205,"text":25681},{"id":25773,"depth":205,"text":25776,"children":26521},[26522],{"id":25784,"depth":232,"text":25787},{"id":26318,"depth":205,"text":26321},{"id":26402,"depth":205,"text":26405},{"id":26442,"depth":205,"text":26445},"content:fr:architecture-craft:principe-ocp-software-craftsmanship-exemples-java.md","fr/architecture-craft/principe-ocp-software-craftsmanship-exemples-java.md","fr/architecture-craft/principe-ocp-software-craftsmanship-exemples-java",{"_path":4036,"_dir":3980,"_draft":7,"_partial":7,"_locale":8,"title":26530,"description":26531,"id":26532,"date":26533,"listed":13,"nocomments":7,"hidden":7,"categories":26534,"tags":26535,"cover":26536,"readingTime":26537,"body":26541,"_type":1471,"_id":28960,"_source":1473,"_file":28961,"_stem":28962,"_extension":1476},"Principe SRP en Software Craftsmanship, Comprendre et Appliquer le Single Responsibility Principle en Java","Découvrez comment appliquer le principe de responsabilité unique (SRP) en Java pour améliorer la lisibilité, la maintenabilité et la testabilité de...",47,"2024-01-16",[1484],[1486,1487],"covers/articles/principe-srp.jpg",{"text":20,"minutes":26538,"time":26539,"words":26540},7.345,440700,1469,{"type":25,"children":26542,"toc":28945},[26543,26549,26568,26588,26593,26599,26616,26621,26626,26853,26873,26878,27149,27176,27185,27191,27204,27210,27215,27221,27226,27232,27237,27243,27249,27262,27531,27536,27931,27937,27949,28274,28279,28731,28734,28740,28745,28798,28804,28810,28815,28821,28826,28832,28837,28843,28848,28857,28860,28866,28879,28892,28905,28918,28931,28934,28941],{"type":28,"tag":29,"props":26544,"children":26546},{"id":26545},"principe-srp-en-software-craftsmanship-explications-et-exemples-en-java",[26547],{"type":34,"value":26548},"Principe SRP en Software Craftsmanship : Explications et Exemples en Java",{"type":28,"tag":44,"props":26550,"children":26551},{},[26552,26554,26559,26561,26566],{"type":34,"value":26553},"Une classe qui fait tellement de choses qu'on ne sait plus par où l'attaquer pour la modifier : chaque équipe que j'accompagne en a au moins une. Ajouter une fonctionnalité ou corriger un bug devient un pari : on touche un endroit, on casse autre chose. Cette situation porte un nom : violation du ",{"type":28,"tag":55,"props":26555,"children":26556},{},[26557],{"type":34,"value":26558},"principe SRP (Single Responsibility Principle)",{"type":34,"value":26560},". Robert C. Martin, qui l'a formalisé dans ",{"type":28,"tag":63,"props":26562,"children":26563},{},[26564],{"type":34,"value":26565},"Clean Code",{"type":34,"value":26567},", le résume ainsi : une classe ne devrait avoir qu'une seule raison de changer.",{"type":28,"tag":44,"props":26569,"children":26570},{},[26571,26573,26577,26579,26586],{"type":34,"value":26572},"Le SRP est l'un des cinq ",{"type":28,"tag":103,"props":26574,"children":26575},{"href":3979},[26576],{"type":34,"value":13398},{"type":34,"value":26578},", piliers du ",{"type":28,"tag":55,"props":26580,"children":26581},{},[26582],{"type":28,"tag":103,"props":26583,"children":26584},{"href":1478},[26585],{"type":34,"value":59},{"type":34,"value":26587},". Comprendre le concept est trivial. L'appliquer sans tomber dans la sur-fragmentation l'est beaucoup moins. La plupart des équipes oscillent entre des classes monolithiques et un éclatement excessif où plus rien n'a de cohérence.",{"type":28,"tag":44,"props":26589,"children":26590},{},[26591],{"type":34,"value":26592},"Cet article montre comment appliquer le SRP de manière pragmatique dans des projets Java, avec des exemples concrets tirés de cas réels.",{"type":28,"tag":29,"props":26594,"children":26596},{"id":26595},"introduction-au-principe-srp",[26597],{"type":34,"value":26598},"Introduction au principe SRP",{"type":28,"tag":44,"props":26600,"children":26601},{},[26602,26603,26607,26609,26614],{"type":34,"value":1636},{"type":28,"tag":55,"props":26604,"children":26605},{},[26606],{"type":34,"value":9857},{"type":34,"value":26608},", ou principe de responsabilité unique, est souvent résumé ainsi : ",{"type":28,"tag":55,"props":26610,"children":26611},{},[26612],{"type":34,"value":26613},"\"Une classe ne devrait avoir qu'une seule raison de changer.\"",{"type":34,"value":26615}," Autrement dit, une classe doit se concentrer sur une seule tâche ou responsabilité.",{"type":28,"tag":44,"props":26617,"children":26618},{},[26619],{"type":34,"value":26620},"L'idée derrière le SRP est simple, mais puissante. Lorsque vous suivez ce principe, chaque classe dans votre code est responsable d'un aspect spécifique du système, ce qui la rend plus facile à comprendre, à modifier et à tester. Si une classe a plusieurs responsabilités, elle devient complexe, et chaque modification pour une responsabilité peut avoir des impacts imprévus sur une autre.",{"type":28,"tag":44,"props":26622,"children":26623},{},[26624],{"type":34,"value":26625},"Prenons un exemple simple :",{"type":28,"tag":181,"props":26627,"children":26629},{"className":183,"code":26628,"language":185,"meta":8,"style":8},"public class UserManager {\n    public void createUser(String username, String password) {\n        // Logique pour créer un utilisateur\n    }\n\n    public void log(String message) {\n        // Logique pour enregistrer un log\n    }\n\n    public void sendEmail(String email, String message) {\n        // Logique pour envoyer un email\n    }\n}\n",[26630],{"type":28,"tag":188,"props":26631,"children":26632},{"__ignoreMap":8},[26633,26653,26703,26711,26718,26725,26761,26769,26776,26783,26831,26839,26846],{"type":28,"tag":192,"props":26634,"children":26635},{"class":194,"line":195},[26636,26640,26644,26649],{"type":28,"tag":192,"props":26637,"children":26638},{"style":209},[26639],{"type":34,"value":212},{"type":28,"tag":192,"props":26641,"children":26642},{"style":209},[26643],{"type":34,"value":217},{"type":28,"tag":192,"props":26645,"children":26646},{"style":220},[26647],{"type":34,"value":26648}," UserManager",{"type":28,"tag":192,"props":26650,"children":26651},{"style":226},[26652],{"type":34,"value":229},{"type":28,"tag":192,"props":26654,"children":26655},{"class":194,"line":205},[26656,26660,26664,26669,26673,26677,26682,26686,26690,26695,26699],{"type":28,"tag":192,"props":26657,"children":26658},{"style":209},[26659],{"type":34,"value":322},{"type":28,"tag":192,"props":26661,"children":26662},{"style":209},[26663],{"type":34,"value":688},{"type":28,"tag":192,"props":26665,"children":26666},{"style":325},[26667],{"type":34,"value":26668}," createUser",{"type":28,"tag":192,"props":26670,"children":26671},{"style":226},[26672],{"type":34,"value":332},{"type":28,"tag":192,"props":26674,"children":26675},{"style":241},[26676],{"type":34,"value":337},{"type":28,"tag":192,"props":26678,"children":26679},{"style":340},[26680],{"type":34,"value":26681}," username",{"type":28,"tag":192,"props":26683,"children":26684},{"style":226},[26685],{"type":34,"value":347},{"type":28,"tag":192,"props":26687,"children":26688},{"style":241},[26689],{"type":34,"value":244},{"type":28,"tag":192,"props":26691,"children":26692},{"style":340},[26693],{"type":34,"value":26694}," password",{"type":28,"tag":192,"props":26696,"children":26697},{"style":226},[26698],{"type":34,"value":360},{"type":28,"tag":192,"props":26700,"children":26701},{"style":226},[26702],{"type":34,"value":229},{"type":28,"tag":192,"props":26704,"children":26705},{"class":194,"line":232},[26706],{"type":28,"tag":192,"props":26707,"children":26708},{"style":199},[26709],{"type":34,"value":26710},"        // Logique pour créer un utilisateur\n",{"type":28,"tag":192,"props":26712,"children":26713},{"class":194,"line":258},[26714],{"type":28,"tag":192,"props":26715,"children":26716},{"style":226},[26717],{"type":34,"value":445},{"type":28,"tag":192,"props":26719,"children":26720},{"class":194,"line":280},[26721],{"type":28,"tag":192,"props":26722,"children":26723},{"emptyLinePlaceholder":13},[26724],{"type":34,"value":313},{"type":28,"tag":192,"props":26726,"children":26727},{"class":194,"line":307},[26728,26732,26736,26741,26745,26749,26753,26757],{"type":28,"tag":192,"props":26729,"children":26730},{"style":209},[26731],{"type":34,"value":322},{"type":28,"tag":192,"props":26733,"children":26734},{"style":209},[26735],{"type":34,"value":688},{"type":28,"tag":192,"props":26737,"children":26738},{"style":325},[26739],{"type":34,"value":26740}," log",{"type":28,"tag":192,"props":26742,"children":26743},{"style":226},[26744],{"type":34,"value":332},{"type":28,"tag":192,"props":26746,"children":26747},{"style":241},[26748],{"type":34,"value":337},{"type":28,"tag":192,"props":26750,"children":26751},{"style":340},[26752],{"type":34,"value":8580},{"type":28,"tag":192,"props":26754,"children":26755},{"style":226},[26756],{"type":34,"value":360},{"type":28,"tag":192,"props":26758,"children":26759},{"style":226},[26760],{"type":34,"value":229},{"type":28,"tag":192,"props":26762,"children":26763},{"class":194,"line":316},[26764],{"type":28,"tag":192,"props":26765,"children":26766},{"style":199},[26767],{"type":34,"value":26768},"        // Logique pour enregistrer un log\n",{"type":28,"tag":192,"props":26770,"children":26771},{"class":194,"line":367},[26772],{"type":28,"tag":192,"props":26773,"children":26774},{"style":226},[26775],{"type":34,"value":445},{"type":28,"tag":192,"props":26777,"children":26778},{"class":194,"line":401},[26779],{"type":28,"tag":192,"props":26780,"children":26781},{"emptyLinePlaceholder":13},[26782],{"type":34,"value":313},{"type":28,"tag":192,"props":26784,"children":26785},{"class":194,"line":430},[26786,26790,26794,26798,26802,26806,26811,26815,26819,26823,26827],{"type":28,"tag":192,"props":26787,"children":26788},{"style":209},[26789],{"type":34,"value":322},{"type":28,"tag":192,"props":26791,"children":26792},{"style":209},[26793],{"type":34,"value":688},{"type":28,"tag":192,"props":26795,"children":26796},{"style":325},[26797],{"type":34,"value":8567},{"type":28,"tag":192,"props":26799,"children":26800},{"style":226},[26801],{"type":34,"value":332},{"type":28,"tag":192,"props":26803,"children":26804},{"style":241},[26805],{"type":34,"value":337},{"type":28,"tag":192,"props":26807,"children":26808},{"style":340},[26809],{"type":34,"value":26810}," email",{"type":28,"tag":192,"props":26812,"children":26813},{"style":226},[26814],{"type":34,"value":347},{"type":28,"tag":192,"props":26816,"children":26817},{"style":241},[26818],{"type":34,"value":244},{"type":28,"tag":192,"props":26820,"children":26821},{"style":340},[26822],{"type":34,"value":8580},{"type":28,"tag":192,"props":26824,"children":26825},{"style":226},[26826],{"type":34,"value":360},{"type":28,"tag":192,"props":26828,"children":26829},{"style":226},[26830],{"type":34,"value":229},{"type":28,"tag":192,"props":26832,"children":26833},{"class":194,"line":439},[26834],{"type":28,"tag":192,"props":26835,"children":26836},{"style":199},[26837],{"type":34,"value":26838},"        // Logique pour envoyer un email\n",{"type":28,"tag":192,"props":26840,"children":26841},{"class":194,"line":448},[26842],{"type":28,"tag":192,"props":26843,"children":26844},{"style":226},[26845],{"type":34,"value":445},{"type":28,"tag":192,"props":26847,"children":26848},{"class":194,"line":456},[26849],{"type":28,"tag":192,"props":26850,"children":26851},{"style":226},[26852],{"type":34,"value":588},{"type":28,"tag":44,"props":26854,"children":26855},{},[26856,26857,26863,26865,26871],{"type":34,"value":20897},{"type":28,"tag":188,"props":26858,"children":26860},{"className":26859},[],[26861],{"type":34,"value":26862},"UserManager",{"type":34,"value":26864}," gère plusieurs responsabilités : la création d'utilisateur, la gestion des logs, et l'envoi d'emails. Si vous devez modifier la méthode ",{"type":28,"tag":188,"props":26866,"children":26868},{"className":26867},[],[26869],{"type":34,"value":26870},"createUser",{"type":34,"value":26872},", vous risquez de casser des fonctionnalités de logging ou d'emailing, car tout est couplé dans une seule classe.",{"type":28,"tag":44,"props":26874,"children":26875},{},[26876],{"type":34,"value":26877},"Pour appliquer le SRP, vous devez découper cette classe en plusieurs classes, chacune ayant une responsabilité bien définie :",{"type":28,"tag":181,"props":26879,"children":26881},{"className":183,"code":26880,"language":185,"meta":8,"style":8},"public class UserManager {\n    public void createUser(String username, String password) {\n        // Logique pour créer un utilisateur\n    }\n}\n\npublic class Logger {\n    public void log(String message) {\n        // Logique pour enregistrer un log\n    }\n}\n\npublic class EmailService {\n    public void sendEmail(String email, String message) {\n        // Logique pour envoyer un email\n    }\n}\n",[26882],{"type":28,"tag":188,"props":26883,"children":26884},{"__ignoreMap":8},[26885,26904,26951,26958,26965,26972,26979,26999,27034,27041,27048,27055,27062,27081,27128,27135,27142],{"type":28,"tag":192,"props":26886,"children":26887},{"class":194,"line":195},[26888,26892,26896,26900],{"type":28,"tag":192,"props":26889,"children":26890},{"style":209},[26891],{"type":34,"value":212},{"type":28,"tag":192,"props":26893,"children":26894},{"style":209},[26895],{"type":34,"value":217},{"type":28,"tag":192,"props":26897,"children":26898},{"style":220},[26899],{"type":34,"value":26648},{"type":28,"tag":192,"props":26901,"children":26902},{"style":226},[26903],{"type":34,"value":229},{"type":28,"tag":192,"props":26905,"children":26906},{"class":194,"line":205},[26907,26911,26915,26919,26923,26927,26931,26935,26939,26943,26947],{"type":28,"tag":192,"props":26908,"children":26909},{"style":209},[26910],{"type":34,"value":322},{"type":28,"tag":192,"props":26912,"children":26913},{"style":209},[26914],{"type":34,"value":688},{"type":28,"tag":192,"props":26916,"children":26917},{"style":325},[26918],{"type":34,"value":26668},{"type":28,"tag":192,"props":26920,"children":26921},{"style":226},[26922],{"type":34,"value":332},{"type":28,"tag":192,"props":26924,"children":26925},{"style":241},[26926],{"type":34,"value":337},{"type":28,"tag":192,"props":26928,"children":26929},{"style":340},[26930],{"type":34,"value":26681},{"type":28,"tag":192,"props":26932,"children":26933},{"style":226},[26934],{"type":34,"value":347},{"type":28,"tag":192,"props":26936,"children":26937},{"style":241},[26938],{"type":34,"value":244},{"type":28,"tag":192,"props":26940,"children":26941},{"style":340},[26942],{"type":34,"value":26694},{"type":28,"tag":192,"props":26944,"children":26945},{"style":226},[26946],{"type":34,"value":360},{"type":28,"tag":192,"props":26948,"children":26949},{"style":226},[26950],{"type":34,"value":229},{"type":28,"tag":192,"props":26952,"children":26953},{"class":194,"line":232},[26954],{"type":28,"tag":192,"props":26955,"children":26956},{"style":199},[26957],{"type":34,"value":26710},{"type":28,"tag":192,"props":26959,"children":26960},{"class":194,"line":258},[26961],{"type":28,"tag":192,"props":26962,"children":26963},{"style":226},[26964],{"type":34,"value":445},{"type":28,"tag":192,"props":26966,"children":26967},{"class":194,"line":280},[26968],{"type":28,"tag":192,"props":26969,"children":26970},{"style":226},[26971],{"type":34,"value":588},{"type":28,"tag":192,"props":26973,"children":26974},{"class":194,"line":307},[26975],{"type":28,"tag":192,"props":26976,"children":26977},{"emptyLinePlaceholder":13},[26978],{"type":34,"value":313},{"type":28,"tag":192,"props":26980,"children":26981},{"class":194,"line":316},[26982,26986,26990,26995],{"type":28,"tag":192,"props":26983,"children":26984},{"style":209},[26985],{"type":34,"value":212},{"type":28,"tag":192,"props":26987,"children":26988},{"style":209},[26989],{"type":34,"value":217},{"type":28,"tag":192,"props":26991,"children":26992},{"style":220},[26993],{"type":34,"value":26994}," Logger",{"type":28,"tag":192,"props":26996,"children":26997},{"style":226},[26998],{"type":34,"value":229},{"type":28,"tag":192,"props":27000,"children":27001},{"class":194,"line":367},[27002,27006,27010,27014,27018,27022,27026,27030],{"type":28,"tag":192,"props":27003,"children":27004},{"style":209},[27005],{"type":34,"value":322},{"type":28,"tag":192,"props":27007,"children":27008},{"style":209},[27009],{"type":34,"value":688},{"type":28,"tag":192,"props":27011,"children":27012},{"style":325},[27013],{"type":34,"value":26740},{"type":28,"tag":192,"props":27015,"children":27016},{"style":226},[27017],{"type":34,"value":332},{"type":28,"tag":192,"props":27019,"children":27020},{"style":241},[27021],{"type":34,"value":337},{"type":28,"tag":192,"props":27023,"children":27024},{"style":340},[27025],{"type":34,"value":8580},{"type":28,"tag":192,"props":27027,"children":27028},{"style":226},[27029],{"type":34,"value":360},{"type":28,"tag":192,"props":27031,"children":27032},{"style":226},[27033],{"type":34,"value":229},{"type":28,"tag":192,"props":27035,"children":27036},{"class":194,"line":401},[27037],{"type":28,"tag":192,"props":27038,"children":27039},{"style":199},[27040],{"type":34,"value":26768},{"type":28,"tag":192,"props":27042,"children":27043},{"class":194,"line":430},[27044],{"type":28,"tag":192,"props":27045,"children":27046},{"style":226},[27047],{"type":34,"value":445},{"type":28,"tag":192,"props":27049,"children":27050},{"class":194,"line":439},[27051],{"type":28,"tag":192,"props":27052,"children":27053},{"style":226},[27054],{"type":34,"value":588},{"type":28,"tag":192,"props":27056,"children":27057},{"class":194,"line":448},[27058],{"type":28,"tag":192,"props":27059,"children":27060},{"emptyLinePlaceholder":13},[27061],{"type":34,"value":313},{"type":28,"tag":192,"props":27063,"children":27064},{"class":194,"line":456},[27065,27069,27073,27077],{"type":28,"tag":192,"props":27066,"children":27067},{"style":209},[27068],{"type":34,"value":212},{"type":28,"tag":192,"props":27070,"children":27071},{"style":209},[27072],{"type":34,"value":217},{"type":28,"tag":192,"props":27074,"children":27075},{"style":220},[27076],{"type":34,"value":8547},{"type":28,"tag":192,"props":27078,"children":27079},{"style":226},[27080],{"type":34,"value":229},{"type":28,"tag":192,"props":27082,"children":27083},{"class":194,"line":482},[27084,27088,27092,27096,27100,27104,27108,27112,27116,27120,27124],{"type":28,"tag":192,"props":27085,"children":27086},{"style":209},[27087],{"type":34,"value":322},{"type":28,"tag":192,"props":27089,"children":27090},{"style":209},[27091],{"type":34,"value":688},{"type":28,"tag":192,"props":27093,"children":27094},{"style":325},[27095],{"type":34,"value":8567},{"type":28,"tag":192,"props":27097,"children":27098},{"style":226},[27099],{"type":34,"value":332},{"type":28,"tag":192,"props":27101,"children":27102},{"style":241},[27103],{"type":34,"value":337},{"type":28,"tag":192,"props":27105,"children":27106},{"style":340},[27107],{"type":34,"value":26810},{"type":28,"tag":192,"props":27109,"children":27110},{"style":226},[27111],{"type":34,"value":347},{"type":28,"tag":192,"props":27113,"children":27114},{"style":241},[27115],{"type":34,"value":244},{"type":28,"tag":192,"props":27117,"children":27118},{"style":340},[27119],{"type":34,"value":8580},{"type":28,"tag":192,"props":27121,"children":27122},{"style":226},[27123],{"type":34,"value":360},{"type":28,"tag":192,"props":27125,"children":27126},{"style":226},[27127],{"type":34,"value":229},{"type":28,"tag":192,"props":27129,"children":27130},{"class":194,"line":499},[27131],{"type":28,"tag":192,"props":27132,"children":27133},{"style":199},[27134],{"type":34,"value":26838},{"type":28,"tag":192,"props":27136,"children":27137},{"class":194,"line":507},[27138],{"type":28,"tag":192,"props":27139,"children":27140},{"style":226},[27141],{"type":34,"value":445},{"type":28,"tag":192,"props":27143,"children":27144},{"class":194,"line":515},[27145],{"type":28,"tag":192,"props":27146,"children":27147},{"style":226},[27148],{"type":34,"value":588},{"type":28,"tag":44,"props":27150,"children":27151},{},[27152,27154,27159,27161,27167,27169,27174],{"type":34,"value":27153},"Maintenant, chaque classe a une seule responsabilité : ",{"type":28,"tag":188,"props":27155,"children":27157},{"className":27156},[],[27158],{"type":34,"value":26862},{"type":34,"value":27160}," s'occupe de la création d'utilisateur, ",{"type":28,"tag":188,"props":27162,"children":27164},{"className":27163},[],[27165],{"type":34,"value":27166},"Logger",{"type":34,"value":27168}," gère les logs, et ",{"type":28,"tag":188,"props":27170,"children":27172},{"className":27171},[],[27173],{"type":34,"value":8523},{"type":34,"value":27175}," est responsable de l'envoi des emails. Cela rend le code plus propre et plus facile à maintenir.",{"type":28,"tag":120,"props":27177,"children":27179},{"cta":122,"href":123,"title":27178,"type":125},"Vous voulez sentir où découper une classe sans tomber dans la sur-fragmentation ?",[27180],{"type":28,"tag":44,"props":27181,"children":27182},{},[27183],{"type":34,"value":27184},"Identifier les responsabilités d'une classe, c'est un jugement qui se travaille, pas une règle qu'on récite. En mentoring 1:1, je relis votre code avec vous et on découpe vos vraies classes ensemble, jusqu'à ce que vous repériez les bonnes frontières d'instinct. Vous arrêtez d'osciller entre le monolithe et la poussière de mini-classes.",{"type":28,"tag":29,"props":27186,"children":27188},{"id":27187},"pourquoi-le-srp-est-il-important-dans-le-software-craftsmanship",[27189],{"type":34,"value":27190},"Pourquoi le SRP est-il important dans le Software Craftsmanship ?",{"type":28,"tag":44,"props":27192,"children":27193},{},[27194,27195,27202],{"type":34,"value":1636},{"type":28,"tag":55,"props":27196,"children":27197},{},[27198],{"type":28,"tag":103,"props":27199,"children":27200},{"href":1478},[27201],{"type":34,"value":59},{"type":34,"value":27203}," se concentre sur l’écriture d’un code de qualité, maintenable et évolutif. C’est un mouvement qui valorise les bonnes pratiques de développement et la création de logiciels avec soin et précision. Dans cette optique, le principe de responsabilité unique (SRP) joue un rôle clé.",{"type":28,"tag":169,"props":27205,"children":27207},{"id":27206},"simplification-et-maintenabilité",[27208],{"type":34,"value":27209},"Simplification et maintenabilité",{"type":28,"tag":44,"props":27211,"children":27212},{},[27213],{"type":34,"value":27214},"Le SRP réduit la complexité du code. Une classe qui fait une seule chose se comprend et se modifie sans effort comparé à une classe qui en porte plusieurs : moins d'erreurs, plus de productivité d'équipe.",{"type":28,"tag":169,"props":27216,"children":27218},{"id":27217},"facilite-les-tests-unitaires",[27219],{"type":34,"value":27220},"Facilite les tests unitaires",{"type":28,"tag":44,"props":27222,"children":27223},{},[27224],{"type":34,"value":27225},"Le SRP rend aussi les tests unitaires plus simples. Une classe à responsabilité unique a généralement peu de dépendances, et chaque fonctionnalité se teste isolément sans avoir à simuler des comportements parasites.",{"type":28,"tag":169,"props":27227,"children":27229},{"id":27228},"favorise-lévolutivité",[27230],{"type":34,"value":27231},"Favorise l’évolutivité",{"type":28,"tag":44,"props":27233,"children":27234},{},[27235],{"type":34,"value":27236},"Avec le SRP, étendre les fonctionnalités d'une application devient prévisible. Quand chaque classe a une responsabilité clairement définie, ajouter une fonctionnalité n'oblige pas à refactoriser une grande partie du code : on ajoute une nouvelle classe ou on modifie une classe existante sans risque de régression ailleurs. Dans une équipe que j'accompagnais dans l'assurance, les cycles de release sont passés de 6 semaines à 2 semaines après l'application du SRP sur les services métier les plus chargés.",{"type":28,"tag":37,"props":27238,"children":27240},{"id":27239},"_3-comment-appliquer-le-srp-en-java-exemples-concrets",[27241],{"type":34,"value":27242},"3. Comment appliquer le SRP en Java : exemples concrets",{"type":28,"tag":169,"props":27244,"children":27246},{"id":27245},"exemple-1-gestion-des-utilisateurs",[27247],{"type":34,"value":27248},"Exemple 1 : Gestion des utilisateurs",{"type":28,"tag":44,"props":27250,"children":27251},{},[27252,27254,27260],{"type":34,"value":27253},"Voici un exemple de violation du SRP avec une classe ",{"type":28,"tag":188,"props":27255,"children":27257},{"className":27256},[],[27258],{"type":34,"value":27259},"UserService",{"type":34,"value":27261}," qui gère à la fois la création d'utilisateurs et l'envoi d'emails.",{"type":28,"tag":181,"props":27263,"children":27265},{"className":183,"code":27264,"language":185,"meta":8,"style":8},"public class UserService {\n    public void createUser(String username, String password) {\n        // Logique pour créer un utilisateur\n        System.out.println(\"Utilisateur créé avec succès !\");\n        \n        // Envoyer un email de bienvenue\n        sendWelcomeEmail(username);\n    }\n\n    public void sendWelcomeEmail(String username) {\n        // Logique pour envoyer un email de bienvenue\n        System.out.println(\"Email envoyé à \" + username);\n    }\n}\n",[27266],{"type":28,"tag":188,"props":27267,"children":27268},{"__ignoreMap":8},[27269,27288,27335,27342,27378,27386,27394,27415,27422,27429,27465,27473,27517,27524],{"type":28,"tag":192,"props":27270,"children":27271},{"class":194,"line":195},[27272,27276,27280,27284],{"type":28,"tag":192,"props":27273,"children":27274},{"style":209},[27275],{"type":34,"value":212},{"type":28,"tag":192,"props":27277,"children":27278},{"style":209},[27279],{"type":34,"value":217},{"type":28,"tag":192,"props":27281,"children":27282},{"style":220},[27283],{"type":34,"value":17140},{"type":28,"tag":192,"props":27285,"children":27286},{"style":226},[27287],{"type":34,"value":229},{"type":28,"tag":192,"props":27289,"children":27290},{"class":194,"line":205},[27291,27295,27299,27303,27307,27311,27315,27319,27323,27327,27331],{"type":28,"tag":192,"props":27292,"children":27293},{"style":209},[27294],{"type":34,"value":322},{"type":28,"tag":192,"props":27296,"children":27297},{"style":209},[27298],{"type":34,"value":688},{"type":28,"tag":192,"props":27300,"children":27301},{"style":325},[27302],{"type":34,"value":26668},{"type":28,"tag":192,"props":27304,"children":27305},{"style":226},[27306],{"type":34,"value":332},{"type":28,"tag":192,"props":27308,"children":27309},{"style":241},[27310],{"type":34,"value":337},{"type":28,"tag":192,"props":27312,"children":27313},{"style":340},[27314],{"type":34,"value":26681},{"type":28,"tag":192,"props":27316,"children":27317},{"style":226},[27318],{"type":34,"value":347},{"type":28,"tag":192,"props":27320,"children":27321},{"style":241},[27322],{"type":34,"value":244},{"type":28,"tag":192,"props":27324,"children":27325},{"style":340},[27326],{"type":34,"value":26694},{"type":28,"tag":192,"props":27328,"children":27329},{"style":226},[27330],{"type":34,"value":360},{"type":28,"tag":192,"props":27332,"children":27333},{"style":226},[27334],{"type":34,"value":229},{"type":28,"tag":192,"props":27336,"children":27337},{"class":194,"line":232},[27338],{"type":28,"tag":192,"props":27339,"children":27340},{"style":199},[27341],{"type":34,"value":26710},{"type":28,"tag":192,"props":27343,"children":27344},{"class":194,"line":258},[27345,27349,27353,27357,27361,27365,27369,27374],{"type":28,"tag":192,"props":27346,"children":27347},{"style":247},[27348],{"type":34,"value":4327},{"type":28,"tag":192,"props":27350,"children":27351},{"style":226},[27352],{"type":34,"value":379},{"type":28,"tag":192,"props":27354,"children":27355},{"style":247},[27356],{"type":34,"value":2673},{"type":28,"tag":192,"props":27358,"children":27359},{"style":226},[27360],{"type":34,"value":379},{"type":28,"tag":192,"props":27362,"children":27363},{"style":325},[27364],{"type":34,"value":2682},{"type":28,"tag":192,"props":27366,"children":27367},{"style":226},[27368],{"type":34,"value":332},{"type":28,"tag":192,"props":27370,"children":27371},{"style":734},[27372],{"type":34,"value":27373},"\"Utilisateur créé avec succès !\"",{"type":28,"tag":192,"props":27375,"children":27376},{"style":226},[27377],{"type":34,"value":752},{"type":28,"tag":192,"props":27379,"children":27380},{"class":194,"line":280},[27381],{"type":28,"tag":192,"props":27382,"children":27383},{"style":247},[27384],{"type":34,"value":27385},"        \n",{"type":28,"tag":192,"props":27387,"children":27388},{"class":194,"line":307},[27389],{"type":28,"tag":192,"props":27390,"children":27391},{"style":199},[27392],{"type":34,"value":27393},"        // Envoyer un email de bienvenue\n",{"type":28,"tag":192,"props":27395,"children":27396},{"class":194,"line":316},[27397,27402,27406,27411],{"type":28,"tag":192,"props":27398,"children":27399},{"style":325},[27400],{"type":34,"value":27401},"        sendWelcomeEmail",{"type":28,"tag":192,"props":27403,"children":27404},{"style":226},[27405],{"type":34,"value":332},{"type":28,"tag":192,"props":27407,"children":27408},{"style":247},[27409],{"type":34,"value":27410},"username",{"type":28,"tag":192,"props":27412,"children":27413},{"style":226},[27414],{"type":34,"value":752},{"type":28,"tag":192,"props":27416,"children":27417},{"class":194,"line":367},[27418],{"type":28,"tag":192,"props":27419,"children":27420},{"style":226},[27421],{"type":34,"value":445},{"type":28,"tag":192,"props":27423,"children":27424},{"class":194,"line":401},[27425],{"type":28,"tag":192,"props":27426,"children":27427},{"emptyLinePlaceholder":13},[27428],{"type":34,"value":313},{"type":28,"tag":192,"props":27430,"children":27431},{"class":194,"line":430},[27432,27436,27440,27445,27449,27453,27457,27461],{"type":28,"tag":192,"props":27433,"children":27434},{"style":209},[27435],{"type":34,"value":322},{"type":28,"tag":192,"props":27437,"children":27438},{"style":209},[27439],{"type":34,"value":688},{"type":28,"tag":192,"props":27441,"children":27442},{"style":325},[27443],{"type":34,"value":27444}," sendWelcomeEmail",{"type":28,"tag":192,"props":27446,"children":27447},{"style":226},[27448],{"type":34,"value":332},{"type":28,"tag":192,"props":27450,"children":27451},{"style":241},[27452],{"type":34,"value":337},{"type":28,"tag":192,"props":27454,"children":27455},{"style":340},[27456],{"type":34,"value":26681},{"type":28,"tag":192,"props":27458,"children":27459},{"style":226},[27460],{"type":34,"value":360},{"type":28,"tag":192,"props":27462,"children":27463},{"style":226},[27464],{"type":34,"value":229},{"type":28,"tag":192,"props":27466,"children":27467},{"class":194,"line":439},[27468],{"type":28,"tag":192,"props":27469,"children":27470},{"style":199},[27471],{"type":34,"value":27472},"        // Logique pour envoyer un email de bienvenue\n",{"type":28,"tag":192,"props":27474,"children":27475},{"class":194,"line":448},[27476,27480,27484,27488,27492,27496,27500,27505,27509,27513],{"type":28,"tag":192,"props":27477,"children":27478},{"style":247},[27479],{"type":34,"value":4327},{"type":28,"tag":192,"props":27481,"children":27482},{"style":226},[27483],{"type":34,"value":379},{"type":28,"tag":192,"props":27485,"children":27486},{"style":247},[27487],{"type":34,"value":2673},{"type":28,"tag":192,"props":27489,"children":27490},{"style":226},[27491],{"type":34,"value":379},{"type":28,"tag":192,"props":27493,"children":27494},{"style":325},[27495],{"type":34,"value":2682},{"type":28,"tag":192,"props":27497,"children":27498},{"style":226},[27499],{"type":34,"value":332},{"type":28,"tag":192,"props":27501,"children":27502},{"style":734},[27503],{"type":34,"value":27504},"\"Email envoyé à \"",{"type":28,"tag":192,"props":27506,"children":27507},{"style":387},[27508],{"type":34,"value":2696},{"type":28,"tag":192,"props":27510,"children":27511},{"style":247},[27512],{"type":34,"value":26681},{"type":28,"tag":192,"props":27514,"children":27515},{"style":226},[27516],{"type":34,"value":752},{"type":28,"tag":192,"props":27518,"children":27519},{"class":194,"line":456},[27520],{"type":28,"tag":192,"props":27521,"children":27522},{"style":226},[27523],{"type":34,"value":445},{"type":28,"tag":192,"props":27525,"children":27526},{"class":194,"line":482},[27527],{"type":28,"tag":192,"props":27528,"children":27529},{"style":226},[27530],{"type":34,"value":588},{"type":28,"tag":44,"props":27532,"children":27533},{},[27534],{"type":34,"value":27535},"Cette classe gère deux responsabilités : la création d'utilisateur et l'envoi d'emails. En suivant le SRP, nous devrions séparer ces responsabilités dans deux classes distinctes.",{"type":28,"tag":181,"props":27537,"children":27539},{"className":183,"code":27538,"language":185,"meta":8,"style":8},"public class UserService {\n    private EmailService emailService;\n\n    public UserService(EmailService emailService) {\n        this.emailService = emailService;\n    }\n\n    public void createUser(String username, String password) {\n        // Logique pour créer un utilisateur\n        System.out.println(\"Utilisateur créé avec succès !\");\n        \n        // Utilisation de l'EmailService pour envoyer l'email\n        emailService.sendWelcomeEmail(username);\n    }\n}\n\npublic class EmailService {\n    public void sendWelcomeEmail(String username) {\n        // Logique pour envoyer un email de bienvenue\n        System.out.println(\"Email envoyé à \" + username);\n    }\n}\n",[27540],{"type":28,"tag":188,"props":27541,"children":27542},{"__ignoreMap":8},[27543,27562,27581,27588,27619,27646,27653,27660,27707,27714,27749,27756,27764,27792,27799,27806,27813,27832,27867,27874,27917,27924],{"type":28,"tag":192,"props":27544,"children":27545},{"class":194,"line":195},[27546,27550,27554,27558],{"type":28,"tag":192,"props":27547,"children":27548},{"style":209},[27549],{"type":34,"value":212},{"type":28,"tag":192,"props":27551,"children":27552},{"style":209},[27553],{"type":34,"value":217},{"type":28,"tag":192,"props":27555,"children":27556},{"style":220},[27557],{"type":34,"value":17140},{"type":28,"tag":192,"props":27559,"children":27560},{"style":226},[27561],{"type":34,"value":229},{"type":28,"tag":192,"props":27563,"children":27564},{"class":194,"line":205},[27565,27569,27573,27577],{"type":28,"tag":192,"props":27566,"children":27567},{"style":209},[27568],{"type":34,"value":238},{"type":28,"tag":192,"props":27570,"children":27571},{"style":241},[27572],{"type":34,"value":8547},{"type":28,"tag":192,"props":27574,"children":27575},{"style":247},[27576],{"type":34,"value":8689},{"type":28,"tag":192,"props":27578,"children":27579},{"style":226},[27580],{"type":34,"value":255},{"type":28,"tag":192,"props":27582,"children":27583},{"class":194,"line":232},[27584],{"type":28,"tag":192,"props":27585,"children":27586},{"emptyLinePlaceholder":13},[27587],{"type":34,"value":313},{"type":28,"tag":192,"props":27589,"children":27590},{"class":194,"line":258},[27591,27595,27599,27603,27607,27611,27615],{"type":28,"tag":192,"props":27592,"children":27593},{"style":209},[27594],{"type":34,"value":322},{"type":28,"tag":192,"props":27596,"children":27597},{"style":325},[27598],{"type":34,"value":17140},{"type":28,"tag":192,"props":27600,"children":27601},{"style":226},[27602],{"type":34,"value":332},{"type":28,"tag":192,"props":27604,"children":27605},{"style":241},[27606],{"type":34,"value":8523},{"type":28,"tag":192,"props":27608,"children":27609},{"style":340},[27610],{"type":34,"value":8689},{"type":28,"tag":192,"props":27612,"children":27613},{"style":226},[27614],{"type":34,"value":360},{"type":28,"tag":192,"props":27616,"children":27617},{"style":226},[27618],{"type":34,"value":229},{"type":28,"tag":192,"props":27620,"children":27621},{"class":194,"line":280},[27622,27626,27630,27634,27638,27642],{"type":28,"tag":192,"props":27623,"children":27624},{"style":371},[27625],{"type":34,"value":374},{"type":28,"tag":192,"props":27627,"children":27628},{"style":226},[27629],{"type":34,"value":379},{"type":28,"tag":192,"props":27631,"children":27632},{"style":247},[27633],{"type":34,"value":8735},{"type":28,"tag":192,"props":27635,"children":27636},{"style":387},[27637],{"type":34,"value":390},{"type":28,"tag":192,"props":27639,"children":27640},{"style":247},[27641],{"type":34,"value":8689},{"type":28,"tag":192,"props":27643,"children":27644},{"style":226},[27645],{"type":34,"value":255},{"type":28,"tag":192,"props":27647,"children":27648},{"class":194,"line":307},[27649],{"type":28,"tag":192,"props":27650,"children":27651},{"style":226},[27652],{"type":34,"value":445},{"type":28,"tag":192,"props":27654,"children":27655},{"class":194,"line":316},[27656],{"type":28,"tag":192,"props":27657,"children":27658},{"emptyLinePlaceholder":13},[27659],{"type":34,"value":313},{"type":28,"tag":192,"props":27661,"children":27662},{"class":194,"line":367},[27663,27667,27671,27675,27679,27683,27687,27691,27695,27699,27703],{"type":28,"tag":192,"props":27664,"children":27665},{"style":209},[27666],{"type":34,"value":322},{"type":28,"tag":192,"props":27668,"children":27669},{"style":209},[27670],{"type":34,"value":688},{"type":28,"tag":192,"props":27672,"children":27673},{"style":325},[27674],{"type":34,"value":26668},{"type":28,"tag":192,"props":27676,"children":27677},{"style":226},[27678],{"type":34,"value":332},{"type":28,"tag":192,"props":27680,"children":27681},{"style":241},[27682],{"type":34,"value":337},{"type":28,"tag":192,"props":27684,"children":27685},{"style":340},[27686],{"type":34,"value":26681},{"type":28,"tag":192,"props":27688,"children":27689},{"style":226},[27690],{"type":34,"value":347},{"type":28,"tag":192,"props":27692,"children":27693},{"style":241},[27694],{"type":34,"value":244},{"type":28,"tag":192,"props":27696,"children":27697},{"style":340},[27698],{"type":34,"value":26694},{"type":28,"tag":192,"props":27700,"children":27701},{"style":226},[27702],{"type":34,"value":360},{"type":28,"tag":192,"props":27704,"children":27705},{"style":226},[27706],{"type":34,"value":229},{"type":28,"tag":192,"props":27708,"children":27709},{"class":194,"line":401},[27710],{"type":28,"tag":192,"props":27711,"children":27712},{"style":199},[27713],{"type":34,"value":26710},{"type":28,"tag":192,"props":27715,"children":27716},{"class":194,"line":430},[27717,27721,27725,27729,27733,27737,27741,27745],{"type":28,"tag":192,"props":27718,"children":27719},{"style":247},[27720],{"type":34,"value":4327},{"type":28,"tag":192,"props":27722,"children":27723},{"style":226},[27724],{"type":34,"value":379},{"type":28,"tag":192,"props":27726,"children":27727},{"style":247},[27728],{"type":34,"value":2673},{"type":28,"tag":192,"props":27730,"children":27731},{"style":226},[27732],{"type":34,"value":379},{"type":28,"tag":192,"props":27734,"children":27735},{"style":325},[27736],{"type":34,"value":2682},{"type":28,"tag":192,"props":27738,"children":27739},{"style":226},[27740],{"type":34,"value":332},{"type":28,"tag":192,"props":27742,"children":27743},{"style":734},[27744],{"type":34,"value":27373},{"type":28,"tag":192,"props":27746,"children":27747},{"style":226},[27748],{"type":34,"value":752},{"type":28,"tag":192,"props":27750,"children":27751},{"class":194,"line":439},[27752],{"type":28,"tag":192,"props":27753,"children":27754},{"style":247},[27755],{"type":34,"value":27385},{"type":28,"tag":192,"props":27757,"children":27758},{"class":194,"line":448},[27759],{"type":28,"tag":192,"props":27760,"children":27761},{"style":199},[27762],{"type":34,"value":27763},"        // Utilisation de l'EmailService pour envoyer l'email\n",{"type":28,"tag":192,"props":27765,"children":27766},{"class":194,"line":456},[27767,27771,27775,27780,27784,27788],{"type":28,"tag":192,"props":27768,"children":27769},{"style":247},[27770],{"type":34,"value":8809},{"type":28,"tag":192,"props":27772,"children":27773},{"style":226},[27774],{"type":34,"value":379},{"type":28,"tag":192,"props":27776,"children":27777},{"style":325},[27778],{"type":34,"value":27779},"sendWelcomeEmail",{"type":28,"tag":192,"props":27781,"children":27782},{"style":226},[27783],{"type":34,"value":332},{"type":28,"tag":192,"props":27785,"children":27786},{"style":247},[27787],{"type":34,"value":27410},{"type":28,"tag":192,"props":27789,"children":27790},{"style":226},[27791],{"type":34,"value":752},{"type":28,"tag":192,"props":27793,"children":27794},{"class":194,"line":482},[27795],{"type":28,"tag":192,"props":27796,"children":27797},{"style":226},[27798],{"type":34,"value":445},{"type":28,"tag":192,"props":27800,"children":27801},{"class":194,"line":499},[27802],{"type":28,"tag":192,"props":27803,"children":27804},{"style":226},[27805],{"type":34,"value":588},{"type":28,"tag":192,"props":27807,"children":27808},{"class":194,"line":507},[27809],{"type":28,"tag":192,"props":27810,"children":27811},{"emptyLinePlaceholder":13},[27812],{"type":34,"value":313},{"type":28,"tag":192,"props":27814,"children":27815},{"class":194,"line":515},[27816,27820,27824,27828],{"type":28,"tag":192,"props":27817,"children":27818},{"style":209},[27819],{"type":34,"value":212},{"type":28,"tag":192,"props":27821,"children":27822},{"style":209},[27823],{"type":34,"value":217},{"type":28,"tag":192,"props":27825,"children":27826},{"style":220},[27827],{"type":34,"value":8547},{"type":28,"tag":192,"props":27829,"children":27830},{"style":226},[27831],{"type":34,"value":229},{"type":28,"tag":192,"props":27833,"children":27834},{"class":194,"line":540},[27835,27839,27843,27847,27851,27855,27859,27863],{"type":28,"tag":192,"props":27836,"children":27837},{"style":209},[27838],{"type":34,"value":322},{"type":28,"tag":192,"props":27840,"children":27841},{"style":209},[27842],{"type":34,"value":688},{"type":28,"tag":192,"props":27844,"children":27845},{"style":325},[27846],{"type":34,"value":27444},{"type":28,"tag":192,"props":27848,"children":27849},{"style":226},[27850],{"type":34,"value":332},{"type":28,"tag":192,"props":27852,"children":27853},{"style":241},[27854],{"type":34,"value":337},{"type":28,"tag":192,"props":27856,"children":27857},{"style":340},[27858],{"type":34,"value":26681},{"type":28,"tag":192,"props":27860,"children":27861},{"style":226},[27862],{"type":34,"value":360},{"type":28,"tag":192,"props":27864,"children":27865},{"style":226},[27866],{"type":34,"value":229},{"type":28,"tag":192,"props":27868,"children":27869},{"class":194,"line":556},[27870],{"type":28,"tag":192,"props":27871,"children":27872},{"style":199},[27873],{"type":34,"value":27472},{"type":28,"tag":192,"props":27875,"children":27876},{"class":194,"line":564},[27877,27881,27885,27889,27893,27897,27901,27905,27909,27913],{"type":28,"tag":192,"props":27878,"children":27879},{"style":247},[27880],{"type":34,"value":4327},{"type":28,"tag":192,"props":27882,"children":27883},{"style":226},[27884],{"type":34,"value":379},{"type":28,"tag":192,"props":27886,"children":27887},{"style":247},[27888],{"type":34,"value":2673},{"type":28,"tag":192,"props":27890,"children":27891},{"style":226},[27892],{"type":34,"value":379},{"type":28,"tag":192,"props":27894,"children":27895},{"style":325},[27896],{"type":34,"value":2682},{"type":28,"tag":192,"props":27898,"children":27899},{"style":226},[27900],{"type":34,"value":332},{"type":28,"tag":192,"props":27902,"children":27903},{"style":734},[27904],{"type":34,"value":27504},{"type":28,"tag":192,"props":27906,"children":27907},{"style":387},[27908],{"type":34,"value":2696},{"type":28,"tag":192,"props":27910,"children":27911},{"style":247},[27912],{"type":34,"value":26681},{"type":28,"tag":192,"props":27914,"children":27915},{"style":226},[27916],{"type":34,"value":752},{"type":28,"tag":192,"props":27918,"children":27919},{"class":194,"line":573},[27920],{"type":28,"tag":192,"props":27921,"children":27922},{"style":226},[27923],{"type":34,"value":445},{"type":28,"tag":192,"props":27925,"children":27926},{"class":194,"line":582},[27927],{"type":28,"tag":192,"props":27928,"children":27929},{"style":226},[27930],{"type":34,"value":588},{"type":28,"tag":169,"props":27932,"children":27934},{"id":27933},"exemple-2-traitement-des-paiements",[27935],{"type":34,"value":27936},"Exemple 2 : Traitement des paiements",{"type":28,"tag":44,"props":27938,"children":27939},{},[27940,27942,27947],{"type":34,"value":27941},"Prenons l’exemple d’une classe ",{"type":28,"tag":188,"props":27943,"children":27945},{"className":27944},[],[27946],{"type":34,"value":4943},{"type":34,"value":27948}," qui viole le SRP en gérant à la fois le traitement des paiements et l’envoi des reçus.",{"type":28,"tag":181,"props":27950,"children":27952},{"className":183,"code":27951,"language":185,"meta":8,"style":8},"public class PaymentProcessor {\n    public void processPayment(String creditCard, double amount) {\n        // Logique pour traiter le paiement\n        System.out.println(\"Paiement de \" + amount + \"€ traité avec la carte \" + creditCard);\n\n        // Envoyer un reçu par email\n        sendReceipt(creditCard, amount);\n    }\n\n    private void sendReceipt(String creditCard, double amount) {\n        // Logique pour envoyer un reçu\n        System.out.println(\"Reçu envoyé pour un paiement de \" + amount + \"€.\");\n    }\n}\n",[27953],{"type":28,"tag":188,"props":27954,"children":27955},{"__ignoreMap":8},[27956,27975,28024,28032,28094,28101,28109,28137,28144,28151,28199,28207,28260,28267],{"type":28,"tag":192,"props":27957,"children":27958},{"class":194,"line":195},[27959,27963,27967,27971],{"type":28,"tag":192,"props":27960,"children":27961},{"style":209},[27962],{"type":34,"value":212},{"type":28,"tag":192,"props":27964,"children":27965},{"style":209},[27966],{"type":34,"value":217},{"type":28,"tag":192,"props":27968,"children":27969},{"style":220},[27970],{"type":34,"value":4968},{"type":28,"tag":192,"props":27972,"children":27973},{"style":226},[27974],{"type":34,"value":229},{"type":28,"tag":192,"props":27976,"children":27977},{"class":194,"line":205},[27978,27982,27986,27990,27994,27998,28003,28007,28011,28016,28020],{"type":28,"tag":192,"props":27979,"children":27980},{"style":209},[27981],{"type":34,"value":322},{"type":28,"tag":192,"props":27983,"children":27984},{"style":209},[27985],{"type":34,"value":688},{"type":28,"tag":192,"props":27987,"children":27988},{"style":325},[27989],{"type":34,"value":4988},{"type":28,"tag":192,"props":27991,"children":27992},{"style":226},[27993],{"type":34,"value":332},{"type":28,"tag":192,"props":27995,"children":27996},{"style":241},[27997],{"type":34,"value":337},{"type":28,"tag":192,"props":27999,"children":28000},{"style":340},[28001],{"type":34,"value":28002}," creditCard",{"type":28,"tag":192,"props":28004,"children":28005},{"style":226},[28006],{"type":34,"value":347},{"type":28,"tag":192,"props":28008,"children":28009},{"style":209},[28010],{"type":34,"value":1703},{"type":28,"tag":192,"props":28012,"children":28013},{"style":340},[28014],{"type":34,"value":28015}," amount",{"type":28,"tag":192,"props":28017,"children":28018},{"style":226},[28019],{"type":34,"value":360},{"type":28,"tag":192,"props":28021,"children":28022},{"style":226},[28023],{"type":34,"value":229},{"type":28,"tag":192,"props":28025,"children":28026},{"class":194,"line":232},[28027],{"type":28,"tag":192,"props":28028,"children":28029},{"style":199},[28030],{"type":34,"value":28031},"        // Logique pour traiter le paiement\n",{"type":28,"tag":192,"props":28033,"children":28034},{"class":194,"line":258},[28035,28039,28043,28047,28051,28055,28059,28064,28068,28073,28077,28082,28086,28090],{"type":28,"tag":192,"props":28036,"children":28037},{"style":247},[28038],{"type":34,"value":4327},{"type":28,"tag":192,"props":28040,"children":28041},{"style":226},[28042],{"type":34,"value":379},{"type":28,"tag":192,"props":28044,"children":28045},{"style":247},[28046],{"type":34,"value":2673},{"type":28,"tag":192,"props":28048,"children":28049},{"style":226},[28050],{"type":34,"value":379},{"type":28,"tag":192,"props":28052,"children":28053},{"style":325},[28054],{"type":34,"value":2682},{"type":28,"tag":192,"props":28056,"children":28057},{"style":226},[28058],{"type":34,"value":332},{"type":28,"tag":192,"props":28060,"children":28061},{"style":734},[28062],{"type":34,"value":28063},"\"Paiement de \"",{"type":28,"tag":192,"props":28065,"children":28066},{"style":387},[28067],{"type":34,"value":2696},{"type":28,"tag":192,"props":28069,"children":28070},{"style":247},[28071],{"type":34,"value":28072}," amount ",{"type":28,"tag":192,"props":28074,"children":28075},{"style":387},[28076],{"type":34,"value":3361},{"type":28,"tag":192,"props":28078,"children":28079},{"style":734},[28080],{"type":34,"value":28081}," \"€ traité avec la carte \"",{"type":28,"tag":192,"props":28083,"children":28084},{"style":387},[28085],{"type":34,"value":2696},{"type":28,"tag":192,"props":28087,"children":28088},{"style":247},[28089],{"type":34,"value":28002},{"type":28,"tag":192,"props":28091,"children":28092},{"style":226},[28093],{"type":34,"value":752},{"type":28,"tag":192,"props":28095,"children":28096},{"class":194,"line":280},[28097],{"type":28,"tag":192,"props":28098,"children":28099},{"emptyLinePlaceholder":13},[28100],{"type":34,"value":313},{"type":28,"tag":192,"props":28102,"children":28103},{"class":194,"line":307},[28104],{"type":28,"tag":192,"props":28105,"children":28106},{"style":199},[28107],{"type":34,"value":28108},"        // Envoyer un reçu par email\n",{"type":28,"tag":192,"props":28110,"children":28111},{"class":194,"line":316},[28112,28117,28121,28125,28129,28133],{"type":28,"tag":192,"props":28113,"children":28114},{"style":325},[28115],{"type":34,"value":28116},"        sendReceipt",{"type":28,"tag":192,"props":28118,"children":28119},{"style":226},[28120],{"type":34,"value":332},{"type":28,"tag":192,"props":28122,"children":28123},{"style":247},[28124],{"type":34,"value":5995},{"type":28,"tag":192,"props":28126,"children":28127},{"style":226},[28128],{"type":34,"value":347},{"type":28,"tag":192,"props":28130,"children":28131},{"style":247},[28132],{"type":34,"value":28015},{"type":28,"tag":192,"props":28134,"children":28135},{"style":226},[28136],{"type":34,"value":752},{"type":28,"tag":192,"props":28138,"children":28139},{"class":194,"line":367},[28140],{"type":28,"tag":192,"props":28141,"children":28142},{"style":226},[28143],{"type":34,"value":445},{"type":28,"tag":192,"props":28145,"children":28146},{"class":194,"line":401},[28147],{"type":28,"tag":192,"props":28148,"children":28149},{"emptyLinePlaceholder":13},[28150],{"type":34,"value":313},{"type":28,"tag":192,"props":28152,"children":28153},{"class":194,"line":430},[28154,28158,28162,28167,28171,28175,28179,28183,28187,28191,28195],{"type":28,"tag":192,"props":28155,"children":28156},{"style":209},[28157],{"type":34,"value":238},{"type":28,"tag":192,"props":28159,"children":28160},{"style":209},[28161],{"type":34,"value":688},{"type":28,"tag":192,"props":28163,"children":28164},{"style":325},[28165],{"type":34,"value":28166}," sendReceipt",{"type":28,"tag":192,"props":28168,"children":28169},{"style":226},[28170],{"type":34,"value":332},{"type":28,"tag":192,"props":28172,"children":28173},{"style":241},[28174],{"type":34,"value":337},{"type":28,"tag":192,"props":28176,"children":28177},{"style":340},[28178],{"type":34,"value":28002},{"type":28,"tag":192,"props":28180,"children":28181},{"style":226},[28182],{"type":34,"value":347},{"type":28,"tag":192,"props":28184,"children":28185},{"style":209},[28186],{"type":34,"value":1703},{"type":28,"tag":192,"props":28188,"children":28189},{"style":340},[28190],{"type":34,"value":28015},{"type":28,"tag":192,"props":28192,"children":28193},{"style":226},[28194],{"type":34,"value":360},{"type":28,"tag":192,"props":28196,"children":28197},{"style":226},[28198],{"type":34,"value":229},{"type":28,"tag":192,"props":28200,"children":28201},{"class":194,"line":439},[28202],{"type":28,"tag":192,"props":28203,"children":28204},{"style":199},[28205],{"type":34,"value":28206},"        // Logique pour envoyer un reçu\n",{"type":28,"tag":192,"props":28208,"children":28209},{"class":194,"line":448},[28210,28214,28218,28222,28226,28230,28234,28239,28243,28247,28251,28256],{"type":28,"tag":192,"props":28211,"children":28212},{"style":247},[28213],{"type":34,"value":4327},{"type":28,"tag":192,"props":28215,"children":28216},{"style":226},[28217],{"type":34,"value":379},{"type":28,"tag":192,"props":28219,"children":28220},{"style":247},[28221],{"type":34,"value":2673},{"type":28,"tag":192,"props":28223,"children":28224},{"style":226},[28225],{"type":34,"value":379},{"type":28,"tag":192,"props":28227,"children":28228},{"style":325},[28229],{"type":34,"value":2682},{"type":28,"tag":192,"props":28231,"children":28232},{"style":226},[28233],{"type":34,"value":332},{"type":28,"tag":192,"props":28235,"children":28236},{"style":734},[28237],{"type":34,"value":28238},"\"Reçu envoyé pour un paiement de \"",{"type":28,"tag":192,"props":28240,"children":28241},{"style":387},[28242],{"type":34,"value":2696},{"type":28,"tag":192,"props":28244,"children":28245},{"style":247},[28246],{"type":34,"value":28072},{"type":28,"tag":192,"props":28248,"children":28249},{"style":387},[28250],{"type":34,"value":3361},{"type":28,"tag":192,"props":28252,"children":28253},{"style":734},[28254],{"type":34,"value":28255}," \"€.\"",{"type":28,"tag":192,"props":28257,"children":28258},{"style":226},[28259],{"type":34,"value":752},{"type":28,"tag":192,"props":28261,"children":28262},{"class":194,"line":456},[28263],{"type":28,"tag":192,"props":28264,"children":28265},{"style":226},[28266],{"type":34,"value":445},{"type":28,"tag":192,"props":28268,"children":28269},{"class":194,"line":482},[28270],{"type":28,"tag":192,"props":28271,"children":28272},{"style":226},[28273],{"type":34,"value":588},{"type":28,"tag":44,"props":28275,"children":28276},{},[28277],{"type":34,"value":28278},"Ici, la classe gère deux responsabilités. En appliquant le SRP, on peut diviser cela en deux classes distinctes.",{"type":28,"tag":181,"props":28280,"children":28282},{"className":183,"code":28281,"language":185,"meta":8,"style":8},"public class PaymentProcessor {\n    private ReceiptSender receiptSender;\n\n    public PaymentProcessor(ReceiptSender receiptSender) {\n        this.receiptSender = receiptSender;\n    }\n\n    public void processPayment(String creditCard, double amount) {\n        // Logique pour traiter le paiement\n        System.out.println(\"Paiement de \" + amount + \"€ traité avec la carte \" + creditCard);\n\n        // Utilisation de ReceiptSender pour envoyer le reçu\n        receiptSender.sendReceipt(creditCard, amount);\n    }\n}\n\npublic class ReceiptSender {\n    public void sendReceipt(String creditCard, double amount) {\n        // Logique pour envoyer un reçu\n        System.out.println(\"Reçu envoyé pour un paiement de \" + amount + \"€.\");\n    }\n}\n",[28283],{"type":28,"tag":188,"props":28284,"children":28285},{"__ignoreMap":8},[28286,28305,28326,28333,28365,28393,28400,28407,28454,28461,28520,28527,28535,28572,28579,28586,28593,28612,28659,28666,28717,28724],{"type":28,"tag":192,"props":28287,"children":28288},{"class":194,"line":195},[28289,28293,28297,28301],{"type":28,"tag":192,"props":28290,"children":28291},{"style":209},[28292],{"type":34,"value":212},{"type":28,"tag":192,"props":28294,"children":28295},{"style":209},[28296],{"type":34,"value":217},{"type":28,"tag":192,"props":28298,"children":28299},{"style":220},[28300],{"type":34,"value":4968},{"type":28,"tag":192,"props":28302,"children":28303},{"style":226},[28304],{"type":34,"value":229},{"type":28,"tag":192,"props":28306,"children":28307},{"class":194,"line":205},[28308,28312,28317,28322],{"type":28,"tag":192,"props":28309,"children":28310},{"style":209},[28311],{"type":34,"value":238},{"type":28,"tag":192,"props":28313,"children":28314},{"style":241},[28315],{"type":34,"value":28316}," ReceiptSender",{"type":28,"tag":192,"props":28318,"children":28319},{"style":247},[28320],{"type":34,"value":28321}," receiptSender",{"type":28,"tag":192,"props":28323,"children":28324},{"style":226},[28325],{"type":34,"value":255},{"type":28,"tag":192,"props":28327,"children":28328},{"class":194,"line":232},[28329],{"type":28,"tag":192,"props":28330,"children":28331},{"emptyLinePlaceholder":13},[28332],{"type":34,"value":313},{"type":28,"tag":192,"props":28334,"children":28335},{"class":194,"line":258},[28336,28340,28344,28348,28353,28357,28361],{"type":28,"tag":192,"props":28337,"children":28338},{"style":209},[28339],{"type":34,"value":322},{"type":28,"tag":192,"props":28341,"children":28342},{"style":325},[28343],{"type":34,"value":4968},{"type":28,"tag":192,"props":28345,"children":28346},{"style":226},[28347],{"type":34,"value":332},{"type":28,"tag":192,"props":28349,"children":28350},{"style":241},[28351],{"type":34,"value":28352},"ReceiptSender",{"type":28,"tag":192,"props":28354,"children":28355},{"style":340},[28356],{"type":34,"value":28321},{"type":28,"tag":192,"props":28358,"children":28359},{"style":226},[28360],{"type":34,"value":360},{"type":28,"tag":192,"props":28362,"children":28363},{"style":226},[28364],{"type":34,"value":229},{"type":28,"tag":192,"props":28366,"children":28367},{"class":194,"line":280},[28368,28372,28376,28381,28385,28389],{"type":28,"tag":192,"props":28369,"children":28370},{"style":371},[28371],{"type":34,"value":374},{"type":28,"tag":192,"props":28373,"children":28374},{"style":226},[28375],{"type":34,"value":379},{"type":28,"tag":192,"props":28377,"children":28378},{"style":247},[28379],{"type":34,"value":28380},"receiptSender ",{"type":28,"tag":192,"props":28382,"children":28383},{"style":387},[28384],{"type":34,"value":390},{"type":28,"tag":192,"props":28386,"children":28387},{"style":247},[28388],{"type":34,"value":28321},{"type":28,"tag":192,"props":28390,"children":28391},{"style":226},[28392],{"type":34,"value":255},{"type":28,"tag":192,"props":28394,"children":28395},{"class":194,"line":307},[28396],{"type":28,"tag":192,"props":28397,"children":28398},{"style":226},[28399],{"type":34,"value":445},{"type":28,"tag":192,"props":28401,"children":28402},{"class":194,"line":316},[28403],{"type":28,"tag":192,"props":28404,"children":28405},{"emptyLinePlaceholder":13},[28406],{"type":34,"value":313},{"type":28,"tag":192,"props":28408,"children":28409},{"class":194,"line":367},[28410,28414,28418,28422,28426,28430,28434,28438,28442,28446,28450],{"type":28,"tag":192,"props":28411,"children":28412},{"style":209},[28413],{"type":34,"value":322},{"type":28,"tag":192,"props":28415,"children":28416},{"style":209},[28417],{"type":34,"value":688},{"type":28,"tag":192,"props":28419,"children":28420},{"style":325},[28421],{"type":34,"value":4988},{"type":28,"tag":192,"props":28423,"children":28424},{"style":226},[28425],{"type":34,"value":332},{"type":28,"tag":192,"props":28427,"children":28428},{"style":241},[28429],{"type":34,"value":337},{"type":28,"tag":192,"props":28431,"children":28432},{"style":340},[28433],{"type":34,"value":28002},{"type":28,"tag":192,"props":28435,"children":28436},{"style":226},[28437],{"type":34,"value":347},{"type":28,"tag":192,"props":28439,"children":28440},{"style":209},[28441],{"type":34,"value":1703},{"type":28,"tag":192,"props":28443,"children":28444},{"style":340},[28445],{"type":34,"value":28015},{"type":28,"tag":192,"props":28447,"children":28448},{"style":226},[28449],{"type":34,"value":360},{"type":28,"tag":192,"props":28451,"children":28452},{"style":226},[28453],{"type":34,"value":229},{"type":28,"tag":192,"props":28455,"children":28456},{"class":194,"line":401},[28457],{"type":28,"tag":192,"props":28458,"children":28459},{"style":199},[28460],{"type":34,"value":28031},{"type":28,"tag":192,"props":28462,"children":28463},{"class":194,"line":430},[28464,28468,28472,28476,28480,28484,28488,28492,28496,28500,28504,28508,28512,28516],{"type":28,"tag":192,"props":28465,"children":28466},{"style":247},[28467],{"type":34,"value":4327},{"type":28,"tag":192,"props":28469,"children":28470},{"style":226},[28471],{"type":34,"value":379},{"type":28,"tag":192,"props":28473,"children":28474},{"style":247},[28475],{"type":34,"value":2673},{"type":28,"tag":192,"props":28477,"children":28478},{"style":226},[28479],{"type":34,"value":379},{"type":28,"tag":192,"props":28481,"children":28482},{"style":325},[28483],{"type":34,"value":2682},{"type":28,"tag":192,"props":28485,"children":28486},{"style":226},[28487],{"type":34,"value":332},{"type":28,"tag":192,"props":28489,"children":28490},{"style":734},[28491],{"type":34,"value":28063},{"type":28,"tag":192,"props":28493,"children":28494},{"style":387},[28495],{"type":34,"value":2696},{"type":28,"tag":192,"props":28497,"children":28498},{"style":247},[28499],{"type":34,"value":28072},{"type":28,"tag":192,"props":28501,"children":28502},{"style":387},[28503],{"type":34,"value":3361},{"type":28,"tag":192,"props":28505,"children":28506},{"style":734},[28507],{"type":34,"value":28081},{"type":28,"tag":192,"props":28509,"children":28510},{"style":387},[28511],{"type":34,"value":2696},{"type":28,"tag":192,"props":28513,"children":28514},{"style":247},[28515],{"type":34,"value":28002},{"type":28,"tag":192,"props":28517,"children":28518},{"style":226},[28519],{"type":34,"value":752},{"type":28,"tag":192,"props":28521,"children":28522},{"class":194,"line":439},[28523],{"type":28,"tag":192,"props":28524,"children":28525},{"emptyLinePlaceholder":13},[28526],{"type":34,"value":313},{"type":28,"tag":192,"props":28528,"children":28529},{"class":194,"line":448},[28530],{"type":28,"tag":192,"props":28531,"children":28532},{"style":199},[28533],{"type":34,"value":28534},"        // Utilisation de ReceiptSender pour envoyer le reçu\n",{"type":28,"tag":192,"props":28536,"children":28537},{"class":194,"line":456},[28538,28543,28547,28552,28556,28560,28564,28568],{"type":28,"tag":192,"props":28539,"children":28540},{"style":247},[28541],{"type":34,"value":28542},"        receiptSender",{"type":28,"tag":192,"props":28544,"children":28545},{"style":226},[28546],{"type":34,"value":379},{"type":28,"tag":192,"props":28548,"children":28549},{"style":325},[28550],{"type":34,"value":28551},"sendReceipt",{"type":28,"tag":192,"props":28553,"children":28554},{"style":226},[28555],{"type":34,"value":332},{"type":28,"tag":192,"props":28557,"children":28558},{"style":247},[28559],{"type":34,"value":5995},{"type":28,"tag":192,"props":28561,"children":28562},{"style":226},[28563],{"type":34,"value":347},{"type":28,"tag":192,"props":28565,"children":28566},{"style":247},[28567],{"type":34,"value":28015},{"type":28,"tag":192,"props":28569,"children":28570},{"style":226},[28571],{"type":34,"value":752},{"type":28,"tag":192,"props":28573,"children":28574},{"class":194,"line":482},[28575],{"type":28,"tag":192,"props":28576,"children":28577},{"style":226},[28578],{"type":34,"value":445},{"type":28,"tag":192,"props":28580,"children":28581},{"class":194,"line":499},[28582],{"type":28,"tag":192,"props":28583,"children":28584},{"style":226},[28585],{"type":34,"value":588},{"type":28,"tag":192,"props":28587,"children":28588},{"class":194,"line":507},[28589],{"type":28,"tag":192,"props":28590,"children":28591},{"emptyLinePlaceholder":13},[28592],{"type":34,"value":313},{"type":28,"tag":192,"props":28594,"children":28595},{"class":194,"line":515},[28596,28600,28604,28608],{"type":28,"tag":192,"props":28597,"children":28598},{"style":209},[28599],{"type":34,"value":212},{"type":28,"tag":192,"props":28601,"children":28602},{"style":209},[28603],{"type":34,"value":217},{"type":28,"tag":192,"props":28605,"children":28606},{"style":220},[28607],{"type":34,"value":28316},{"type":28,"tag":192,"props":28609,"children":28610},{"style":226},[28611],{"type":34,"value":229},{"type":28,"tag":192,"props":28613,"children":28614},{"class":194,"line":540},[28615,28619,28623,28627,28631,28635,28639,28643,28647,28651,28655],{"type":28,"tag":192,"props":28616,"children":28617},{"style":209},[28618],{"type":34,"value":322},{"type":28,"tag":192,"props":28620,"children":28621},{"style":209},[28622],{"type":34,"value":688},{"type":28,"tag":192,"props":28624,"children":28625},{"style":325},[28626],{"type":34,"value":28166},{"type":28,"tag":192,"props":28628,"children":28629},{"style":226},[28630],{"type":34,"value":332},{"type":28,"tag":192,"props":28632,"children":28633},{"style":241},[28634],{"type":34,"value":337},{"type":28,"tag":192,"props":28636,"children":28637},{"style":340},[28638],{"type":34,"value":28002},{"type":28,"tag":192,"props":28640,"children":28641},{"style":226},[28642],{"type":34,"value":347},{"type":28,"tag":192,"props":28644,"children":28645},{"style":209},[28646],{"type":34,"value":1703},{"type":28,"tag":192,"props":28648,"children":28649},{"style":340},[28650],{"type":34,"value":28015},{"type":28,"tag":192,"props":28652,"children":28653},{"style":226},[28654],{"type":34,"value":360},{"type":28,"tag":192,"props":28656,"children":28657},{"style":226},[28658],{"type":34,"value":229},{"type":28,"tag":192,"props":28660,"children":28661},{"class":194,"line":556},[28662],{"type":28,"tag":192,"props":28663,"children":28664},{"style":199},[28665],{"type":34,"value":28206},{"type":28,"tag":192,"props":28667,"children":28668},{"class":194,"line":564},[28669,28673,28677,28681,28685,28689,28693,28697,28701,28705,28709,28713],{"type":28,"tag":192,"props":28670,"children":28671},{"style":247},[28672],{"type":34,"value":4327},{"type":28,"tag":192,"props":28674,"children":28675},{"style":226},[28676],{"type":34,"value":379},{"type":28,"tag":192,"props":28678,"children":28679},{"style":247},[28680],{"type":34,"value":2673},{"type":28,"tag":192,"props":28682,"children":28683},{"style":226},[28684],{"type":34,"value":379},{"type":28,"tag":192,"props":28686,"children":28687},{"style":325},[28688],{"type":34,"value":2682},{"type":28,"tag":192,"props":28690,"children":28691},{"style":226},[28692],{"type":34,"value":332},{"type":28,"tag":192,"props":28694,"children":28695},{"style":734},[28696],{"type":34,"value":28238},{"type":28,"tag":192,"props":28698,"children":28699},{"style":387},[28700],{"type":34,"value":2696},{"type":28,"tag":192,"props":28702,"children":28703},{"style":247},[28704],{"type":34,"value":28072},{"type":28,"tag":192,"props":28706,"children":28707},{"style":387},[28708],{"type":34,"value":3361},{"type":28,"tag":192,"props":28710,"children":28711},{"style":734},[28712],{"type":34,"value":28255},{"type":28,"tag":192,"props":28714,"children":28715},{"style":226},[28716],{"type":34,"value":752},{"type":28,"tag":192,"props":28718,"children":28719},{"class":194,"line":573},[28720],{"type":28,"tag":192,"props":28721,"children":28722},{"style":226},[28723],{"type":34,"value":445},{"type":28,"tag":192,"props":28725,"children":28726},{"class":194,"line":582},[28727],{"type":28,"tag":192,"props":28728,"children":28729},{"style":226},[28730],{"type":34,"value":588},{"type":28,"tag":83,"props":28732,"children":28733},{},[],{"type":28,"tag":29,"props":28735,"children":28737},{"id":28736},"les-avantages-pratiques-du-srp",[28738],{"type":34,"value":28739},"Les avantages pratiques du SRP",{"type":28,"tag":44,"props":28741,"children":28742},{},[28743],{"type":34,"value":28744},"Appliquer le SRP apporte plusieurs avantages concrets :",{"type":28,"tag":144,"props":28746,"children":28747},{},[28748,28758,28768,28778,28788],{"type":28,"tag":148,"props":28749,"children":28750},{},[28751,28756],{"type":28,"tag":55,"props":28752,"children":28753},{},[28754],{"type":34,"value":28755},"Lisibilité accrue",{"type":34,"value":28757}," : chaque classe porte une seule tâche, la compréhension du code est immédiate.",{"type":28,"tag":148,"props":28759,"children":28760},{},[28761,28766],{"type":28,"tag":55,"props":28762,"children":28763},{},[28764],{"type":34,"value":28765},"Maintenance et évolutions",{"type":34,"value":28767}," : modifier une fonctionnalité n'impacte plus le reste du système.",{"type":28,"tag":148,"props":28769,"children":28770},{},[28771,28776],{"type":28,"tag":55,"props":28772,"children":28773},{},[28774],{"type":34,"value":28775},"Tests unitaires plus simples",{"type":34,"value":28777}," : responsabilité unique = peu de dépendances à mocker.",{"type":28,"tag":148,"props":28779,"children":28780},{},[28781,28786],{"type":28,"tag":55,"props":28782,"children":28783},{},[28784],{"type":34,"value":28785},"Couplage réduit",{"type":34,"value":28787}," : le découpage des responsabilités casse les dépendances entre composants.",{"type":28,"tag":148,"props":28789,"children":28790},{},[28791,28796],{"type":28,"tag":55,"props":28792,"children":28793},{},[28794],{"type":34,"value":28795},"Réutilisabilité accrue",{"type":34,"value":28797}," : les classes spécialisées trouvent leur place dans d'autres projets.",{"type":28,"tag":29,"props":28799,"children":28801},{"id":28800},"quand-et-pourquoi-le-srp-peut-poser-des-défis",[28802],{"type":34,"value":28803},"Quand et pourquoi le SRP peut poser des défis",{"type":28,"tag":37,"props":28805,"children":28807},{"id":28806},"risque-de-sur-fragmentation",[28808],{"type":34,"value":28809},"Risque de sur-fragmentation",{"type":28,"tag":44,"props":28811,"children":28812},{},[28813],{"type":34,"value":28814},"Un SRP appliqué de manière dogmatique éclate le code en trop de classes et rend la navigation pénible. Cherchez l'équilibre : un cluster cohérent vaut mieux qu'une poussière de mini-classes.",{"type":28,"tag":37,"props":28816,"children":28818},{"id":28817},"complexité-dans-les-petites-applications",[28819],{"type":34,"value":28820},"Complexité dans les petites applications",{"type":28,"tag":44,"props":28822,"children":28823},{},[28824],{"type":34,"value":28825},"Sur un prototype ou un petit projet, suivre rigoureusement le SRP ralentit le développement. C'est parfois acceptable de ne pas l'appliquer strictement quand le code restera simple ou temporaire.",{"type":28,"tag":37,"props":28827,"children":28829},{"id":28828},"difficulté-à-identifier-les-responsabilités",[28830],{"type":34,"value":28831},"Difficulté à identifier les responsabilités",{"type":28,"tag":44,"props":28833,"children":28834},{},[28835],{"type":34,"value":28836},"Les frontières entre responsabilités sont parfois floues. Posez-vous la question : \"Pourquoi cette classe pourrait-elle changer ?\" Si la réponse contient plusieurs axes, vous tenez probablement une violation du SRP.",{"type":28,"tag":37,"props":28838,"children":28840},{"id":28839},"refactorisation-dans-les-projets-existants",[28841],{"type":34,"value":28842},"Refactorisation dans les projets existants",{"type":28,"tag":44,"props":28844,"children":28845},{},[28846],{"type":34,"value":28847},"Appliquer le SRP à un projet existant chargé de dette technique demande une refactorisation lourde. Procédez par paliers : chaque classe découpée est un gain isolé, n'essayez pas de tout corriger d'un coup.",{"type":28,"tag":120,"props":28849,"children":28851},{"cta":1327,"href":1328,"title":28850,"type":1330},"Le SRP n'est qu'une pratique parmi 100 pour coder propre",[28852],{"type":28,"tag":44,"props":28853,"children":28854},{},[28855],{"type":34,"value":28856},"Savoir découper une classe selon ses responsabilités, c'est une des pratiques craft que j'applique au quotidien. Le Craft Bundle réunit les 100 que j'utilise pour écrire un code propre et maintenable, du SRP au reste. Ce sont les pratiques que l'IA ne vous apprendra jamais, parce qu'elle ne les a jamais vues tenir un projet sur la durée.",{"type":28,"tag":83,"props":28858,"children":28859},{},[],{"type":28,"tag":29,"props":28861,"children":28863},{"id":28862},"faq-questions-fréquemment-posées-sur-le-srp",[28864],{"type":34,"value":28865},"FAQ : Questions fréquemment posées sur le SRP",{"type":28,"tag":1347,"props":28867,"children":28868},{},[28869,28874],{"type":28,"tag":1351,"props":28870,"children":28871},{},[28872],{"type":34,"value":28873},"1. Qu’est-ce que le principe de responsabilité unique (SRP) ?",{"type":28,"tag":44,"props":28875,"children":28876},{},[28877],{"type":34,"value":28878},"Le SRP stipule qu’une classe ne doit avoir qu’une seule responsabilité, c’est-à-dire qu’elle ne devrait avoir qu’une seule raison de changer.",{"type":28,"tag":1347,"props":28880,"children":28881},{},[28882,28887],{"type":28,"tag":1351,"props":28883,"children":28884},{},[28885],{"type":34,"value":28886},"2. Pourquoi est-il important de suivre le SRP ?",{"type":28,"tag":44,"props":28888,"children":28889},{},[28890],{"type":34,"value":28891},"Le SRP améliore la lisibilité, la maintenabilité et la testabilité du code, et réduit le couplage entre composants.",{"type":28,"tag":1347,"props":28893,"children":28894},{},[28895,28900],{"type":28,"tag":1351,"props":28896,"children":28897},{},[28898],{"type":34,"value":28899},"3. Comment savoir si une classe viole le SRP ?",{"type":28,"tag":44,"props":28901,"children":28902},{},[28903],{"type":34,"value":28904},"Si une classe a plusieurs responsabilités ou plusieurs raisons de changer, elle viole probablement le SRP.",{"type":28,"tag":1347,"props":28906,"children":28907},{},[28908,28913],{"type":28,"tag":1351,"props":28909,"children":28910},{},[28911],{"type":34,"value":28912},"4. Le SRP n’augmente-t-il pas le nombre de classes et la complexité du projet ?",{"type":28,"tag":44,"props":28914,"children":28915},{},[28916],{"type":34,"value":28917},"Le SRP augmente effectivement le nombre de classes, mais chaque classe devient triviale à comprendre, et le projet, plus simple à maintenir.",{"type":28,"tag":1347,"props":28919,"children":28920},{},[28921,28926],{"type":28,"tag":1351,"props":28922,"children":28923},{},[28924],{"type":34,"value":28925},"5. Dois-je toujours appliquer le SRP, même dans les petits projets ?",{"type":28,"tag":44,"props":28927,"children":28928},{},[28929],{"type":34,"value":28930},"Dans de petits projets ou prototypes, il est acceptable de ne pas appliquer strictement le SRP dès le début, mais le principe devient crucial à mesure que le projet évolue.",{"type":28,"tag":83,"props":28932,"children":28933},{},[],{"type":28,"tag":120,"props":28935,"children":28936},{"cta":1444,"href":1445,"title":1446,"type":1447},[28937],{"type":28,"tag":44,"props":28938,"children":28939},{},[28940],{"type":34,"value":10072},{"type":28,"tag":1455,"props":28942,"children":28943},{},[28944],{"type":34,"value":1459},{"title":8,"searchDepth":205,"depth":205,"links":28946},[28947,28948,28949,28952,28953,28959],{"id":26545,"depth":205,"text":26548},{"id":26595,"depth":205,"text":26598},{"id":27187,"depth":205,"text":27190,"children":28950},[28951],{"id":27239,"depth":232,"text":27242},{"id":28736,"depth":205,"text":28739},{"id":28800,"depth":205,"text":28803,"children":28954},[28955,28956,28957,28958],{"id":28806,"depth":232,"text":28809},{"id":28817,"depth":232,"text":28820},{"id":28828,"depth":232,"text":28831},{"id":28839,"depth":232,"text":28842},{"id":28862,"depth":205,"text":28865},"content:fr:architecture-craft:principe-srp-software-craftsmanship-exemples-java.md","fr/architecture-craft/principe-srp-software-craftsmanship-exemples-java.md","fr/architecture-craft/principe-srp-software-craftsmanship-exemples-java",1782669335795]