[{"data":1,"prerenderedAt":40309},["ShallowReactive",2],{"search-api":-1,"listing-tag-solid-page-1":3},[4,5783,8445,10112,10525,15682,16936,19382,25466,28814,31644,35766,37880],{"_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":19,"readingTime":20,"body":25,"_type":5777,"_id":5778,"_source":5779,"_file":5780,"_stem":5781,"_extension":5782},"\u002Ffr\u002Farchitecture-craft\u002Fdependency-inversion-pratique","architecture-craft",false,"","Dependency Inversion Principle : 3 exemples concrets","Le DIP est le principe SOLID le plus mal compris. Pas un pattern de conception, mais une règle sur la direction des dépendances. Trois implémentations Java concrètes.",30,"2026-03-13",true,[6],[16,17,18],"solid","architecture","clean-code","covers\u002Farticles\u002Fdependency-inversion-principe.jpg",{"text":21,"minutes":22,"time":23,"words":24},"9 min read",8.44,506400,1688,{"type":26,"children":27,"toc":5768},"root",[28,36,41,46,50,57,71,76,443,452,500,503,509,553,561,566,569,575,1617,1625,2287,2300,2303,2309,4590,4623,4626,4632,5527,5545,5548,5554,5562,5580,5588,5606,5624,5627,5639,5642,5648,5663,5676,5689,5710,5747,5750,5762],{"type":29,"tag":30,"props":31,"children":32},"element","p",{},[33],{"type":34,"value":35},"text","Chez un client dans le secteur de l'assurance que j'accompagnais (20 développeurs, 8 services backend), la suite de tests prenait 18 minutes à s'exécuter. Pas parce que les tests étaient lents. Parce que chaque test unitaire démarrait une vraie base de données PostgreSQL, un vrai serveur Redis, et appelait le vrai Sendgrid.",{"type":29,"tag":30,"props":37,"children":38},{},[39],{"type":34,"value":40},"Ce n'était pas un problème de tests. C'était un problème d'architecture : les modules métier dépendaient directement des implémentations concrètes d'infrastructure.",{"type":29,"tag":30,"props":42,"children":43},{},[44],{"type":34,"value":45},"Après avoir introduit le Dependency Inversion Principle sur les 8 services les plus critiques, la suite de tests est passée à 3 minutes. La couverture de tests a augmenté de 35% à 72% en 3 mois. Pas parce que les développeurs avaient soudain envie d'écrire des tests, mais parce que les tests étaient devenus faciles à écrire.",{"type":29,"tag":47,"props":48,"children":49},"hr",{},[],{"type":29,"tag":51,"props":52,"children":54},"h2",{"id":53},"le-problème-la-dépendance-directe",[55],{"type":34,"value":56},"Le problème : la dépendance directe",{"type":29,"tag":30,"props":58,"children":59},{},[60,62,69],{"type":34,"value":61},"Robert C. Martin (Uncle Bob) a formulé le DIP en 1996 dans ses travaux sur les principes SOLID : \"Les modules de haut niveau ne doivent pas dépendre des modules de bas niveau. Les deux doivent dépendre d'abstractions.\" C'est la règle de dépendance au cœur de la ",{"type":29,"tag":63,"props":64,"children":66},"a",{"href":65},"\u002Ffr\u002Farchitecture-craft\u002Fclean-architecture-3-regles",[67],{"type":34,"value":68},"Clean Architecture",{"type":34,"value":70}," : les flèches de dépendance doivent toujours pointer vers l'intérieur, vers le domaine métier.",{"type":29,"tag":30,"props":72,"children":73},{},[74],{"type":34,"value":75},"En pratique, la quasi-totalité des codebases sans discipline architecturale viole ce principe :",{"type":29,"tag":77,"props":78,"children":82},"pre",{"code":79,"language":80,"meta":8,"className":81,"style":8},"\u002F\u002F Violation du DIP : le module de haut niveau dépend des implémentations concrètes\npublic class OrderService {\n\n    private final PostgresDatabase db = new PostgresDatabase(\"localhost\", 5432); \u002F\u002F dépendance directe\n    private final SendgridEmailClient email = new SendgridEmailClient(\"api-key\"); \u002F\u002F dépendance directe\n\n    public String createOrder(OrderData orderData) {\n        String orderId = db.save(orderData);\n        email.sendConfirmation(orderData.getEmail(), orderId);\n        return orderId;\n    }\n}\n","java","language-java shiki shiki-themes catppuccin-frappe github-dark",[83],{"type":29,"tag":84,"props":85,"children":86},"code",{"__ignoreMap":8},[87,99,126,135,209,260,268,311,358,407,425,434],{"type":29,"tag":88,"props":89,"children":92},"span",{"class":90,"line":91},"line",1,[93],{"type":29,"tag":88,"props":94,"children":96},{"style":95},"--shiki-default:#737994;--shiki-default-font-style:italic;--shiki-dark:#6A737D;--shiki-dark-font-style:inherit",[97],{"type":34,"value":98},"\u002F\u002F Violation du DIP : le module de haut niveau dépend des implémentations concrètes\n",{"type":29,"tag":88,"props":100,"children":102},{"class":90,"line":101},2,[103,109,114,120],{"type":29,"tag":88,"props":104,"children":106},{"style":105},"--shiki-default:#CA9EE6;--shiki-dark:#F97583",[107],{"type":34,"value":108},"public",{"type":29,"tag":88,"props":110,"children":111},{"style":105},[112],{"type":34,"value":113}," class",{"type":29,"tag":88,"props":115,"children":117},{"style":116},"--shiki-default:#E5C890;--shiki-default-font-style:italic;--shiki-dark:#B392F0;--shiki-dark-font-style:inherit",[118],{"type":34,"value":119}," OrderService",{"type":29,"tag":88,"props":121,"children":123},{"style":122},"--shiki-default:#949CBB;--shiki-dark:#E1E4E8",[124],{"type":34,"value":125}," {\n",{"type":29,"tag":88,"props":127,"children":129},{"class":90,"line":128},3,[130],{"type":29,"tag":88,"props":131,"children":132},{"emptyLinePlaceholder":13},[133],{"type":34,"value":134},"\n",{"type":29,"tag":88,"props":136,"children":138},{"class":90,"line":137},4,[139,144,149,155,161,167,172,177,182,188,193,199,204],{"type":29,"tag":88,"props":140,"children":141},{"style":105},[142],{"type":34,"value":143},"    private",{"type":29,"tag":88,"props":145,"children":146},{"style":105},[147],{"type":34,"value":148}," final",{"type":29,"tag":88,"props":150,"children":152},{"style":151},"--shiki-default:#CA9EE6;--shiki-dark:#E1E4E8",[153],{"type":34,"value":154}," PostgresDatabase",{"type":29,"tag":88,"props":156,"children":158},{"style":157},"--shiki-default:#C6D0F5;--shiki-dark:#E1E4E8",[159],{"type":34,"value":160}," db ",{"type":29,"tag":88,"props":162,"children":164},{"style":163},"--shiki-default:#81C8BE;--shiki-dark:#F97583",[165],{"type":34,"value":166},"=",{"type":29,"tag":88,"props":168,"children":169},{"style":105},[170],{"type":34,"value":171}," new",{"type":29,"tag":88,"props":173,"children":175},{"style":174},"--shiki-default:#8CAAEE;--shiki-default-font-style:italic;--shiki-dark:#B392F0;--shiki-dark-font-style:inherit",[176],{"type":34,"value":154},{"type":29,"tag":88,"props":178,"children":179},{"style":122},[180],{"type":34,"value":181},"(",{"type":29,"tag":88,"props":183,"children":185},{"style":184},"--shiki-default:#A6D189;--shiki-dark:#9ECBFF",[186],{"type":34,"value":187},"\"localhost\"",{"type":29,"tag":88,"props":189,"children":190},{"style":122},[191],{"type":34,"value":192},",",{"type":29,"tag":88,"props":194,"children":196},{"style":195},"--shiki-default:#EF9F76;--shiki-dark:#79B8FF",[197],{"type":34,"value":198}," 5432",{"type":29,"tag":88,"props":200,"children":201},{"style":122},[202],{"type":34,"value":203},");",{"type":29,"tag":88,"props":205,"children":206},{"style":95},[207],{"type":34,"value":208}," \u002F\u002F dépendance directe\n",{"type":29,"tag":88,"props":210,"children":212},{"class":90,"line":211},5,[213,217,221,226,231,235,239,243,247,252,256],{"type":29,"tag":88,"props":214,"children":215},{"style":105},[216],{"type":34,"value":143},{"type":29,"tag":88,"props":218,"children":219},{"style":105},[220],{"type":34,"value":148},{"type":29,"tag":88,"props":222,"children":223},{"style":151},[224],{"type":34,"value":225}," SendgridEmailClient",{"type":29,"tag":88,"props":227,"children":228},{"style":157},[229],{"type":34,"value":230}," email ",{"type":29,"tag":88,"props":232,"children":233},{"style":163},[234],{"type":34,"value":166},{"type":29,"tag":88,"props":236,"children":237},{"style":105},[238],{"type":34,"value":171},{"type":29,"tag":88,"props":240,"children":241},{"style":174},[242],{"type":34,"value":225},{"type":29,"tag":88,"props":244,"children":245},{"style":122},[246],{"type":34,"value":181},{"type":29,"tag":88,"props":248,"children":249},{"style":184},[250],{"type":34,"value":251},"\"api-key\"",{"type":29,"tag":88,"props":253,"children":254},{"style":122},[255],{"type":34,"value":203},{"type":29,"tag":88,"props":257,"children":258},{"style":95},[259],{"type":34,"value":208},{"type":29,"tag":88,"props":261,"children":263},{"class":90,"line":262},6,[264],{"type":29,"tag":88,"props":265,"children":266},{"emptyLinePlaceholder":13},[267],{"type":34,"value":134},{"type":29,"tag":88,"props":269,"children":271},{"class":90,"line":270},7,[272,277,282,287,291,296,302,307],{"type":29,"tag":88,"props":273,"children":274},{"style":105},[275],{"type":34,"value":276},"    public",{"type":29,"tag":88,"props":278,"children":279},{"style":151},[280],{"type":34,"value":281}," String",{"type":29,"tag":88,"props":283,"children":284},{"style":174},[285],{"type":34,"value":286}," createOrder",{"type":29,"tag":88,"props":288,"children":289},{"style":122},[290],{"type":34,"value":181},{"type":29,"tag":88,"props":292,"children":293},{"style":151},[294],{"type":34,"value":295},"OrderData",{"type":29,"tag":88,"props":297,"children":299},{"style":298},"--shiki-default:#EA999C;--shiki-default-font-style:italic;--shiki-dark:#FFAB70;--shiki-dark-font-style:inherit",[300],{"type":34,"value":301}," orderData",{"type":29,"tag":88,"props":303,"children":304},{"style":122},[305],{"type":34,"value":306},")",{"type":29,"tag":88,"props":308,"children":309},{"style":122},[310],{"type":34,"value":125},{"type":29,"tag":88,"props":312,"children":314},{"class":90,"line":313},8,[315,320,325,329,334,339,344,348,353],{"type":29,"tag":88,"props":316,"children":317},{"style":151},[318],{"type":34,"value":319},"        String",{"type":29,"tag":88,"props":321,"children":322},{"style":157},[323],{"type":34,"value":324}," orderId ",{"type":29,"tag":88,"props":326,"children":327},{"style":163},[328],{"type":34,"value":166},{"type":29,"tag":88,"props":330,"children":331},{"style":157},[332],{"type":34,"value":333}," db",{"type":29,"tag":88,"props":335,"children":336},{"style":122},[337],{"type":34,"value":338},".",{"type":29,"tag":88,"props":340,"children":341},{"style":174},[342],{"type":34,"value":343},"save",{"type":29,"tag":88,"props":345,"children":346},{"style":122},[347],{"type":34,"value":181},{"type":29,"tag":88,"props":349,"children":350},{"style":157},[351],{"type":34,"value":352},"orderData",{"type":29,"tag":88,"props":354,"children":355},{"style":122},[356],{"type":34,"value":357},");\n",{"type":29,"tag":88,"props":359,"children":361},{"class":90,"line":360},9,[362,367,371,376,380,384,388,393,398,403],{"type":29,"tag":88,"props":363,"children":364},{"style":157},[365],{"type":34,"value":366},"        email",{"type":29,"tag":88,"props":368,"children":369},{"style":122},[370],{"type":34,"value":338},{"type":29,"tag":88,"props":372,"children":373},{"style":174},[374],{"type":34,"value":375},"sendConfirmation",{"type":29,"tag":88,"props":377,"children":378},{"style":122},[379],{"type":34,"value":181},{"type":29,"tag":88,"props":381,"children":382},{"style":157},[383],{"type":34,"value":352},{"type":29,"tag":88,"props":385,"children":386},{"style":122},[387],{"type":34,"value":338},{"type":29,"tag":88,"props":389,"children":390},{"style":174},[391],{"type":34,"value":392},"getEmail",{"type":29,"tag":88,"props":394,"children":395},{"style":122},[396],{"type":34,"value":397},"(),",{"type":29,"tag":88,"props":399,"children":400},{"style":157},[401],{"type":34,"value":402}," orderId",{"type":29,"tag":88,"props":404,"children":405},{"style":122},[406],{"type":34,"value":357},{"type":29,"tag":88,"props":408,"children":410},{"class":90,"line":409},10,[411,416,420],{"type":29,"tag":88,"props":412,"children":413},{"style":105},[414],{"type":34,"value":415},"        return",{"type":29,"tag":88,"props":417,"children":418},{"style":157},[419],{"type":34,"value":402},{"type":29,"tag":88,"props":421,"children":422},{"style":122},[423],{"type":34,"value":424},";\n",{"type":29,"tag":88,"props":426,"children":428},{"class":90,"line":427},11,[429],{"type":29,"tag":88,"props":430,"children":431},{"style":122},[432],{"type":34,"value":433},"    }\n",{"type":29,"tag":88,"props":435,"children":437},{"class":90,"line":436},12,[438],{"type":29,"tag":88,"props":439,"children":440},{"style":122},[441],{"type":34,"value":442},"}\n",{"type":29,"tag":30,"props":444,"children":445},{},[446],{"type":29,"tag":447,"props":448,"children":449},"strong",{},[450],{"type":34,"value":451},"Ce que ça coûte concrètement :",{"type":29,"tag":453,"props":454,"children":455},"ul",{},[456,470,480,490],{"type":29,"tag":457,"props":458,"children":459},"li",{},[460,462,468],{"type":34,"value":461},"Impossible de tester ",{"type":29,"tag":84,"props":463,"children":465},{"className":464},[],[466],{"type":34,"value":467},"OrderService",{"type":34,"value":469}," sans une vraie base de données PostgreSQL et un compte Sendgrid",{"type":29,"tag":457,"props":471,"children":472},{},[473,475],{"type":34,"value":474},"Changer de base de données oblige à modifier ",{"type":29,"tag":84,"props":476,"children":478},{"className":477},[],[479],{"type":34,"value":467},{"type":29,"tag":457,"props":481,"children":482},{},[483,485],{"type":34,"value":484},"Changer d'email provider oblige à modifier ",{"type":29,"tag":84,"props":486,"children":488},{"className":487},[],[489],{"type":34,"value":467},{"type":29,"tag":457,"props":491,"children":492},{},[493,498],{"type":29,"tag":84,"props":494,"children":496},{"className":495},[],[497],{"type":34,"value":467},{"type":34,"value":499}," connaît des détails d'implémentation (host, port, api_key) qui n'ont rien à voir avec la logique métier de commande",{"type":29,"tag":47,"props":501,"children":502},{},[],{"type":29,"tag":51,"props":504,"children":506},{"id":505},"le-principe-inverser-la-direction-des-dépendances",[507],{"type":34,"value":508},"Le principe : inverser la direction des dépendances",{"type":29,"tag":30,"props":510,"children":511},{},[512,514,519,521,527,529,535,537,543,545,551],{"type":34,"value":513},"La solution DIP : ",{"type":29,"tag":84,"props":515,"children":517},{"className":516},[],[518],{"type":34,"value":467},{"type":34,"value":520}," ne dépend pas de ",{"type":29,"tag":84,"props":522,"children":524},{"className":523},[],[525],{"type":34,"value":526},"PostgreSQLDatabase",{"type":34,"value":528}," ni de ",{"type":29,"tag":84,"props":530,"children":532},{"className":531},[],[533],{"type":34,"value":534},"SendgridEmailClient",{"type":34,"value":536},". Il dépend d'abstractions (",{"type":29,"tag":84,"props":538,"children":540},{"className":539},[],[541],{"type":34,"value":542},"OrderRepository",{"type":34,"value":544},", ",{"type":29,"tag":84,"props":546,"children":548},{"className":547},[],[549],{"type":34,"value":550},"EmailNotifier",{"type":34,"value":552},") que les implémentations concrètes respectent.",{"type":29,"tag":77,"props":554,"children":556},{"code":555},"Sans DIP :\nOrderService → PostgreSQLDatabase\nOrderService → SendgridEmailClient\n\nAvec DIP :\nOrderService → OrderRepository (abstraction) ← PostgreSQLOrderRepository (implémentation)\nOrderService → EmailNotifier (abstraction)   ← SendgridEmailNotifier (implémentation)\n",[557],{"type":29,"tag":84,"props":558,"children":559},{"__ignoreMap":8},[560],{"type":34,"value":555},{"type":29,"tag":30,"props":562,"children":563},{},[564],{"type":34,"value":565},"La flèche s'inverse : l'implémentation concrète dépend de l'abstraction, pas l'inverse.",{"type":29,"tag":47,"props":567,"children":568},{},[],{"type":29,"tag":51,"props":570,"children":572},{"id":571},"exemple-1-java-injection-par-constructeur",[573],{"type":34,"value":574},"Exemple 1 : Java, injection par constructeur",{"type":29,"tag":77,"props":576,"children":578},{"code":577,"language":80,"meta":8,"className":81,"style":8},"\u002F\u002F Les abstractions\npublic interface OrderRepository {\n    String save(OrderData orderData);\n}\n\npublic interface EmailNotifier {\n    void sendConfirmation(String email, String orderId);\n}\n\n\u002F\u002F Le module de haut niveau : dépend uniquement des abstractions\npublic class OrderService {\n\n    private final OrderRepository repository;\n    private final EmailNotifier notifier;\n\n    public OrderService(OrderRepository repository, EmailNotifier notifier) {\n        this.repository = repository;\n        this.notifier = notifier;\n    }\n\n    public String createOrder(OrderData orderData) {\n        String orderId = repository.save(orderData);\n        notifier.sendConfirmation(orderData.getEmail(), orderId);\n        return orderId;\n    }\n}\n\n\u002F\u002F Les implémentations concrètes\npublic class PostgresOrderRepository implements OrderRepository {\n    public String save(OrderData orderData) {\n        return jdbcTemplate.queryForObject(\"INSERT INTO orders ... RETURNING id\", String.class, orderData);\n    }\n}\n\npublic class SendgridEmailNotifier implements EmailNotifier {\n    public void sendConfirmation(String email, String orderId) {\n        client.send(email, \"order_confirmation\", Map.of(\"orderId\", orderId));\n    }\n}\n\n\u002F\u002F Composition à la racine de l'application\npublic OrderService createOrderService() {\n    OrderRepository repository = new PostgresOrderRepository(dataSource);\n    EmailNotifier notifier = new SendgridEmailNotifier(System.getenv(\"SENDGRID_KEY\"));\n    return new OrderService(repository, notifier);\n}\n",[579],{"type":29,"tag":84,"props":580,"children":581},{"__ignoreMap":8},[582,590,611,640,647,654,674,717,724,731,739,758,765,790,815,823,867,898,927,935,943,979,1019,1064,1080,1088,1096,1104,1113,1143,1178,1238,1246,1254,1262,1291,1340,1416,1424,1432,1440,1449,1475,1514,1571,1609],{"type":29,"tag":88,"props":583,"children":584},{"class":90,"line":91},[585],{"type":29,"tag":88,"props":586,"children":587},{"style":95},[588],{"type":34,"value":589},"\u002F\u002F Les abstractions\n",{"type":29,"tag":88,"props":591,"children":592},{"class":90,"line":101},[593,597,602,607],{"type":29,"tag":88,"props":594,"children":595},{"style":105},[596],{"type":34,"value":108},{"type":29,"tag":88,"props":598,"children":599},{"style":105},[600],{"type":34,"value":601}," interface",{"type":29,"tag":88,"props":603,"children":604},{"style":116},[605],{"type":34,"value":606}," OrderRepository",{"type":29,"tag":88,"props":608,"children":609},{"style":122},[610],{"type":34,"value":125},{"type":29,"tag":88,"props":612,"children":613},{"class":90,"line":128},[614,619,624,628,632,636],{"type":29,"tag":88,"props":615,"children":616},{"style":151},[617],{"type":34,"value":618},"    String",{"type":29,"tag":88,"props":620,"children":621},{"style":174},[622],{"type":34,"value":623}," save",{"type":29,"tag":88,"props":625,"children":626},{"style":122},[627],{"type":34,"value":181},{"type":29,"tag":88,"props":629,"children":630},{"style":151},[631],{"type":34,"value":295},{"type":29,"tag":88,"props":633,"children":634},{"style":298},[635],{"type":34,"value":301},{"type":29,"tag":88,"props":637,"children":638},{"style":122},[639],{"type":34,"value":357},{"type":29,"tag":88,"props":641,"children":642},{"class":90,"line":137},[643],{"type":29,"tag":88,"props":644,"children":645},{"style":122},[646],{"type":34,"value":442},{"type":29,"tag":88,"props":648,"children":649},{"class":90,"line":211},[650],{"type":29,"tag":88,"props":651,"children":652},{"emptyLinePlaceholder":13},[653],{"type":34,"value":134},{"type":29,"tag":88,"props":655,"children":656},{"class":90,"line":262},[657,661,665,670],{"type":29,"tag":88,"props":658,"children":659},{"style":105},[660],{"type":34,"value":108},{"type":29,"tag":88,"props":662,"children":663},{"style":105},[664],{"type":34,"value":601},{"type":29,"tag":88,"props":666,"children":667},{"style":116},[668],{"type":34,"value":669}," EmailNotifier",{"type":29,"tag":88,"props":671,"children":672},{"style":122},[673],{"type":34,"value":125},{"type":29,"tag":88,"props":675,"children":676},{"class":90,"line":270},[677,682,687,691,696,701,705,709,713],{"type":29,"tag":88,"props":678,"children":679},{"style":105},[680],{"type":34,"value":681},"    void",{"type":29,"tag":88,"props":683,"children":684},{"style":174},[685],{"type":34,"value":686}," sendConfirmation",{"type":29,"tag":88,"props":688,"children":689},{"style":122},[690],{"type":34,"value":181},{"type":29,"tag":88,"props":692,"children":693},{"style":151},[694],{"type":34,"value":695},"String",{"type":29,"tag":88,"props":697,"children":698},{"style":298},[699],{"type":34,"value":700}," email",{"type":29,"tag":88,"props":702,"children":703},{"style":122},[704],{"type":34,"value":192},{"type":29,"tag":88,"props":706,"children":707},{"style":151},[708],{"type":34,"value":281},{"type":29,"tag":88,"props":710,"children":711},{"style":298},[712],{"type":34,"value":402},{"type":29,"tag":88,"props":714,"children":715},{"style":122},[716],{"type":34,"value":357},{"type":29,"tag":88,"props":718,"children":719},{"class":90,"line":313},[720],{"type":29,"tag":88,"props":721,"children":722},{"style":122},[723],{"type":34,"value":442},{"type":29,"tag":88,"props":725,"children":726},{"class":90,"line":360},[727],{"type":29,"tag":88,"props":728,"children":729},{"emptyLinePlaceholder":13},[730],{"type":34,"value":134},{"type":29,"tag":88,"props":732,"children":733},{"class":90,"line":409},[734],{"type":29,"tag":88,"props":735,"children":736},{"style":95},[737],{"type":34,"value":738},"\u002F\u002F Le module de haut niveau : dépend uniquement des abstractions\n",{"type":29,"tag":88,"props":740,"children":741},{"class":90,"line":427},[742,746,750,754],{"type":29,"tag":88,"props":743,"children":744},{"style":105},[745],{"type":34,"value":108},{"type":29,"tag":88,"props":747,"children":748},{"style":105},[749],{"type":34,"value":113},{"type":29,"tag":88,"props":751,"children":752},{"style":116},[753],{"type":34,"value":119},{"type":29,"tag":88,"props":755,"children":756},{"style":122},[757],{"type":34,"value":125},{"type":29,"tag":88,"props":759,"children":760},{"class":90,"line":436},[761],{"type":29,"tag":88,"props":762,"children":763},{"emptyLinePlaceholder":13},[764],{"type":34,"value":134},{"type":29,"tag":88,"props":766,"children":768},{"class":90,"line":767},13,[769,773,777,781,786],{"type":29,"tag":88,"props":770,"children":771},{"style":105},[772],{"type":34,"value":143},{"type":29,"tag":88,"props":774,"children":775},{"style":105},[776],{"type":34,"value":148},{"type":29,"tag":88,"props":778,"children":779},{"style":151},[780],{"type":34,"value":606},{"type":29,"tag":88,"props":782,"children":783},{"style":157},[784],{"type":34,"value":785}," repository",{"type":29,"tag":88,"props":787,"children":788},{"style":122},[789],{"type":34,"value":424},{"type":29,"tag":88,"props":791,"children":793},{"class":90,"line":792},14,[794,798,802,806,811],{"type":29,"tag":88,"props":795,"children":796},{"style":105},[797],{"type":34,"value":143},{"type":29,"tag":88,"props":799,"children":800},{"style":105},[801],{"type":34,"value":148},{"type":29,"tag":88,"props":803,"children":804},{"style":151},[805],{"type":34,"value":669},{"type":29,"tag":88,"props":807,"children":808},{"style":157},[809],{"type":34,"value":810}," notifier",{"type":29,"tag":88,"props":812,"children":813},{"style":122},[814],{"type":34,"value":424},{"type":29,"tag":88,"props":816,"children":818},{"class":90,"line":817},15,[819],{"type":29,"tag":88,"props":820,"children":821},{"emptyLinePlaceholder":13},[822],{"type":34,"value":134},{"type":29,"tag":88,"props":824,"children":826},{"class":90,"line":825},16,[827,831,835,839,843,847,851,855,859,863],{"type":29,"tag":88,"props":828,"children":829},{"style":105},[830],{"type":34,"value":276},{"type":29,"tag":88,"props":832,"children":833},{"style":174},[834],{"type":34,"value":119},{"type":29,"tag":88,"props":836,"children":837},{"style":122},[838],{"type":34,"value":181},{"type":29,"tag":88,"props":840,"children":841},{"style":151},[842],{"type":34,"value":542},{"type":29,"tag":88,"props":844,"children":845},{"style":298},[846],{"type":34,"value":785},{"type":29,"tag":88,"props":848,"children":849},{"style":122},[850],{"type":34,"value":192},{"type":29,"tag":88,"props":852,"children":853},{"style":151},[854],{"type":34,"value":669},{"type":29,"tag":88,"props":856,"children":857},{"style":298},[858],{"type":34,"value":810},{"type":29,"tag":88,"props":860,"children":861},{"style":122},[862],{"type":34,"value":306},{"type":29,"tag":88,"props":864,"children":865},{"style":122},[866],{"type":34,"value":125},{"type":29,"tag":88,"props":868,"children":870},{"class":90,"line":869},17,[871,877,881,886,890,894],{"type":29,"tag":88,"props":872,"children":874},{"style":873},"--shiki-default:#E78284;--shiki-dark:#79B8FF",[875],{"type":34,"value":876},"        this",{"type":29,"tag":88,"props":878,"children":879},{"style":122},[880],{"type":34,"value":338},{"type":29,"tag":88,"props":882,"children":883},{"style":157},[884],{"type":34,"value":885},"repository ",{"type":29,"tag":88,"props":887,"children":888},{"style":163},[889],{"type":34,"value":166},{"type":29,"tag":88,"props":891,"children":892},{"style":157},[893],{"type":34,"value":785},{"type":29,"tag":88,"props":895,"children":896},{"style":122},[897],{"type":34,"value":424},{"type":29,"tag":88,"props":899,"children":901},{"class":90,"line":900},18,[902,906,910,915,919,923],{"type":29,"tag":88,"props":903,"children":904},{"style":873},[905],{"type":34,"value":876},{"type":29,"tag":88,"props":907,"children":908},{"style":122},[909],{"type":34,"value":338},{"type":29,"tag":88,"props":911,"children":912},{"style":157},[913],{"type":34,"value":914},"notifier ",{"type":29,"tag":88,"props":916,"children":917},{"style":163},[918],{"type":34,"value":166},{"type":29,"tag":88,"props":920,"children":921},{"style":157},[922],{"type":34,"value":810},{"type":29,"tag":88,"props":924,"children":925},{"style":122},[926],{"type":34,"value":424},{"type":29,"tag":88,"props":928,"children":930},{"class":90,"line":929},19,[931],{"type":29,"tag":88,"props":932,"children":933},{"style":122},[934],{"type":34,"value":433},{"type":29,"tag":88,"props":936,"children":938},{"class":90,"line":937},20,[939],{"type":29,"tag":88,"props":940,"children":941},{"emptyLinePlaceholder":13},[942],{"type":34,"value":134},{"type":29,"tag":88,"props":944,"children":946},{"class":90,"line":945},21,[947,951,955,959,963,967,971,975],{"type":29,"tag":88,"props":948,"children":949},{"style":105},[950],{"type":34,"value":276},{"type":29,"tag":88,"props":952,"children":953},{"style":151},[954],{"type":34,"value":281},{"type":29,"tag":88,"props":956,"children":957},{"style":174},[958],{"type":34,"value":286},{"type":29,"tag":88,"props":960,"children":961},{"style":122},[962],{"type":34,"value":181},{"type":29,"tag":88,"props":964,"children":965},{"style":151},[966],{"type":34,"value":295},{"type":29,"tag":88,"props":968,"children":969},{"style":298},[970],{"type":34,"value":301},{"type":29,"tag":88,"props":972,"children":973},{"style":122},[974],{"type":34,"value":306},{"type":29,"tag":88,"props":976,"children":977},{"style":122},[978],{"type":34,"value":125},{"type":29,"tag":88,"props":980,"children":982},{"class":90,"line":981},22,[983,987,991,995,999,1003,1007,1011,1015],{"type":29,"tag":88,"props":984,"children":985},{"style":151},[986],{"type":34,"value":319},{"type":29,"tag":88,"props":988,"children":989},{"style":157},[990],{"type":34,"value":324},{"type":29,"tag":88,"props":992,"children":993},{"style":163},[994],{"type":34,"value":166},{"type":29,"tag":88,"props":996,"children":997},{"style":157},[998],{"type":34,"value":785},{"type":29,"tag":88,"props":1000,"children":1001},{"style":122},[1002],{"type":34,"value":338},{"type":29,"tag":88,"props":1004,"children":1005},{"style":174},[1006],{"type":34,"value":343},{"type":29,"tag":88,"props":1008,"children":1009},{"style":122},[1010],{"type":34,"value":181},{"type":29,"tag":88,"props":1012,"children":1013},{"style":157},[1014],{"type":34,"value":352},{"type":29,"tag":88,"props":1016,"children":1017},{"style":122},[1018],{"type":34,"value":357},{"type":29,"tag":88,"props":1020,"children":1022},{"class":90,"line":1021},23,[1023,1028,1032,1036,1040,1044,1048,1052,1056,1060],{"type":29,"tag":88,"props":1024,"children":1025},{"style":157},[1026],{"type":34,"value":1027},"        notifier",{"type":29,"tag":88,"props":1029,"children":1030},{"style":122},[1031],{"type":34,"value":338},{"type":29,"tag":88,"props":1033,"children":1034},{"style":174},[1035],{"type":34,"value":375},{"type":29,"tag":88,"props":1037,"children":1038},{"style":122},[1039],{"type":34,"value":181},{"type":29,"tag":88,"props":1041,"children":1042},{"style":157},[1043],{"type":34,"value":352},{"type":29,"tag":88,"props":1045,"children":1046},{"style":122},[1047],{"type":34,"value":338},{"type":29,"tag":88,"props":1049,"children":1050},{"style":174},[1051],{"type":34,"value":392},{"type":29,"tag":88,"props":1053,"children":1054},{"style":122},[1055],{"type":34,"value":397},{"type":29,"tag":88,"props":1057,"children":1058},{"style":157},[1059],{"type":34,"value":402},{"type":29,"tag":88,"props":1061,"children":1062},{"style":122},[1063],{"type":34,"value":357},{"type":29,"tag":88,"props":1065,"children":1067},{"class":90,"line":1066},24,[1068,1072,1076],{"type":29,"tag":88,"props":1069,"children":1070},{"style":105},[1071],{"type":34,"value":415},{"type":29,"tag":88,"props":1073,"children":1074},{"style":157},[1075],{"type":34,"value":402},{"type":29,"tag":88,"props":1077,"children":1078},{"style":122},[1079],{"type":34,"value":424},{"type":29,"tag":88,"props":1081,"children":1083},{"class":90,"line":1082},25,[1084],{"type":29,"tag":88,"props":1085,"children":1086},{"style":122},[1087],{"type":34,"value":433},{"type":29,"tag":88,"props":1089,"children":1091},{"class":90,"line":1090},26,[1092],{"type":29,"tag":88,"props":1093,"children":1094},{"style":122},[1095],{"type":34,"value":442},{"type":29,"tag":88,"props":1097,"children":1099},{"class":90,"line":1098},27,[1100],{"type":29,"tag":88,"props":1101,"children":1102},{"emptyLinePlaceholder":13},[1103],{"type":34,"value":134},{"type":29,"tag":88,"props":1105,"children":1107},{"class":90,"line":1106},28,[1108],{"type":29,"tag":88,"props":1109,"children":1110},{"style":95},[1111],{"type":34,"value":1112},"\u002F\u002F Les implémentations concrètes\n",{"type":29,"tag":88,"props":1114,"children":1116},{"class":90,"line":1115},29,[1117,1121,1125,1130,1135,1139],{"type":29,"tag":88,"props":1118,"children":1119},{"style":105},[1120],{"type":34,"value":108},{"type":29,"tag":88,"props":1122,"children":1123},{"style":105},[1124],{"type":34,"value":113},{"type":29,"tag":88,"props":1126,"children":1127},{"style":116},[1128],{"type":34,"value":1129}," PostgresOrderRepository",{"type":29,"tag":88,"props":1131,"children":1132},{"style":105},[1133],{"type":34,"value":1134}," implements",{"type":29,"tag":88,"props":1136,"children":1137},{"style":116},[1138],{"type":34,"value":606},{"type":29,"tag":88,"props":1140,"children":1141},{"style":122},[1142],{"type":34,"value":125},{"type":29,"tag":88,"props":1144,"children":1145},{"class":90,"line":11},[1146,1150,1154,1158,1162,1166,1170,1174],{"type":29,"tag":88,"props":1147,"children":1148},{"style":105},[1149],{"type":34,"value":276},{"type":29,"tag":88,"props":1151,"children":1152},{"style":151},[1153],{"type":34,"value":281},{"type":29,"tag":88,"props":1155,"children":1156},{"style":174},[1157],{"type":34,"value":623},{"type":29,"tag":88,"props":1159,"children":1160},{"style":122},[1161],{"type":34,"value":181},{"type":29,"tag":88,"props":1163,"children":1164},{"style":151},[1165],{"type":34,"value":295},{"type":29,"tag":88,"props":1167,"children":1168},{"style":298},[1169],{"type":34,"value":301},{"type":29,"tag":88,"props":1171,"children":1172},{"style":122},[1173],{"type":34,"value":306},{"type":29,"tag":88,"props":1175,"children":1176},{"style":122},[1177],{"type":34,"value":125},{"type":29,"tag":88,"props":1179,"children":1181},{"class":90,"line":1180},31,[1182,1186,1191,1195,1200,1204,1209,1213,1217,1221,1226,1230,1234],{"type":29,"tag":88,"props":1183,"children":1184},{"style":105},[1185],{"type":34,"value":415},{"type":29,"tag":88,"props":1187,"children":1188},{"style":157},[1189],{"type":34,"value":1190}," jdbcTemplate",{"type":29,"tag":88,"props":1192,"children":1193},{"style":122},[1194],{"type":34,"value":338},{"type":29,"tag":88,"props":1196,"children":1197},{"style":174},[1198],{"type":34,"value":1199},"queryForObject",{"type":29,"tag":88,"props":1201,"children":1202},{"style":122},[1203],{"type":34,"value":181},{"type":29,"tag":88,"props":1205,"children":1206},{"style":184},[1207],{"type":34,"value":1208},"\"INSERT INTO orders ... RETURNING id\"",{"type":29,"tag":88,"props":1210,"children":1211},{"style":122},[1212],{"type":34,"value":192},{"type":29,"tag":88,"props":1214,"children":1215},{"style":157},[1216],{"type":34,"value":281},{"type":29,"tag":88,"props":1218,"children":1219},{"style":122},[1220],{"type":34,"value":338},{"type":29,"tag":88,"props":1222,"children":1223},{"style":157},[1224],{"type":34,"value":1225},"class",{"type":29,"tag":88,"props":1227,"children":1228},{"style":122},[1229],{"type":34,"value":192},{"type":29,"tag":88,"props":1231,"children":1232},{"style":157},[1233],{"type":34,"value":301},{"type":29,"tag":88,"props":1235,"children":1236},{"style":122},[1237],{"type":34,"value":357},{"type":29,"tag":88,"props":1239,"children":1241},{"class":90,"line":1240},32,[1242],{"type":29,"tag":88,"props":1243,"children":1244},{"style":122},[1245],{"type":34,"value":433},{"type":29,"tag":88,"props":1247,"children":1249},{"class":90,"line":1248},33,[1250],{"type":29,"tag":88,"props":1251,"children":1252},{"style":122},[1253],{"type":34,"value":442},{"type":29,"tag":88,"props":1255,"children":1257},{"class":90,"line":1256},34,[1258],{"type":29,"tag":88,"props":1259,"children":1260},{"emptyLinePlaceholder":13},[1261],{"type":34,"value":134},{"type":29,"tag":88,"props":1263,"children":1265},{"class":90,"line":1264},35,[1266,1270,1274,1279,1283,1287],{"type":29,"tag":88,"props":1267,"children":1268},{"style":105},[1269],{"type":34,"value":108},{"type":29,"tag":88,"props":1271,"children":1272},{"style":105},[1273],{"type":34,"value":113},{"type":29,"tag":88,"props":1275,"children":1276},{"style":116},[1277],{"type":34,"value":1278}," SendgridEmailNotifier",{"type":29,"tag":88,"props":1280,"children":1281},{"style":105},[1282],{"type":34,"value":1134},{"type":29,"tag":88,"props":1284,"children":1285},{"style":116},[1286],{"type":34,"value":669},{"type":29,"tag":88,"props":1288,"children":1289},{"style":122},[1290],{"type":34,"value":125},{"type":29,"tag":88,"props":1292,"children":1294},{"class":90,"line":1293},36,[1295,1299,1304,1308,1312,1316,1320,1324,1328,1332,1336],{"type":29,"tag":88,"props":1296,"children":1297},{"style":105},[1298],{"type":34,"value":276},{"type":29,"tag":88,"props":1300,"children":1301},{"style":105},[1302],{"type":34,"value":1303}," void",{"type":29,"tag":88,"props":1305,"children":1306},{"style":174},[1307],{"type":34,"value":686},{"type":29,"tag":88,"props":1309,"children":1310},{"style":122},[1311],{"type":34,"value":181},{"type":29,"tag":88,"props":1313,"children":1314},{"style":151},[1315],{"type":34,"value":695},{"type":29,"tag":88,"props":1317,"children":1318},{"style":298},[1319],{"type":34,"value":700},{"type":29,"tag":88,"props":1321,"children":1322},{"style":122},[1323],{"type":34,"value":192},{"type":29,"tag":88,"props":1325,"children":1326},{"style":151},[1327],{"type":34,"value":281},{"type":29,"tag":88,"props":1329,"children":1330},{"style":298},[1331],{"type":34,"value":402},{"type":29,"tag":88,"props":1333,"children":1334},{"style":122},[1335],{"type":34,"value":306},{"type":29,"tag":88,"props":1337,"children":1338},{"style":122},[1339],{"type":34,"value":125},{"type":29,"tag":88,"props":1341,"children":1343},{"class":90,"line":1342},37,[1344,1349,1353,1358,1362,1367,1371,1376,1380,1385,1389,1394,1398,1403,1407,1411],{"type":29,"tag":88,"props":1345,"children":1346},{"style":157},[1347],{"type":34,"value":1348},"        client",{"type":29,"tag":88,"props":1350,"children":1351},{"style":122},[1352],{"type":34,"value":338},{"type":29,"tag":88,"props":1354,"children":1355},{"style":174},[1356],{"type":34,"value":1357},"send",{"type":29,"tag":88,"props":1359,"children":1360},{"style":122},[1361],{"type":34,"value":181},{"type":29,"tag":88,"props":1363,"children":1364},{"style":157},[1365],{"type":34,"value":1366},"email",{"type":29,"tag":88,"props":1368,"children":1369},{"style":122},[1370],{"type":34,"value":192},{"type":29,"tag":88,"props":1372,"children":1373},{"style":184},[1374],{"type":34,"value":1375}," \"order_confirmation\"",{"type":29,"tag":88,"props":1377,"children":1378},{"style":122},[1379],{"type":34,"value":192},{"type":29,"tag":88,"props":1381,"children":1382},{"style":157},[1383],{"type":34,"value":1384}," Map",{"type":29,"tag":88,"props":1386,"children":1387},{"style":122},[1388],{"type":34,"value":338},{"type":29,"tag":88,"props":1390,"children":1391},{"style":174},[1392],{"type":34,"value":1393},"of",{"type":29,"tag":88,"props":1395,"children":1396},{"style":122},[1397],{"type":34,"value":181},{"type":29,"tag":88,"props":1399,"children":1400},{"style":184},[1401],{"type":34,"value":1402},"\"orderId\"",{"type":29,"tag":88,"props":1404,"children":1405},{"style":122},[1406],{"type":34,"value":192},{"type":29,"tag":88,"props":1408,"children":1409},{"style":157},[1410],{"type":34,"value":402},{"type":29,"tag":88,"props":1412,"children":1413},{"style":122},[1414],{"type":34,"value":1415},"));\n",{"type":29,"tag":88,"props":1417,"children":1419},{"class":90,"line":1418},38,[1420],{"type":29,"tag":88,"props":1421,"children":1422},{"style":122},[1423],{"type":34,"value":433},{"type":29,"tag":88,"props":1425,"children":1427},{"class":90,"line":1426},39,[1428],{"type":29,"tag":88,"props":1429,"children":1430},{"style":122},[1431],{"type":34,"value":442},{"type":29,"tag":88,"props":1433,"children":1435},{"class":90,"line":1434},40,[1436],{"type":29,"tag":88,"props":1437,"children":1438},{"emptyLinePlaceholder":13},[1439],{"type":34,"value":134},{"type":29,"tag":88,"props":1441,"children":1443},{"class":90,"line":1442},41,[1444],{"type":29,"tag":88,"props":1445,"children":1446},{"style":95},[1447],{"type":34,"value":1448},"\u002F\u002F Composition à la racine de l'application\n",{"type":29,"tag":88,"props":1450,"children":1452},{"class":90,"line":1451},42,[1453,1457,1461,1466,1471],{"type":29,"tag":88,"props":1454,"children":1455},{"style":105},[1456],{"type":34,"value":108},{"type":29,"tag":88,"props":1458,"children":1459},{"style":151},[1460],{"type":34,"value":119},{"type":29,"tag":88,"props":1462,"children":1463},{"style":174},[1464],{"type":34,"value":1465}," createOrderService",{"type":29,"tag":88,"props":1467,"children":1468},{"style":122},[1469],{"type":34,"value":1470},"()",{"type":29,"tag":88,"props":1472,"children":1473},{"style":122},[1474],{"type":34,"value":125},{"type":29,"tag":88,"props":1476,"children":1478},{"class":90,"line":1477},43,[1479,1484,1489,1493,1497,1501,1505,1510],{"type":29,"tag":88,"props":1480,"children":1481},{"style":151},[1482],{"type":34,"value":1483},"    OrderRepository",{"type":29,"tag":88,"props":1485,"children":1486},{"style":157},[1487],{"type":34,"value":1488}," repository ",{"type":29,"tag":88,"props":1490,"children":1491},{"style":163},[1492],{"type":34,"value":166},{"type":29,"tag":88,"props":1494,"children":1495},{"style":105},[1496],{"type":34,"value":171},{"type":29,"tag":88,"props":1498,"children":1499},{"style":174},[1500],{"type":34,"value":1129},{"type":29,"tag":88,"props":1502,"children":1503},{"style":122},[1504],{"type":34,"value":181},{"type":29,"tag":88,"props":1506,"children":1507},{"style":157},[1508],{"type":34,"value":1509},"dataSource",{"type":29,"tag":88,"props":1511,"children":1512},{"style":122},[1513],{"type":34,"value":357},{"type":29,"tag":88,"props":1515,"children":1517},{"class":90,"line":1516},44,[1518,1523,1528,1532,1536,1540,1544,1549,1553,1558,1562,1567],{"type":29,"tag":88,"props":1519,"children":1520},{"style":151},[1521],{"type":34,"value":1522},"    EmailNotifier",{"type":29,"tag":88,"props":1524,"children":1525},{"style":157},[1526],{"type":34,"value":1527}," notifier ",{"type":29,"tag":88,"props":1529,"children":1530},{"style":163},[1531],{"type":34,"value":166},{"type":29,"tag":88,"props":1533,"children":1534},{"style":105},[1535],{"type":34,"value":171},{"type":29,"tag":88,"props":1537,"children":1538},{"style":174},[1539],{"type":34,"value":1278},{"type":29,"tag":88,"props":1541,"children":1542},{"style":122},[1543],{"type":34,"value":181},{"type":29,"tag":88,"props":1545,"children":1546},{"style":157},[1547],{"type":34,"value":1548},"System",{"type":29,"tag":88,"props":1550,"children":1551},{"style":122},[1552],{"type":34,"value":338},{"type":29,"tag":88,"props":1554,"children":1555},{"style":174},[1556],{"type":34,"value":1557},"getenv",{"type":29,"tag":88,"props":1559,"children":1560},{"style":122},[1561],{"type":34,"value":181},{"type":29,"tag":88,"props":1563,"children":1564},{"style":184},[1565],{"type":34,"value":1566},"\"SENDGRID_KEY\"",{"type":29,"tag":88,"props":1568,"children":1569},{"style":122},[1570],{"type":34,"value":1415},{"type":29,"tag":88,"props":1572,"children":1574},{"class":90,"line":1573},45,[1575,1580,1584,1588,1592,1597,1601,1605],{"type":29,"tag":88,"props":1576,"children":1577},{"style":105},[1578],{"type":34,"value":1579},"    return",{"type":29,"tag":88,"props":1581,"children":1582},{"style":105},[1583],{"type":34,"value":171},{"type":29,"tag":88,"props":1585,"children":1586},{"style":174},[1587],{"type":34,"value":119},{"type":29,"tag":88,"props":1589,"children":1590},{"style":122},[1591],{"type":34,"value":181},{"type":29,"tag":88,"props":1593,"children":1594},{"style":157},[1595],{"type":34,"value":1596},"repository",{"type":29,"tag":88,"props":1598,"children":1599},{"style":122},[1600],{"type":34,"value":192},{"type":29,"tag":88,"props":1602,"children":1603},{"style":157},[1604],{"type":34,"value":810},{"type":29,"tag":88,"props":1606,"children":1607},{"style":122},[1608],{"type":34,"value":357},{"type":29,"tag":88,"props":1610,"children":1612},{"class":90,"line":1611},46,[1613],{"type":29,"tag":88,"props":1614,"children":1615},{"style":122},[1616],{"type":34,"value":442},{"type":29,"tag":30,"props":1618,"children":1619},{},[1620],{"type":29,"tag":447,"props":1621,"children":1622},{},[1623],{"type":34,"value":1624},"Le gain pour les tests :",{"type":29,"tag":77,"props":1626,"children":1628},{"code":1627,"language":80,"meta":8,"className":81,"style":8},"\u002F\u002F Test sans base de données ni Sendgrid : s'exécute en millisecondes\nclass InMemoryOrderRepository implements OrderRepository {\n    private final Map\u003CString, OrderData> orders = new HashMap\u003C>();\n\n    public String save(OrderData orderData) {\n        String orderId = UUID.randomUUID().toString();\n        orders.put(orderId, orderData);\n        return orderId;\n    }\n\n    public boolean contains(String orderId) {\n        return orders.containsKey(orderId);\n    }\n}\n\n@Test\nvoid createOrder_persiste_et_notifie() {\n    InMemoryOrderRepository repository = new InMemoryOrderRepository();\n    FakeEmailNotifier notifier = new FakeEmailNotifier();\n    OrderService service = new OrderService(repository, notifier);\n\n    String orderId = service.createOrder(new OrderData(\"user@example.com\", items));\n\n    assertThat(repository.contains(orderId)).isTrue();\n    assertThat(notifier.getSentConfirmations()).hasSize(1);\n}\n",[1629],{"type":29,"tag":84,"props":1630,"children":1631},{"__ignoreMap":8},[1632,1640,1664,1725,1732,1767,1811,1849,1864,1871,1878,1915,1948,1955,1962,1969,1984,2005,2033,2062,2107,2114,2178,2185,2232,2280],{"type":29,"tag":88,"props":1633,"children":1634},{"class":90,"line":91},[1635],{"type":29,"tag":88,"props":1636,"children":1637},{"style":95},[1638],{"type":34,"value":1639},"\u002F\u002F Test sans base de données ni Sendgrid : s'exécute en millisecondes\n",{"type":29,"tag":88,"props":1641,"children":1642},{"class":90,"line":101},[1643,1647,1652,1656,1660],{"type":29,"tag":88,"props":1644,"children":1645},{"style":105},[1646],{"type":34,"value":1225},{"type":29,"tag":88,"props":1648,"children":1649},{"style":116},[1650],{"type":34,"value":1651}," InMemoryOrderRepository",{"type":29,"tag":88,"props":1653,"children":1654},{"style":105},[1655],{"type":34,"value":1134},{"type":29,"tag":88,"props":1657,"children":1658},{"style":116},[1659],{"type":34,"value":606},{"type":29,"tag":88,"props":1661,"children":1662},{"style":122},[1663],{"type":34,"value":125},{"type":29,"tag":88,"props":1665,"children":1666},{"class":90,"line":128},[1667,1671,1675,1679,1684,1688,1692,1697,1702,1707,1711,1715,1720],{"type":29,"tag":88,"props":1668,"children":1669},{"style":105},[1670],{"type":34,"value":143},{"type":29,"tag":88,"props":1672,"children":1673},{"style":105},[1674],{"type":34,"value":148},{"type":29,"tag":88,"props":1676,"children":1677},{"style":151},[1678],{"type":34,"value":1384},{"type":29,"tag":88,"props":1680,"children":1681},{"style":122},[1682],{"type":34,"value":1683},"\u003C",{"type":29,"tag":88,"props":1685,"children":1686},{"style":105},[1687],{"type":34,"value":695},{"type":29,"tag":88,"props":1689,"children":1690},{"style":122},[1691],{"type":34,"value":192},{"type":29,"tag":88,"props":1693,"children":1694},{"style":105},[1695],{"type":34,"value":1696}," OrderData",{"type":29,"tag":88,"props":1698,"children":1699},{"style":122},[1700],{"type":34,"value":1701},">",{"type":29,"tag":88,"props":1703,"children":1704},{"style":157},[1705],{"type":34,"value":1706}," orders ",{"type":29,"tag":88,"props":1708,"children":1709},{"style":163},[1710],{"type":34,"value":166},{"type":29,"tag":88,"props":1712,"children":1713},{"style":105},[1714],{"type":34,"value":171},{"type":29,"tag":88,"props":1716,"children":1717},{"style":151},[1718],{"type":34,"value":1719}," HashMap",{"type":29,"tag":88,"props":1721,"children":1722},{"style":122},[1723],{"type":34,"value":1724},"\u003C>();\n",{"type":29,"tag":88,"props":1726,"children":1727},{"class":90,"line":137},[1728],{"type":29,"tag":88,"props":1729,"children":1730},{"emptyLinePlaceholder":13},[1731],{"type":34,"value":134},{"type":29,"tag":88,"props":1733,"children":1734},{"class":90,"line":211},[1735,1739,1743,1747,1751,1755,1759,1763],{"type":29,"tag":88,"props":1736,"children":1737},{"style":105},[1738],{"type":34,"value":276},{"type":29,"tag":88,"props":1740,"children":1741},{"style":151},[1742],{"type":34,"value":281},{"type":29,"tag":88,"props":1744,"children":1745},{"style":174},[1746],{"type":34,"value":623},{"type":29,"tag":88,"props":1748,"children":1749},{"style":122},[1750],{"type":34,"value":181},{"type":29,"tag":88,"props":1752,"children":1753},{"style":151},[1754],{"type":34,"value":295},{"type":29,"tag":88,"props":1756,"children":1757},{"style":298},[1758],{"type":34,"value":301},{"type":29,"tag":88,"props":1760,"children":1761},{"style":122},[1762],{"type":34,"value":306},{"type":29,"tag":88,"props":1764,"children":1765},{"style":122},[1766],{"type":34,"value":125},{"type":29,"tag":88,"props":1768,"children":1769},{"class":90,"line":262},[1770,1774,1778,1782,1787,1791,1796,1801,1806],{"type":29,"tag":88,"props":1771,"children":1772},{"style":151},[1773],{"type":34,"value":319},{"type":29,"tag":88,"props":1775,"children":1776},{"style":157},[1777],{"type":34,"value":324},{"type":29,"tag":88,"props":1779,"children":1780},{"style":163},[1781],{"type":34,"value":166},{"type":29,"tag":88,"props":1783,"children":1784},{"style":157},[1785],{"type":34,"value":1786}," UUID",{"type":29,"tag":88,"props":1788,"children":1789},{"style":122},[1790],{"type":34,"value":338},{"type":29,"tag":88,"props":1792,"children":1793},{"style":174},[1794],{"type":34,"value":1795},"randomUUID",{"type":29,"tag":88,"props":1797,"children":1798},{"style":122},[1799],{"type":34,"value":1800},"().",{"type":29,"tag":88,"props":1802,"children":1803},{"style":174},[1804],{"type":34,"value":1805},"toString",{"type":29,"tag":88,"props":1807,"children":1808},{"style":122},[1809],{"type":34,"value":1810},"();\n",{"type":29,"tag":88,"props":1812,"children":1813},{"class":90,"line":270},[1814,1819,1823,1828,1832,1837,1841,1845],{"type":29,"tag":88,"props":1815,"children":1816},{"style":157},[1817],{"type":34,"value":1818},"        orders",{"type":29,"tag":88,"props":1820,"children":1821},{"style":122},[1822],{"type":34,"value":338},{"type":29,"tag":88,"props":1824,"children":1825},{"style":174},[1826],{"type":34,"value":1827},"put",{"type":29,"tag":88,"props":1829,"children":1830},{"style":122},[1831],{"type":34,"value":181},{"type":29,"tag":88,"props":1833,"children":1834},{"style":157},[1835],{"type":34,"value":1836},"orderId",{"type":29,"tag":88,"props":1838,"children":1839},{"style":122},[1840],{"type":34,"value":192},{"type":29,"tag":88,"props":1842,"children":1843},{"style":157},[1844],{"type":34,"value":301},{"type":29,"tag":88,"props":1846,"children":1847},{"style":122},[1848],{"type":34,"value":357},{"type":29,"tag":88,"props":1850,"children":1851},{"class":90,"line":313},[1852,1856,1860],{"type":29,"tag":88,"props":1853,"children":1854},{"style":105},[1855],{"type":34,"value":415},{"type":29,"tag":88,"props":1857,"children":1858},{"style":157},[1859],{"type":34,"value":402},{"type":29,"tag":88,"props":1861,"children":1862},{"style":122},[1863],{"type":34,"value":424},{"type":29,"tag":88,"props":1865,"children":1866},{"class":90,"line":360},[1867],{"type":29,"tag":88,"props":1868,"children":1869},{"style":122},[1870],{"type":34,"value":433},{"type":29,"tag":88,"props":1872,"children":1873},{"class":90,"line":409},[1874],{"type":29,"tag":88,"props":1875,"children":1876},{"emptyLinePlaceholder":13},[1877],{"type":34,"value":134},{"type":29,"tag":88,"props":1879,"children":1880},{"class":90,"line":427},[1881,1885,1890,1895,1899,1903,1907,1911],{"type":29,"tag":88,"props":1882,"children":1883},{"style":105},[1884],{"type":34,"value":276},{"type":29,"tag":88,"props":1886,"children":1887},{"style":105},[1888],{"type":34,"value":1889}," boolean",{"type":29,"tag":88,"props":1891,"children":1892},{"style":174},[1893],{"type":34,"value":1894}," contains",{"type":29,"tag":88,"props":1896,"children":1897},{"style":122},[1898],{"type":34,"value":181},{"type":29,"tag":88,"props":1900,"children":1901},{"style":151},[1902],{"type":34,"value":695},{"type":29,"tag":88,"props":1904,"children":1905},{"style":298},[1906],{"type":34,"value":402},{"type":29,"tag":88,"props":1908,"children":1909},{"style":122},[1910],{"type":34,"value":306},{"type":29,"tag":88,"props":1912,"children":1913},{"style":122},[1914],{"type":34,"value":125},{"type":29,"tag":88,"props":1916,"children":1917},{"class":90,"line":436},[1918,1922,1927,1931,1936,1940,1944],{"type":29,"tag":88,"props":1919,"children":1920},{"style":105},[1921],{"type":34,"value":415},{"type":29,"tag":88,"props":1923,"children":1924},{"style":157},[1925],{"type":34,"value":1926}," orders",{"type":29,"tag":88,"props":1928,"children":1929},{"style":122},[1930],{"type":34,"value":338},{"type":29,"tag":88,"props":1932,"children":1933},{"style":174},[1934],{"type":34,"value":1935},"containsKey",{"type":29,"tag":88,"props":1937,"children":1938},{"style":122},[1939],{"type":34,"value":181},{"type":29,"tag":88,"props":1941,"children":1942},{"style":157},[1943],{"type":34,"value":1836},{"type":29,"tag":88,"props":1945,"children":1946},{"style":122},[1947],{"type":34,"value":357},{"type":29,"tag":88,"props":1949,"children":1950},{"class":90,"line":767},[1951],{"type":29,"tag":88,"props":1952,"children":1953},{"style":122},[1954],{"type":34,"value":433},{"type":29,"tag":88,"props":1956,"children":1957},{"class":90,"line":792},[1958],{"type":29,"tag":88,"props":1959,"children":1960},{"style":122},[1961],{"type":34,"value":442},{"type":29,"tag":88,"props":1963,"children":1964},{"class":90,"line":817},[1965],{"type":29,"tag":88,"props":1966,"children":1967},{"emptyLinePlaceholder":13},[1968],{"type":34,"value":134},{"type":29,"tag":88,"props":1970,"children":1971},{"class":90,"line":825},[1972,1978],{"type":29,"tag":88,"props":1973,"children":1975},{"style":1974},"--shiki-default:#EF9F76;--shiki-dark:#E1E4E8",[1976],{"type":34,"value":1977},"@",{"type":29,"tag":88,"props":1979,"children":1981},{"style":1980},"--shiki-default:#EF9F76;--shiki-dark:#F97583",[1982],{"type":34,"value":1983},"Test\n",{"type":29,"tag":88,"props":1985,"children":1986},{"class":90,"line":869},[1987,1992,1997,2001],{"type":29,"tag":88,"props":1988,"children":1989},{"style":105},[1990],{"type":34,"value":1991},"void",{"type":29,"tag":88,"props":1993,"children":1994},{"style":174},[1995],{"type":34,"value":1996}," createOrder_persiste_et_notifie",{"type":29,"tag":88,"props":1998,"children":1999},{"style":122},[2000],{"type":34,"value":1470},{"type":29,"tag":88,"props":2002,"children":2003},{"style":122},[2004],{"type":34,"value":125},{"type":29,"tag":88,"props":2006,"children":2007},{"class":90,"line":900},[2008,2013,2017,2021,2025,2029],{"type":29,"tag":88,"props":2009,"children":2010},{"style":151},[2011],{"type":34,"value":2012},"    InMemoryOrderRepository",{"type":29,"tag":88,"props":2014,"children":2015},{"style":157},[2016],{"type":34,"value":1488},{"type":29,"tag":88,"props":2018,"children":2019},{"style":163},[2020],{"type":34,"value":166},{"type":29,"tag":88,"props":2022,"children":2023},{"style":105},[2024],{"type":34,"value":171},{"type":29,"tag":88,"props":2026,"children":2027},{"style":174},[2028],{"type":34,"value":1651},{"type":29,"tag":88,"props":2030,"children":2031},{"style":122},[2032],{"type":34,"value":1810},{"type":29,"tag":88,"props":2034,"children":2035},{"class":90,"line":929},[2036,2041,2045,2049,2053,2058],{"type":29,"tag":88,"props":2037,"children":2038},{"style":151},[2039],{"type":34,"value":2040},"    FakeEmailNotifier",{"type":29,"tag":88,"props":2042,"children":2043},{"style":157},[2044],{"type":34,"value":1527},{"type":29,"tag":88,"props":2046,"children":2047},{"style":163},[2048],{"type":34,"value":166},{"type":29,"tag":88,"props":2050,"children":2051},{"style":105},[2052],{"type":34,"value":171},{"type":29,"tag":88,"props":2054,"children":2055},{"style":174},[2056],{"type":34,"value":2057}," FakeEmailNotifier",{"type":29,"tag":88,"props":2059,"children":2060},{"style":122},[2061],{"type":34,"value":1810},{"type":29,"tag":88,"props":2063,"children":2064},{"class":90,"line":937},[2065,2070,2075,2079,2083,2087,2091,2095,2099,2103],{"type":29,"tag":88,"props":2066,"children":2067},{"style":151},[2068],{"type":34,"value":2069},"    OrderService",{"type":29,"tag":88,"props":2071,"children":2072},{"style":157},[2073],{"type":34,"value":2074}," service ",{"type":29,"tag":88,"props":2076,"children":2077},{"style":163},[2078],{"type":34,"value":166},{"type":29,"tag":88,"props":2080,"children":2081},{"style":105},[2082],{"type":34,"value":171},{"type":29,"tag":88,"props":2084,"children":2085},{"style":174},[2086],{"type":34,"value":119},{"type":29,"tag":88,"props":2088,"children":2089},{"style":122},[2090],{"type":34,"value":181},{"type":29,"tag":88,"props":2092,"children":2093},{"style":157},[2094],{"type":34,"value":1596},{"type":29,"tag":88,"props":2096,"children":2097},{"style":122},[2098],{"type":34,"value":192},{"type":29,"tag":88,"props":2100,"children":2101},{"style":157},[2102],{"type":34,"value":810},{"type":29,"tag":88,"props":2104,"children":2105},{"style":122},[2106],{"type":34,"value":357},{"type":29,"tag":88,"props":2108,"children":2109},{"class":90,"line":945},[2110],{"type":29,"tag":88,"props":2111,"children":2112},{"emptyLinePlaceholder":13},[2113],{"type":34,"value":134},{"type":29,"tag":88,"props":2115,"children":2116},{"class":90,"line":981},[2117,2121,2125,2129,2134,2138,2143,2147,2152,2156,2160,2165,2169,2174],{"type":29,"tag":88,"props":2118,"children":2119},{"style":151},[2120],{"type":34,"value":618},{"type":29,"tag":88,"props":2122,"children":2123},{"style":157},[2124],{"type":34,"value":324},{"type":29,"tag":88,"props":2126,"children":2127},{"style":163},[2128],{"type":34,"value":166},{"type":29,"tag":88,"props":2130,"children":2131},{"style":157},[2132],{"type":34,"value":2133}," service",{"type":29,"tag":88,"props":2135,"children":2136},{"style":122},[2137],{"type":34,"value":338},{"type":29,"tag":88,"props":2139,"children":2140},{"style":174},[2141],{"type":34,"value":2142},"createOrder",{"type":29,"tag":88,"props":2144,"children":2145},{"style":122},[2146],{"type":34,"value":181},{"type":29,"tag":88,"props":2148,"children":2149},{"style":105},[2150],{"type":34,"value":2151},"new",{"type":29,"tag":88,"props":2153,"children":2154},{"style":174},[2155],{"type":34,"value":1696},{"type":29,"tag":88,"props":2157,"children":2158},{"style":122},[2159],{"type":34,"value":181},{"type":29,"tag":88,"props":2161,"children":2162},{"style":184},[2163],{"type":34,"value":2164},"\"user@example.com\"",{"type":29,"tag":88,"props":2166,"children":2167},{"style":122},[2168],{"type":34,"value":192},{"type":29,"tag":88,"props":2170,"children":2171},{"style":157},[2172],{"type":34,"value":2173}," items",{"type":29,"tag":88,"props":2175,"children":2176},{"style":122},[2177],{"type":34,"value":1415},{"type":29,"tag":88,"props":2179,"children":2180},{"class":90,"line":1021},[2181],{"type":29,"tag":88,"props":2182,"children":2183},{"emptyLinePlaceholder":13},[2184],{"type":34,"value":134},{"type":29,"tag":88,"props":2186,"children":2187},{"class":90,"line":1066},[2188,2193,2197,2201,2205,2210,2214,2218,2223,2228],{"type":29,"tag":88,"props":2189,"children":2190},{"style":174},[2191],{"type":34,"value":2192},"    assertThat",{"type":29,"tag":88,"props":2194,"children":2195},{"style":122},[2196],{"type":34,"value":181},{"type":29,"tag":88,"props":2198,"children":2199},{"style":157},[2200],{"type":34,"value":1596},{"type":29,"tag":88,"props":2202,"children":2203},{"style":122},[2204],{"type":34,"value":338},{"type":29,"tag":88,"props":2206,"children":2207},{"style":174},[2208],{"type":34,"value":2209},"contains",{"type":29,"tag":88,"props":2211,"children":2212},{"style":122},[2213],{"type":34,"value":181},{"type":29,"tag":88,"props":2215,"children":2216},{"style":157},[2217],{"type":34,"value":1836},{"type":29,"tag":88,"props":2219,"children":2220},{"style":122},[2221],{"type":34,"value":2222},")).",{"type":29,"tag":88,"props":2224,"children":2225},{"style":174},[2226],{"type":34,"value":2227},"isTrue",{"type":29,"tag":88,"props":2229,"children":2230},{"style":122},[2231],{"type":34,"value":1810},{"type":29,"tag":88,"props":2233,"children":2234},{"class":90,"line":1082},[2235,2239,2243,2248,2252,2257,2262,2267,2271,2276],{"type":29,"tag":88,"props":2236,"children":2237},{"style":174},[2238],{"type":34,"value":2192},{"type":29,"tag":88,"props":2240,"children":2241},{"style":122},[2242],{"type":34,"value":181},{"type":29,"tag":88,"props":2244,"children":2245},{"style":157},[2246],{"type":34,"value":2247},"notifier",{"type":29,"tag":88,"props":2249,"children":2250},{"style":122},[2251],{"type":34,"value":338},{"type":29,"tag":88,"props":2253,"children":2254},{"style":174},[2255],{"type":34,"value":2256},"getSentConfirmations",{"type":29,"tag":88,"props":2258,"children":2259},{"style":122},[2260],{"type":34,"value":2261},"()).",{"type":29,"tag":88,"props":2263,"children":2264},{"style":174},[2265],{"type":34,"value":2266},"hasSize",{"type":29,"tag":88,"props":2268,"children":2269},{"style":122},[2270],{"type":34,"value":181},{"type":29,"tag":88,"props":2272,"children":2273},{"style":195},[2274],{"type":34,"value":2275},"1",{"type":29,"tag":88,"props":2277,"children":2278},{"style":122},[2279],{"type":34,"value":357},{"type":29,"tag":88,"props":2281,"children":2282},{"class":90,"line":1090},[2283],{"type":29,"tag":88,"props":2284,"children":2285},{"style":122},[2286],{"type":34,"value":442},{"type":29,"tag":2288,"props":2289,"children":2294},"cta",{"cta":2290,"href":2291,"title":2292,"type":2293},"Coder comme un senior →","https:\u002F\u002Fapp.kamanga.fr\u002Fforms\u002Fmentoring","Vous voulez savoir où placer l'abstraction et où vous arrêter ?","call",[2295],{"type":29,"tag":30,"props":2296,"children":2297},{},[2298],{"type":34,"value":2299},"Inverser une dépendance au bon endroit (et résister à l'envie d'abstraire le reste) ne s'apprend pas en lisant un exemple, ça se travaille sur votre propre code. En mentoring 1:1, je relis vos services avec vous, on extrait les ports ensemble et vous repartez avec le réflexe de sentir quand une dépendance mérite une interface. C'est du 1:1 pour monter en niveau, pas un audit d'équipe.",{"type":29,"tag":47,"props":2301,"children":2302},{},[],{"type":29,"tag":51,"props":2304,"children":2306},{"id":2305},"exemple-2-java-ports-hexagonaux-et-fakes-en-mémoire",[2307],{"type":34,"value":2308},"Exemple 2 : Java, ports hexagonaux et fakes en mémoire",{"type":29,"tag":77,"props":2310,"children":2312},{"code":2311,"language":80,"meta":8,"className":81,"style":8},"\u002F\u002F Les ports (abstractions hexagonales)\npublic interface OrderRepository {\n    String save(OrderData orderData);\n    Optional\u003COrder> findById(String orderId);\n}\n\npublic interface PaymentGateway {\n    PaymentResult charge(BigDecimal amount, String currency, String paymentMethodId);\n}\n\n\u002F\u002F Le module de haut niveau - dépend uniquement des ports\n@Service\npublic class OrderService {\n\n    private final OrderRepository repository;\n    private final PaymentGateway payment;\n\n    public OrderService(OrderRepository repository, PaymentGateway payment) {\n        this.repository = repository;\n        this.payment = payment;\n    }\n\n    public Order createPaidOrder(OrderData orderData) {\n        PaymentResult result = payment.charge(\n            orderData.getTotal(),\n            orderData.getCurrency(),\n            orderData.getPaymentMethodId()\n        );\n\n        if (!result.isSuccess()) {\n            throw new PaymentFailedException(result.getErrorCode());\n        }\n\n        String orderId = repository.save(\n            orderData.withPaymentId(result.getTransactionId())\n                     .withStatus(OrderStatus.PAID)\n        );\n\n        return repository.findById(orderId)\n            .orElseThrow(() -> new IllegalStateException(\"Order not found after save\"));\n    }\n}\n\n\u002F\u002F Fake en mémoire pour les tests - sans Stripe, sans base de données\nclass InMemoryOrderRepository implements OrderRepository {\n\n    private final Map\u003CString, OrderData> store = new HashMap\u003C>();\n\n    @Override\n    public String save(OrderData orderData) {\n        String id = UUID.randomUUID().toString();\n        store.put(id, orderData);\n        return id;\n    }\n\n    @Override\n    public Optional\u003COrder> findById(String orderId) {\n        return Optional.ofNullable(store.get(orderId))\n            .map(data -> new Order(orderId, data.getStatus()));\n    }\n}\n\nclass StubPaymentGateway implements PaymentGateway {\n\n    private final boolean shouldSucceed;\n\n    StubPaymentGateway(boolean shouldSucceed) {\n        this.shouldSucceed = shouldSucceed;\n    }\n\n    @Override\n    public PaymentResult charge(BigDecimal amount, String currency, String paymentMethodId) {\n        return shouldSucceed\n            ? PaymentResult.success(\"txn-456\")\n            : PaymentResult.failure(\"CARD_DECLINED\");\n    }\n}\n\n\u002F\u002F Test JUnit 5 - s'exécute en millisecondes, sans infra\nclass OrderServiceTest {\n\n    @Test\n    void shouldCreateOrderWithSuccessfulPayment() {\n        OrderRepository repository = new InMemoryOrderRepository();\n        PaymentGateway payment = new StubPaymentGateway(true);\n        OrderService service = new OrderService(repository, payment);\n\n        Order order = service.createPaidOrder(\n            new OrderData(new BigDecimal(\"1000\"), \"EUR\", \"pm-123\")\n        );\n\n        assertEquals(OrderStatus.PAID, order.getStatus());\n    }\n\n    @Test\n    void shouldThrowWhenPaymentFails() {\n        OrderService service = new OrderService(\n            new InMemoryOrderRepository(),\n            new StubPaymentGateway(false)\n        );\n\n        assertThrows(PaymentFailedException.class, () ->\n            service.createPaidOrder(new OrderData(new BigDecimal(\"1000\"), \"EUR\", \"pm-123\"))\n        );\n    }\n}\n",[2313],{"type":29,"tag":84,"props":2314,"children":2315},{"__ignoreMap":8},[2316,2324,2343,2370,2412,2419,2426,2446,2503,2510,2517,2525,2537,2556,2563,2586,2610,2617,2660,2687,2715,2722,2729,2766,2801,2823,2843,2864,2872,2879,2920,2959,2967,2974,3005,3043,3079,3086,3093,3125,3170,3177,3184,3191,3199,3222,3229,3286,3294,3308,3344,3385,3423,3440,3448,3456,3468,3517,3569,3635,3643,3651,3659,3684,3692,3717,3725,3755,3784,3792,3800,3812,3873,3886,3921,3956,3964,3972,3980,3989,4006,4014,4026,4047,4076,4115,4160,4168,4203,4261,4269,4277,4323,4331,4339,4351,4372,4400,4416,4441,4449,4457,4497,4566,4574,4582],{"type":29,"tag":88,"props":2317,"children":2318},{"class":90,"line":91},[2319],{"type":29,"tag":88,"props":2320,"children":2321},{"style":95},[2322],{"type":34,"value":2323},"\u002F\u002F Les ports (abstractions hexagonales)\n",{"type":29,"tag":88,"props":2325,"children":2326},{"class":90,"line":101},[2327,2331,2335,2339],{"type":29,"tag":88,"props":2328,"children":2329},{"style":105},[2330],{"type":34,"value":108},{"type":29,"tag":88,"props":2332,"children":2333},{"style":105},[2334],{"type":34,"value":601},{"type":29,"tag":88,"props":2336,"children":2337},{"style":116},[2338],{"type":34,"value":606},{"type":29,"tag":88,"props":2340,"children":2341},{"style":122},[2342],{"type":34,"value":125},{"type":29,"tag":88,"props":2344,"children":2345},{"class":90,"line":128},[2346,2350,2354,2358,2362,2366],{"type":29,"tag":88,"props":2347,"children":2348},{"style":151},[2349],{"type":34,"value":618},{"type":29,"tag":88,"props":2351,"children":2352},{"style":174},[2353],{"type":34,"value":623},{"type":29,"tag":88,"props":2355,"children":2356},{"style":122},[2357],{"type":34,"value":181},{"type":29,"tag":88,"props":2359,"children":2360},{"style":151},[2361],{"type":34,"value":295},{"type":29,"tag":88,"props":2363,"children":2364},{"style":298},[2365],{"type":34,"value":301},{"type":29,"tag":88,"props":2367,"children":2368},{"style":122},[2369],{"type":34,"value":357},{"type":29,"tag":88,"props":2371,"children":2372},{"class":90,"line":137},[2373,2378,2382,2387,2391,2396,2400,2404,2408],{"type":29,"tag":88,"props":2374,"children":2375},{"style":151},[2376],{"type":34,"value":2377},"    Optional",{"type":29,"tag":88,"props":2379,"children":2380},{"style":122},[2381],{"type":34,"value":1683},{"type":29,"tag":88,"props":2383,"children":2384},{"style":105},[2385],{"type":34,"value":2386},"Order",{"type":29,"tag":88,"props":2388,"children":2389},{"style":122},[2390],{"type":34,"value":1701},{"type":29,"tag":88,"props":2392,"children":2393},{"style":174},[2394],{"type":34,"value":2395}," findById",{"type":29,"tag":88,"props":2397,"children":2398},{"style":122},[2399],{"type":34,"value":181},{"type":29,"tag":88,"props":2401,"children":2402},{"style":151},[2403],{"type":34,"value":695},{"type":29,"tag":88,"props":2405,"children":2406},{"style":298},[2407],{"type":34,"value":402},{"type":29,"tag":88,"props":2409,"children":2410},{"style":122},[2411],{"type":34,"value":357},{"type":29,"tag":88,"props":2413,"children":2414},{"class":90,"line":211},[2415],{"type":29,"tag":88,"props":2416,"children":2417},{"style":122},[2418],{"type":34,"value":442},{"type":29,"tag":88,"props":2420,"children":2421},{"class":90,"line":262},[2422],{"type":29,"tag":88,"props":2423,"children":2424},{"emptyLinePlaceholder":13},[2425],{"type":34,"value":134},{"type":29,"tag":88,"props":2427,"children":2428},{"class":90,"line":270},[2429,2433,2437,2442],{"type":29,"tag":88,"props":2430,"children":2431},{"style":105},[2432],{"type":34,"value":108},{"type":29,"tag":88,"props":2434,"children":2435},{"style":105},[2436],{"type":34,"value":601},{"type":29,"tag":88,"props":2438,"children":2439},{"style":116},[2440],{"type":34,"value":2441}," PaymentGateway",{"type":29,"tag":88,"props":2443,"children":2444},{"style":122},[2445],{"type":34,"value":125},{"type":29,"tag":88,"props":2447,"children":2448},{"class":90,"line":313},[2449,2454,2459,2463,2468,2473,2477,2481,2486,2490,2494,2499],{"type":29,"tag":88,"props":2450,"children":2451},{"style":151},[2452],{"type":34,"value":2453},"    PaymentResult",{"type":29,"tag":88,"props":2455,"children":2456},{"style":174},[2457],{"type":34,"value":2458}," charge",{"type":29,"tag":88,"props":2460,"children":2461},{"style":122},[2462],{"type":34,"value":181},{"type":29,"tag":88,"props":2464,"children":2465},{"style":151},[2466],{"type":34,"value":2467},"BigDecimal",{"type":29,"tag":88,"props":2469,"children":2470},{"style":298},[2471],{"type":34,"value":2472}," amount",{"type":29,"tag":88,"props":2474,"children":2475},{"style":122},[2476],{"type":34,"value":192},{"type":29,"tag":88,"props":2478,"children":2479},{"style":151},[2480],{"type":34,"value":281},{"type":29,"tag":88,"props":2482,"children":2483},{"style":298},[2484],{"type":34,"value":2485}," currency",{"type":29,"tag":88,"props":2487,"children":2488},{"style":122},[2489],{"type":34,"value":192},{"type":29,"tag":88,"props":2491,"children":2492},{"style":151},[2493],{"type":34,"value":281},{"type":29,"tag":88,"props":2495,"children":2496},{"style":298},[2497],{"type":34,"value":2498}," paymentMethodId",{"type":29,"tag":88,"props":2500,"children":2501},{"style":122},[2502],{"type":34,"value":357},{"type":29,"tag":88,"props":2504,"children":2505},{"class":90,"line":360},[2506],{"type":29,"tag":88,"props":2507,"children":2508},{"style":122},[2509],{"type":34,"value":442},{"type":29,"tag":88,"props":2511,"children":2512},{"class":90,"line":409},[2513],{"type":29,"tag":88,"props":2514,"children":2515},{"emptyLinePlaceholder":13},[2516],{"type":34,"value":134},{"type":29,"tag":88,"props":2518,"children":2519},{"class":90,"line":427},[2520],{"type":29,"tag":88,"props":2521,"children":2522},{"style":95},[2523],{"type":34,"value":2524},"\u002F\u002F Le module de haut niveau - dépend uniquement des ports\n",{"type":29,"tag":88,"props":2526,"children":2527},{"class":90,"line":436},[2528,2532],{"type":29,"tag":88,"props":2529,"children":2530},{"style":1974},[2531],{"type":34,"value":1977},{"type":29,"tag":88,"props":2533,"children":2534},{"style":1980},[2535],{"type":34,"value":2536},"Service\n",{"type":29,"tag":88,"props":2538,"children":2539},{"class":90,"line":767},[2540,2544,2548,2552],{"type":29,"tag":88,"props":2541,"children":2542},{"style":105},[2543],{"type":34,"value":108},{"type":29,"tag":88,"props":2545,"children":2546},{"style":105},[2547],{"type":34,"value":113},{"type":29,"tag":88,"props":2549,"children":2550},{"style":116},[2551],{"type":34,"value":119},{"type":29,"tag":88,"props":2553,"children":2554},{"style":122},[2555],{"type":34,"value":125},{"type":29,"tag":88,"props":2557,"children":2558},{"class":90,"line":792},[2559],{"type":29,"tag":88,"props":2560,"children":2561},{"emptyLinePlaceholder":13},[2562],{"type":34,"value":134},{"type":29,"tag":88,"props":2564,"children":2565},{"class":90,"line":817},[2566,2570,2574,2578,2582],{"type":29,"tag":88,"props":2567,"children":2568},{"style":105},[2569],{"type":34,"value":143},{"type":29,"tag":88,"props":2571,"children":2572},{"style":105},[2573],{"type":34,"value":148},{"type":29,"tag":88,"props":2575,"children":2576},{"style":151},[2577],{"type":34,"value":606},{"type":29,"tag":88,"props":2579,"children":2580},{"style":157},[2581],{"type":34,"value":785},{"type":29,"tag":88,"props":2583,"children":2584},{"style":122},[2585],{"type":34,"value":424},{"type":29,"tag":88,"props":2587,"children":2588},{"class":90,"line":825},[2589,2593,2597,2601,2606],{"type":29,"tag":88,"props":2590,"children":2591},{"style":105},[2592],{"type":34,"value":143},{"type":29,"tag":88,"props":2594,"children":2595},{"style":105},[2596],{"type":34,"value":148},{"type":29,"tag":88,"props":2598,"children":2599},{"style":151},[2600],{"type":34,"value":2441},{"type":29,"tag":88,"props":2602,"children":2603},{"style":157},[2604],{"type":34,"value":2605}," payment",{"type":29,"tag":88,"props":2607,"children":2608},{"style":122},[2609],{"type":34,"value":424},{"type":29,"tag":88,"props":2611,"children":2612},{"class":90,"line":869},[2613],{"type":29,"tag":88,"props":2614,"children":2615},{"emptyLinePlaceholder":13},[2616],{"type":34,"value":134},{"type":29,"tag":88,"props":2618,"children":2619},{"class":90,"line":900},[2620,2624,2628,2632,2636,2640,2644,2648,2652,2656],{"type":29,"tag":88,"props":2621,"children":2622},{"style":105},[2623],{"type":34,"value":276},{"type":29,"tag":88,"props":2625,"children":2626},{"style":174},[2627],{"type":34,"value":119},{"type":29,"tag":88,"props":2629,"children":2630},{"style":122},[2631],{"type":34,"value":181},{"type":29,"tag":88,"props":2633,"children":2634},{"style":151},[2635],{"type":34,"value":542},{"type":29,"tag":88,"props":2637,"children":2638},{"style":298},[2639],{"type":34,"value":785},{"type":29,"tag":88,"props":2641,"children":2642},{"style":122},[2643],{"type":34,"value":192},{"type":29,"tag":88,"props":2645,"children":2646},{"style":151},[2647],{"type":34,"value":2441},{"type":29,"tag":88,"props":2649,"children":2650},{"style":298},[2651],{"type":34,"value":2605},{"type":29,"tag":88,"props":2653,"children":2654},{"style":122},[2655],{"type":34,"value":306},{"type":29,"tag":88,"props":2657,"children":2658},{"style":122},[2659],{"type":34,"value":125},{"type":29,"tag":88,"props":2661,"children":2662},{"class":90,"line":929},[2663,2667,2671,2675,2679,2683],{"type":29,"tag":88,"props":2664,"children":2665},{"style":873},[2666],{"type":34,"value":876},{"type":29,"tag":88,"props":2668,"children":2669},{"style":122},[2670],{"type":34,"value":338},{"type":29,"tag":88,"props":2672,"children":2673},{"style":157},[2674],{"type":34,"value":885},{"type":29,"tag":88,"props":2676,"children":2677},{"style":163},[2678],{"type":34,"value":166},{"type":29,"tag":88,"props":2680,"children":2681},{"style":157},[2682],{"type":34,"value":785},{"type":29,"tag":88,"props":2684,"children":2685},{"style":122},[2686],{"type":34,"value":424},{"type":29,"tag":88,"props":2688,"children":2689},{"class":90,"line":937},[2690,2694,2698,2703,2707,2711],{"type":29,"tag":88,"props":2691,"children":2692},{"style":873},[2693],{"type":34,"value":876},{"type":29,"tag":88,"props":2695,"children":2696},{"style":122},[2697],{"type":34,"value":338},{"type":29,"tag":88,"props":2699,"children":2700},{"style":157},[2701],{"type":34,"value":2702},"payment ",{"type":29,"tag":88,"props":2704,"children":2705},{"style":163},[2706],{"type":34,"value":166},{"type":29,"tag":88,"props":2708,"children":2709},{"style":157},[2710],{"type":34,"value":2605},{"type":29,"tag":88,"props":2712,"children":2713},{"style":122},[2714],{"type":34,"value":424},{"type":29,"tag":88,"props":2716,"children":2717},{"class":90,"line":945},[2718],{"type":29,"tag":88,"props":2719,"children":2720},{"style":122},[2721],{"type":34,"value":433},{"type":29,"tag":88,"props":2723,"children":2724},{"class":90,"line":981},[2725],{"type":29,"tag":88,"props":2726,"children":2727},{"emptyLinePlaceholder":13},[2728],{"type":34,"value":134},{"type":29,"tag":88,"props":2730,"children":2731},{"class":90,"line":1021},[2732,2736,2741,2746,2750,2754,2758,2762],{"type":29,"tag":88,"props":2733,"children":2734},{"style":105},[2735],{"type":34,"value":276},{"type":29,"tag":88,"props":2737,"children":2738},{"style":151},[2739],{"type":34,"value":2740}," Order",{"type":29,"tag":88,"props":2742,"children":2743},{"style":174},[2744],{"type":34,"value":2745}," createPaidOrder",{"type":29,"tag":88,"props":2747,"children":2748},{"style":122},[2749],{"type":34,"value":181},{"type":29,"tag":88,"props":2751,"children":2752},{"style":151},[2753],{"type":34,"value":295},{"type":29,"tag":88,"props":2755,"children":2756},{"style":298},[2757],{"type":34,"value":301},{"type":29,"tag":88,"props":2759,"children":2760},{"style":122},[2761],{"type":34,"value":306},{"type":29,"tag":88,"props":2763,"children":2764},{"style":122},[2765],{"type":34,"value":125},{"type":29,"tag":88,"props":2767,"children":2768},{"class":90,"line":1066},[2769,2774,2779,2783,2787,2791,2796],{"type":29,"tag":88,"props":2770,"children":2771},{"style":151},[2772],{"type":34,"value":2773},"        PaymentResult",{"type":29,"tag":88,"props":2775,"children":2776},{"style":157},[2777],{"type":34,"value":2778}," result ",{"type":29,"tag":88,"props":2780,"children":2781},{"style":163},[2782],{"type":34,"value":166},{"type":29,"tag":88,"props":2784,"children":2785},{"style":157},[2786],{"type":34,"value":2605},{"type":29,"tag":88,"props":2788,"children":2789},{"style":122},[2790],{"type":34,"value":338},{"type":29,"tag":88,"props":2792,"children":2793},{"style":174},[2794],{"type":34,"value":2795},"charge",{"type":29,"tag":88,"props":2797,"children":2798},{"style":122},[2799],{"type":34,"value":2800},"(\n",{"type":29,"tag":88,"props":2802,"children":2803},{"class":90,"line":1082},[2804,2809,2813,2818],{"type":29,"tag":88,"props":2805,"children":2806},{"style":157},[2807],{"type":34,"value":2808},"            orderData",{"type":29,"tag":88,"props":2810,"children":2811},{"style":122},[2812],{"type":34,"value":338},{"type":29,"tag":88,"props":2814,"children":2815},{"style":174},[2816],{"type":34,"value":2817},"getTotal",{"type":29,"tag":88,"props":2819,"children":2820},{"style":122},[2821],{"type":34,"value":2822},"(),\n",{"type":29,"tag":88,"props":2824,"children":2825},{"class":90,"line":1090},[2826,2830,2834,2839],{"type":29,"tag":88,"props":2827,"children":2828},{"style":157},[2829],{"type":34,"value":2808},{"type":29,"tag":88,"props":2831,"children":2832},{"style":122},[2833],{"type":34,"value":338},{"type":29,"tag":88,"props":2835,"children":2836},{"style":174},[2837],{"type":34,"value":2838},"getCurrency",{"type":29,"tag":88,"props":2840,"children":2841},{"style":122},[2842],{"type":34,"value":2822},{"type":29,"tag":88,"props":2844,"children":2845},{"class":90,"line":1098},[2846,2850,2854,2859],{"type":29,"tag":88,"props":2847,"children":2848},{"style":157},[2849],{"type":34,"value":2808},{"type":29,"tag":88,"props":2851,"children":2852},{"style":122},[2853],{"type":34,"value":338},{"type":29,"tag":88,"props":2855,"children":2856},{"style":174},[2857],{"type":34,"value":2858},"getPaymentMethodId",{"type":29,"tag":88,"props":2860,"children":2861},{"style":122},[2862],{"type":34,"value":2863},"()\n",{"type":29,"tag":88,"props":2865,"children":2866},{"class":90,"line":1106},[2867],{"type":29,"tag":88,"props":2868,"children":2869},{"style":122},[2870],{"type":34,"value":2871},"        );\n",{"type":29,"tag":88,"props":2873,"children":2874},{"class":90,"line":1115},[2875],{"type":29,"tag":88,"props":2876,"children":2877},{"emptyLinePlaceholder":13},[2878],{"type":34,"value":134},{"type":29,"tag":88,"props":2880,"children":2881},{"class":90,"line":11},[2882,2887,2892,2897,2902,2906,2911,2916],{"type":29,"tag":88,"props":2883,"children":2884},{"style":105},[2885],{"type":34,"value":2886},"        if",{"type":29,"tag":88,"props":2888,"children":2889},{"style":122},[2890],{"type":34,"value":2891}," (",{"type":29,"tag":88,"props":2893,"children":2894},{"style":163},[2895],{"type":34,"value":2896},"!",{"type":29,"tag":88,"props":2898,"children":2899},{"style":157},[2900],{"type":34,"value":2901},"result",{"type":29,"tag":88,"props":2903,"children":2904},{"style":122},[2905],{"type":34,"value":338},{"type":29,"tag":88,"props":2907,"children":2908},{"style":174},[2909],{"type":34,"value":2910},"isSuccess",{"type":29,"tag":88,"props":2912,"children":2913},{"style":122},[2914],{"type":34,"value":2915},"())",{"type":29,"tag":88,"props":2917,"children":2918},{"style":122},[2919],{"type":34,"value":125},{"type":29,"tag":88,"props":2921,"children":2922},{"class":90,"line":1180},[2923,2928,2932,2937,2941,2945,2949,2954],{"type":29,"tag":88,"props":2924,"children":2925},{"style":105},[2926],{"type":34,"value":2927},"            throw",{"type":29,"tag":88,"props":2929,"children":2930},{"style":105},[2931],{"type":34,"value":171},{"type":29,"tag":88,"props":2933,"children":2934},{"style":174},[2935],{"type":34,"value":2936}," PaymentFailedException",{"type":29,"tag":88,"props":2938,"children":2939},{"style":122},[2940],{"type":34,"value":181},{"type":29,"tag":88,"props":2942,"children":2943},{"style":157},[2944],{"type":34,"value":2901},{"type":29,"tag":88,"props":2946,"children":2947},{"style":122},[2948],{"type":34,"value":338},{"type":29,"tag":88,"props":2950,"children":2951},{"style":174},[2952],{"type":34,"value":2953},"getErrorCode",{"type":29,"tag":88,"props":2955,"children":2956},{"style":122},[2957],{"type":34,"value":2958},"());\n",{"type":29,"tag":88,"props":2960,"children":2961},{"class":90,"line":1240},[2962],{"type":29,"tag":88,"props":2963,"children":2964},{"style":122},[2965],{"type":34,"value":2966},"        }\n",{"type":29,"tag":88,"props":2968,"children":2969},{"class":90,"line":1248},[2970],{"type":29,"tag":88,"props":2971,"children":2972},{"emptyLinePlaceholder":13},[2973],{"type":34,"value":134},{"type":29,"tag":88,"props":2975,"children":2976},{"class":90,"line":1256},[2977,2981,2985,2989,2993,2997,3001],{"type":29,"tag":88,"props":2978,"children":2979},{"style":151},[2980],{"type":34,"value":319},{"type":29,"tag":88,"props":2982,"children":2983},{"style":157},[2984],{"type":34,"value":324},{"type":29,"tag":88,"props":2986,"children":2987},{"style":163},[2988],{"type":34,"value":166},{"type":29,"tag":88,"props":2990,"children":2991},{"style":157},[2992],{"type":34,"value":785},{"type":29,"tag":88,"props":2994,"children":2995},{"style":122},[2996],{"type":34,"value":338},{"type":29,"tag":88,"props":2998,"children":2999},{"style":174},[3000],{"type":34,"value":343},{"type":29,"tag":88,"props":3002,"children":3003},{"style":122},[3004],{"type":34,"value":2800},{"type":29,"tag":88,"props":3006,"children":3007},{"class":90,"line":1264},[3008,3012,3016,3021,3025,3029,3033,3038],{"type":29,"tag":88,"props":3009,"children":3010},{"style":157},[3011],{"type":34,"value":2808},{"type":29,"tag":88,"props":3013,"children":3014},{"style":122},[3015],{"type":34,"value":338},{"type":29,"tag":88,"props":3017,"children":3018},{"style":174},[3019],{"type":34,"value":3020},"withPaymentId",{"type":29,"tag":88,"props":3022,"children":3023},{"style":122},[3024],{"type":34,"value":181},{"type":29,"tag":88,"props":3026,"children":3027},{"style":157},[3028],{"type":34,"value":2901},{"type":29,"tag":88,"props":3030,"children":3031},{"style":122},[3032],{"type":34,"value":338},{"type":29,"tag":88,"props":3034,"children":3035},{"style":174},[3036],{"type":34,"value":3037},"getTransactionId",{"type":29,"tag":88,"props":3039,"children":3040},{"style":122},[3041],{"type":34,"value":3042},"())\n",{"type":29,"tag":88,"props":3044,"children":3045},{"class":90,"line":1293},[3046,3051,3056,3060,3065,3069,3074],{"type":29,"tag":88,"props":3047,"children":3048},{"style":122},[3049],{"type":34,"value":3050},"                     .",{"type":29,"tag":88,"props":3052,"children":3053},{"style":174},[3054],{"type":34,"value":3055},"withStatus",{"type":29,"tag":88,"props":3057,"children":3058},{"style":122},[3059],{"type":34,"value":181},{"type":29,"tag":88,"props":3061,"children":3062},{"style":157},[3063],{"type":34,"value":3064},"OrderStatus",{"type":29,"tag":88,"props":3066,"children":3067},{"style":122},[3068],{"type":34,"value":338},{"type":29,"tag":88,"props":3070,"children":3071},{"style":157},[3072],{"type":34,"value":3073},"PAID",{"type":29,"tag":88,"props":3075,"children":3076},{"style":122},[3077],{"type":34,"value":3078},")\n",{"type":29,"tag":88,"props":3080,"children":3081},{"class":90,"line":1342},[3082],{"type":29,"tag":88,"props":3083,"children":3084},{"style":122},[3085],{"type":34,"value":2871},{"type":29,"tag":88,"props":3087,"children":3088},{"class":90,"line":1418},[3089],{"type":29,"tag":88,"props":3090,"children":3091},{"emptyLinePlaceholder":13},[3092],{"type":34,"value":134},{"type":29,"tag":88,"props":3094,"children":3095},{"class":90,"line":1426},[3096,3100,3104,3108,3113,3117,3121],{"type":29,"tag":88,"props":3097,"children":3098},{"style":105},[3099],{"type":34,"value":415},{"type":29,"tag":88,"props":3101,"children":3102},{"style":157},[3103],{"type":34,"value":785},{"type":29,"tag":88,"props":3105,"children":3106},{"style":122},[3107],{"type":34,"value":338},{"type":29,"tag":88,"props":3109,"children":3110},{"style":174},[3111],{"type":34,"value":3112},"findById",{"type":29,"tag":88,"props":3114,"children":3115},{"style":122},[3116],{"type":34,"value":181},{"type":29,"tag":88,"props":3118,"children":3119},{"style":157},[3120],{"type":34,"value":1836},{"type":29,"tag":88,"props":3122,"children":3123},{"style":122},[3124],{"type":34,"value":3078},{"type":29,"tag":88,"props":3126,"children":3127},{"class":90,"line":1434},[3128,3133,3138,3143,3148,3152,3157,3161,3166],{"type":29,"tag":88,"props":3129,"children":3130},{"style":122},[3131],{"type":34,"value":3132},"            .",{"type":29,"tag":88,"props":3134,"children":3135},{"style":174},[3136],{"type":34,"value":3137},"orElseThrow",{"type":29,"tag":88,"props":3139,"children":3140},{"style":122},[3141],{"type":34,"value":3142},"(()",{"type":29,"tag":88,"props":3144,"children":3145},{"style":105},[3146],{"type":34,"value":3147}," ->",{"type":29,"tag":88,"props":3149,"children":3150},{"style":105},[3151],{"type":34,"value":171},{"type":29,"tag":88,"props":3153,"children":3154},{"style":174},[3155],{"type":34,"value":3156}," IllegalStateException",{"type":29,"tag":88,"props":3158,"children":3159},{"style":122},[3160],{"type":34,"value":181},{"type":29,"tag":88,"props":3162,"children":3163},{"style":184},[3164],{"type":34,"value":3165},"\"Order not found after save\"",{"type":29,"tag":88,"props":3167,"children":3168},{"style":122},[3169],{"type":34,"value":1415},{"type":29,"tag":88,"props":3171,"children":3172},{"class":90,"line":1442},[3173],{"type":29,"tag":88,"props":3174,"children":3175},{"style":122},[3176],{"type":34,"value":433},{"type":29,"tag":88,"props":3178,"children":3179},{"class":90,"line":1451},[3180],{"type":29,"tag":88,"props":3181,"children":3182},{"style":122},[3183],{"type":34,"value":442},{"type":29,"tag":88,"props":3185,"children":3186},{"class":90,"line":1477},[3187],{"type":29,"tag":88,"props":3188,"children":3189},{"emptyLinePlaceholder":13},[3190],{"type":34,"value":134},{"type":29,"tag":88,"props":3192,"children":3193},{"class":90,"line":1516},[3194],{"type":29,"tag":88,"props":3195,"children":3196},{"style":95},[3197],{"type":34,"value":3198},"\u002F\u002F Fake en mémoire pour les tests - sans Stripe, sans base de données\n",{"type":29,"tag":88,"props":3200,"children":3201},{"class":90,"line":1573},[3202,3206,3210,3214,3218],{"type":29,"tag":88,"props":3203,"children":3204},{"style":105},[3205],{"type":34,"value":1225},{"type":29,"tag":88,"props":3207,"children":3208},{"style":116},[3209],{"type":34,"value":1651},{"type":29,"tag":88,"props":3211,"children":3212},{"style":105},[3213],{"type":34,"value":1134},{"type":29,"tag":88,"props":3215,"children":3216},{"style":116},[3217],{"type":34,"value":606},{"type":29,"tag":88,"props":3219,"children":3220},{"style":122},[3221],{"type":34,"value":125},{"type":29,"tag":88,"props":3223,"children":3224},{"class":90,"line":1611},[3225],{"type":29,"tag":88,"props":3226,"children":3227},{"emptyLinePlaceholder":13},[3228],{"type":34,"value":134},{"type":29,"tag":88,"props":3230,"children":3232},{"class":90,"line":3231},47,[3233,3237,3241,3245,3249,3253,3257,3261,3265,3270,3274,3278,3282],{"type":29,"tag":88,"props":3234,"children":3235},{"style":105},[3236],{"type":34,"value":143},{"type":29,"tag":88,"props":3238,"children":3239},{"style":105},[3240],{"type":34,"value":148},{"type":29,"tag":88,"props":3242,"children":3243},{"style":151},[3244],{"type":34,"value":1384},{"type":29,"tag":88,"props":3246,"children":3247},{"style":122},[3248],{"type":34,"value":1683},{"type":29,"tag":88,"props":3250,"children":3251},{"style":105},[3252],{"type":34,"value":695},{"type":29,"tag":88,"props":3254,"children":3255},{"style":122},[3256],{"type":34,"value":192},{"type":29,"tag":88,"props":3258,"children":3259},{"style":105},[3260],{"type":34,"value":1696},{"type":29,"tag":88,"props":3262,"children":3263},{"style":122},[3264],{"type":34,"value":1701},{"type":29,"tag":88,"props":3266,"children":3267},{"style":157},[3268],{"type":34,"value":3269}," store ",{"type":29,"tag":88,"props":3271,"children":3272},{"style":163},[3273],{"type":34,"value":166},{"type":29,"tag":88,"props":3275,"children":3276},{"style":105},[3277],{"type":34,"value":171},{"type":29,"tag":88,"props":3279,"children":3280},{"style":151},[3281],{"type":34,"value":1719},{"type":29,"tag":88,"props":3283,"children":3284},{"style":122},[3285],{"type":34,"value":1724},{"type":29,"tag":88,"props":3287,"children":3289},{"class":90,"line":3288},48,[3290],{"type":29,"tag":88,"props":3291,"children":3292},{"emptyLinePlaceholder":13},[3293],{"type":34,"value":134},{"type":29,"tag":88,"props":3295,"children":3297},{"class":90,"line":3296},49,[3298,3303],{"type":29,"tag":88,"props":3299,"children":3300},{"style":1974},[3301],{"type":34,"value":3302},"    @",{"type":29,"tag":88,"props":3304,"children":3305},{"style":1980},[3306],{"type":34,"value":3307},"Override\n",{"type":29,"tag":88,"props":3309,"children":3311},{"class":90,"line":3310},50,[3312,3316,3320,3324,3328,3332,3336,3340],{"type":29,"tag":88,"props":3313,"children":3314},{"style":105},[3315],{"type":34,"value":276},{"type":29,"tag":88,"props":3317,"children":3318},{"style":151},[3319],{"type":34,"value":281},{"type":29,"tag":88,"props":3321,"children":3322},{"style":174},[3323],{"type":34,"value":623},{"type":29,"tag":88,"props":3325,"children":3326},{"style":122},[3327],{"type":34,"value":181},{"type":29,"tag":88,"props":3329,"children":3330},{"style":151},[3331],{"type":34,"value":295},{"type":29,"tag":88,"props":3333,"children":3334},{"style":298},[3335],{"type":34,"value":301},{"type":29,"tag":88,"props":3337,"children":3338},{"style":122},[3339],{"type":34,"value":306},{"type":29,"tag":88,"props":3341,"children":3342},{"style":122},[3343],{"type":34,"value":125},{"type":29,"tag":88,"props":3345,"children":3347},{"class":90,"line":3346},51,[3348,3352,3357,3361,3365,3369,3373,3377,3381],{"type":29,"tag":88,"props":3349,"children":3350},{"style":151},[3351],{"type":34,"value":319},{"type":29,"tag":88,"props":3353,"children":3354},{"style":157},[3355],{"type":34,"value":3356}," id ",{"type":29,"tag":88,"props":3358,"children":3359},{"style":163},[3360],{"type":34,"value":166},{"type":29,"tag":88,"props":3362,"children":3363},{"style":157},[3364],{"type":34,"value":1786},{"type":29,"tag":88,"props":3366,"children":3367},{"style":122},[3368],{"type":34,"value":338},{"type":29,"tag":88,"props":3370,"children":3371},{"style":174},[3372],{"type":34,"value":1795},{"type":29,"tag":88,"props":3374,"children":3375},{"style":122},[3376],{"type":34,"value":1800},{"type":29,"tag":88,"props":3378,"children":3379},{"style":174},[3380],{"type":34,"value":1805},{"type":29,"tag":88,"props":3382,"children":3383},{"style":122},[3384],{"type":34,"value":1810},{"type":29,"tag":88,"props":3386,"children":3388},{"class":90,"line":3387},52,[3389,3394,3398,3402,3406,3411,3415,3419],{"type":29,"tag":88,"props":3390,"children":3391},{"style":157},[3392],{"type":34,"value":3393},"        store",{"type":29,"tag":88,"props":3395,"children":3396},{"style":122},[3397],{"type":34,"value":338},{"type":29,"tag":88,"props":3399,"children":3400},{"style":174},[3401],{"type":34,"value":1827},{"type":29,"tag":88,"props":3403,"children":3404},{"style":122},[3405],{"type":34,"value":181},{"type":29,"tag":88,"props":3407,"children":3408},{"style":157},[3409],{"type":34,"value":3410},"id",{"type":29,"tag":88,"props":3412,"children":3413},{"style":122},[3414],{"type":34,"value":192},{"type":29,"tag":88,"props":3416,"children":3417},{"style":157},[3418],{"type":34,"value":301},{"type":29,"tag":88,"props":3420,"children":3421},{"style":122},[3422],{"type":34,"value":357},{"type":29,"tag":88,"props":3424,"children":3426},{"class":90,"line":3425},53,[3427,3431,3436],{"type":29,"tag":88,"props":3428,"children":3429},{"style":105},[3430],{"type":34,"value":415},{"type":29,"tag":88,"props":3432,"children":3433},{"style":157},[3434],{"type":34,"value":3435}," id",{"type":29,"tag":88,"props":3437,"children":3438},{"style":122},[3439],{"type":34,"value":424},{"type":29,"tag":88,"props":3441,"children":3443},{"class":90,"line":3442},54,[3444],{"type":29,"tag":88,"props":3445,"children":3446},{"style":122},[3447],{"type":34,"value":433},{"type":29,"tag":88,"props":3449,"children":3451},{"class":90,"line":3450},55,[3452],{"type":29,"tag":88,"props":3453,"children":3454},{"emptyLinePlaceholder":13},[3455],{"type":34,"value":134},{"type":29,"tag":88,"props":3457,"children":3459},{"class":90,"line":3458},56,[3460,3464],{"type":29,"tag":88,"props":3461,"children":3462},{"style":1974},[3463],{"type":34,"value":3302},{"type":29,"tag":88,"props":3465,"children":3466},{"style":1980},[3467],{"type":34,"value":3307},{"type":29,"tag":88,"props":3469,"children":3471},{"class":90,"line":3470},57,[3472,3476,3481,3485,3489,3493,3497,3501,3505,3509,3513],{"type":29,"tag":88,"props":3473,"children":3474},{"style":105},[3475],{"type":34,"value":276},{"type":29,"tag":88,"props":3477,"children":3478},{"style":151},[3479],{"type":34,"value":3480}," Optional",{"type":29,"tag":88,"props":3482,"children":3483},{"style":122},[3484],{"type":34,"value":1683},{"type":29,"tag":88,"props":3486,"children":3487},{"style":105},[3488],{"type":34,"value":2386},{"type":29,"tag":88,"props":3490,"children":3491},{"style":122},[3492],{"type":34,"value":1701},{"type":29,"tag":88,"props":3494,"children":3495},{"style":174},[3496],{"type":34,"value":2395},{"type":29,"tag":88,"props":3498,"children":3499},{"style":122},[3500],{"type":34,"value":181},{"type":29,"tag":88,"props":3502,"children":3503},{"style":151},[3504],{"type":34,"value":695},{"type":29,"tag":88,"props":3506,"children":3507},{"style":298},[3508],{"type":34,"value":402},{"type":29,"tag":88,"props":3510,"children":3511},{"style":122},[3512],{"type":34,"value":306},{"type":29,"tag":88,"props":3514,"children":3515},{"style":122},[3516],{"type":34,"value":125},{"type":29,"tag":88,"props":3518,"children":3520},{"class":90,"line":3519},58,[3521,3525,3529,3533,3538,3542,3547,3551,3556,3560,3564],{"type":29,"tag":88,"props":3522,"children":3523},{"style":105},[3524],{"type":34,"value":415},{"type":29,"tag":88,"props":3526,"children":3527},{"style":157},[3528],{"type":34,"value":3480},{"type":29,"tag":88,"props":3530,"children":3531},{"style":122},[3532],{"type":34,"value":338},{"type":29,"tag":88,"props":3534,"children":3535},{"style":174},[3536],{"type":34,"value":3537},"ofNullable",{"type":29,"tag":88,"props":3539,"children":3540},{"style":122},[3541],{"type":34,"value":181},{"type":29,"tag":88,"props":3543,"children":3544},{"style":157},[3545],{"type":34,"value":3546},"store",{"type":29,"tag":88,"props":3548,"children":3549},{"style":122},[3550],{"type":34,"value":338},{"type":29,"tag":88,"props":3552,"children":3553},{"style":174},[3554],{"type":34,"value":3555},"get",{"type":29,"tag":88,"props":3557,"children":3558},{"style":122},[3559],{"type":34,"value":181},{"type":29,"tag":88,"props":3561,"children":3562},{"style":157},[3563],{"type":34,"value":1836},{"type":29,"tag":88,"props":3565,"children":3566},{"style":122},[3567],{"type":34,"value":3568},"))\n",{"type":29,"tag":88,"props":3570,"children":3572},{"class":90,"line":3571},59,[3573,3577,3582,3586,3591,3596,3600,3604,3608,3612,3616,3621,3625,3630],{"type":29,"tag":88,"props":3574,"children":3575},{"style":122},[3576],{"type":34,"value":3132},{"type":29,"tag":88,"props":3578,"children":3579},{"style":174},[3580],{"type":34,"value":3581},"map",{"type":29,"tag":88,"props":3583,"children":3584},{"style":122},[3585],{"type":34,"value":181},{"type":29,"tag":88,"props":3587,"children":3588},{"style":157},[3589],{"type":34,"value":3590},"data ",{"type":29,"tag":88,"props":3592,"children":3593},{"style":105},[3594],{"type":34,"value":3595},"->",{"type":29,"tag":88,"props":3597,"children":3598},{"style":105},[3599],{"type":34,"value":171},{"type":29,"tag":88,"props":3601,"children":3602},{"style":174},[3603],{"type":34,"value":2740},{"type":29,"tag":88,"props":3605,"children":3606},{"style":122},[3607],{"type":34,"value":181},{"type":29,"tag":88,"props":3609,"children":3610},{"style":157},[3611],{"type":34,"value":1836},{"type":29,"tag":88,"props":3613,"children":3614},{"style":122},[3615],{"type":34,"value":192},{"type":29,"tag":88,"props":3617,"children":3618},{"style":157},[3619],{"type":34,"value":3620}," data",{"type":29,"tag":88,"props":3622,"children":3623},{"style":122},[3624],{"type":34,"value":338},{"type":29,"tag":88,"props":3626,"children":3627},{"style":174},[3628],{"type":34,"value":3629},"getStatus",{"type":29,"tag":88,"props":3631,"children":3632},{"style":122},[3633],{"type":34,"value":3634},"()));\n",{"type":29,"tag":88,"props":3636,"children":3638},{"class":90,"line":3637},60,[3639],{"type":29,"tag":88,"props":3640,"children":3641},{"style":122},[3642],{"type":34,"value":433},{"type":29,"tag":88,"props":3644,"children":3646},{"class":90,"line":3645},61,[3647],{"type":29,"tag":88,"props":3648,"children":3649},{"style":122},[3650],{"type":34,"value":442},{"type":29,"tag":88,"props":3652,"children":3654},{"class":90,"line":3653},62,[3655],{"type":29,"tag":88,"props":3656,"children":3657},{"emptyLinePlaceholder":13},[3658],{"type":34,"value":134},{"type":29,"tag":88,"props":3660,"children":3662},{"class":90,"line":3661},63,[3663,3667,3672,3676,3680],{"type":29,"tag":88,"props":3664,"children":3665},{"style":105},[3666],{"type":34,"value":1225},{"type":29,"tag":88,"props":3668,"children":3669},{"style":116},[3670],{"type":34,"value":3671}," StubPaymentGateway",{"type":29,"tag":88,"props":3673,"children":3674},{"style":105},[3675],{"type":34,"value":1134},{"type":29,"tag":88,"props":3677,"children":3678},{"style":116},[3679],{"type":34,"value":2441},{"type":29,"tag":88,"props":3681,"children":3682},{"style":122},[3683],{"type":34,"value":125},{"type":29,"tag":88,"props":3685,"children":3687},{"class":90,"line":3686},64,[3688],{"type":29,"tag":88,"props":3689,"children":3690},{"emptyLinePlaceholder":13},[3691],{"type":34,"value":134},{"type":29,"tag":88,"props":3693,"children":3695},{"class":90,"line":3694},65,[3696,3700,3704,3708,3713],{"type":29,"tag":88,"props":3697,"children":3698},{"style":105},[3699],{"type":34,"value":143},{"type":29,"tag":88,"props":3701,"children":3702},{"style":105},[3703],{"type":34,"value":148},{"type":29,"tag":88,"props":3705,"children":3706},{"style":105},[3707],{"type":34,"value":1889},{"type":29,"tag":88,"props":3709,"children":3710},{"style":157},[3711],{"type":34,"value":3712}," shouldSucceed",{"type":29,"tag":88,"props":3714,"children":3715},{"style":122},[3716],{"type":34,"value":424},{"type":29,"tag":88,"props":3718,"children":3720},{"class":90,"line":3719},66,[3721],{"type":29,"tag":88,"props":3722,"children":3723},{"emptyLinePlaceholder":13},[3724],{"type":34,"value":134},{"type":29,"tag":88,"props":3726,"children":3728},{"class":90,"line":3727},67,[3729,3734,3738,3743,3747,3751],{"type":29,"tag":88,"props":3730,"children":3731},{"style":174},[3732],{"type":34,"value":3733},"    StubPaymentGateway",{"type":29,"tag":88,"props":3735,"children":3736},{"style":122},[3737],{"type":34,"value":181},{"type":29,"tag":88,"props":3739,"children":3740},{"style":105},[3741],{"type":34,"value":3742},"boolean",{"type":29,"tag":88,"props":3744,"children":3745},{"style":298},[3746],{"type":34,"value":3712},{"type":29,"tag":88,"props":3748,"children":3749},{"style":122},[3750],{"type":34,"value":306},{"type":29,"tag":88,"props":3752,"children":3753},{"style":122},[3754],{"type":34,"value":125},{"type":29,"tag":88,"props":3756,"children":3758},{"class":90,"line":3757},68,[3759,3763,3767,3772,3776,3780],{"type":29,"tag":88,"props":3760,"children":3761},{"style":873},[3762],{"type":34,"value":876},{"type":29,"tag":88,"props":3764,"children":3765},{"style":122},[3766],{"type":34,"value":338},{"type":29,"tag":88,"props":3768,"children":3769},{"style":157},[3770],{"type":34,"value":3771},"shouldSucceed ",{"type":29,"tag":88,"props":3773,"children":3774},{"style":163},[3775],{"type":34,"value":166},{"type":29,"tag":88,"props":3777,"children":3778},{"style":157},[3779],{"type":34,"value":3712},{"type":29,"tag":88,"props":3781,"children":3782},{"style":122},[3783],{"type":34,"value":424},{"type":29,"tag":88,"props":3785,"children":3787},{"class":90,"line":3786},69,[3788],{"type":29,"tag":88,"props":3789,"children":3790},{"style":122},[3791],{"type":34,"value":433},{"type":29,"tag":88,"props":3793,"children":3795},{"class":90,"line":3794},70,[3796],{"type":29,"tag":88,"props":3797,"children":3798},{"emptyLinePlaceholder":13},[3799],{"type":34,"value":134},{"type":29,"tag":88,"props":3801,"children":3803},{"class":90,"line":3802},71,[3804,3808],{"type":29,"tag":88,"props":3805,"children":3806},{"style":1974},[3807],{"type":34,"value":3302},{"type":29,"tag":88,"props":3809,"children":3810},{"style":1980},[3811],{"type":34,"value":3307},{"type":29,"tag":88,"props":3813,"children":3815},{"class":90,"line":3814},72,[3816,3820,3825,3829,3833,3837,3841,3845,3849,3853,3857,3861,3865,3869],{"type":29,"tag":88,"props":3817,"children":3818},{"style":105},[3819],{"type":34,"value":276},{"type":29,"tag":88,"props":3821,"children":3822},{"style":151},[3823],{"type":34,"value":3824}," PaymentResult",{"type":29,"tag":88,"props":3826,"children":3827},{"style":174},[3828],{"type":34,"value":2458},{"type":29,"tag":88,"props":3830,"children":3831},{"style":122},[3832],{"type":34,"value":181},{"type":29,"tag":88,"props":3834,"children":3835},{"style":151},[3836],{"type":34,"value":2467},{"type":29,"tag":88,"props":3838,"children":3839},{"style":298},[3840],{"type":34,"value":2472},{"type":29,"tag":88,"props":3842,"children":3843},{"style":122},[3844],{"type":34,"value":192},{"type":29,"tag":88,"props":3846,"children":3847},{"style":151},[3848],{"type":34,"value":281},{"type":29,"tag":88,"props":3850,"children":3851},{"style":298},[3852],{"type":34,"value":2485},{"type":29,"tag":88,"props":3854,"children":3855},{"style":122},[3856],{"type":34,"value":192},{"type":29,"tag":88,"props":3858,"children":3859},{"style":151},[3860],{"type":34,"value":281},{"type":29,"tag":88,"props":3862,"children":3863},{"style":298},[3864],{"type":34,"value":2498},{"type":29,"tag":88,"props":3866,"children":3867},{"style":122},[3868],{"type":34,"value":306},{"type":29,"tag":88,"props":3870,"children":3871},{"style":122},[3872],{"type":34,"value":125},{"type":29,"tag":88,"props":3874,"children":3876},{"class":90,"line":3875},73,[3877,3881],{"type":29,"tag":88,"props":3878,"children":3879},{"style":105},[3880],{"type":34,"value":415},{"type":29,"tag":88,"props":3882,"children":3883},{"style":157},[3884],{"type":34,"value":3885}," shouldSucceed\n",{"type":29,"tag":88,"props":3887,"children":3889},{"class":90,"line":3888},74,[3890,3895,3899,3903,3908,3912,3917],{"type":29,"tag":88,"props":3891,"children":3892},{"style":105},[3893],{"type":34,"value":3894},"            ?",{"type":29,"tag":88,"props":3896,"children":3897},{"style":157},[3898],{"type":34,"value":3824},{"type":29,"tag":88,"props":3900,"children":3901},{"style":122},[3902],{"type":34,"value":338},{"type":29,"tag":88,"props":3904,"children":3905},{"style":174},[3906],{"type":34,"value":3907},"success",{"type":29,"tag":88,"props":3909,"children":3910},{"style":122},[3911],{"type":34,"value":181},{"type":29,"tag":88,"props":3913,"children":3914},{"style":184},[3915],{"type":34,"value":3916},"\"txn-456\"",{"type":29,"tag":88,"props":3918,"children":3919},{"style":122},[3920],{"type":34,"value":3078},{"type":29,"tag":88,"props":3922,"children":3924},{"class":90,"line":3923},75,[3925,3930,3934,3938,3943,3947,3952],{"type":29,"tag":88,"props":3926,"children":3927},{"style":105},[3928],{"type":34,"value":3929},"            :",{"type":29,"tag":88,"props":3931,"children":3932},{"style":157},[3933],{"type":34,"value":3824},{"type":29,"tag":88,"props":3935,"children":3936},{"style":122},[3937],{"type":34,"value":338},{"type":29,"tag":88,"props":3939,"children":3940},{"style":174},[3941],{"type":34,"value":3942},"failure",{"type":29,"tag":88,"props":3944,"children":3945},{"style":122},[3946],{"type":34,"value":181},{"type":29,"tag":88,"props":3948,"children":3949},{"style":184},[3950],{"type":34,"value":3951},"\"CARD_DECLINED\"",{"type":29,"tag":88,"props":3953,"children":3954},{"style":122},[3955],{"type":34,"value":357},{"type":29,"tag":88,"props":3957,"children":3959},{"class":90,"line":3958},76,[3960],{"type":29,"tag":88,"props":3961,"children":3962},{"style":122},[3963],{"type":34,"value":433},{"type":29,"tag":88,"props":3965,"children":3967},{"class":90,"line":3966},77,[3968],{"type":29,"tag":88,"props":3969,"children":3970},{"style":122},[3971],{"type":34,"value":442},{"type":29,"tag":88,"props":3973,"children":3975},{"class":90,"line":3974},78,[3976],{"type":29,"tag":88,"props":3977,"children":3978},{"emptyLinePlaceholder":13},[3979],{"type":34,"value":134},{"type":29,"tag":88,"props":3981,"children":3983},{"class":90,"line":3982},79,[3984],{"type":29,"tag":88,"props":3985,"children":3986},{"style":95},[3987],{"type":34,"value":3988},"\u002F\u002F Test JUnit 5 - s'exécute en millisecondes, sans infra\n",{"type":29,"tag":88,"props":3990,"children":3992},{"class":90,"line":3991},80,[3993,3997,4002],{"type":29,"tag":88,"props":3994,"children":3995},{"style":105},[3996],{"type":34,"value":1225},{"type":29,"tag":88,"props":3998,"children":3999},{"style":116},[4000],{"type":34,"value":4001}," OrderServiceTest",{"type":29,"tag":88,"props":4003,"children":4004},{"style":122},[4005],{"type":34,"value":125},{"type":29,"tag":88,"props":4007,"children":4009},{"class":90,"line":4008},81,[4010],{"type":29,"tag":88,"props":4011,"children":4012},{"emptyLinePlaceholder":13},[4013],{"type":34,"value":134},{"type":29,"tag":88,"props":4015,"children":4017},{"class":90,"line":4016},82,[4018,4022],{"type":29,"tag":88,"props":4019,"children":4020},{"style":1974},[4021],{"type":34,"value":3302},{"type":29,"tag":88,"props":4023,"children":4024},{"style":1980},[4025],{"type":34,"value":1983},{"type":29,"tag":88,"props":4027,"children":4029},{"class":90,"line":4028},83,[4030,4034,4039,4043],{"type":29,"tag":88,"props":4031,"children":4032},{"style":105},[4033],{"type":34,"value":681},{"type":29,"tag":88,"props":4035,"children":4036},{"style":174},[4037],{"type":34,"value":4038}," shouldCreateOrderWithSuccessfulPayment",{"type":29,"tag":88,"props":4040,"children":4041},{"style":122},[4042],{"type":34,"value":1470},{"type":29,"tag":88,"props":4044,"children":4045},{"style":122},[4046],{"type":34,"value":125},{"type":29,"tag":88,"props":4048,"children":4050},{"class":90,"line":4049},84,[4051,4056,4060,4064,4068,4072],{"type":29,"tag":88,"props":4052,"children":4053},{"style":151},[4054],{"type":34,"value":4055},"        OrderRepository",{"type":29,"tag":88,"props":4057,"children":4058},{"style":157},[4059],{"type":34,"value":1488},{"type":29,"tag":88,"props":4061,"children":4062},{"style":163},[4063],{"type":34,"value":166},{"type":29,"tag":88,"props":4065,"children":4066},{"style":105},[4067],{"type":34,"value":171},{"type":29,"tag":88,"props":4069,"children":4070},{"style":174},[4071],{"type":34,"value":1651},{"type":29,"tag":88,"props":4073,"children":4074},{"style":122},[4075],{"type":34,"value":1810},{"type":29,"tag":88,"props":4077,"children":4079},{"class":90,"line":4078},85,[4080,4085,4090,4094,4098,4102,4106,4111],{"type":29,"tag":88,"props":4081,"children":4082},{"style":151},[4083],{"type":34,"value":4084},"        PaymentGateway",{"type":29,"tag":88,"props":4086,"children":4087},{"style":157},[4088],{"type":34,"value":4089}," payment ",{"type":29,"tag":88,"props":4091,"children":4092},{"style":163},[4093],{"type":34,"value":166},{"type":29,"tag":88,"props":4095,"children":4096},{"style":105},[4097],{"type":34,"value":171},{"type":29,"tag":88,"props":4099,"children":4100},{"style":174},[4101],{"type":34,"value":3671},{"type":29,"tag":88,"props":4103,"children":4104},{"style":122},[4105],{"type":34,"value":181},{"type":29,"tag":88,"props":4107,"children":4108},{"style":873},[4109],{"type":34,"value":4110},"true",{"type":29,"tag":88,"props":4112,"children":4113},{"style":122},[4114],{"type":34,"value":357},{"type":29,"tag":88,"props":4116,"children":4118},{"class":90,"line":4117},86,[4119,4124,4128,4132,4136,4140,4144,4148,4152,4156],{"type":29,"tag":88,"props":4120,"children":4121},{"style":151},[4122],{"type":34,"value":4123},"        OrderService",{"type":29,"tag":88,"props":4125,"children":4126},{"style":157},[4127],{"type":34,"value":2074},{"type":29,"tag":88,"props":4129,"children":4130},{"style":163},[4131],{"type":34,"value":166},{"type":29,"tag":88,"props":4133,"children":4134},{"style":105},[4135],{"type":34,"value":171},{"type":29,"tag":88,"props":4137,"children":4138},{"style":174},[4139],{"type":34,"value":119},{"type":29,"tag":88,"props":4141,"children":4142},{"style":122},[4143],{"type":34,"value":181},{"type":29,"tag":88,"props":4145,"children":4146},{"style":157},[4147],{"type":34,"value":1596},{"type":29,"tag":88,"props":4149,"children":4150},{"style":122},[4151],{"type":34,"value":192},{"type":29,"tag":88,"props":4153,"children":4154},{"style":157},[4155],{"type":34,"value":2605},{"type":29,"tag":88,"props":4157,"children":4158},{"style":122},[4159],{"type":34,"value":357},{"type":29,"tag":88,"props":4161,"children":4163},{"class":90,"line":4162},87,[4164],{"type":29,"tag":88,"props":4165,"children":4166},{"emptyLinePlaceholder":13},[4167],{"type":34,"value":134},{"type":29,"tag":88,"props":4169,"children":4171},{"class":90,"line":4170},88,[4172,4177,4182,4186,4190,4194,4199],{"type":29,"tag":88,"props":4173,"children":4174},{"style":151},[4175],{"type":34,"value":4176},"        Order",{"type":29,"tag":88,"props":4178,"children":4179},{"style":157},[4180],{"type":34,"value":4181}," order ",{"type":29,"tag":88,"props":4183,"children":4184},{"style":163},[4185],{"type":34,"value":166},{"type":29,"tag":88,"props":4187,"children":4188},{"style":157},[4189],{"type":34,"value":2133},{"type":29,"tag":88,"props":4191,"children":4192},{"style":122},[4193],{"type":34,"value":338},{"type":29,"tag":88,"props":4195,"children":4196},{"style":174},[4197],{"type":34,"value":4198},"createPaidOrder",{"type":29,"tag":88,"props":4200,"children":4201},{"style":122},[4202],{"type":34,"value":2800},{"type":29,"tag":88,"props":4204,"children":4206},{"class":90,"line":4205},89,[4207,4212,4216,4220,4224,4229,4233,4238,4243,4248,4252,4257],{"type":29,"tag":88,"props":4208,"children":4209},{"style":105},[4210],{"type":34,"value":4211},"            new",{"type":29,"tag":88,"props":4213,"children":4214},{"style":174},[4215],{"type":34,"value":1696},{"type":29,"tag":88,"props":4217,"children":4218},{"style":122},[4219],{"type":34,"value":181},{"type":29,"tag":88,"props":4221,"children":4222},{"style":105},[4223],{"type":34,"value":2151},{"type":29,"tag":88,"props":4225,"children":4226},{"style":174},[4227],{"type":34,"value":4228}," BigDecimal",{"type":29,"tag":88,"props":4230,"children":4231},{"style":122},[4232],{"type":34,"value":181},{"type":29,"tag":88,"props":4234,"children":4235},{"style":184},[4236],{"type":34,"value":4237},"\"1000\"",{"type":29,"tag":88,"props":4239,"children":4240},{"style":122},[4241],{"type":34,"value":4242},"),",{"type":29,"tag":88,"props":4244,"children":4245},{"style":184},[4246],{"type":34,"value":4247}," \"EUR\"",{"type":29,"tag":88,"props":4249,"children":4250},{"style":122},[4251],{"type":34,"value":192},{"type":29,"tag":88,"props":4253,"children":4254},{"style":184},[4255],{"type":34,"value":4256}," \"pm-123\"",{"type":29,"tag":88,"props":4258,"children":4259},{"style":122},[4260],{"type":34,"value":3078},{"type":29,"tag":88,"props":4262,"children":4264},{"class":90,"line":4263},90,[4265],{"type":29,"tag":88,"props":4266,"children":4267},{"style":122},[4268],{"type":34,"value":2871},{"type":29,"tag":88,"props":4270,"children":4272},{"class":90,"line":4271},91,[4273],{"type":29,"tag":88,"props":4274,"children":4275},{"emptyLinePlaceholder":13},[4276],{"type":34,"value":134},{"type":29,"tag":88,"props":4278,"children":4280},{"class":90,"line":4279},92,[4281,4286,4290,4294,4298,4302,4306,4311,4315,4319],{"type":29,"tag":88,"props":4282,"children":4283},{"style":174},[4284],{"type":34,"value":4285},"        assertEquals",{"type":29,"tag":88,"props":4287,"children":4288},{"style":122},[4289],{"type":34,"value":181},{"type":29,"tag":88,"props":4291,"children":4292},{"style":157},[4293],{"type":34,"value":3064},{"type":29,"tag":88,"props":4295,"children":4296},{"style":122},[4297],{"type":34,"value":338},{"type":29,"tag":88,"props":4299,"children":4300},{"style":157},[4301],{"type":34,"value":3073},{"type":29,"tag":88,"props":4303,"children":4304},{"style":122},[4305],{"type":34,"value":192},{"type":29,"tag":88,"props":4307,"children":4308},{"style":157},[4309],{"type":34,"value":4310}," order",{"type":29,"tag":88,"props":4312,"children":4313},{"style":122},[4314],{"type":34,"value":338},{"type":29,"tag":88,"props":4316,"children":4317},{"style":174},[4318],{"type":34,"value":3629},{"type":29,"tag":88,"props":4320,"children":4321},{"style":122},[4322],{"type":34,"value":2958},{"type":29,"tag":88,"props":4324,"children":4326},{"class":90,"line":4325},93,[4327],{"type":29,"tag":88,"props":4328,"children":4329},{"style":122},[4330],{"type":34,"value":433},{"type":29,"tag":88,"props":4332,"children":4334},{"class":90,"line":4333},94,[4335],{"type":29,"tag":88,"props":4336,"children":4337},{"emptyLinePlaceholder":13},[4338],{"type":34,"value":134},{"type":29,"tag":88,"props":4340,"children":4342},{"class":90,"line":4341},95,[4343,4347],{"type":29,"tag":88,"props":4344,"children":4345},{"style":1974},[4346],{"type":34,"value":3302},{"type":29,"tag":88,"props":4348,"children":4349},{"style":1980},[4350],{"type":34,"value":1983},{"type":29,"tag":88,"props":4352,"children":4354},{"class":90,"line":4353},96,[4355,4359,4364,4368],{"type":29,"tag":88,"props":4356,"children":4357},{"style":105},[4358],{"type":34,"value":681},{"type":29,"tag":88,"props":4360,"children":4361},{"style":174},[4362],{"type":34,"value":4363}," shouldThrowWhenPaymentFails",{"type":29,"tag":88,"props":4365,"children":4366},{"style":122},[4367],{"type":34,"value":1470},{"type":29,"tag":88,"props":4369,"children":4370},{"style":122},[4371],{"type":34,"value":125},{"type":29,"tag":88,"props":4373,"children":4375},{"class":90,"line":4374},97,[4376,4380,4384,4388,4392,4396],{"type":29,"tag":88,"props":4377,"children":4378},{"style":151},[4379],{"type":34,"value":4123},{"type":29,"tag":88,"props":4381,"children":4382},{"style":157},[4383],{"type":34,"value":2074},{"type":29,"tag":88,"props":4385,"children":4386},{"style":163},[4387],{"type":34,"value":166},{"type":29,"tag":88,"props":4389,"children":4390},{"style":105},[4391],{"type":34,"value":171},{"type":29,"tag":88,"props":4393,"children":4394},{"style":174},[4395],{"type":34,"value":119},{"type":29,"tag":88,"props":4397,"children":4398},{"style":122},[4399],{"type":34,"value":2800},{"type":29,"tag":88,"props":4401,"children":4403},{"class":90,"line":4402},98,[4404,4408,4412],{"type":29,"tag":88,"props":4405,"children":4406},{"style":105},[4407],{"type":34,"value":4211},{"type":29,"tag":88,"props":4409,"children":4410},{"style":174},[4411],{"type":34,"value":1651},{"type":29,"tag":88,"props":4413,"children":4414},{"style":122},[4415],{"type":34,"value":2822},{"type":29,"tag":88,"props":4417,"children":4419},{"class":90,"line":4418},99,[4420,4424,4428,4432,4437],{"type":29,"tag":88,"props":4421,"children":4422},{"style":105},[4423],{"type":34,"value":4211},{"type":29,"tag":88,"props":4425,"children":4426},{"style":174},[4427],{"type":34,"value":3671},{"type":29,"tag":88,"props":4429,"children":4430},{"style":122},[4431],{"type":34,"value":181},{"type":29,"tag":88,"props":4433,"children":4434},{"style":873},[4435],{"type":34,"value":4436},"false",{"type":29,"tag":88,"props":4438,"children":4439},{"style":122},[4440],{"type":34,"value":3078},{"type":29,"tag":88,"props":4442,"children":4444},{"class":90,"line":4443},100,[4445],{"type":29,"tag":88,"props":4446,"children":4447},{"style":122},[4448],{"type":34,"value":2871},{"type":29,"tag":88,"props":4450,"children":4452},{"class":90,"line":4451},101,[4453],{"type":29,"tag":88,"props":4454,"children":4455},{"emptyLinePlaceholder":13},[4456],{"type":34,"value":134},{"type":29,"tag":88,"props":4458,"children":4460},{"class":90,"line":4459},102,[4461,4466,4470,4475,4479,4483,4487,4492],{"type":29,"tag":88,"props":4462,"children":4463},{"style":174},[4464],{"type":34,"value":4465},"        assertThrows",{"type":29,"tag":88,"props":4467,"children":4468},{"style":122},[4469],{"type":34,"value":181},{"type":29,"tag":88,"props":4471,"children":4472},{"style":157},[4473],{"type":34,"value":4474},"PaymentFailedException",{"type":29,"tag":88,"props":4476,"children":4477},{"style":122},[4478],{"type":34,"value":338},{"type":29,"tag":88,"props":4480,"children":4481},{"style":157},[4482],{"type":34,"value":1225},{"type":29,"tag":88,"props":4484,"children":4485},{"style":122},[4486],{"type":34,"value":192},{"type":29,"tag":88,"props":4488,"children":4489},{"style":122},[4490],{"type":34,"value":4491}," ()",{"type":29,"tag":88,"props":4493,"children":4494},{"style":105},[4495],{"type":34,"value":4496}," ->\n",{"type":29,"tag":88,"props":4498,"children":4500},{"class":90,"line":4499},103,[4501,4506,4510,4514,4518,4522,4526,4530,4534,4538,4542,4546,4550,4554,4558,4562],{"type":29,"tag":88,"props":4502,"children":4503},{"style":157},[4504],{"type":34,"value":4505},"            service",{"type":29,"tag":88,"props":4507,"children":4508},{"style":122},[4509],{"type":34,"value":338},{"type":29,"tag":88,"props":4511,"children":4512},{"style":174},[4513],{"type":34,"value":4198},{"type":29,"tag":88,"props":4515,"children":4516},{"style":122},[4517],{"type":34,"value":181},{"type":29,"tag":88,"props":4519,"children":4520},{"style":105},[4521],{"type":34,"value":2151},{"type":29,"tag":88,"props":4523,"children":4524},{"style":174},[4525],{"type":34,"value":1696},{"type":29,"tag":88,"props":4527,"children":4528},{"style":122},[4529],{"type":34,"value":181},{"type":29,"tag":88,"props":4531,"children":4532},{"style":105},[4533],{"type":34,"value":2151},{"type":29,"tag":88,"props":4535,"children":4536},{"style":174},[4537],{"type":34,"value":4228},{"type":29,"tag":88,"props":4539,"children":4540},{"style":122},[4541],{"type":34,"value":181},{"type":29,"tag":88,"props":4543,"children":4544},{"style":184},[4545],{"type":34,"value":4237},{"type":29,"tag":88,"props":4547,"children":4548},{"style":122},[4549],{"type":34,"value":4242},{"type":29,"tag":88,"props":4551,"children":4552},{"style":184},[4553],{"type":34,"value":4247},{"type":29,"tag":88,"props":4555,"children":4556},{"style":122},[4557],{"type":34,"value":192},{"type":29,"tag":88,"props":4559,"children":4560},{"style":184},[4561],{"type":34,"value":4256},{"type":29,"tag":88,"props":4563,"children":4564},{"style":122},[4565],{"type":34,"value":3568},{"type":29,"tag":88,"props":4567,"children":4569},{"class":90,"line":4568},104,[4570],{"type":29,"tag":88,"props":4571,"children":4572},{"style":122},[4573],{"type":34,"value":2871},{"type":29,"tag":88,"props":4575,"children":4577},{"class":90,"line":4576},105,[4578],{"type":29,"tag":88,"props":4579,"children":4580},{"style":122},[4581],{"type":34,"value":433},{"type":29,"tag":88,"props":4583,"children":4585},{"class":90,"line":4584},106,[4586],{"type":29,"tag":88,"props":4587,"children":4588},{"style":122},[4589],{"type":34,"value":442},{"type":29,"tag":30,"props":4591,"children":4592},{},[4593,4598,4600,4606,4608,4614,4615,4621],{"type":29,"tag":447,"props":4594,"children":4595},{},[4596],{"type":34,"value":4597},"L'avantage Java\u002FSpring :",{"type":34,"value":4599}," les interfaces sont des contrats vérifiés à la compilation. Si un adapter ne respecte pas le port, ",{"type":29,"tag":84,"props":4601,"children":4603},{"className":4602},[],[4604],{"type":34,"value":4605},"javac",{"type":34,"value":4607}," rejette le code avant l'exécution. Spring injecte automatiquement l'adapter correct (",{"type":29,"tag":84,"props":4609,"children":4611},{"className":4610},[],[4612],{"type":34,"value":4613},"@Repository",{"type":34,"value":544},{"type":29,"tag":84,"props":4616,"children":4618},{"className":4617},[],[4619],{"type":34,"value":4620},"@Component",{"type":34,"value":4622},") en production : le service métier ne sait pas quelle implémentation tourne.",{"type":29,"tag":47,"props":4624,"children":4625},{},[],{"type":29,"tag":51,"props":4627,"children":4629},{"id":4628},"exemple-3-java-le-dip-avec-spring",[4630],{"type":34,"value":4631},"Exemple 3 : Java, le DIP avec Spring",{"type":29,"tag":77,"props":4633,"children":4635},{"code":4634,"language":80,"meta":8,"className":81,"style":8},"\u002F\u002F L'abstraction\npublic interface NotificationService {\n    void sendOrderConfirmation(String userId, String orderId);\n    void sendShippingUpdate(String userId, String orderId, String trackingCode);\n}\n\n\u002F\u002F Le module de haut niveau (service métier)\n@Service\npublic class OrderFulfillmentService {\n\n    private final OrderRepository orderRepository;\n    private final NotificationService notificationService;\n\n    public OrderFulfillmentService(\n            OrderRepository orderRepository,\n            NotificationService notificationService) {\n        this.orderRepository = orderRepository;\n        this.notificationService = notificationService;\n    }\n\n    public void fulfillOrder(String orderId) {\n        Order order = orderRepository.findById(orderId)\n            .orElseThrow(() -> new OrderNotFoundException(orderId));\n\n        order.setStatus(OrderStatus.FULFILLING);\n        orderRepository.save(order);\n\n        notificationService.sendOrderConfirmation(order.getUserId(), orderId);\n    }\n}\n\n\u002F\u002F Implémentation de test\n@Service\n@Profile(\"test\")\npublic class MockNotificationService implements NotificationService {\n\n    private final List\u003CString> sentNotifications = new ArrayList\u003C>();\n\n    @Override\n    public void sendOrderConfirmation(String userId, String orderId) {\n        sentNotifications.add(\"confirmation:\" + userId + \":\" + orderId);\n    }\n}\n",[4636],{"type":29,"tag":84,"props":4637,"children":4638},{"__ignoreMap":8},[4639,4647,4667,4708,4761,4768,4775,4783,4794,4814,4821,4845,4869,4876,4891,4908,4928,4956,4984,4991,4998,5034,5073,5113,5120,5158,5187,5194,5240,5247,5254,5261,5269,5280,5305,5333,5340,5390,5397,5408,5455,5513,5520],{"type":29,"tag":88,"props":4640,"children":4641},{"class":90,"line":91},[4642],{"type":29,"tag":88,"props":4643,"children":4644},{"style":95},[4645],{"type":34,"value":4646},"\u002F\u002F L'abstraction\n",{"type":29,"tag":88,"props":4648,"children":4649},{"class":90,"line":101},[4650,4654,4658,4663],{"type":29,"tag":88,"props":4651,"children":4652},{"style":105},[4653],{"type":34,"value":108},{"type":29,"tag":88,"props":4655,"children":4656},{"style":105},[4657],{"type":34,"value":601},{"type":29,"tag":88,"props":4659,"children":4660},{"style":116},[4661],{"type":34,"value":4662}," NotificationService",{"type":29,"tag":88,"props":4664,"children":4665},{"style":122},[4666],{"type":34,"value":125},{"type":29,"tag":88,"props":4668,"children":4669},{"class":90,"line":128},[4670,4674,4679,4683,4687,4692,4696,4700,4704],{"type":29,"tag":88,"props":4671,"children":4672},{"style":105},[4673],{"type":34,"value":681},{"type":29,"tag":88,"props":4675,"children":4676},{"style":174},[4677],{"type":34,"value":4678}," sendOrderConfirmation",{"type":29,"tag":88,"props":4680,"children":4681},{"style":122},[4682],{"type":34,"value":181},{"type":29,"tag":88,"props":4684,"children":4685},{"style":151},[4686],{"type":34,"value":695},{"type":29,"tag":88,"props":4688,"children":4689},{"style":298},[4690],{"type":34,"value":4691}," userId",{"type":29,"tag":88,"props":4693,"children":4694},{"style":122},[4695],{"type":34,"value":192},{"type":29,"tag":88,"props":4697,"children":4698},{"style":151},[4699],{"type":34,"value":281},{"type":29,"tag":88,"props":4701,"children":4702},{"style":298},[4703],{"type":34,"value":402},{"type":29,"tag":88,"props":4705,"children":4706},{"style":122},[4707],{"type":34,"value":357},{"type":29,"tag":88,"props":4709,"children":4710},{"class":90,"line":137},[4711,4715,4720,4724,4728,4732,4736,4740,4744,4748,4752,4757],{"type":29,"tag":88,"props":4712,"children":4713},{"style":105},[4714],{"type":34,"value":681},{"type":29,"tag":88,"props":4716,"children":4717},{"style":174},[4718],{"type":34,"value":4719}," sendShippingUpdate",{"type":29,"tag":88,"props":4721,"children":4722},{"style":122},[4723],{"type":34,"value":181},{"type":29,"tag":88,"props":4725,"children":4726},{"style":151},[4727],{"type":34,"value":695},{"type":29,"tag":88,"props":4729,"children":4730},{"style":298},[4731],{"type":34,"value":4691},{"type":29,"tag":88,"props":4733,"children":4734},{"style":122},[4735],{"type":34,"value":192},{"type":29,"tag":88,"props":4737,"children":4738},{"style":151},[4739],{"type":34,"value":281},{"type":29,"tag":88,"props":4741,"children":4742},{"style":298},[4743],{"type":34,"value":402},{"type":29,"tag":88,"props":4745,"children":4746},{"style":122},[4747],{"type":34,"value":192},{"type":29,"tag":88,"props":4749,"children":4750},{"style":151},[4751],{"type":34,"value":281},{"type":29,"tag":88,"props":4753,"children":4754},{"style":298},[4755],{"type":34,"value":4756}," trackingCode",{"type":29,"tag":88,"props":4758,"children":4759},{"style":122},[4760],{"type":34,"value":357},{"type":29,"tag":88,"props":4762,"children":4763},{"class":90,"line":211},[4764],{"type":29,"tag":88,"props":4765,"children":4766},{"style":122},[4767],{"type":34,"value":442},{"type":29,"tag":88,"props":4769,"children":4770},{"class":90,"line":262},[4771],{"type":29,"tag":88,"props":4772,"children":4773},{"emptyLinePlaceholder":13},[4774],{"type":34,"value":134},{"type":29,"tag":88,"props":4776,"children":4777},{"class":90,"line":270},[4778],{"type":29,"tag":88,"props":4779,"children":4780},{"style":95},[4781],{"type":34,"value":4782},"\u002F\u002F Le module de haut niveau (service métier)\n",{"type":29,"tag":88,"props":4784,"children":4785},{"class":90,"line":313},[4786,4790],{"type":29,"tag":88,"props":4787,"children":4788},{"style":1974},[4789],{"type":34,"value":1977},{"type":29,"tag":88,"props":4791,"children":4792},{"style":1980},[4793],{"type":34,"value":2536},{"type":29,"tag":88,"props":4795,"children":4796},{"class":90,"line":360},[4797,4801,4805,4810],{"type":29,"tag":88,"props":4798,"children":4799},{"style":105},[4800],{"type":34,"value":108},{"type":29,"tag":88,"props":4802,"children":4803},{"style":105},[4804],{"type":34,"value":113},{"type":29,"tag":88,"props":4806,"children":4807},{"style":116},[4808],{"type":34,"value":4809}," OrderFulfillmentService",{"type":29,"tag":88,"props":4811,"children":4812},{"style":122},[4813],{"type":34,"value":125},{"type":29,"tag":88,"props":4815,"children":4816},{"class":90,"line":409},[4817],{"type":29,"tag":88,"props":4818,"children":4819},{"emptyLinePlaceholder":13},[4820],{"type":34,"value":134},{"type":29,"tag":88,"props":4822,"children":4823},{"class":90,"line":427},[4824,4828,4832,4836,4841],{"type":29,"tag":88,"props":4825,"children":4826},{"style":105},[4827],{"type":34,"value":143},{"type":29,"tag":88,"props":4829,"children":4830},{"style":105},[4831],{"type":34,"value":148},{"type":29,"tag":88,"props":4833,"children":4834},{"style":151},[4835],{"type":34,"value":606},{"type":29,"tag":88,"props":4837,"children":4838},{"style":157},[4839],{"type":34,"value":4840}," orderRepository",{"type":29,"tag":88,"props":4842,"children":4843},{"style":122},[4844],{"type":34,"value":424},{"type":29,"tag":88,"props":4846,"children":4847},{"class":90,"line":436},[4848,4852,4856,4860,4865],{"type":29,"tag":88,"props":4849,"children":4850},{"style":105},[4851],{"type":34,"value":143},{"type":29,"tag":88,"props":4853,"children":4854},{"style":105},[4855],{"type":34,"value":148},{"type":29,"tag":88,"props":4857,"children":4858},{"style":151},[4859],{"type":34,"value":4662},{"type":29,"tag":88,"props":4861,"children":4862},{"style":157},[4863],{"type":34,"value":4864}," notificationService",{"type":29,"tag":88,"props":4866,"children":4867},{"style":122},[4868],{"type":34,"value":424},{"type":29,"tag":88,"props":4870,"children":4871},{"class":90,"line":767},[4872],{"type":29,"tag":88,"props":4873,"children":4874},{"emptyLinePlaceholder":13},[4875],{"type":34,"value":134},{"type":29,"tag":88,"props":4877,"children":4878},{"class":90,"line":792},[4879,4883,4887],{"type":29,"tag":88,"props":4880,"children":4881},{"style":105},[4882],{"type":34,"value":276},{"type":29,"tag":88,"props":4884,"children":4885},{"style":174},[4886],{"type":34,"value":4809},{"type":29,"tag":88,"props":4888,"children":4889},{"style":122},[4890],{"type":34,"value":2800},{"type":29,"tag":88,"props":4892,"children":4893},{"class":90,"line":817},[4894,4899,4903],{"type":29,"tag":88,"props":4895,"children":4896},{"style":151},[4897],{"type":34,"value":4898},"            OrderRepository",{"type":29,"tag":88,"props":4900,"children":4901},{"style":298},[4902],{"type":34,"value":4840},{"type":29,"tag":88,"props":4904,"children":4905},{"style":122},[4906],{"type":34,"value":4907},",\n",{"type":29,"tag":88,"props":4909,"children":4910},{"class":90,"line":825},[4911,4916,4920,4924],{"type":29,"tag":88,"props":4912,"children":4913},{"style":151},[4914],{"type":34,"value":4915},"            NotificationService",{"type":29,"tag":88,"props":4917,"children":4918},{"style":298},[4919],{"type":34,"value":4864},{"type":29,"tag":88,"props":4921,"children":4922},{"style":122},[4923],{"type":34,"value":306},{"type":29,"tag":88,"props":4925,"children":4926},{"style":122},[4927],{"type":34,"value":125},{"type":29,"tag":88,"props":4929,"children":4930},{"class":90,"line":869},[4931,4935,4939,4944,4948,4952],{"type":29,"tag":88,"props":4932,"children":4933},{"style":873},[4934],{"type":34,"value":876},{"type":29,"tag":88,"props":4936,"children":4937},{"style":122},[4938],{"type":34,"value":338},{"type":29,"tag":88,"props":4940,"children":4941},{"style":157},[4942],{"type":34,"value":4943},"orderRepository ",{"type":29,"tag":88,"props":4945,"children":4946},{"style":163},[4947],{"type":34,"value":166},{"type":29,"tag":88,"props":4949,"children":4950},{"style":157},[4951],{"type":34,"value":4840},{"type":29,"tag":88,"props":4953,"children":4954},{"style":122},[4955],{"type":34,"value":424},{"type":29,"tag":88,"props":4957,"children":4958},{"class":90,"line":900},[4959,4963,4967,4972,4976,4980],{"type":29,"tag":88,"props":4960,"children":4961},{"style":873},[4962],{"type":34,"value":876},{"type":29,"tag":88,"props":4964,"children":4965},{"style":122},[4966],{"type":34,"value":338},{"type":29,"tag":88,"props":4968,"children":4969},{"style":157},[4970],{"type":34,"value":4971},"notificationService ",{"type":29,"tag":88,"props":4973,"children":4974},{"style":163},[4975],{"type":34,"value":166},{"type":29,"tag":88,"props":4977,"children":4978},{"style":157},[4979],{"type":34,"value":4864},{"type":29,"tag":88,"props":4981,"children":4982},{"style":122},[4983],{"type":34,"value":424},{"type":29,"tag":88,"props":4985,"children":4986},{"class":90,"line":929},[4987],{"type":29,"tag":88,"props":4988,"children":4989},{"style":122},[4990],{"type":34,"value":433},{"type":29,"tag":88,"props":4992,"children":4993},{"class":90,"line":937},[4994],{"type":29,"tag":88,"props":4995,"children":4996},{"emptyLinePlaceholder":13},[4997],{"type":34,"value":134},{"type":29,"tag":88,"props":4999,"children":5000},{"class":90,"line":945},[5001,5005,5009,5014,5018,5022,5026,5030],{"type":29,"tag":88,"props":5002,"children":5003},{"style":105},[5004],{"type":34,"value":276},{"type":29,"tag":88,"props":5006,"children":5007},{"style":105},[5008],{"type":34,"value":1303},{"type":29,"tag":88,"props":5010,"children":5011},{"style":174},[5012],{"type":34,"value":5013}," fulfillOrder",{"type":29,"tag":88,"props":5015,"children":5016},{"style":122},[5017],{"type":34,"value":181},{"type":29,"tag":88,"props":5019,"children":5020},{"style":151},[5021],{"type":34,"value":695},{"type":29,"tag":88,"props":5023,"children":5024},{"style":298},[5025],{"type":34,"value":402},{"type":29,"tag":88,"props":5027,"children":5028},{"style":122},[5029],{"type":34,"value":306},{"type":29,"tag":88,"props":5031,"children":5032},{"style":122},[5033],{"type":34,"value":125},{"type":29,"tag":88,"props":5035,"children":5036},{"class":90,"line":981},[5037,5041,5045,5049,5053,5057,5061,5065,5069],{"type":29,"tag":88,"props":5038,"children":5039},{"style":151},[5040],{"type":34,"value":4176},{"type":29,"tag":88,"props":5042,"children":5043},{"style":157},[5044],{"type":34,"value":4181},{"type":29,"tag":88,"props":5046,"children":5047},{"style":163},[5048],{"type":34,"value":166},{"type":29,"tag":88,"props":5050,"children":5051},{"style":157},[5052],{"type":34,"value":4840},{"type":29,"tag":88,"props":5054,"children":5055},{"style":122},[5056],{"type":34,"value":338},{"type":29,"tag":88,"props":5058,"children":5059},{"style":174},[5060],{"type":34,"value":3112},{"type":29,"tag":88,"props":5062,"children":5063},{"style":122},[5064],{"type":34,"value":181},{"type":29,"tag":88,"props":5066,"children":5067},{"style":157},[5068],{"type":34,"value":1836},{"type":29,"tag":88,"props":5070,"children":5071},{"style":122},[5072],{"type":34,"value":3078},{"type":29,"tag":88,"props":5074,"children":5075},{"class":90,"line":1021},[5076,5080,5084,5088,5092,5096,5101,5105,5109],{"type":29,"tag":88,"props":5077,"children":5078},{"style":122},[5079],{"type":34,"value":3132},{"type":29,"tag":88,"props":5081,"children":5082},{"style":174},[5083],{"type":34,"value":3137},{"type":29,"tag":88,"props":5085,"children":5086},{"style":122},[5087],{"type":34,"value":3142},{"type":29,"tag":88,"props":5089,"children":5090},{"style":105},[5091],{"type":34,"value":3147},{"type":29,"tag":88,"props":5093,"children":5094},{"style":105},[5095],{"type":34,"value":171},{"type":29,"tag":88,"props":5097,"children":5098},{"style":174},[5099],{"type":34,"value":5100}," OrderNotFoundException",{"type":29,"tag":88,"props":5102,"children":5103},{"style":122},[5104],{"type":34,"value":181},{"type":29,"tag":88,"props":5106,"children":5107},{"style":157},[5108],{"type":34,"value":1836},{"type":29,"tag":88,"props":5110,"children":5111},{"style":122},[5112],{"type":34,"value":1415},{"type":29,"tag":88,"props":5114,"children":5115},{"class":90,"line":1066},[5116],{"type":29,"tag":88,"props":5117,"children":5118},{"emptyLinePlaceholder":13},[5119],{"type":34,"value":134},{"type":29,"tag":88,"props":5121,"children":5122},{"class":90,"line":1082},[5123,5128,5132,5137,5141,5145,5149,5154],{"type":29,"tag":88,"props":5124,"children":5125},{"style":157},[5126],{"type":34,"value":5127},"        order",{"type":29,"tag":88,"props":5129,"children":5130},{"style":122},[5131],{"type":34,"value":338},{"type":29,"tag":88,"props":5133,"children":5134},{"style":174},[5135],{"type":34,"value":5136},"setStatus",{"type":29,"tag":88,"props":5138,"children":5139},{"style":122},[5140],{"type":34,"value":181},{"type":29,"tag":88,"props":5142,"children":5143},{"style":157},[5144],{"type":34,"value":3064},{"type":29,"tag":88,"props":5146,"children":5147},{"style":122},[5148],{"type":34,"value":338},{"type":29,"tag":88,"props":5150,"children":5151},{"style":157},[5152],{"type":34,"value":5153},"FULFILLING",{"type":29,"tag":88,"props":5155,"children":5156},{"style":122},[5157],{"type":34,"value":357},{"type":29,"tag":88,"props":5159,"children":5160},{"class":90,"line":1090},[5161,5166,5170,5174,5178,5183],{"type":29,"tag":88,"props":5162,"children":5163},{"style":157},[5164],{"type":34,"value":5165},"        orderRepository",{"type":29,"tag":88,"props":5167,"children":5168},{"style":122},[5169],{"type":34,"value":338},{"type":29,"tag":88,"props":5171,"children":5172},{"style":174},[5173],{"type":34,"value":343},{"type":29,"tag":88,"props":5175,"children":5176},{"style":122},[5177],{"type":34,"value":181},{"type":29,"tag":88,"props":5179,"children":5180},{"style":157},[5181],{"type":34,"value":5182},"order",{"type":29,"tag":88,"props":5184,"children":5185},{"style":122},[5186],{"type":34,"value":357},{"type":29,"tag":88,"props":5188,"children":5189},{"class":90,"line":1098},[5190],{"type":29,"tag":88,"props":5191,"children":5192},{"emptyLinePlaceholder":13},[5193],{"type":34,"value":134},{"type":29,"tag":88,"props":5195,"children":5196},{"class":90,"line":1106},[5197,5202,5206,5211,5215,5219,5223,5228,5232,5236],{"type":29,"tag":88,"props":5198,"children":5199},{"style":157},[5200],{"type":34,"value":5201},"        notificationService",{"type":29,"tag":88,"props":5203,"children":5204},{"style":122},[5205],{"type":34,"value":338},{"type":29,"tag":88,"props":5207,"children":5208},{"style":174},[5209],{"type":34,"value":5210},"sendOrderConfirmation",{"type":29,"tag":88,"props":5212,"children":5213},{"style":122},[5214],{"type":34,"value":181},{"type":29,"tag":88,"props":5216,"children":5217},{"style":157},[5218],{"type":34,"value":5182},{"type":29,"tag":88,"props":5220,"children":5221},{"style":122},[5222],{"type":34,"value":338},{"type":29,"tag":88,"props":5224,"children":5225},{"style":174},[5226],{"type":34,"value":5227},"getUserId",{"type":29,"tag":88,"props":5229,"children":5230},{"style":122},[5231],{"type":34,"value":397},{"type":29,"tag":88,"props":5233,"children":5234},{"style":157},[5235],{"type":34,"value":402},{"type":29,"tag":88,"props":5237,"children":5238},{"style":122},[5239],{"type":34,"value":357},{"type":29,"tag":88,"props":5241,"children":5242},{"class":90,"line":1115},[5243],{"type":29,"tag":88,"props":5244,"children":5245},{"style":122},[5246],{"type":34,"value":433},{"type":29,"tag":88,"props":5248,"children":5249},{"class":90,"line":11},[5250],{"type":29,"tag":88,"props":5251,"children":5252},{"style":122},[5253],{"type":34,"value":442},{"type":29,"tag":88,"props":5255,"children":5256},{"class":90,"line":1180},[5257],{"type":29,"tag":88,"props":5258,"children":5259},{"emptyLinePlaceholder":13},[5260],{"type":34,"value":134},{"type":29,"tag":88,"props":5262,"children":5263},{"class":90,"line":1240},[5264],{"type":29,"tag":88,"props":5265,"children":5266},{"style":95},[5267],{"type":34,"value":5268},"\u002F\u002F Implémentation de test\n",{"type":29,"tag":88,"props":5270,"children":5271},{"class":90,"line":1248},[5272,5276],{"type":29,"tag":88,"props":5273,"children":5274},{"style":1974},[5275],{"type":34,"value":1977},{"type":29,"tag":88,"props":5277,"children":5278},{"style":1980},[5279],{"type":34,"value":2536},{"type":29,"tag":88,"props":5281,"children":5282},{"class":90,"line":1256},[5283,5287,5292,5296,5301],{"type":29,"tag":88,"props":5284,"children":5285},{"style":1974},[5286],{"type":34,"value":1977},{"type":29,"tag":88,"props":5288,"children":5289},{"style":1980},[5290],{"type":34,"value":5291},"Profile",{"type":29,"tag":88,"props":5293,"children":5294},{"style":122},[5295],{"type":34,"value":181},{"type":29,"tag":88,"props":5297,"children":5298},{"style":184},[5299],{"type":34,"value":5300},"\"test\"",{"type":29,"tag":88,"props":5302,"children":5303},{"style":122},[5304],{"type":34,"value":3078},{"type":29,"tag":88,"props":5306,"children":5307},{"class":90,"line":1264},[5308,5312,5316,5321,5325,5329],{"type":29,"tag":88,"props":5309,"children":5310},{"style":105},[5311],{"type":34,"value":108},{"type":29,"tag":88,"props":5313,"children":5314},{"style":105},[5315],{"type":34,"value":113},{"type":29,"tag":88,"props":5317,"children":5318},{"style":116},[5319],{"type":34,"value":5320}," MockNotificationService",{"type":29,"tag":88,"props":5322,"children":5323},{"style":105},[5324],{"type":34,"value":1134},{"type":29,"tag":88,"props":5326,"children":5327},{"style":116},[5328],{"type":34,"value":4662},{"type":29,"tag":88,"props":5330,"children":5331},{"style":122},[5332],{"type":34,"value":125},{"type":29,"tag":88,"props":5334,"children":5335},{"class":90,"line":1293},[5336],{"type":29,"tag":88,"props":5337,"children":5338},{"emptyLinePlaceholder":13},[5339],{"type":34,"value":134},{"type":29,"tag":88,"props":5341,"children":5342},{"class":90,"line":1342},[5343,5347,5351,5356,5360,5364,5368,5373,5377,5381,5386],{"type":29,"tag":88,"props":5344,"children":5345},{"style":105},[5346],{"type":34,"value":143},{"type":29,"tag":88,"props":5348,"children":5349},{"style":105},[5350],{"type":34,"value":148},{"type":29,"tag":88,"props":5352,"children":5353},{"style":151},[5354],{"type":34,"value":5355}," List",{"type":29,"tag":88,"props":5357,"children":5358},{"style":122},[5359],{"type":34,"value":1683},{"type":29,"tag":88,"props":5361,"children":5362},{"style":105},[5363],{"type":34,"value":695},{"type":29,"tag":88,"props":5365,"children":5366},{"style":122},[5367],{"type":34,"value":1701},{"type":29,"tag":88,"props":5369,"children":5370},{"style":157},[5371],{"type":34,"value":5372}," sentNotifications ",{"type":29,"tag":88,"props":5374,"children":5375},{"style":163},[5376],{"type":34,"value":166},{"type":29,"tag":88,"props":5378,"children":5379},{"style":105},[5380],{"type":34,"value":171},{"type":29,"tag":88,"props":5382,"children":5383},{"style":151},[5384],{"type":34,"value":5385}," ArrayList",{"type":29,"tag":88,"props":5387,"children":5388},{"style":122},[5389],{"type":34,"value":1724},{"type":29,"tag":88,"props":5391,"children":5392},{"class":90,"line":1418},[5393],{"type":29,"tag":88,"props":5394,"children":5395},{"emptyLinePlaceholder":13},[5396],{"type":34,"value":134},{"type":29,"tag":88,"props":5398,"children":5399},{"class":90,"line":1426},[5400,5404],{"type":29,"tag":88,"props":5401,"children":5402},{"style":1974},[5403],{"type":34,"value":3302},{"type":29,"tag":88,"props":5405,"children":5406},{"style":1980},[5407],{"type":34,"value":3307},{"type":29,"tag":88,"props":5409,"children":5410},{"class":90,"line":1434},[5411,5415,5419,5423,5427,5431,5435,5439,5443,5447,5451],{"type":29,"tag":88,"props":5412,"children":5413},{"style":105},[5414],{"type":34,"value":276},{"type":29,"tag":88,"props":5416,"children":5417},{"style":105},[5418],{"type":34,"value":1303},{"type":29,"tag":88,"props":5420,"children":5421},{"style":174},[5422],{"type":34,"value":4678},{"type":29,"tag":88,"props":5424,"children":5425},{"style":122},[5426],{"type":34,"value":181},{"type":29,"tag":88,"props":5428,"children":5429},{"style":151},[5430],{"type":34,"value":695},{"type":29,"tag":88,"props":5432,"children":5433},{"style":298},[5434],{"type":34,"value":4691},{"type":29,"tag":88,"props":5436,"children":5437},{"style":122},[5438],{"type":34,"value":192},{"type":29,"tag":88,"props":5440,"children":5441},{"style":151},[5442],{"type":34,"value":281},{"type":29,"tag":88,"props":5444,"children":5445},{"style":298},[5446],{"type":34,"value":402},{"type":29,"tag":88,"props":5448,"children":5449},{"style":122},[5450],{"type":34,"value":306},{"type":29,"tag":88,"props":5452,"children":5453},{"style":122},[5454],{"type":34,"value":125},{"type":29,"tag":88,"props":5456,"children":5457},{"class":90,"line":1442},[5458,5463,5467,5472,5476,5481,5486,5491,5496,5501,5505,5509],{"type":29,"tag":88,"props":5459,"children":5460},{"style":157},[5461],{"type":34,"value":5462},"        sentNotifications",{"type":29,"tag":88,"props":5464,"children":5465},{"style":122},[5466],{"type":34,"value":338},{"type":29,"tag":88,"props":5468,"children":5469},{"style":174},[5470],{"type":34,"value":5471},"add",{"type":29,"tag":88,"props":5473,"children":5474},{"style":122},[5475],{"type":34,"value":181},{"type":29,"tag":88,"props":5477,"children":5478},{"style":184},[5479],{"type":34,"value":5480},"\"confirmation:\"",{"type":29,"tag":88,"props":5482,"children":5483},{"style":163},[5484],{"type":34,"value":5485}," +",{"type":29,"tag":88,"props":5487,"children":5488},{"style":157},[5489],{"type":34,"value":5490}," userId ",{"type":29,"tag":88,"props":5492,"children":5493},{"style":163},[5494],{"type":34,"value":5495},"+",{"type":29,"tag":88,"props":5497,"children":5498},{"style":184},[5499],{"type":34,"value":5500}," \":\"",{"type":29,"tag":88,"props":5502,"children":5503},{"style":163},[5504],{"type":34,"value":5485},{"type":29,"tag":88,"props":5506,"children":5507},{"style":157},[5508],{"type":34,"value":402},{"type":29,"tag":88,"props":5510,"children":5511},{"style":122},[5512],{"type":34,"value":357},{"type":29,"tag":88,"props":5514,"children":5515},{"class":90,"line":1451},[5516],{"type":29,"tag":88,"props":5517,"children":5518},{"style":122},[5519],{"type":34,"value":433},{"type":29,"tag":88,"props":5521,"children":5522},{"class":90,"line":1477},[5523],{"type":29,"tag":88,"props":5524,"children":5525},{"style":122},[5526],{"type":34,"value":442},{"type":29,"tag":30,"props":5528,"children":5529},{},[5530,5535,5537,5543],{"type":29,"tag":447,"props":5531,"children":5532},{},[5533],{"type":34,"value":5534},"L'avantage Spring :",{"type":34,"value":5536}," ",{"type":29,"tag":84,"props":5538,"children":5540},{"className":5539},[],[5541],{"type":34,"value":5542},"@Profile(\"test\")",{"type":34,"value":5544}," permet d'utiliser automatiquement le mock en environnement de test sans modifier le code métier. Le framework gère le wiring, le code métier reste pur.",{"type":29,"tag":47,"props":5546,"children":5547},{},[],{"type":29,"tag":51,"props":5549,"children":5551},{"id":5550},"quand-appliquer-le-dip-et-quand-ne-pas-le-faire",[5552],{"type":34,"value":5553},"Quand appliquer le DIP, et quand ne pas le faire",{"type":29,"tag":30,"props":5555,"children":5556},{},[5557],{"type":29,"tag":447,"props":5558,"children":5559},{},[5560],{"type":34,"value":5561},"Appliquer le DIP :",{"type":29,"tag":453,"props":5563,"children":5564},{},[5565,5570,5575],{"type":29,"tag":457,"props":5566,"children":5567},{},[5568],{"type":34,"value":5569},"Toute dépendance vers un système externe (base de données, API tierce, service d'email, service de paiement, file de message)",{"type":29,"tag":457,"props":5571,"children":5572},{},[5573],{"type":34,"value":5574},"Toute dépendance vers une infrastructure susceptible de changer",{"type":29,"tag":457,"props":5576,"children":5577},{},[5578],{"type":34,"value":5579},"Tout code que vous voulez unit-tester sans infrastructure",{"type":29,"tag":30,"props":5581,"children":5582},{},[5583],{"type":29,"tag":447,"props":5584,"children":5585},{},[5586],{"type":34,"value":5587},"Ne pas appliquer le DIP mécaniquement :",{"type":29,"tag":453,"props":5589,"children":5590},{},[5591,5596,5601],{"type":29,"tag":457,"props":5592,"children":5593},{},[5594],{"type":34,"value":5595},"Les entités et value objects du domaine (Order, User, Money) : pas de logique d'infrastructure",{"type":29,"tag":457,"props":5597,"children":5598},{},[5599],{"type":34,"value":5600},"Les utilitaires purs (calculs mathématiques, formatage de dates) : pas d'effet de bord",{"type":29,"tag":457,"props":5602,"children":5603},{},[5604],{"type":34,"value":5605},"Les dépendances stables et peu susceptibles de changer dans des petits projets",{"type":29,"tag":30,"props":5607,"children":5608},{},[5609,5614,5616,5622],{"type":29,"tag":447,"props":5610,"children":5611},{},[5612],{"type":34,"value":5613},"Le signal",{"type":34,"value":5615}," : si écrire un test unitaire pour votre classe nécessite de démarrer une base de données, une queue de messages, ou de configurer un service externe, appliquez le DIP. Cette question est aussi centrale dans les ",{"type":29,"tag":63,"props":5617,"children":5619},{"href":5618},"\u002Ffr\u002Fdette-technique\u002Ftests-integration-legacy-pieges",[5620],{"type":34,"value":5621},"tests d'intégration sur du code legacy",{"type":34,"value":5623}," : l'absence de DIP est souvent ce qui rend ces tests si difficiles et si fragiles à mettre en place.",{"type":29,"tag":47,"props":5625,"children":5626},{},[],{"type":29,"tag":2288,"props":5628,"children":5633},{"cta":5629,"href":5630,"title":5631,"type":5632},"Les 100 pratiques que l'IA n'enseigne pas →","https:\u002F\u002Fkamanga.fr\u002Freferentiel-craft","Le DIP n'est qu'une des 100 pratiques qui rendent un code testable","product",[5634],{"type":29,"tag":30,"props":5635,"children":5636},{},[5637],{"type":34,"value":5638},"Cet article détaille une pratique craft : inverser ses dépendances pour découpler le métier de l'infrastructure. Le Craft Bundle réunit les 100 pratiques que j'applique pour coder propre, du choix d'une abstraction au design d'un test rapide. Celles que l'IA ne vous apprendra jamais parce qu'elle ne les a jamais vues tenir en production.",{"type":29,"tag":47,"props":5640,"children":5641},{},[],{"type":29,"tag":51,"props":5643,"children":5645},{"id":5644},"faq-sur-le-dependency-inversion-principle",[5646],{"type":34,"value":5647},"FAQ sur le Dependency Inversion Principle",{"type":29,"tag":5649,"props":5650,"children":5651},"details",{},[5652,5658],{"type":29,"tag":5653,"props":5654,"children":5655},"summary",{},[5656],{"type":34,"value":5657},"1. Quelle est la différence entre DIP et Dependency Injection ?",{"type":29,"tag":30,"props":5659,"children":5660},{},[5661],{"type":34,"value":5662},"Le DIP est un principe architectural : les modules doivent dépendre d'abstractions. La Dependency Injection (DI) est une technique d'implémentation du DIP : les dépendances sont fournies de l'extérieur plutôt que créées à l'intérieur. On peut respecter le DIP sans DI (ex : factory pattern). On peut utiliser la DI sans respecter le DIP (ex : injecter une classe concrète sans interface). En pratique, les deux vont généralement ensemble.",{"type":29,"tag":5649,"props":5664,"children":5665},{},[5666,5671],{"type":29,"tag":5653,"props":5667,"children":5668},{},[5669],{"type":34,"value":5670},"2. Les containers DI (Spring, .NET DI, Angular) font-ils le travail à notre place ?",{"type":29,"tag":30,"props":5672,"children":5673},{},[5674],{"type":34,"value":5675},"Ils automatisent le wiring (qui injecte quoi), mais ne créent pas les abstractions à notre place. Spring injecte les classes concrètes si vous ne créez pas d'interfaces. La discipline architecturale de créer des interfaces pour les dépendances d'infrastructure reste une décision de l'équipe. Le framework ne peut pas la prendre à votre place.",{"type":29,"tag":5649,"props":5677,"children":5678},{},[5679,5684],{"type":29,"tag":5653,"props":5680,"children":5681},{},[5682],{"type":34,"value":5683},"3. Le DIP ne crée-t-il pas trop d'abstractions ?",{"type":29,"tag":30,"props":5685,"children":5686},{},[5687],{"type":34,"value":5688},"Oui, si mal appliqué. Créer une interface pour chaque classe, même les plus stables, est du sur-engineering. La règle que Martin Fowler formule clairement : créer une abstraction quand il y a au moins 2 implémentations possibles (production + test, provider A + provider B) ou quand la dépendance est vers un système externe. \"Pas d'abstraction prématurée\" s'applique au DIP comme à tout principe.",{"type":29,"tag":5649,"props":5690,"children":5691},{},[5692,5697],{"type":29,"tag":5653,"props":5693,"children":5694},{},[5695],{"type":34,"value":5696},"4. Comment introduire le DIP progressivement dans un codebase existant ?",{"type":29,"tag":30,"props":5698,"children":5699},{},[5700,5702,5708],{"type":34,"value":5701},"Le strangler fig pattern appliqué au DIP : ne pas refactorer tout le code existant d'un coup. À chaque nouvelle fonctionnalité ou bug fix qui touche une classe avec dépendances directes, extraire l'interface et introduire l'injection. Après 6 mois de cette discipline, les zones les plus actives du codebase respectent le DIP. Les zones stables peuvent rester dans l'état existant si elles ne causent pas de problèmes. Dans un contexte de ",{"type":29,"tag":63,"props":5703,"children":5705},{"href":5704},"\u002Ffr\u002Fdette-technique\u002Flegacy-code-evaluer-risque",[5706],{"type":34,"value":5707},"code legacy fortement couplé",{"type":34,"value":5709},", cette approche progressive est souvent la seule viable sans bloquer les livraisons.",{"type":29,"tag":5649,"props":5711,"children":5712},{},[5713,5718],{"type":29,"tag":5653,"props":5714,"children":5715},{},[5716],{"type":34,"value":5717},"5. Le DIP s'applique-t-il aux frontends (React, Vue) ?",{"type":29,"tag":30,"props":5719,"children":5720},{},[5721,5723,5729,5731,5737,5739,5745],{"type":34,"value":5722},"Oui. En React : les composants ne doivent pas appeler directement ",{"type":29,"tag":84,"props":5724,"children":5726},{"className":5725},[],[5727],{"type":34,"value":5728},"fetch()",{"type":34,"value":5730}," ou ",{"type":29,"tag":84,"props":5732,"children":5734},{"className":5733},[],[5735],{"type":34,"value":5736},"axios",{"type":34,"value":5738}," : ils doivent dépendre d'une abstraction (un service, un hook custom, un context) qui peut être mockée dans les tests. ",{"type":29,"tag":84,"props":5740,"children":5742},{"className":5741},[],[5743],{"type":34,"value":5744},"useOrderService()",{"type":34,"value":5746}," hook qui cache l'implémentation HTTP, facilement mockable dans les tests. Le DIP s'applique partout où il y a des effets de bord, frontend inclus.",{"type":29,"tag":47,"props":5748,"children":5749},{},[],{"type":29,"tag":2288,"props":5751,"children":5756},{"cta":5752,"href":5753,"title":5754,"type":5755},"Faire mon auto-évaluation →","\u002Fema","Ressource gratuite : Engineering Maturity Self-Assessment","resource",[5757],{"type":29,"tag":30,"props":5758,"children":5759},{},[5760],{"type":34,"value":5761},"L'Engineering Maturity Self-Assessment couvre le domaine Craft & Conception : évaluez votre niveau sur les principes SOLID, le couplage, et la testabilité. Obtenez un score de maturité et des recommandations concrètes en 10 minutes.",{"type":29,"tag":5763,"props":5764,"children":5765},"style",{},[5766],{"type":34,"value":5767},"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":101,"depth":101,"links":5769},[5770,5771,5772,5773,5774,5775,5776],{"id":53,"depth":101,"text":56},{"id":505,"depth":101,"text":508},{"id":571,"depth":101,"text":574},{"id":2305,"depth":101,"text":2308},{"id":4628,"depth":101,"text":4631},{"id":5550,"depth":101,"text":5553},{"id":5644,"depth":101,"text":5647},"markdown","content:fr:architecture-craft:dependency-inversion-pratique.md","content","fr\u002Farchitecture-craft\u002Fdependency-inversion-pratique.md","fr\u002Farchitecture-craft\u002Fdependency-inversion-pratique","md",{"_path":65,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":5784,"description":5785,"id":409,"date":5786,"listed":13,"nocomments":7,"hidden":7,"categories":5787,"tags":5788,"cover":5789,"readingTime":5790,"body":5794,"_type":5777,"_id":8442,"_source":5779,"_file":8443,"_stem":8444,"_extension":5782},"Clean Architecture : les 3 règles qui suffisent","La Clean Architecture est souvent sur-implémentée. 3 règles fondamentales couvrent 80% de la valeur sans la complexité qui fait fuir les équipes.","2026-01-26",[6],[17,16],"covers\u002Farticles\u002Fclean-architecture-regles.jpg",{"text":21,"minutes":5791,"time":5792,"words":5793},8.615,516900,1723,{"type":26,"children":5795,"toc":8433},[5796,5801,5806,5811,5816,5819,5825,5830,5835,5840,5853,5856,5862,5867,5886,5894,5912,6367,6383,6386,6392,6397,6404,6445,7142,7152,7161,7164,7170,7175,7185,7192,7225,8259,8262,8268,8278,8288,8298,8301,8307,8317,8327,8336,8339,8345,8358,8371,8384,8397,8418,8421,8429],{"type":29,"tag":30,"props":5797,"children":5798},{},[5799],{"type":34,"value":5800},"J'accompagnais une équipe engineering chez Canal+ (20 développeurs). Une API de 45 endpoints, 4 ans de code accumulé, une couverture de tests à 28%. Les nouveaux développeurs atteignaient leur autonomie en 7 semaines. Pas parce qu'ils étaient mauvais, parce que le code était impossible à naviguer.",{"type":29,"tag":30,"props":5802,"children":5803},{},[5804],{"type":34,"value":5805},"Ils m'ont demandé si la Clean Architecture pouvait les aider. Ma réponse : oui, mais pas telle qu'on l'applique généralement.",{"type":29,"tag":30,"props":5807,"children":5808},{},[5809],{"type":34,"value":5810},"J'ai introduit 3 règles, pas les 8 couches du diagramme en cercles de Robert Martin. En 4 mois : couverture de tests passée de 28% à 67%, lead time baissé de 35%, onboarding raccourci de 7 à 3 semaines.",{"type":29,"tag":30,"props":5812,"children":5813},{},[5814],{"type":34,"value":5815},"La Clean Architecture n'est pas une religion. C'est un outil. Et comme tout outil, c'est la maîtrise qui compte, pas la conformité.",{"type":29,"tag":47,"props":5817,"children":5818},{},[],{"type":29,"tag":51,"props":5820,"children":5822},{"id":5821},"pourquoi-la-clean-architecture-divise-les-équipes",[5823],{"type":34,"value":5824},"Pourquoi la Clean Architecture divise les équipes",{"type":29,"tag":30,"props":5826,"children":5827},{},[5828],{"type":34,"value":5829},"L'architecture \"full Clean\" avec des entités, des use cases, des interfaces presenters, des controllers, des gateways se justifie dans des contextes spécifiques : applications complexes avec des règles métier riches, systèmes qui doivent changer de framework ou de base de données, projets long-terme avec de nombreux développeurs.",{"type":29,"tag":30,"props":5831,"children":5832},{},[5833],{"type":34,"value":5834},"Dans la plupart des contextes (une API REST de taille moyenne, une application en phase de croissance), la mise en place complète génère plus de complexité qu'elle n'en résout. Les symptômes sont toujours les mêmes : des dizaines de fichiers pour chaque feature, des indirections qui rendent le debug cauchemardesque, des juniors qui passent 3 jours à comprendre où écrire un bout de logique.",{"type":29,"tag":30,"props":5836,"children":5837},{},[5838],{"type":34,"value":5839},"Le problème n'est pas la Clean Architecture. C'est l'application dogmatique de sa forme sans en comprendre l'essence.",{"type":29,"tag":30,"props":5841,"children":5842},{},[5843,5845,5851],{"type":34,"value":5844},"Robert C. Martin (Uncle Bob) a formalisé ces principes dans son livre éponyme de 2017. Ce qu'il dit, et que beaucoup oublient : les couches ne sont pas une prescription rigide. Ce sont des guides. L'essence, elle, tient en 3 règles. Et quand une équipe adopte cette architecture, documenter les décisions structurantes dans des ",{"type":29,"tag":63,"props":5846,"children":5848},{"href":5847},"\u002Ffr\u002Farchitecture-craft\u002Fadr-architecture-decision-record",[5849],{"type":34,"value":5850},"Architecture Decision Records",{"type":34,"value":5852}," évite de refaire les mêmes débats à chaque nouveau développeur.",{"type":29,"tag":47,"props":5854,"children":5855},{},[],{"type":29,"tag":51,"props":5857,"children":5859},{"id":5858},"règle-1-la-règle-de-dépendance-les-flèches-pointent-vers-lintérieur",[5860],{"type":34,"value":5861},"Règle 1 : La règle de dépendance : les flèches pointent vers l'intérieur",{"type":29,"tag":30,"props":5863,"children":5864},{},[5865],{"type":34,"value":5866},"C'est la règle fondamentale. Dans un système bien architecturé, les modules de haut niveau (métier, règles business) ne doivent jamais dépendre des modules de bas niveau (frameworks, base de données, HTTP).",{"type":29,"tag":30,"props":5868,"children":5869},{},[5870,5872,5877,5879,5884],{"type":34,"value":5871},"La dépendance va dans une seule direction : ",{"type":29,"tag":447,"props":5873,"children":5874},{},[5875],{"type":34,"value":5876},"de l'extérieur vers l'intérieur",{"type":34,"value":5878},". Les couches externes dépendent des couches internes. Jamais l'inverse. C'est exactement ce que formule le ",{"type":29,"tag":63,"props":5880,"children":5881},{"href":5},[5882],{"type":34,"value":5883},"Dependency Inversion Principle",{"type":34,"value":5885},", et l'appliquer concrètement est le premier pas vers une codebase testable et maintenable.",{"type":29,"tag":30,"props":5887,"children":5888},{},[5889],{"type":29,"tag":447,"props":5890,"children":5891},{},[5892],{"type":34,"value":5893},"Ce que cela signifie concrètement :",{"type":29,"tag":453,"props":5895,"children":5896},{},[5897,5902,5907],{"type":29,"tag":457,"props":5898,"children":5899},{},[5900],{"type":34,"value":5901},"Votre logique métier ne doit pas importer Spring, Express, Django, ou aucun framework",{"type":29,"tag":457,"props":5903,"children":5904},{},[5905],{"type":34,"value":5906},"Votre logique métier ne doit pas importer de driver de base de données ou d'ORM",{"type":29,"tag":457,"props":5908,"children":5909},{},[5910],{"type":34,"value":5911},"Votre logique métier ne doit pas connaître le format HTTP (statut codes, headers)",{"type":29,"tag":77,"props":5913,"children":5915},{"className":81,"code":5914,"language":80,"meta":8,"style":8},"\u002F\u002F Mauvais : la logique métier dépend de Spring\n@Service\npublic class OrderService {\n    @Autowired\n    private OrderRepository repository; \u002F\u002F dépendance sur Spring Data\n\n    public void processOrder(Long orderId) {\n        Order order = repository.findById(orderId)\n            .orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND)); \u002F\u002F dépendance sur Spring HTTP\n        \u002F\u002F logique métier...\n    }\n}\n\n\u002F\u002F Mieux : la logique métier ne connaît pas Spring\npublic class ProcessOrderUseCase {\n    private final OrderRepository repository; \u002F\u002F interface, pas Spring Data\n\n    public void execute(OrderId orderId) {\n        Order order = repository.findById(orderId)\n            .orElseThrow(() -> new OrderNotFoundException(orderId)); \u002F\u002F exception métier\n        \u002F\u002F logique métier pure...\n    }\n}\n",[5916],{"type":29,"tag":84,"props":5917,"children":5918},{"__ignoreMap":8},[5919,5927,5938,5957,5969,5994,6001,6038,6077,6133,6141,6148,6155,6162,6170,6190,6218,6225,6262,6301,6345,6353,6360],{"type":29,"tag":88,"props":5920,"children":5921},{"class":90,"line":91},[5922],{"type":29,"tag":88,"props":5923,"children":5924},{"style":95},[5925],{"type":34,"value":5926},"\u002F\u002F Mauvais : la logique métier dépend de Spring\n",{"type":29,"tag":88,"props":5928,"children":5929},{"class":90,"line":101},[5930,5934],{"type":29,"tag":88,"props":5931,"children":5932},{"style":1974},[5933],{"type":34,"value":1977},{"type":29,"tag":88,"props":5935,"children":5936},{"style":1980},[5937],{"type":34,"value":2536},{"type":29,"tag":88,"props":5939,"children":5940},{"class":90,"line":128},[5941,5945,5949,5953],{"type":29,"tag":88,"props":5942,"children":5943},{"style":105},[5944],{"type":34,"value":108},{"type":29,"tag":88,"props":5946,"children":5947},{"style":105},[5948],{"type":34,"value":113},{"type":29,"tag":88,"props":5950,"children":5951},{"style":116},[5952],{"type":34,"value":119},{"type":29,"tag":88,"props":5954,"children":5955},{"style":122},[5956],{"type":34,"value":125},{"type":29,"tag":88,"props":5958,"children":5959},{"class":90,"line":137},[5960,5964],{"type":29,"tag":88,"props":5961,"children":5962},{"style":1974},[5963],{"type":34,"value":3302},{"type":29,"tag":88,"props":5965,"children":5966},{"style":1980},[5967],{"type":34,"value":5968},"Autowired\n",{"type":29,"tag":88,"props":5970,"children":5971},{"class":90,"line":211},[5972,5976,5980,5984,5989],{"type":29,"tag":88,"props":5973,"children":5974},{"style":105},[5975],{"type":34,"value":143},{"type":29,"tag":88,"props":5977,"children":5978},{"style":151},[5979],{"type":34,"value":606},{"type":29,"tag":88,"props":5981,"children":5982},{"style":157},[5983],{"type":34,"value":785},{"type":29,"tag":88,"props":5985,"children":5986},{"style":122},[5987],{"type":34,"value":5988},";",{"type":29,"tag":88,"props":5990,"children":5991},{"style":95},[5992],{"type":34,"value":5993}," \u002F\u002F dépendance sur Spring Data\n",{"type":29,"tag":88,"props":5995,"children":5996},{"class":90,"line":262},[5997],{"type":29,"tag":88,"props":5998,"children":5999},{"emptyLinePlaceholder":13},[6000],{"type":34,"value":134},{"type":29,"tag":88,"props":6002,"children":6003},{"class":90,"line":270},[6004,6008,6012,6017,6021,6026,6030,6034],{"type":29,"tag":88,"props":6005,"children":6006},{"style":105},[6007],{"type":34,"value":276},{"type":29,"tag":88,"props":6009,"children":6010},{"style":105},[6011],{"type":34,"value":1303},{"type":29,"tag":88,"props":6013,"children":6014},{"style":174},[6015],{"type":34,"value":6016}," processOrder",{"type":29,"tag":88,"props":6018,"children":6019},{"style":122},[6020],{"type":34,"value":181},{"type":29,"tag":88,"props":6022,"children":6023},{"style":151},[6024],{"type":34,"value":6025},"Long",{"type":29,"tag":88,"props":6027,"children":6028},{"style":298},[6029],{"type":34,"value":402},{"type":29,"tag":88,"props":6031,"children":6032},{"style":122},[6033],{"type":34,"value":306},{"type":29,"tag":88,"props":6035,"children":6036},{"style":122},[6037],{"type":34,"value":125},{"type":29,"tag":88,"props":6039,"children":6040},{"class":90,"line":313},[6041,6045,6049,6053,6057,6061,6065,6069,6073],{"type":29,"tag":88,"props":6042,"children":6043},{"style":151},[6044],{"type":34,"value":4176},{"type":29,"tag":88,"props":6046,"children":6047},{"style":157},[6048],{"type":34,"value":4181},{"type":29,"tag":88,"props":6050,"children":6051},{"style":163},[6052],{"type":34,"value":166},{"type":29,"tag":88,"props":6054,"children":6055},{"style":157},[6056],{"type":34,"value":785},{"type":29,"tag":88,"props":6058,"children":6059},{"style":122},[6060],{"type":34,"value":338},{"type":29,"tag":88,"props":6062,"children":6063},{"style":174},[6064],{"type":34,"value":3112},{"type":29,"tag":88,"props":6066,"children":6067},{"style":122},[6068],{"type":34,"value":181},{"type":29,"tag":88,"props":6070,"children":6071},{"style":157},[6072],{"type":34,"value":1836},{"type":29,"tag":88,"props":6074,"children":6075},{"style":122},[6076],{"type":34,"value":3078},{"type":29,"tag":88,"props":6078,"children":6079},{"class":90,"line":360},[6080,6084,6088,6092,6096,6100,6105,6109,6114,6118,6123,6128],{"type":29,"tag":88,"props":6081,"children":6082},{"style":122},[6083],{"type":34,"value":3132},{"type":29,"tag":88,"props":6085,"children":6086},{"style":174},[6087],{"type":34,"value":3137},{"type":29,"tag":88,"props":6089,"children":6090},{"style":122},[6091],{"type":34,"value":3142},{"type":29,"tag":88,"props":6093,"children":6094},{"style":105},[6095],{"type":34,"value":3147},{"type":29,"tag":88,"props":6097,"children":6098},{"style":105},[6099],{"type":34,"value":171},{"type":29,"tag":88,"props":6101,"children":6102},{"style":174},[6103],{"type":34,"value":6104}," ResponseStatusException",{"type":29,"tag":88,"props":6106,"children":6107},{"style":122},[6108],{"type":34,"value":181},{"type":29,"tag":88,"props":6110,"children":6111},{"style":157},[6112],{"type":34,"value":6113},"HttpStatus",{"type":29,"tag":88,"props":6115,"children":6116},{"style":122},[6117],{"type":34,"value":338},{"type":29,"tag":88,"props":6119,"children":6120},{"style":157},[6121],{"type":34,"value":6122},"NOT_FOUND",{"type":29,"tag":88,"props":6124,"children":6125},{"style":122},[6126],{"type":34,"value":6127},"));",{"type":29,"tag":88,"props":6129,"children":6130},{"style":95},[6131],{"type":34,"value":6132}," \u002F\u002F dépendance sur Spring HTTP\n",{"type":29,"tag":88,"props":6134,"children":6135},{"class":90,"line":409},[6136],{"type":29,"tag":88,"props":6137,"children":6138},{"style":95},[6139],{"type":34,"value":6140},"        \u002F\u002F logique métier...\n",{"type":29,"tag":88,"props":6142,"children":6143},{"class":90,"line":427},[6144],{"type":29,"tag":88,"props":6145,"children":6146},{"style":122},[6147],{"type":34,"value":433},{"type":29,"tag":88,"props":6149,"children":6150},{"class":90,"line":436},[6151],{"type":29,"tag":88,"props":6152,"children":6153},{"style":122},[6154],{"type":34,"value":442},{"type":29,"tag":88,"props":6156,"children":6157},{"class":90,"line":767},[6158],{"type":29,"tag":88,"props":6159,"children":6160},{"emptyLinePlaceholder":13},[6161],{"type":34,"value":134},{"type":29,"tag":88,"props":6163,"children":6164},{"class":90,"line":792},[6165],{"type":29,"tag":88,"props":6166,"children":6167},{"style":95},[6168],{"type":34,"value":6169},"\u002F\u002F Mieux : la logique métier ne connaît pas Spring\n",{"type":29,"tag":88,"props":6171,"children":6172},{"class":90,"line":817},[6173,6177,6181,6186],{"type":29,"tag":88,"props":6174,"children":6175},{"style":105},[6176],{"type":34,"value":108},{"type":29,"tag":88,"props":6178,"children":6179},{"style":105},[6180],{"type":34,"value":113},{"type":29,"tag":88,"props":6182,"children":6183},{"style":116},[6184],{"type":34,"value":6185}," ProcessOrderUseCase",{"type":29,"tag":88,"props":6187,"children":6188},{"style":122},[6189],{"type":34,"value":125},{"type":29,"tag":88,"props":6191,"children":6192},{"class":90,"line":825},[6193,6197,6201,6205,6209,6213],{"type":29,"tag":88,"props":6194,"children":6195},{"style":105},[6196],{"type":34,"value":143},{"type":29,"tag":88,"props":6198,"children":6199},{"style":105},[6200],{"type":34,"value":148},{"type":29,"tag":88,"props":6202,"children":6203},{"style":151},[6204],{"type":34,"value":606},{"type":29,"tag":88,"props":6206,"children":6207},{"style":157},[6208],{"type":34,"value":785},{"type":29,"tag":88,"props":6210,"children":6211},{"style":122},[6212],{"type":34,"value":5988},{"type":29,"tag":88,"props":6214,"children":6215},{"style":95},[6216],{"type":34,"value":6217}," \u002F\u002F interface, pas Spring Data\n",{"type":29,"tag":88,"props":6219,"children":6220},{"class":90,"line":869},[6221],{"type":29,"tag":88,"props":6222,"children":6223},{"emptyLinePlaceholder":13},[6224],{"type":34,"value":134},{"type":29,"tag":88,"props":6226,"children":6227},{"class":90,"line":900},[6228,6232,6236,6241,6245,6250,6254,6258],{"type":29,"tag":88,"props":6229,"children":6230},{"style":105},[6231],{"type":34,"value":276},{"type":29,"tag":88,"props":6233,"children":6234},{"style":105},[6235],{"type":34,"value":1303},{"type":29,"tag":88,"props":6237,"children":6238},{"style":174},[6239],{"type":34,"value":6240}," execute",{"type":29,"tag":88,"props":6242,"children":6243},{"style":122},[6244],{"type":34,"value":181},{"type":29,"tag":88,"props":6246,"children":6247},{"style":151},[6248],{"type":34,"value":6249},"OrderId",{"type":29,"tag":88,"props":6251,"children":6252},{"style":298},[6253],{"type":34,"value":402},{"type":29,"tag":88,"props":6255,"children":6256},{"style":122},[6257],{"type":34,"value":306},{"type":29,"tag":88,"props":6259,"children":6260},{"style":122},[6261],{"type":34,"value":125},{"type":29,"tag":88,"props":6263,"children":6264},{"class":90,"line":929},[6265,6269,6273,6277,6281,6285,6289,6293,6297],{"type":29,"tag":88,"props":6266,"children":6267},{"style":151},[6268],{"type":34,"value":4176},{"type":29,"tag":88,"props":6270,"children":6271},{"style":157},[6272],{"type":34,"value":4181},{"type":29,"tag":88,"props":6274,"children":6275},{"style":163},[6276],{"type":34,"value":166},{"type":29,"tag":88,"props":6278,"children":6279},{"style":157},[6280],{"type":34,"value":785},{"type":29,"tag":88,"props":6282,"children":6283},{"style":122},[6284],{"type":34,"value":338},{"type":29,"tag":88,"props":6286,"children":6287},{"style":174},[6288],{"type":34,"value":3112},{"type":29,"tag":88,"props":6290,"children":6291},{"style":122},[6292],{"type":34,"value":181},{"type":29,"tag":88,"props":6294,"children":6295},{"style":157},[6296],{"type":34,"value":1836},{"type":29,"tag":88,"props":6298,"children":6299},{"style":122},[6300],{"type":34,"value":3078},{"type":29,"tag":88,"props":6302,"children":6303},{"class":90,"line":937},[6304,6308,6312,6316,6320,6324,6328,6332,6336,6340],{"type":29,"tag":88,"props":6305,"children":6306},{"style":122},[6307],{"type":34,"value":3132},{"type":29,"tag":88,"props":6309,"children":6310},{"style":174},[6311],{"type":34,"value":3137},{"type":29,"tag":88,"props":6313,"children":6314},{"style":122},[6315],{"type":34,"value":3142},{"type":29,"tag":88,"props":6317,"children":6318},{"style":105},[6319],{"type":34,"value":3147},{"type":29,"tag":88,"props":6321,"children":6322},{"style":105},[6323],{"type":34,"value":171},{"type":29,"tag":88,"props":6325,"children":6326},{"style":174},[6327],{"type":34,"value":5100},{"type":29,"tag":88,"props":6329,"children":6330},{"style":122},[6331],{"type":34,"value":181},{"type":29,"tag":88,"props":6333,"children":6334},{"style":157},[6335],{"type":34,"value":1836},{"type":29,"tag":88,"props":6337,"children":6338},{"style":122},[6339],{"type":34,"value":6127},{"type":29,"tag":88,"props":6341,"children":6342},{"style":95},[6343],{"type":34,"value":6344}," \u002F\u002F exception métier\n",{"type":29,"tag":88,"props":6346,"children":6347},{"class":90,"line":945},[6348],{"type":29,"tag":88,"props":6349,"children":6350},{"style":95},[6351],{"type":34,"value":6352},"        \u002F\u002F logique métier pure...\n",{"type":29,"tag":88,"props":6354,"children":6355},{"class":90,"line":981},[6356],{"type":29,"tag":88,"props":6357,"children":6358},{"style":122},[6359],{"type":34,"value":433},{"type":29,"tag":88,"props":6361,"children":6362},{"class":90,"line":1021},[6363],{"type":29,"tag":88,"props":6364,"children":6365},{"style":122},[6366],{"type":34,"value":442},{"type":29,"tag":30,"props":6368,"children":6369},{},[6370,6375,6377,6381],{"type":29,"tag":447,"props":6371,"children":6372},{},[6373],{"type":34,"value":6374},"Pourquoi c'est important :",{"type":34,"value":6376}," si votre logique métier est indépendante des frameworks, vous pouvez la tester sans démarrer de serveur HTTP et sans base de données. Vos tests métier s'exécutent en millisecondes, ce qui résout précisément le problème des ",{"type":29,"tag":63,"props":6378,"children":6379},{"href":5618},[6380],{"type":34,"value":5621},{"type":34,"value":6382}," où chaque test démarre une vraie infrastructure. Et si vous changez de framework un jour, la logique métier n'est pas touchée.",{"type":29,"tag":47,"props":6384,"children":6385},{},[],{"type":29,"tag":51,"props":6387,"children":6389},{"id":6388},"règle-2-les-entités-métier-ne-connaissent-pas-linfrastructure",[6390],{"type":34,"value":6391},"Règle 2 : Les entités métier ne connaissent pas l'infrastructure",{"type":29,"tag":30,"props":6393,"children":6394},{},[6395],{"type":34,"value":6396},"Vos objets métier (Order, User, Product, Contract) doivent pouvoir exister et être testés sans base de données, sans framework de persistance, sans format de sérialisation.",{"type":29,"tag":30,"props":6398,"children":6399},{},[6400],{"type":29,"tag":447,"props":6401,"children":6402},{},[6403],{"type":34,"value":5893},{"type":29,"tag":453,"props":6405,"children":6406},{},[6407,6427,6440],{"type":29,"tag":457,"props":6408,"children":6409},{},[6410,6412,6418,6419,6425],{"type":34,"value":6411},"Pas d'annotations JPA (",{"type":29,"tag":84,"props":6413,"children":6415},{"className":6414},[],[6416],{"type":34,"value":6417},"@Entity",{"type":34,"value":544},{"type":29,"tag":84,"props":6420,"children":6422},{"className":6421},[],[6423],{"type":34,"value":6424},"@Column",{"type":34,"value":6426},") sur vos classes métier",{"type":29,"tag":457,"props":6428,"children":6429},{},[6430,6432,6438],{"type":34,"value":6431},"Pas de décorateurs de sérialisation (",{"type":29,"tag":84,"props":6433,"children":6435},{"className":6434},[],[6436],{"type":34,"value":6437},"@JsonProperty",{"type":34,"value":6439},") sur vos domaines objects",{"type":29,"tag":457,"props":6441,"children":6442},{},[6443],{"type":34,"value":6444},"Pas d'héritage de classes framework dans vos entités métier",{"type":29,"tag":77,"props":6446,"children":6448},{"className":81,"code":6447,"language":80,"meta":8,"style":8},"\u002F\u002F Entité métier polluée par l'infrastructure\n@Entity\n@Table(name = \"orders\")\npublic class Order {\n    @Id\n    @GeneratedValue(strategy = GenerationType.IDENTITY)\n    @ApiModelProperty  \u002F\u002F annotation Swagger\n    private Long id;\n\n    @Column(nullable = false)\n    @NotEmpty          \u002F\u002F annotation validation HTTP\n    private Long customerId;\n}\n\n\u002F\u002F Entité métier pure : aucune annotation framework\npublic class Order {\n    private final OrderId id;\n    private final CustomerId customerId;\n    private OrderStatus status;\n\n    public Order(OrderId id, CustomerId customerId, OrderStatus status) {\n        this.id = id;\n        this.customerId = customerId;\n        this.status = status;\n    }\n\n    public void confirm() {\n        if (this.status != OrderStatus.PENDING) {\n            throw new OrderAlreadyConfirmedException(this.id);\n        }\n        this.status = OrderStatus.CONFIRMED;\n    }\n}\n\u002F\u002F La persistance est gérée par une entité JPA séparée dans la couche infrastructure\n",[6449],{"type":29,"tag":84,"props":6450,"children":6451},{"__ignoreMap":8},[6452,6460,6472,6508,6527,6539,6582,6599,6619,6626,6660,6677,6697,6704,6711,6719,6738,6762,6786,6807,6814,6869,6897,6925,6953,6960,6967,6991,7041,7077,7084,7120,7127,7134],{"type":29,"tag":88,"props":6453,"children":6454},{"class":90,"line":91},[6455],{"type":29,"tag":88,"props":6456,"children":6457},{"style":95},[6458],{"type":34,"value":6459},"\u002F\u002F Entité métier polluée par l'infrastructure\n",{"type":29,"tag":88,"props":6461,"children":6462},{"class":90,"line":101},[6463,6467],{"type":29,"tag":88,"props":6464,"children":6465},{"style":1974},[6466],{"type":34,"value":1977},{"type":29,"tag":88,"props":6468,"children":6469},{"style":1980},[6470],{"type":34,"value":6471},"Entity\n",{"type":29,"tag":88,"props":6473,"children":6474},{"class":90,"line":128},[6475,6479,6484,6488,6494,6499,6504],{"type":29,"tag":88,"props":6476,"children":6477},{"style":1974},[6478],{"type":34,"value":1977},{"type":29,"tag":88,"props":6480,"children":6481},{"style":1980},[6482],{"type":34,"value":6483},"Table",{"type":29,"tag":88,"props":6485,"children":6486},{"style":122},[6487],{"type":34,"value":181},{"type":29,"tag":88,"props":6489,"children":6491},{"style":6490},"--shiki-default:#C6D0F5;--shiki-dark:#79B8FF",[6492],{"type":34,"value":6493},"name",{"type":29,"tag":88,"props":6495,"children":6496},{"style":163},[6497],{"type":34,"value":6498}," =",{"type":29,"tag":88,"props":6500,"children":6501},{"style":184},[6502],{"type":34,"value":6503}," \"orders\"",{"type":29,"tag":88,"props":6505,"children":6506},{"style":122},[6507],{"type":34,"value":3078},{"type":29,"tag":88,"props":6509,"children":6510},{"class":90,"line":137},[6511,6515,6519,6523],{"type":29,"tag":88,"props":6512,"children":6513},{"style":105},[6514],{"type":34,"value":108},{"type":29,"tag":88,"props":6516,"children":6517},{"style":105},[6518],{"type":34,"value":113},{"type":29,"tag":88,"props":6520,"children":6521},{"style":116},[6522],{"type":34,"value":2740},{"type":29,"tag":88,"props":6524,"children":6525},{"style":122},[6526],{"type":34,"value":125},{"type":29,"tag":88,"props":6528,"children":6529},{"class":90,"line":211},[6530,6534],{"type":29,"tag":88,"props":6531,"children":6532},{"style":1974},[6533],{"type":34,"value":3302},{"type":29,"tag":88,"props":6535,"children":6536},{"style":1980},[6537],{"type":34,"value":6538},"Id\n",{"type":29,"tag":88,"props":6540,"children":6541},{"class":90,"line":262},[6542,6546,6551,6555,6560,6564,6569,6573,6578],{"type":29,"tag":88,"props":6543,"children":6544},{"style":1974},[6545],{"type":34,"value":3302},{"type":29,"tag":88,"props":6547,"children":6548},{"style":1980},[6549],{"type":34,"value":6550},"GeneratedValue",{"type":29,"tag":88,"props":6552,"children":6553},{"style":122},[6554],{"type":34,"value":181},{"type":29,"tag":88,"props":6556,"children":6557},{"style":6490},[6558],{"type":34,"value":6559},"strategy",{"type":29,"tag":88,"props":6561,"children":6562},{"style":163},[6563],{"type":34,"value":6498},{"type":29,"tag":88,"props":6565,"children":6566},{"style":157},[6567],{"type":34,"value":6568}," GenerationType",{"type":29,"tag":88,"props":6570,"children":6571},{"style":122},[6572],{"type":34,"value":338},{"type":29,"tag":88,"props":6574,"children":6575},{"style":157},[6576],{"type":34,"value":6577},"IDENTITY",{"type":29,"tag":88,"props":6579,"children":6580},{"style":122},[6581],{"type":34,"value":3078},{"type":29,"tag":88,"props":6583,"children":6584},{"class":90,"line":270},[6585,6589,6594],{"type":29,"tag":88,"props":6586,"children":6587},{"style":1974},[6588],{"type":34,"value":3302},{"type":29,"tag":88,"props":6590,"children":6591},{"style":1980},[6592],{"type":34,"value":6593},"ApiModelProperty",{"type":29,"tag":88,"props":6595,"children":6596},{"style":95},[6597],{"type":34,"value":6598},"  \u002F\u002F annotation Swagger\n",{"type":29,"tag":88,"props":6600,"children":6601},{"class":90,"line":313},[6602,6606,6611,6615],{"type":29,"tag":88,"props":6603,"children":6604},{"style":105},[6605],{"type":34,"value":143},{"type":29,"tag":88,"props":6607,"children":6608},{"style":151},[6609],{"type":34,"value":6610}," Long",{"type":29,"tag":88,"props":6612,"children":6613},{"style":157},[6614],{"type":34,"value":3435},{"type":29,"tag":88,"props":6616,"children":6617},{"style":122},[6618],{"type":34,"value":424},{"type":29,"tag":88,"props":6620,"children":6621},{"class":90,"line":360},[6622],{"type":29,"tag":88,"props":6623,"children":6624},{"emptyLinePlaceholder":13},[6625],{"type":34,"value":134},{"type":29,"tag":88,"props":6627,"children":6628},{"class":90,"line":409},[6629,6633,6638,6642,6647,6651,6656],{"type":29,"tag":88,"props":6630,"children":6631},{"style":1974},[6632],{"type":34,"value":3302},{"type":29,"tag":88,"props":6634,"children":6635},{"style":1980},[6636],{"type":34,"value":6637},"Column",{"type":29,"tag":88,"props":6639,"children":6640},{"style":122},[6641],{"type":34,"value":181},{"type":29,"tag":88,"props":6643,"children":6644},{"style":6490},[6645],{"type":34,"value":6646},"nullable",{"type":29,"tag":88,"props":6648,"children":6649},{"style":163},[6650],{"type":34,"value":6498},{"type":29,"tag":88,"props":6652,"children":6653},{"style":873},[6654],{"type":34,"value":6655}," false",{"type":29,"tag":88,"props":6657,"children":6658},{"style":122},[6659],{"type":34,"value":3078},{"type":29,"tag":88,"props":6661,"children":6662},{"class":90,"line":427},[6663,6667,6672],{"type":29,"tag":88,"props":6664,"children":6665},{"style":1974},[6666],{"type":34,"value":3302},{"type":29,"tag":88,"props":6668,"children":6669},{"style":1980},[6670],{"type":34,"value":6671},"NotEmpty",{"type":29,"tag":88,"props":6673,"children":6674},{"style":95},[6675],{"type":34,"value":6676},"          \u002F\u002F annotation validation HTTP\n",{"type":29,"tag":88,"props":6678,"children":6679},{"class":90,"line":436},[6680,6684,6688,6693],{"type":29,"tag":88,"props":6681,"children":6682},{"style":105},[6683],{"type":34,"value":143},{"type":29,"tag":88,"props":6685,"children":6686},{"style":151},[6687],{"type":34,"value":6610},{"type":29,"tag":88,"props":6689,"children":6690},{"style":157},[6691],{"type":34,"value":6692}," customerId",{"type":29,"tag":88,"props":6694,"children":6695},{"style":122},[6696],{"type":34,"value":424},{"type":29,"tag":88,"props":6698,"children":6699},{"class":90,"line":767},[6700],{"type":29,"tag":88,"props":6701,"children":6702},{"style":122},[6703],{"type":34,"value":442},{"type":29,"tag":88,"props":6705,"children":6706},{"class":90,"line":792},[6707],{"type":29,"tag":88,"props":6708,"children":6709},{"emptyLinePlaceholder":13},[6710],{"type":34,"value":134},{"type":29,"tag":88,"props":6712,"children":6713},{"class":90,"line":817},[6714],{"type":29,"tag":88,"props":6715,"children":6716},{"style":95},[6717],{"type":34,"value":6718},"\u002F\u002F Entité métier pure : aucune annotation framework\n",{"type":29,"tag":88,"props":6720,"children":6721},{"class":90,"line":825},[6722,6726,6730,6734],{"type":29,"tag":88,"props":6723,"children":6724},{"style":105},[6725],{"type":34,"value":108},{"type":29,"tag":88,"props":6727,"children":6728},{"style":105},[6729],{"type":34,"value":113},{"type":29,"tag":88,"props":6731,"children":6732},{"style":116},[6733],{"type":34,"value":2740},{"type":29,"tag":88,"props":6735,"children":6736},{"style":122},[6737],{"type":34,"value":125},{"type":29,"tag":88,"props":6739,"children":6740},{"class":90,"line":869},[6741,6745,6749,6754,6758],{"type":29,"tag":88,"props":6742,"children":6743},{"style":105},[6744],{"type":34,"value":143},{"type":29,"tag":88,"props":6746,"children":6747},{"style":105},[6748],{"type":34,"value":148},{"type":29,"tag":88,"props":6750,"children":6751},{"style":151},[6752],{"type":34,"value":6753}," OrderId",{"type":29,"tag":88,"props":6755,"children":6756},{"style":157},[6757],{"type":34,"value":3435},{"type":29,"tag":88,"props":6759,"children":6760},{"style":122},[6761],{"type":34,"value":424},{"type":29,"tag":88,"props":6763,"children":6764},{"class":90,"line":900},[6765,6769,6773,6778,6782],{"type":29,"tag":88,"props":6766,"children":6767},{"style":105},[6768],{"type":34,"value":143},{"type":29,"tag":88,"props":6770,"children":6771},{"style":105},[6772],{"type":34,"value":148},{"type":29,"tag":88,"props":6774,"children":6775},{"style":151},[6776],{"type":34,"value":6777}," CustomerId",{"type":29,"tag":88,"props":6779,"children":6780},{"style":157},[6781],{"type":34,"value":6692},{"type":29,"tag":88,"props":6783,"children":6784},{"style":122},[6785],{"type":34,"value":424},{"type":29,"tag":88,"props":6787,"children":6788},{"class":90,"line":929},[6789,6793,6798,6803],{"type":29,"tag":88,"props":6790,"children":6791},{"style":105},[6792],{"type":34,"value":143},{"type":29,"tag":88,"props":6794,"children":6795},{"style":151},[6796],{"type":34,"value":6797}," OrderStatus",{"type":29,"tag":88,"props":6799,"children":6800},{"style":157},[6801],{"type":34,"value":6802}," status",{"type":29,"tag":88,"props":6804,"children":6805},{"style":122},[6806],{"type":34,"value":424},{"type":29,"tag":88,"props":6808,"children":6809},{"class":90,"line":937},[6810],{"type":29,"tag":88,"props":6811,"children":6812},{"emptyLinePlaceholder":13},[6813],{"type":34,"value":134},{"type":29,"tag":88,"props":6815,"children":6816},{"class":90,"line":945},[6817,6821,6825,6829,6833,6837,6841,6845,6849,6853,6857,6861,6865],{"type":29,"tag":88,"props":6818,"children":6819},{"style":105},[6820],{"type":34,"value":276},{"type":29,"tag":88,"props":6822,"children":6823},{"style":174},[6824],{"type":34,"value":2740},{"type":29,"tag":88,"props":6826,"children":6827},{"style":122},[6828],{"type":34,"value":181},{"type":29,"tag":88,"props":6830,"children":6831},{"style":151},[6832],{"type":34,"value":6249},{"type":29,"tag":88,"props":6834,"children":6835},{"style":298},[6836],{"type":34,"value":3435},{"type":29,"tag":88,"props":6838,"children":6839},{"style":122},[6840],{"type":34,"value":192},{"type":29,"tag":88,"props":6842,"children":6843},{"style":151},[6844],{"type":34,"value":6777},{"type":29,"tag":88,"props":6846,"children":6847},{"style":298},[6848],{"type":34,"value":6692},{"type":29,"tag":88,"props":6850,"children":6851},{"style":122},[6852],{"type":34,"value":192},{"type":29,"tag":88,"props":6854,"children":6855},{"style":151},[6856],{"type":34,"value":6797},{"type":29,"tag":88,"props":6858,"children":6859},{"style":298},[6860],{"type":34,"value":6802},{"type":29,"tag":88,"props":6862,"children":6863},{"style":122},[6864],{"type":34,"value":306},{"type":29,"tag":88,"props":6866,"children":6867},{"style":122},[6868],{"type":34,"value":125},{"type":29,"tag":88,"props":6870,"children":6871},{"class":90,"line":981},[6872,6876,6880,6885,6889,6893],{"type":29,"tag":88,"props":6873,"children":6874},{"style":873},[6875],{"type":34,"value":876},{"type":29,"tag":88,"props":6877,"children":6878},{"style":122},[6879],{"type":34,"value":338},{"type":29,"tag":88,"props":6881,"children":6882},{"style":157},[6883],{"type":34,"value":6884},"id ",{"type":29,"tag":88,"props":6886,"children":6887},{"style":163},[6888],{"type":34,"value":166},{"type":29,"tag":88,"props":6890,"children":6891},{"style":157},[6892],{"type":34,"value":3435},{"type":29,"tag":88,"props":6894,"children":6895},{"style":122},[6896],{"type":34,"value":424},{"type":29,"tag":88,"props":6898,"children":6899},{"class":90,"line":1021},[6900,6904,6908,6913,6917,6921],{"type":29,"tag":88,"props":6901,"children":6902},{"style":873},[6903],{"type":34,"value":876},{"type":29,"tag":88,"props":6905,"children":6906},{"style":122},[6907],{"type":34,"value":338},{"type":29,"tag":88,"props":6909,"children":6910},{"style":157},[6911],{"type":34,"value":6912},"customerId ",{"type":29,"tag":88,"props":6914,"children":6915},{"style":163},[6916],{"type":34,"value":166},{"type":29,"tag":88,"props":6918,"children":6919},{"style":157},[6920],{"type":34,"value":6692},{"type":29,"tag":88,"props":6922,"children":6923},{"style":122},[6924],{"type":34,"value":424},{"type":29,"tag":88,"props":6926,"children":6927},{"class":90,"line":1066},[6928,6932,6936,6941,6945,6949],{"type":29,"tag":88,"props":6929,"children":6930},{"style":873},[6931],{"type":34,"value":876},{"type":29,"tag":88,"props":6933,"children":6934},{"style":122},[6935],{"type":34,"value":338},{"type":29,"tag":88,"props":6937,"children":6938},{"style":157},[6939],{"type":34,"value":6940},"status ",{"type":29,"tag":88,"props":6942,"children":6943},{"style":163},[6944],{"type":34,"value":166},{"type":29,"tag":88,"props":6946,"children":6947},{"style":157},[6948],{"type":34,"value":6802},{"type":29,"tag":88,"props":6950,"children":6951},{"style":122},[6952],{"type":34,"value":424},{"type":29,"tag":88,"props":6954,"children":6955},{"class":90,"line":1082},[6956],{"type":29,"tag":88,"props":6957,"children":6958},{"style":122},[6959],{"type":34,"value":433},{"type":29,"tag":88,"props":6961,"children":6962},{"class":90,"line":1090},[6963],{"type":29,"tag":88,"props":6964,"children":6965},{"emptyLinePlaceholder":13},[6966],{"type":34,"value":134},{"type":29,"tag":88,"props":6968,"children":6969},{"class":90,"line":1098},[6970,6974,6978,6983,6987],{"type":29,"tag":88,"props":6971,"children":6972},{"style":105},[6973],{"type":34,"value":276},{"type":29,"tag":88,"props":6975,"children":6976},{"style":105},[6977],{"type":34,"value":1303},{"type":29,"tag":88,"props":6979,"children":6980},{"style":174},[6981],{"type":34,"value":6982}," confirm",{"type":29,"tag":88,"props":6984,"children":6985},{"style":122},[6986],{"type":34,"value":1470},{"type":29,"tag":88,"props":6988,"children":6989},{"style":122},[6990],{"type":34,"value":125},{"type":29,"tag":88,"props":6992,"children":6993},{"class":90,"line":1106},[6994,6998,7002,7007,7011,7015,7020,7024,7028,7033,7037],{"type":29,"tag":88,"props":6995,"children":6996},{"style":105},[6997],{"type":34,"value":2886},{"type":29,"tag":88,"props":6999,"children":7000},{"style":122},[7001],{"type":34,"value":2891},{"type":29,"tag":88,"props":7003,"children":7004},{"style":873},[7005],{"type":34,"value":7006},"this",{"type":29,"tag":88,"props":7008,"children":7009},{"style":122},[7010],{"type":34,"value":338},{"type":29,"tag":88,"props":7012,"children":7013},{"style":157},[7014],{"type":34,"value":6940},{"type":29,"tag":88,"props":7016,"children":7017},{"style":163},[7018],{"type":34,"value":7019},"!=",{"type":29,"tag":88,"props":7021,"children":7022},{"style":157},[7023],{"type":34,"value":6797},{"type":29,"tag":88,"props":7025,"children":7026},{"style":122},[7027],{"type":34,"value":338},{"type":29,"tag":88,"props":7029,"children":7030},{"style":157},[7031],{"type":34,"value":7032},"PENDING",{"type":29,"tag":88,"props":7034,"children":7035},{"style":122},[7036],{"type":34,"value":306},{"type":29,"tag":88,"props":7038,"children":7039},{"style":122},[7040],{"type":34,"value":125},{"type":29,"tag":88,"props":7042,"children":7043},{"class":90,"line":1115},[7044,7048,7052,7057,7061,7065,7069,7073],{"type":29,"tag":88,"props":7045,"children":7046},{"style":105},[7047],{"type":34,"value":2927},{"type":29,"tag":88,"props":7049,"children":7050},{"style":105},[7051],{"type":34,"value":171},{"type":29,"tag":88,"props":7053,"children":7054},{"style":174},[7055],{"type":34,"value":7056}," OrderAlreadyConfirmedException",{"type":29,"tag":88,"props":7058,"children":7059},{"style":122},[7060],{"type":34,"value":181},{"type":29,"tag":88,"props":7062,"children":7063},{"style":873},[7064],{"type":34,"value":7006},{"type":29,"tag":88,"props":7066,"children":7067},{"style":122},[7068],{"type":34,"value":338},{"type":29,"tag":88,"props":7070,"children":7071},{"style":157},[7072],{"type":34,"value":3410},{"type":29,"tag":88,"props":7074,"children":7075},{"style":122},[7076],{"type":34,"value":357},{"type":29,"tag":88,"props":7078,"children":7079},{"class":90,"line":11},[7080],{"type":29,"tag":88,"props":7081,"children":7082},{"style":122},[7083],{"type":34,"value":2966},{"type":29,"tag":88,"props":7085,"children":7086},{"class":90,"line":1180},[7087,7091,7095,7099,7103,7107,7111,7116],{"type":29,"tag":88,"props":7088,"children":7089},{"style":873},[7090],{"type":34,"value":876},{"type":29,"tag":88,"props":7092,"children":7093},{"style":122},[7094],{"type":34,"value":338},{"type":29,"tag":88,"props":7096,"children":7097},{"style":157},[7098],{"type":34,"value":6940},{"type":29,"tag":88,"props":7100,"children":7101},{"style":163},[7102],{"type":34,"value":166},{"type":29,"tag":88,"props":7104,"children":7105},{"style":157},[7106],{"type":34,"value":6797},{"type":29,"tag":88,"props":7108,"children":7109},{"style":122},[7110],{"type":34,"value":338},{"type":29,"tag":88,"props":7112,"children":7113},{"style":157},[7114],{"type":34,"value":7115},"CONFIRMED",{"type":29,"tag":88,"props":7117,"children":7118},{"style":122},[7119],{"type":34,"value":424},{"type":29,"tag":88,"props":7121,"children":7122},{"class":90,"line":1240},[7123],{"type":29,"tag":88,"props":7124,"children":7125},{"style":122},[7126],{"type":34,"value":433},{"type":29,"tag":88,"props":7128,"children":7129},{"class":90,"line":1248},[7130],{"type":29,"tag":88,"props":7131,"children":7132},{"style":122},[7133],{"type":34,"value":442},{"type":29,"tag":88,"props":7135,"children":7136},{"class":90,"line":1256},[7137],{"type":29,"tag":88,"props":7138,"children":7139},{"style":95},[7140],{"type":34,"value":7141},"\u002F\u002F La persistance est gérée par une entité JPA séparée dans la couche infrastructure\n",{"type":29,"tag":30,"props":7143,"children":7144},{},[7145,7150],{"type":29,"tag":447,"props":7146,"children":7147},{},[7148],{"type":34,"value":7149},"L'erreur courante :",{"type":34,"value":7151}," mettre les annotations de persistance directement sur les objets métier par pragmatisme. Ça fonctionne pour les petites applications. Sur une application qui grandit, ça crée un couplage fort entre la représentation métier et le schéma de base de données, deux choses qui évoluent à des rythmes différents.",{"type":29,"tag":2288,"props":7153,"children":7155},{"cta":2290,"href":2291,"title":7154,"type":2293},"Vous voulez savoir où placer la frontière entre métier et infrastructure, sur votre vrai code ?",[7156],{"type":29,"tag":30,"props":7157,"children":7158},{},[7159],{"type":34,"value":7160},"Décider quelle annotation polluer, quel objet garder pur, où tracer la règle de dépendance, ça ne se lit pas dans un article : ça se travaille sur votre codebase. En mentoring 1:1, je relis vos use cases et vos entités avec vous et on découpe ensemble les couches qui résistent. Vous repartez avec le réflexe de sentir un couplage avant qu'il vous coûte cher.",{"type":29,"tag":47,"props":7162,"children":7163},{},[],{"type":29,"tag":51,"props":7165,"children":7167},{"id":7166},"règle-3-les-use-cases-orchestrent-sans-dépendre-du-delivery-mechanism",[7168],{"type":34,"value":7169},"Règle 3 : Les use cases orchestrent sans dépendre du delivery mechanism",{"type":29,"tag":30,"props":7171,"children":7172},{},[7173],{"type":34,"value":7174},"Un use case implémente un cas d'utilisation métier. Il orchestre des entités, appelle des repositories, et retourne un résultat.",{"type":29,"tag":30,"props":7176,"children":7177},{},[7178,7183],{"type":29,"tag":447,"props":7179,"children":7180},{},[7181],{"type":34,"value":7182},"Ce qu'il ne doit pas faire :",{"type":34,"value":7184}," connaître comment son résultat va être utilisé : HTTP response, message queue, CLI output, test assertion. Le use case retourne un objet métier. La couche externe décide de comment le sérialiser.",{"type":29,"tag":30,"props":7186,"children":7187},{},[7188],{"type":29,"tag":447,"props":7189,"children":7190},{},[7191],{"type":34,"value":5893},{"type":29,"tag":453,"props":7193,"children":7194},{},[7195,7208,7220],{"type":29,"tag":457,"props":7196,"children":7197},{},[7198,7200,7206],{"type":34,"value":7199},"Un use case ne retourne pas de ",{"type":29,"tag":84,"props":7201,"children":7203},{"className":7202},[],[7204],{"type":34,"value":7205},"ResponseEntity\u003C>",{"type":34,"value":7207}," ou d'objet HTTP",{"type":29,"tag":457,"props":7209,"children":7210},{},[7211,7213,7219],{"type":34,"value":7212},"Un use case ne lève pas d'exceptions HTTP (",{"type":29,"tag":84,"props":7214,"children":7216},{"className":7215},[],[7217],{"type":34,"value":7218},"HttpStatus.NOT_FOUND",{"type":34,"value":306},{"type":29,"tag":457,"props":7221,"children":7222},{},[7223],{"type":34,"value":7224},"Un use case peut être appelé depuis un controller HTTP, un consumer de message queue, ou un test sans modification",{"type":29,"tag":77,"props":7226,"children":7228},{"className":81,"code":7227,"language":80,"meta":8,"style":8},"\u002F\u002F Use case indépendant du delivery mechanism : POJO pur, pas d'import Spring\npublic class CreateUserUseCase {\n    private final UserRepository userRepository;\n    private final EmailService emailService;\n\n    public CreateUserUseCase(UserRepository userRepository, EmailService emailService) {\n        this.userRepository = userRepository;\n        this.emailService = emailService;\n    }\n\n    public User execute(CreateUserCommand command) {\n        if (userRepository.existsByEmail(command.email())) {\n            throw new EmailAlreadyExistsException(command.email()); \u002F\u002F exception métier\n        }\n        User user = User.create(command.email(), command.name());\n        userRepository.save(user);\n        emailService.sendWelcome(user);\n        return user; \u002F\u002F retourne un objet métier, pas un objet HTTP\n    }\n}\n\n\u002F\u002F Le controller Spring gère la sérialisation et le mapping HTTP\n@RestController\n@RequestMapping(\"\u002Fusers\")\npublic class UserController {\n    private final CreateUserUseCase createUserUseCase;\n\n    public UserController(CreateUserUseCase createUserUseCase) {\n        this.createUserUseCase = createUserUseCase;\n    }\n\n    @PostMapping\n    public ResponseEntity\u003CUserDTO> createUser(@RequestBody CreateUserRequest request) {\n        try {\n            CreateUserCommand command = new CreateUserCommand(request.email(), request.name());\n            User user = createUserUseCase.execute(command);\n            return ResponseEntity.status(201).body(UserDTO.fromDomain(user));\n        } catch (EmailAlreadyExistsException e) {\n            return ResponseEntity.status(409).build();\n        }\n    }\n}\n",[7229],{"type":29,"tag":84,"props":7230,"children":7231},{"__ignoreMap":8},[7232,7240,7260,7285,7310,7317,7361,7389,7417,7424,7431,7469,7520,7561,7568,7634,7663,7692,7713,7720,7727,7734,7742,7754,7779,7799,7823,7830,7862,7890,7897,7904,7916,7977,7989,8052,8093,8162,8197,8238,8245,8252],{"type":29,"tag":88,"props":7233,"children":7234},{"class":90,"line":91},[7235],{"type":29,"tag":88,"props":7236,"children":7237},{"style":95},[7238],{"type":34,"value":7239},"\u002F\u002F Use case indépendant du delivery mechanism : POJO pur, pas d'import Spring\n",{"type":29,"tag":88,"props":7241,"children":7242},{"class":90,"line":101},[7243,7247,7251,7256],{"type":29,"tag":88,"props":7244,"children":7245},{"style":105},[7246],{"type":34,"value":108},{"type":29,"tag":88,"props":7248,"children":7249},{"style":105},[7250],{"type":34,"value":113},{"type":29,"tag":88,"props":7252,"children":7253},{"style":116},[7254],{"type":34,"value":7255}," CreateUserUseCase",{"type":29,"tag":88,"props":7257,"children":7258},{"style":122},[7259],{"type":34,"value":125},{"type":29,"tag":88,"props":7261,"children":7262},{"class":90,"line":128},[7263,7267,7271,7276,7281],{"type":29,"tag":88,"props":7264,"children":7265},{"style":105},[7266],{"type":34,"value":143},{"type":29,"tag":88,"props":7268,"children":7269},{"style":105},[7270],{"type":34,"value":148},{"type":29,"tag":88,"props":7272,"children":7273},{"style":151},[7274],{"type":34,"value":7275}," UserRepository",{"type":29,"tag":88,"props":7277,"children":7278},{"style":157},[7279],{"type":34,"value":7280}," userRepository",{"type":29,"tag":88,"props":7282,"children":7283},{"style":122},[7284],{"type":34,"value":424},{"type":29,"tag":88,"props":7286,"children":7287},{"class":90,"line":137},[7288,7292,7296,7301,7306],{"type":29,"tag":88,"props":7289,"children":7290},{"style":105},[7291],{"type":34,"value":143},{"type":29,"tag":88,"props":7293,"children":7294},{"style":105},[7295],{"type":34,"value":148},{"type":29,"tag":88,"props":7297,"children":7298},{"style":151},[7299],{"type":34,"value":7300}," EmailService",{"type":29,"tag":88,"props":7302,"children":7303},{"style":157},[7304],{"type":34,"value":7305}," emailService",{"type":29,"tag":88,"props":7307,"children":7308},{"style":122},[7309],{"type":34,"value":424},{"type":29,"tag":88,"props":7311,"children":7312},{"class":90,"line":211},[7313],{"type":29,"tag":88,"props":7314,"children":7315},{"emptyLinePlaceholder":13},[7316],{"type":34,"value":134},{"type":29,"tag":88,"props":7318,"children":7319},{"class":90,"line":262},[7320,7324,7328,7332,7337,7341,7345,7349,7353,7357],{"type":29,"tag":88,"props":7321,"children":7322},{"style":105},[7323],{"type":34,"value":276},{"type":29,"tag":88,"props":7325,"children":7326},{"style":174},[7327],{"type":34,"value":7255},{"type":29,"tag":88,"props":7329,"children":7330},{"style":122},[7331],{"type":34,"value":181},{"type":29,"tag":88,"props":7333,"children":7334},{"style":151},[7335],{"type":34,"value":7336},"UserRepository",{"type":29,"tag":88,"props":7338,"children":7339},{"style":298},[7340],{"type":34,"value":7280},{"type":29,"tag":88,"props":7342,"children":7343},{"style":122},[7344],{"type":34,"value":192},{"type":29,"tag":88,"props":7346,"children":7347},{"style":151},[7348],{"type":34,"value":7300},{"type":29,"tag":88,"props":7350,"children":7351},{"style":298},[7352],{"type":34,"value":7305},{"type":29,"tag":88,"props":7354,"children":7355},{"style":122},[7356],{"type":34,"value":306},{"type":29,"tag":88,"props":7358,"children":7359},{"style":122},[7360],{"type":34,"value":125},{"type":29,"tag":88,"props":7362,"children":7363},{"class":90,"line":270},[7364,7368,7372,7377,7381,7385],{"type":29,"tag":88,"props":7365,"children":7366},{"style":873},[7367],{"type":34,"value":876},{"type":29,"tag":88,"props":7369,"children":7370},{"style":122},[7371],{"type":34,"value":338},{"type":29,"tag":88,"props":7373,"children":7374},{"style":157},[7375],{"type":34,"value":7376},"userRepository ",{"type":29,"tag":88,"props":7378,"children":7379},{"style":163},[7380],{"type":34,"value":166},{"type":29,"tag":88,"props":7382,"children":7383},{"style":157},[7384],{"type":34,"value":7280},{"type":29,"tag":88,"props":7386,"children":7387},{"style":122},[7388],{"type":34,"value":424},{"type":29,"tag":88,"props":7390,"children":7391},{"class":90,"line":313},[7392,7396,7400,7405,7409,7413],{"type":29,"tag":88,"props":7393,"children":7394},{"style":873},[7395],{"type":34,"value":876},{"type":29,"tag":88,"props":7397,"children":7398},{"style":122},[7399],{"type":34,"value":338},{"type":29,"tag":88,"props":7401,"children":7402},{"style":157},[7403],{"type":34,"value":7404},"emailService ",{"type":29,"tag":88,"props":7406,"children":7407},{"style":163},[7408],{"type":34,"value":166},{"type":29,"tag":88,"props":7410,"children":7411},{"style":157},[7412],{"type":34,"value":7305},{"type":29,"tag":88,"props":7414,"children":7415},{"style":122},[7416],{"type":34,"value":424},{"type":29,"tag":88,"props":7418,"children":7419},{"class":90,"line":360},[7420],{"type":29,"tag":88,"props":7421,"children":7422},{"style":122},[7423],{"type":34,"value":433},{"type":29,"tag":88,"props":7425,"children":7426},{"class":90,"line":409},[7427],{"type":29,"tag":88,"props":7428,"children":7429},{"emptyLinePlaceholder":13},[7430],{"type":34,"value":134},{"type":29,"tag":88,"props":7432,"children":7433},{"class":90,"line":427},[7434,7438,7443,7447,7451,7456,7461,7465],{"type":29,"tag":88,"props":7435,"children":7436},{"style":105},[7437],{"type":34,"value":276},{"type":29,"tag":88,"props":7439,"children":7440},{"style":151},[7441],{"type":34,"value":7442}," User",{"type":29,"tag":88,"props":7444,"children":7445},{"style":174},[7446],{"type":34,"value":6240},{"type":29,"tag":88,"props":7448,"children":7449},{"style":122},[7450],{"type":34,"value":181},{"type":29,"tag":88,"props":7452,"children":7453},{"style":151},[7454],{"type":34,"value":7455},"CreateUserCommand",{"type":29,"tag":88,"props":7457,"children":7458},{"style":298},[7459],{"type":34,"value":7460}," command",{"type":29,"tag":88,"props":7462,"children":7463},{"style":122},[7464],{"type":34,"value":306},{"type":29,"tag":88,"props":7466,"children":7467},{"style":122},[7468],{"type":34,"value":125},{"type":29,"tag":88,"props":7470,"children":7471},{"class":90,"line":436},[7472,7476,7480,7485,7489,7494,7498,7503,7507,7511,7516],{"type":29,"tag":88,"props":7473,"children":7474},{"style":105},[7475],{"type":34,"value":2886},{"type":29,"tag":88,"props":7477,"children":7478},{"style":122},[7479],{"type":34,"value":2891},{"type":29,"tag":88,"props":7481,"children":7482},{"style":157},[7483],{"type":34,"value":7484},"userRepository",{"type":29,"tag":88,"props":7486,"children":7487},{"style":122},[7488],{"type":34,"value":338},{"type":29,"tag":88,"props":7490,"children":7491},{"style":174},[7492],{"type":34,"value":7493},"existsByEmail",{"type":29,"tag":88,"props":7495,"children":7496},{"style":122},[7497],{"type":34,"value":181},{"type":29,"tag":88,"props":7499,"children":7500},{"style":157},[7501],{"type":34,"value":7502},"command",{"type":29,"tag":88,"props":7504,"children":7505},{"style":122},[7506],{"type":34,"value":338},{"type":29,"tag":88,"props":7508,"children":7509},{"style":174},[7510],{"type":34,"value":1366},{"type":29,"tag":88,"props":7512,"children":7513},{"style":122},[7514],{"type":34,"value":7515},"()))",{"type":29,"tag":88,"props":7517,"children":7518},{"style":122},[7519],{"type":34,"value":125},{"type":29,"tag":88,"props":7521,"children":7522},{"class":90,"line":767},[7523,7527,7531,7536,7540,7544,7548,7552,7557],{"type":29,"tag":88,"props":7524,"children":7525},{"style":105},[7526],{"type":34,"value":2927},{"type":29,"tag":88,"props":7528,"children":7529},{"style":105},[7530],{"type":34,"value":171},{"type":29,"tag":88,"props":7532,"children":7533},{"style":174},[7534],{"type":34,"value":7535}," EmailAlreadyExistsException",{"type":29,"tag":88,"props":7537,"children":7538},{"style":122},[7539],{"type":34,"value":181},{"type":29,"tag":88,"props":7541,"children":7542},{"style":157},[7543],{"type":34,"value":7502},{"type":29,"tag":88,"props":7545,"children":7546},{"style":122},[7547],{"type":34,"value":338},{"type":29,"tag":88,"props":7549,"children":7550},{"style":174},[7551],{"type":34,"value":1366},{"type":29,"tag":88,"props":7553,"children":7554},{"style":122},[7555],{"type":34,"value":7556},"());",{"type":29,"tag":88,"props":7558,"children":7559},{"style":95},[7560],{"type":34,"value":6344},{"type":29,"tag":88,"props":7562,"children":7563},{"class":90,"line":792},[7564],{"type":29,"tag":88,"props":7565,"children":7566},{"style":122},[7567],{"type":34,"value":2966},{"type":29,"tag":88,"props":7569,"children":7570},{"class":90,"line":817},[7571,7576,7581,7585,7589,7593,7598,7602,7606,7610,7614,7618,7622,7626,7630],{"type":29,"tag":88,"props":7572,"children":7573},{"style":151},[7574],{"type":34,"value":7575},"        User",{"type":29,"tag":88,"props":7577,"children":7578},{"style":157},[7579],{"type":34,"value":7580}," user ",{"type":29,"tag":88,"props":7582,"children":7583},{"style":163},[7584],{"type":34,"value":166},{"type":29,"tag":88,"props":7586,"children":7587},{"style":157},[7588],{"type":34,"value":7442},{"type":29,"tag":88,"props":7590,"children":7591},{"style":122},[7592],{"type":34,"value":338},{"type":29,"tag":88,"props":7594,"children":7595},{"style":174},[7596],{"type":34,"value":7597},"create",{"type":29,"tag":88,"props":7599,"children":7600},{"style":122},[7601],{"type":34,"value":181},{"type":29,"tag":88,"props":7603,"children":7604},{"style":157},[7605],{"type":34,"value":7502},{"type":29,"tag":88,"props":7607,"children":7608},{"style":122},[7609],{"type":34,"value":338},{"type":29,"tag":88,"props":7611,"children":7612},{"style":174},[7613],{"type":34,"value":1366},{"type":29,"tag":88,"props":7615,"children":7616},{"style":122},[7617],{"type":34,"value":397},{"type":29,"tag":88,"props":7619,"children":7620},{"style":157},[7621],{"type":34,"value":7460},{"type":29,"tag":88,"props":7623,"children":7624},{"style":122},[7625],{"type":34,"value":338},{"type":29,"tag":88,"props":7627,"children":7628},{"style":174},[7629],{"type":34,"value":6493},{"type":29,"tag":88,"props":7631,"children":7632},{"style":122},[7633],{"type":34,"value":2958},{"type":29,"tag":88,"props":7635,"children":7636},{"class":90,"line":825},[7637,7642,7646,7650,7654,7659],{"type":29,"tag":88,"props":7638,"children":7639},{"style":157},[7640],{"type":34,"value":7641},"        userRepository",{"type":29,"tag":88,"props":7643,"children":7644},{"style":122},[7645],{"type":34,"value":338},{"type":29,"tag":88,"props":7647,"children":7648},{"style":174},[7649],{"type":34,"value":343},{"type":29,"tag":88,"props":7651,"children":7652},{"style":122},[7653],{"type":34,"value":181},{"type":29,"tag":88,"props":7655,"children":7656},{"style":157},[7657],{"type":34,"value":7658},"user",{"type":29,"tag":88,"props":7660,"children":7661},{"style":122},[7662],{"type":34,"value":357},{"type":29,"tag":88,"props":7664,"children":7665},{"class":90,"line":869},[7666,7671,7675,7680,7684,7688],{"type":29,"tag":88,"props":7667,"children":7668},{"style":157},[7669],{"type":34,"value":7670},"        emailService",{"type":29,"tag":88,"props":7672,"children":7673},{"style":122},[7674],{"type":34,"value":338},{"type":29,"tag":88,"props":7676,"children":7677},{"style":174},[7678],{"type":34,"value":7679},"sendWelcome",{"type":29,"tag":88,"props":7681,"children":7682},{"style":122},[7683],{"type":34,"value":181},{"type":29,"tag":88,"props":7685,"children":7686},{"style":157},[7687],{"type":34,"value":7658},{"type":29,"tag":88,"props":7689,"children":7690},{"style":122},[7691],{"type":34,"value":357},{"type":29,"tag":88,"props":7693,"children":7694},{"class":90,"line":900},[7695,7699,7704,7708],{"type":29,"tag":88,"props":7696,"children":7697},{"style":105},[7698],{"type":34,"value":415},{"type":29,"tag":88,"props":7700,"children":7701},{"style":157},[7702],{"type":34,"value":7703}," user",{"type":29,"tag":88,"props":7705,"children":7706},{"style":122},[7707],{"type":34,"value":5988},{"type":29,"tag":88,"props":7709,"children":7710},{"style":95},[7711],{"type":34,"value":7712}," \u002F\u002F retourne un objet métier, pas un objet HTTP\n",{"type":29,"tag":88,"props":7714,"children":7715},{"class":90,"line":929},[7716],{"type":29,"tag":88,"props":7717,"children":7718},{"style":122},[7719],{"type":34,"value":433},{"type":29,"tag":88,"props":7721,"children":7722},{"class":90,"line":937},[7723],{"type":29,"tag":88,"props":7724,"children":7725},{"style":122},[7726],{"type":34,"value":442},{"type":29,"tag":88,"props":7728,"children":7729},{"class":90,"line":945},[7730],{"type":29,"tag":88,"props":7731,"children":7732},{"emptyLinePlaceholder":13},[7733],{"type":34,"value":134},{"type":29,"tag":88,"props":7735,"children":7736},{"class":90,"line":981},[7737],{"type":29,"tag":88,"props":7738,"children":7739},{"style":95},[7740],{"type":34,"value":7741},"\u002F\u002F Le controller Spring gère la sérialisation et le mapping HTTP\n",{"type":29,"tag":88,"props":7743,"children":7744},{"class":90,"line":1021},[7745,7749],{"type":29,"tag":88,"props":7746,"children":7747},{"style":1974},[7748],{"type":34,"value":1977},{"type":29,"tag":88,"props":7750,"children":7751},{"style":1980},[7752],{"type":34,"value":7753},"RestController\n",{"type":29,"tag":88,"props":7755,"children":7756},{"class":90,"line":1066},[7757,7761,7766,7770,7775],{"type":29,"tag":88,"props":7758,"children":7759},{"style":1974},[7760],{"type":34,"value":1977},{"type":29,"tag":88,"props":7762,"children":7763},{"style":1980},[7764],{"type":34,"value":7765},"RequestMapping",{"type":29,"tag":88,"props":7767,"children":7768},{"style":122},[7769],{"type":34,"value":181},{"type":29,"tag":88,"props":7771,"children":7772},{"style":184},[7773],{"type":34,"value":7774},"\"\u002Fusers\"",{"type":29,"tag":88,"props":7776,"children":7777},{"style":122},[7778],{"type":34,"value":3078},{"type":29,"tag":88,"props":7780,"children":7781},{"class":90,"line":1082},[7782,7786,7790,7795],{"type":29,"tag":88,"props":7783,"children":7784},{"style":105},[7785],{"type":34,"value":108},{"type":29,"tag":88,"props":7787,"children":7788},{"style":105},[7789],{"type":34,"value":113},{"type":29,"tag":88,"props":7791,"children":7792},{"style":116},[7793],{"type":34,"value":7794}," UserController",{"type":29,"tag":88,"props":7796,"children":7797},{"style":122},[7798],{"type":34,"value":125},{"type":29,"tag":88,"props":7800,"children":7801},{"class":90,"line":1090},[7802,7806,7810,7814,7819],{"type":29,"tag":88,"props":7803,"children":7804},{"style":105},[7805],{"type":34,"value":143},{"type":29,"tag":88,"props":7807,"children":7808},{"style":105},[7809],{"type":34,"value":148},{"type":29,"tag":88,"props":7811,"children":7812},{"style":151},[7813],{"type":34,"value":7255},{"type":29,"tag":88,"props":7815,"children":7816},{"style":157},[7817],{"type":34,"value":7818}," createUserUseCase",{"type":29,"tag":88,"props":7820,"children":7821},{"style":122},[7822],{"type":34,"value":424},{"type":29,"tag":88,"props":7824,"children":7825},{"class":90,"line":1098},[7826],{"type":29,"tag":88,"props":7827,"children":7828},{"emptyLinePlaceholder":13},[7829],{"type":34,"value":134},{"type":29,"tag":88,"props":7831,"children":7832},{"class":90,"line":1106},[7833,7837,7841,7845,7850,7854,7858],{"type":29,"tag":88,"props":7834,"children":7835},{"style":105},[7836],{"type":34,"value":276},{"type":29,"tag":88,"props":7838,"children":7839},{"style":174},[7840],{"type":34,"value":7794},{"type":29,"tag":88,"props":7842,"children":7843},{"style":122},[7844],{"type":34,"value":181},{"type":29,"tag":88,"props":7846,"children":7847},{"style":151},[7848],{"type":34,"value":7849},"CreateUserUseCase",{"type":29,"tag":88,"props":7851,"children":7852},{"style":298},[7853],{"type":34,"value":7818},{"type":29,"tag":88,"props":7855,"children":7856},{"style":122},[7857],{"type":34,"value":306},{"type":29,"tag":88,"props":7859,"children":7860},{"style":122},[7861],{"type":34,"value":125},{"type":29,"tag":88,"props":7863,"children":7864},{"class":90,"line":1115},[7865,7869,7873,7878,7882,7886],{"type":29,"tag":88,"props":7866,"children":7867},{"style":873},[7868],{"type":34,"value":876},{"type":29,"tag":88,"props":7870,"children":7871},{"style":122},[7872],{"type":34,"value":338},{"type":29,"tag":88,"props":7874,"children":7875},{"style":157},[7876],{"type":34,"value":7877},"createUserUseCase ",{"type":29,"tag":88,"props":7879,"children":7880},{"style":163},[7881],{"type":34,"value":166},{"type":29,"tag":88,"props":7883,"children":7884},{"style":157},[7885],{"type":34,"value":7818},{"type":29,"tag":88,"props":7887,"children":7888},{"style":122},[7889],{"type":34,"value":424},{"type":29,"tag":88,"props":7891,"children":7892},{"class":90,"line":11},[7893],{"type":29,"tag":88,"props":7894,"children":7895},{"style":122},[7896],{"type":34,"value":433},{"type":29,"tag":88,"props":7898,"children":7899},{"class":90,"line":1180},[7900],{"type":29,"tag":88,"props":7901,"children":7902},{"emptyLinePlaceholder":13},[7903],{"type":34,"value":134},{"type":29,"tag":88,"props":7905,"children":7906},{"class":90,"line":1240},[7907,7911],{"type":29,"tag":88,"props":7908,"children":7909},{"style":1974},[7910],{"type":34,"value":3302},{"type":29,"tag":88,"props":7912,"children":7913},{"style":1980},[7914],{"type":34,"value":7915},"PostMapping\n",{"type":29,"tag":88,"props":7917,"children":7918},{"class":90,"line":1248},[7919,7923,7928,7932,7937,7941,7946,7950,7954,7959,7964,7969,7973],{"type":29,"tag":88,"props":7920,"children":7921},{"style":105},[7922],{"type":34,"value":276},{"type":29,"tag":88,"props":7924,"children":7925},{"style":151},[7926],{"type":34,"value":7927}," ResponseEntity",{"type":29,"tag":88,"props":7929,"children":7930},{"style":122},[7931],{"type":34,"value":1683},{"type":29,"tag":88,"props":7933,"children":7934},{"style":105},[7935],{"type":34,"value":7936},"UserDTO",{"type":29,"tag":88,"props":7938,"children":7939},{"style":122},[7940],{"type":34,"value":1701},{"type":29,"tag":88,"props":7942,"children":7943},{"style":174},[7944],{"type":34,"value":7945}," createUser",{"type":29,"tag":88,"props":7947,"children":7948},{"style":122},[7949],{"type":34,"value":181},{"type":29,"tag":88,"props":7951,"children":7952},{"style":1974},[7953],{"type":34,"value":1977},{"type":29,"tag":88,"props":7955,"children":7956},{"style":1980},[7957],{"type":34,"value":7958},"RequestBody",{"type":29,"tag":88,"props":7960,"children":7961},{"style":151},[7962],{"type":34,"value":7963}," CreateUserRequest",{"type":29,"tag":88,"props":7965,"children":7966},{"style":298},[7967],{"type":34,"value":7968}," request",{"type":29,"tag":88,"props":7970,"children":7971},{"style":122},[7972],{"type":34,"value":306},{"type":29,"tag":88,"props":7974,"children":7975},{"style":122},[7976],{"type":34,"value":125},{"type":29,"tag":88,"props":7978,"children":7979},{"class":90,"line":1256},[7980,7985],{"type":29,"tag":88,"props":7981,"children":7982},{"style":105},[7983],{"type":34,"value":7984},"        try",{"type":29,"tag":88,"props":7986,"children":7987},{"style":122},[7988],{"type":34,"value":125},{"type":29,"tag":88,"props":7990,"children":7991},{"class":90,"line":1264},[7992,7997,8002,8006,8010,8015,8019,8024,8028,8032,8036,8040,8044,8048],{"type":29,"tag":88,"props":7993,"children":7994},{"style":151},[7995],{"type":34,"value":7996},"            CreateUserCommand",{"type":29,"tag":88,"props":7998,"children":7999},{"style":157},[8000],{"type":34,"value":8001}," command ",{"type":29,"tag":88,"props":8003,"children":8004},{"style":163},[8005],{"type":34,"value":166},{"type":29,"tag":88,"props":8007,"children":8008},{"style":105},[8009],{"type":34,"value":171},{"type":29,"tag":88,"props":8011,"children":8012},{"style":174},[8013],{"type":34,"value":8014}," CreateUserCommand",{"type":29,"tag":88,"props":8016,"children":8017},{"style":122},[8018],{"type":34,"value":181},{"type":29,"tag":88,"props":8020,"children":8021},{"style":157},[8022],{"type":34,"value":8023},"request",{"type":29,"tag":88,"props":8025,"children":8026},{"style":122},[8027],{"type":34,"value":338},{"type":29,"tag":88,"props":8029,"children":8030},{"style":174},[8031],{"type":34,"value":1366},{"type":29,"tag":88,"props":8033,"children":8034},{"style":122},[8035],{"type":34,"value":397},{"type":29,"tag":88,"props":8037,"children":8038},{"style":157},[8039],{"type":34,"value":7968},{"type":29,"tag":88,"props":8041,"children":8042},{"style":122},[8043],{"type":34,"value":338},{"type":29,"tag":88,"props":8045,"children":8046},{"style":174},[8047],{"type":34,"value":6493},{"type":29,"tag":88,"props":8049,"children":8050},{"style":122},[8051],{"type":34,"value":2958},{"type":29,"tag":88,"props":8053,"children":8054},{"class":90,"line":1293},[8055,8060,8064,8068,8072,8076,8081,8085,8089],{"type":29,"tag":88,"props":8056,"children":8057},{"style":151},[8058],{"type":34,"value":8059},"            User",{"type":29,"tag":88,"props":8061,"children":8062},{"style":157},[8063],{"type":34,"value":7580},{"type":29,"tag":88,"props":8065,"children":8066},{"style":163},[8067],{"type":34,"value":166},{"type":29,"tag":88,"props":8069,"children":8070},{"style":157},[8071],{"type":34,"value":7818},{"type":29,"tag":88,"props":8073,"children":8074},{"style":122},[8075],{"type":34,"value":338},{"type":29,"tag":88,"props":8077,"children":8078},{"style":174},[8079],{"type":34,"value":8080},"execute",{"type":29,"tag":88,"props":8082,"children":8083},{"style":122},[8084],{"type":34,"value":181},{"type":29,"tag":88,"props":8086,"children":8087},{"style":157},[8088],{"type":34,"value":7502},{"type":29,"tag":88,"props":8090,"children":8091},{"style":122},[8092],{"type":34,"value":357},{"type":29,"tag":88,"props":8094,"children":8095},{"class":90,"line":1342},[8096,8101,8105,8109,8114,8118,8123,8128,8133,8137,8141,8145,8150,8154,8158],{"type":29,"tag":88,"props":8097,"children":8098},{"style":105},[8099],{"type":34,"value":8100},"            return",{"type":29,"tag":88,"props":8102,"children":8103},{"style":157},[8104],{"type":34,"value":7927},{"type":29,"tag":88,"props":8106,"children":8107},{"style":122},[8108],{"type":34,"value":338},{"type":29,"tag":88,"props":8110,"children":8111},{"style":174},[8112],{"type":34,"value":8113},"status",{"type":29,"tag":88,"props":8115,"children":8116},{"style":122},[8117],{"type":34,"value":181},{"type":29,"tag":88,"props":8119,"children":8120},{"style":195},[8121],{"type":34,"value":8122},"201",{"type":29,"tag":88,"props":8124,"children":8125},{"style":122},[8126],{"type":34,"value":8127},").",{"type":29,"tag":88,"props":8129,"children":8130},{"style":174},[8131],{"type":34,"value":8132},"body",{"type":29,"tag":88,"props":8134,"children":8135},{"style":122},[8136],{"type":34,"value":181},{"type":29,"tag":88,"props":8138,"children":8139},{"style":157},[8140],{"type":34,"value":7936},{"type":29,"tag":88,"props":8142,"children":8143},{"style":122},[8144],{"type":34,"value":338},{"type":29,"tag":88,"props":8146,"children":8147},{"style":174},[8148],{"type":34,"value":8149},"fromDomain",{"type":29,"tag":88,"props":8151,"children":8152},{"style":122},[8153],{"type":34,"value":181},{"type":29,"tag":88,"props":8155,"children":8156},{"style":157},[8157],{"type":34,"value":7658},{"type":29,"tag":88,"props":8159,"children":8160},{"style":122},[8161],{"type":34,"value":1415},{"type":29,"tag":88,"props":8163,"children":8164},{"class":90,"line":1418},[8165,8170,8175,8179,8184,8189,8193],{"type":29,"tag":88,"props":8166,"children":8167},{"style":122},[8168],{"type":34,"value":8169},"        }",{"type":29,"tag":88,"props":8171,"children":8172},{"style":105},[8173],{"type":34,"value":8174}," catch",{"type":29,"tag":88,"props":8176,"children":8177},{"style":122},[8178],{"type":34,"value":2891},{"type":29,"tag":88,"props":8180,"children":8181},{"style":151},[8182],{"type":34,"value":8183},"EmailAlreadyExistsException",{"type":29,"tag":88,"props":8185,"children":8186},{"style":298},[8187],{"type":34,"value":8188}," e",{"type":29,"tag":88,"props":8190,"children":8191},{"style":122},[8192],{"type":34,"value":306},{"type":29,"tag":88,"props":8194,"children":8195},{"style":122},[8196],{"type":34,"value":125},{"type":29,"tag":88,"props":8198,"children":8199},{"class":90,"line":1426},[8200,8204,8208,8212,8216,8220,8225,8229,8234],{"type":29,"tag":88,"props":8201,"children":8202},{"style":105},[8203],{"type":34,"value":8100},{"type":29,"tag":88,"props":8205,"children":8206},{"style":157},[8207],{"type":34,"value":7927},{"type":29,"tag":88,"props":8209,"children":8210},{"style":122},[8211],{"type":34,"value":338},{"type":29,"tag":88,"props":8213,"children":8214},{"style":174},[8215],{"type":34,"value":8113},{"type":29,"tag":88,"props":8217,"children":8218},{"style":122},[8219],{"type":34,"value":181},{"type":29,"tag":88,"props":8221,"children":8222},{"style":195},[8223],{"type":34,"value":8224},"409",{"type":29,"tag":88,"props":8226,"children":8227},{"style":122},[8228],{"type":34,"value":8127},{"type":29,"tag":88,"props":8230,"children":8231},{"style":174},[8232],{"type":34,"value":8233},"build",{"type":29,"tag":88,"props":8235,"children":8236},{"style":122},[8237],{"type":34,"value":1810},{"type":29,"tag":88,"props":8239,"children":8240},{"class":90,"line":1434},[8241],{"type":29,"tag":88,"props":8242,"children":8243},{"style":122},[8244],{"type":34,"value":2966},{"type":29,"tag":88,"props":8246,"children":8247},{"class":90,"line":1442},[8248],{"type":29,"tag":88,"props":8249,"children":8250},{"style":122},[8251],{"type":34,"value":433},{"type":29,"tag":88,"props":8253,"children":8254},{"class":90,"line":1451},[8255],{"type":29,"tag":88,"props":8256,"children":8257},{"style":122},[8258],{"type":34,"value":442},{"type":29,"tag":47,"props":8260,"children":8261},{},[],{"type":29,"tag":51,"props":8263,"children":8265},{"id":8264},"les-anti-patterns-courants-à-éviter",[8266],{"type":34,"value":8267},"Les anti-patterns courants à éviter",{"type":29,"tag":30,"props":8269,"children":8270},{},[8271,8276],{"type":29,"tag":447,"props":8272,"children":8273},{},[8274],{"type":34,"value":8275},"L'Anemic Domain Model :",{"type":34,"value":8277}," les entités ne contiennent que des getters\u002Fsetters, et toute la logique est dans les services. Le domaine est vide de sens. La logique métier se retrouve dispersée dans tous les services et est difficile à tester isolément.",{"type":29,"tag":30,"props":8279,"children":8280},{},[8281,8286],{"type":29,"tag":447,"props":8282,"children":8283},{},[8284],{"type":34,"value":8285},"Le God Service :",{"type":34,"value":8287}," un service qui fait tout : valide, orchestre, persiste, formate. Difficile à tester, impossible à réutiliser, cauchemar à maintenir.",{"type":29,"tag":30,"props":8289,"children":8290},{},[8291,8296],{"type":29,"tag":447,"props":8292,"children":8293},{},[8294],{"type":34,"value":8295},"Le leak d'infrastructure :",{"type":34,"value":8297}," des dépendances sur des frameworks qui se propagent jusqu'aux entités métier. Le signe infaillible que la règle 2 est violée.",{"type":29,"tag":47,"props":8299,"children":8300},{},[],{"type":29,"tag":51,"props":8302,"children":8304},{"id":8303},"quand-appliquer-les-3-règles-quand-ne-pas-les-appliquer",[8305],{"type":34,"value":8306},"Quand appliquer les 3 règles, quand ne pas les appliquer",{"type":29,"tag":30,"props":8308,"children":8309},{},[8310,8315],{"type":29,"tag":447,"props":8311,"children":8312},{},[8313],{"type":34,"value":8314},"Appliquer dès que :",{"type":34,"value":8316}," la logique métier est non-triviale, l'application doit durer plus de 2 ans, ou plusieurs développeurs travaillent sur le même codebase.",{"type":29,"tag":30,"props":8318,"children":8319},{},[8320,8325],{"type":29,"tag":447,"props":8321,"children":8322},{},[8323],{"type":34,"value":8324},"Ne pas appliquer dans sa totalité :",{"type":34,"value":8326}," pour des scripts, des prototypes, des outils internes à courte durée de vie. La Clean Architecture a un coût d'entrée qui doit être justifié par la longévité et la complexité du projet.",{"type":29,"tag":2288,"props":8328,"children":8330},{"cta":5629,"href":5630,"title":8329,"type":5632},"Tracer la règle de dépendance n'est qu'une pratique parmi 100",[8331],{"type":29,"tag":30,"props":8332,"children":8333},{},[8334],{"type":34,"value":8335},"Cet article isole une pratique : garder le métier indépendant de l'infrastructure. Le Craft Bundle réunit les 100 pratiques que j'applique pour coder propre, des frontières de couches au découpage des use cases en passant par les tests qui tournent en millisecondes. Ce sont les réflexes que l'IA ne vous apprendra jamais, parce qu'elle ne les a jamais vus tenir une codebase sur quatre ans.",{"type":29,"tag":47,"props":8337,"children":8338},{},[],{"type":29,"tag":51,"props":8340,"children":8342},{"id":8341},"faq-sur-la-clean-architecture",[8343],{"type":34,"value":8344},"FAQ sur la Clean Architecture",{"type":29,"tag":5649,"props":8346,"children":8347},{},[8348,8353],{"type":29,"tag":5653,"props":8349,"children":8350},{},[8351],{"type":34,"value":8352},"1. La Clean Architecture est-elle compatible avec les frameworks comme Spring ou NestJS ?",{"type":29,"tag":30,"props":8354,"children":8355},{},[8356],{"type":34,"value":8357},"Oui, mais avec discipline. Spring et NestJS sont excellents comme couches d'infrastructure (injection de dépendances, routing HTTP). La règle est de ne pas laisser leurs annotations et abstractions contaminer les couches métier. Utiliser la DI du framework pour injecter les dépendances dans les use cases, sans que les use cases aient connaissance du framework lui-même.",{"type":29,"tag":5649,"props":8359,"children":8360},{},[8361,8366],{"type":29,"tag":5653,"props":8362,"children":8363},{},[8364],{"type":34,"value":8365},"2. Faut-il refactoriser tout un codebase existant pour appliquer ces 3 règles ?",{"type":29,"tag":30,"props":8367,"children":8368},{},[8369],{"type":34,"value":8370},"Non. Appliquer les 3 règles progressivement, au fil des nouvelles features et des refactorings planifiés. Commencer par les modules les plus actifs, ceux sur lesquels l'équipe travaille le plus souvent. Sur les modules legacy stables, le coût du refactoring n'est pas justifié si le gain opérationnel est faible. C'est la stratégie que j'applique systématiquement dans mes missions.",{"type":29,"tag":5649,"props":8372,"children":8373},{},[8374,8379],{"type":29,"tag":5653,"props":8375,"children":8376},{},[8377],{"type":34,"value":8378},"3. La Clean Architecture ralentit-elle le développement au départ ?",{"type":29,"tag":30,"props":8380,"children":8381},{},[8382],{"type":34,"value":8383},"Légèrement, sur les 2 à 4 premières semaines. Le coût est l'apprentissage de la structuration correcte du code. Après cette période, le développement accélère parce que les tests sont rapides, les changements sont localisés, et les nouveaux développeurs comprennent la structure rapidement. Sur l'équipe dont je parlais en ouverture, le ralentissement initial a été compensé dès le premier mois.",{"type":29,"tag":5649,"props":8385,"children":8386},{},[8387,8392],{"type":29,"tag":5653,"props":8388,"children":8389},{},[8390],{"type":34,"value":8391},"4. Clean Architecture, Hexagonal Architecture, Onion Architecture : quelle différence ?",{"type":29,"tag":30,"props":8393,"children":8394},{},[8395],{"type":34,"value":8396},"Ce sont des variantes du même principe : séparer le domaine de l'infrastructure et diriger les dépendances vers le centre. Les différences sont principalement de vocabulaire et d'emphase. L'Hexagonal (ports et adapters) est souvent plus simple à expliquer. La Clean Architecture est plus prescriptive sur les couches. Choisissez le vocabulaire qui résonne avec votre équipe. Le principe est le même.",{"type":29,"tag":5649,"props":8398,"children":8399},{},[8400,8405],{"type":29,"tag":5653,"props":8401,"children":8402},{},[8403],{"type":34,"value":8404},"5. Comment justifier le temps d'investissement en Clean Architecture auprès du management ?",{"type":29,"tag":30,"props":8406,"children":8407},{},[8408,8410,8416],{"type":34,"value":8409},"Trois arguments concrets que j'utilise : (1) Les tests métier s'exécutent en secondes et non en minutes, réduisant le feedback loop et le temps de CI. (2) Les nouveaux développeurs atteignent l'autonomie 2 à 4 semaines plus tôt, ce qui représente une économie de 40 à 80 heures d'accompagnement par recrutement. (3) Les changements de framework ou de base de données, qui arrivent tous les 3 à 5 ans, ne nécessitent pas de réécriture de la logique métier. Pour un CTO qui prend ses fonctions, investir dans ces fondations architecturales fait partie des ",{"type":29,"tag":63,"props":8411,"children":8413},{"href":8412},"\u002Ffr\u002Fmanagement\u002Fcto-premiere-annee-90-jours",[8414],{"type":34,"value":8415},"décisions structurantes à prendre dans les 90 premiers jours",{"type":34,"value":8417},", avant que la dette s'accumule et rende le changement trop coûteux.",{"type":29,"tag":47,"props":8419,"children":8420},{},[],{"type":29,"tag":2288,"props":8422,"children":8423},{"cta":5752,"href":5753,"title":5754,"type":5755},[8424],{"type":29,"tag":30,"props":8425,"children":8426},{},[8427],{"type":34,"value":8428},"L'Engineering Maturity Self-Assessment couvre le domaine Architecture & Craft : évaluez votre niveau sur la séparation des couches, le couplage, et la testabilité de votre codebase. Score et recommandations en 10 minutes.",{"type":29,"tag":5763,"props":8430,"children":8431},{},[8432],{"type":34,"value":5767},{"title":8,"searchDepth":101,"depth":101,"links":8434},[8435,8436,8437,8438,8439,8440,8441],{"id":5821,"depth":101,"text":5824},{"id":5858,"depth":101,"text":5861},{"id":6388,"depth":101,"text":6391},{"id":7166,"depth":101,"text":7169},{"id":8264,"depth":101,"text":8267},{"id":8303,"depth":101,"text":8306},{"id":8341,"depth":101,"text":8344},"content:fr:architecture-craft:clean-architecture-3-regles.md","fr\u002Farchitecture-craft\u002Fclean-architecture-3-regles.md","fr\u002Farchitecture-craft\u002Fclean-architecture-3-regles",{"_path":8446,"_dir":8447,"_draft":7,"_partial":7,"_locale":8,"title":8448,"description":8449,"id":3425,"date":8450,"listed":13,"nocomments":7,"hidden":7,"categories":8451,"tags":8452,"cover":8455,"readingTime":8456,"body":8461,"_type":5777,"_id":10109,"_source":5779,"_file":10110,"_stem":10111,"_extension":5782},"\u002Ffr\u002Fdette-technique\u002Frevue-de-code-java-guide-exemples","dette-technique","Comment Maîtriser la Revue de Code en Java, Guide Complet avec Exemples et Astuces","Découvrez comment tirer le meilleur parti des revues de code en Java grâce à ce guide complet. Inclut des exemples de code, des astuces pratiques, et une FAQ.","2024-08-30",[8447],[16,8453,8454],"qualite","code-review","covers\u002Farticles\u002Frevue-de-code.jpg",{"text":8457,"minutes":8458,"time":8459,"words":8460},"8 min read",7.485,449100,1497,{"type":26,"children":8462,"toc":10087},[8463,8468,8481,8487,8492,8525,8535,8541,8548,8553,8571,8577,8582,8742,8748,8753,8762,8768,8773,8786,8803,8808,8816,8821,8827,8832,8838,8843,8849,8857,8945,8953,9006,9012,9019,9278,9285,9306,9486,9489,9494,9500,9507,9631,9638,9681,9817,9823,9829,9866,9872,9905,9911,9916,9933,9943,9953,9971,9981,9996,10005,10008,10014,10027,10040,10053,10072,10083],{"type":29,"tag":30,"props":8464,"children":8465},{},[8466],{"type":34,"value":8467},"Trois ans d'accompagnement chez BNP Paribas CIB sur la qualité du code, six mois chez Canal+ sur les pratiques d'équipe. Sur les deux missions, la même constatation : quand les revues de code passent du statut de formalité à celui de discipline rigoureuse, les bugs en production chutent de manière mesurable et les délais tiennent. La revue n'est pas un moment de jugement, ce n'est pas non plus une case à cocher dans Jira. C'est le moment où le code passe du statut \"fonctionne sur ma machine\" à celui de code partageable et maintenable.",{"type":29,"tag":30,"props":8469,"children":8470},{},[8471,8473,8479],{"type":34,"value":8472},"Robert C. Martin le rappelle dans ",{"type":29,"tag":8474,"props":8475,"children":8476},"em",{},[8477],{"type":34,"value":8478},"Clean Code",{"type":34,"value":8480}," : un code se lit bien plus souvent qu'il ne s'écrit. La revue est précisément le moment où cette asymétrie devient tangible, et coûteuse quand on la néglige. Cet article rassemble ce qui fait la différence entre une revue qui apporte de la valeur et une revue qui pollue le workflow : ce qu'on regarde, comment on formule, quels outils on utilise, et la checklist concrète à dérouler sur un projet Java sérieux.",{"type":29,"tag":51,"props":8482,"children":8484},{"id":8483},"ce-quune-revue-de-code-apporte-vraiment",[8485],{"type":34,"value":8486},"Ce qu'une revue de code apporte vraiment",{"type":29,"tag":30,"props":8488,"children":8489},{},[8490],{"type":34,"value":8491},"Une revue de code est l'examen du code d'un développeur par un ou plusieurs pairs avant intégration. La définition est simple, l'impact moins évident à percevoir. Trois bénéfices concrets justifient le temps investi :",{"type":29,"tag":453,"props":8493,"children":8494},{},[8495,8505,8515],{"type":29,"tag":457,"props":8496,"children":8497},{},[8498,8503],{"type":29,"tag":447,"props":8499,"children":8500},{},[8501],{"type":34,"value":8502},"Détection précoce.",{"type":34,"value":8504}," Les bugs repérés en revue ne se transforment pas en incidents production. Une deuxième paire d'yeux repère ce que l'auteur a manqué, c'est mécanique.",{"type":29,"tag":457,"props":8506,"children":8507},{},[8508,8513],{"type":29,"tag":447,"props":8509,"children":8510},{},[8511],{"type":34,"value":8512},"Transmission.",{"type":34,"value":8514}," Chaque revue est un moment de partage technique : sur les patterns, sur les conventions, sur les pièges du domaine. Plus efficace qu'une formation, parce qu'ancré dans le code réel.",{"type":29,"tag":457,"props":8516,"children":8517},{},[8518,8523],{"type":29,"tag":447,"props":8519,"children":8520},{},[8521],{"type":34,"value":8522},"Cohérence collective.",{"type":34,"value":8524}," Sans revue, chaque développeur écrit dans son style. Avec revue, l'équipe converge progressivement vers des standards partagés, ce qui rend la base maintenable sur la durée.",{"type":29,"tag":8526,"props":8527,"children":8529},"alert",{"type":8528},"TIP",[8530],{"type":29,"tag":30,"props":8531,"children":8532},{},[8533],{"type":34,"value":8534},"Avant de soumettre votre code pour revue, relisez-le comme si c'était celui de quelqu'un d'autre. La majorité des remarques évidentes apparaissent à cette lecture-là.",{"type":29,"tag":51,"props":8536,"children":8538},{"id":8537},"comment-préparer-son-code-pour-une-revue",[8539],{"type":34,"value":8540},"Comment Préparer son Code pour une Revue",{"type":29,"tag":8542,"props":8543,"children":8545},"h3",{"id":8544},"nettoyer-le-code",[8546],{"type":34,"value":8547},"Nettoyer le Code",{"type":29,"tag":30,"props":8549,"children":8550},{},[8551],{"type":34,"value":8552},"Avant de demander une revue, assurez-vous que votre code est propre et lisible. Cela signifie :",{"type":29,"tag":453,"props":8554,"children":8555},{},[8556,8561,8566],{"type":29,"tag":457,"props":8557,"children":8558},{},[8559],{"type":34,"value":8560},"Supprimer les morceaux de code inutiles ou commentés.",{"type":29,"tag":457,"props":8562,"children":8563},{},[8564],{"type":34,"value":8565},"Utiliser des noms de variables et de fonctions explicites.",{"type":29,"tag":457,"props":8567,"children":8568},{},[8569],{"type":34,"value":8570},"Organiser votre code de manière logique.",{"type":29,"tag":8542,"props":8572,"children":8574},{"id":8573},"commenter-les-parties-complexes",[8575],{"type":34,"value":8576},"Commenter les Parties Complexes",{"type":29,"tag":30,"props":8578,"children":8579},{},[8580],{"type":34,"value":8581},"Si une partie de votre code est complexe ou nécessite une explication particulière, ajoutez des commentaires. Cela aidera les autres développeurs à comprendre votre raisonnement et à faire des critiques plus pertinentes.",{"type":29,"tag":77,"props":8583,"children":8585},{"className":81,"code":8584,"language":80,"meta":8,"style":8},"\u002F\u002F This method calculates the factorial of a number recursively\npublic int factorial(int n) {\n    if (n \u003C= 1) {\n        return 1;\n    }\n    return n * factorial(n - 1);\n}\n",[8586],{"type":29,"tag":84,"props":8587,"children":8588},{"__ignoreMap":8},[8589,8597,8636,8671,8686,8693,8735],{"type":29,"tag":88,"props":8590,"children":8591},{"class":90,"line":91},[8592],{"type":29,"tag":88,"props":8593,"children":8594},{"style":95},[8595],{"type":34,"value":8596},"\u002F\u002F This method calculates the factorial of a number recursively\n",{"type":29,"tag":88,"props":8598,"children":8599},{"class":90,"line":101},[8600,8604,8609,8614,8618,8623,8628,8632],{"type":29,"tag":88,"props":8601,"children":8602},{"style":105},[8603],{"type":34,"value":108},{"type":29,"tag":88,"props":8605,"children":8606},{"style":105},[8607],{"type":34,"value":8608}," int",{"type":29,"tag":88,"props":8610,"children":8611},{"style":174},[8612],{"type":34,"value":8613}," factorial",{"type":29,"tag":88,"props":8615,"children":8616},{"style":122},[8617],{"type":34,"value":181},{"type":29,"tag":88,"props":8619,"children":8620},{"style":105},[8621],{"type":34,"value":8622},"int",{"type":29,"tag":88,"props":8624,"children":8625},{"style":157},[8626],{"type":34,"value":8627}," n",{"type":29,"tag":88,"props":8629,"children":8630},{"style":122},[8631],{"type":34,"value":306},{"type":29,"tag":88,"props":8633,"children":8634},{"style":122},[8635],{"type":34,"value":125},{"type":29,"tag":88,"props":8637,"children":8638},{"class":90,"line":128},[8639,8644,8648,8653,8658,8663,8667],{"type":29,"tag":88,"props":8640,"children":8641},{"style":105},[8642],{"type":34,"value":8643},"    if",{"type":29,"tag":88,"props":8645,"children":8646},{"style":122},[8647],{"type":34,"value":2891},{"type":29,"tag":88,"props":8649,"children":8650},{"style":157},[8651],{"type":34,"value":8652},"n ",{"type":29,"tag":88,"props":8654,"children":8655},{"style":163},[8656],{"type":34,"value":8657},"\u003C=",{"type":29,"tag":88,"props":8659,"children":8660},{"style":195},[8661],{"type":34,"value":8662}," 1",{"type":29,"tag":88,"props":8664,"children":8665},{"style":122},[8666],{"type":34,"value":306},{"type":29,"tag":88,"props":8668,"children":8669},{"style":122},[8670],{"type":34,"value":125},{"type":29,"tag":88,"props":8672,"children":8673},{"class":90,"line":137},[8674,8678,8682],{"type":29,"tag":88,"props":8675,"children":8676},{"style":105},[8677],{"type":34,"value":415},{"type":29,"tag":88,"props":8679,"children":8680},{"style":195},[8681],{"type":34,"value":8662},{"type":29,"tag":88,"props":8683,"children":8684},{"style":122},[8685],{"type":34,"value":424},{"type":29,"tag":88,"props":8687,"children":8688},{"class":90,"line":211},[8689],{"type":29,"tag":88,"props":8690,"children":8691},{"style":122},[8692],{"type":34,"value":433},{"type":29,"tag":88,"props":8694,"children":8695},{"class":90,"line":262},[8696,8700,8705,8710,8714,8718,8722,8727,8731],{"type":29,"tag":88,"props":8697,"children":8698},{"style":105},[8699],{"type":34,"value":1579},{"type":29,"tag":88,"props":8701,"children":8702},{"style":157},[8703],{"type":34,"value":8704}," n ",{"type":29,"tag":88,"props":8706,"children":8707},{"style":163},[8708],{"type":34,"value":8709},"*",{"type":29,"tag":88,"props":8711,"children":8712},{"style":174},[8713],{"type":34,"value":8613},{"type":29,"tag":88,"props":8715,"children":8716},{"style":122},[8717],{"type":34,"value":181},{"type":29,"tag":88,"props":8719,"children":8720},{"style":157},[8721],{"type":34,"value":8652},{"type":29,"tag":88,"props":8723,"children":8724},{"style":163},[8725],{"type":34,"value":8726},"-",{"type":29,"tag":88,"props":8728,"children":8729},{"style":195},[8730],{"type":34,"value":8662},{"type":29,"tag":88,"props":8732,"children":8733},{"style":122},[8734],{"type":34,"value":357},{"type":29,"tag":88,"props":8736,"children":8737},{"class":90,"line":270},[8738],{"type":29,"tag":88,"props":8739,"children":8740},{"style":122},[8741],{"type":34,"value":442},{"type":29,"tag":8542,"props":8743,"children":8745},{"id":8744},"sassurer-que-le-code-est-fonctionnel",[8746],{"type":34,"value":8747},"S'assurer que le Code est Fonctionnel",{"type":29,"tag":30,"props":8749,"children":8750},{},[8751],{"type":34,"value":8752},"Testez votre code avant de le soumettre. Rien n'est plus frustrant pour un reviewer que de recevoir un code qui ne fonctionne pas ou qui génère des erreurs.",{"type":29,"tag":2288,"props":8754,"children":8756},{"cta":2290,"href":2291,"title":8755,"type":2293},"Vous voulez repérer ce que les autres laissent passer en revue ?",[8757],{"type":29,"tag":30,"props":8758,"children":8759},{},[8760],{"type":34,"value":8761},"Lire une PR et voir tout de suite ce qui cloche, le bug latent, le couplage évitable, le nommage qui ment, ça ne s'apprend pas en lisant un guide : ça se travaille. En mentoring 1:1, je relis votre code avec vous et je vous transmets les réflexes qui font la différence entre un reviewer qui valide et un reviewer qui élève la qualité de toute l'équipe.",{"type":29,"tag":51,"props":8763,"children":8765},{"id":8764},"formuler-des-feedbacks-qui-font-progresser",[8766],{"type":34,"value":8767},"Formuler des feedbacks qui font progresser",{"type":29,"tag":30,"props":8769,"children":8770},{},[8771],{"type":34,"value":8772},"Un feedback utile est précis, ancré dans le code et orienté vers une amélioration concrète. La différence entre une remarque qui fait avancer et une remarque qui crispe tient souvent à la formulation.",{"type":29,"tag":30,"props":8774,"children":8775},{},[8776,8778,8784],{"type":34,"value":8777},"Exemple sur une méthode ",{"type":29,"tag":84,"props":8779,"children":8781},{"className":8780},[],[8782],{"type":34,"value":8783},"calculateSum()",{"type":34,"value":8785}," qui pourrait utiliser un stream :",{"type":29,"tag":8787,"props":8788,"children":8789},"blockquote",{},[8790],{"type":29,"tag":30,"props":8791,"children":8792},{},[8793,8795,8801],{"type":34,"value":8794},"\"Cette boucle gagnerait en lisibilité avec un ",{"type":29,"tag":84,"props":8796,"children":8798},{"className":8797},[],[8799],{"type":34,"value":8800},"stream().sum()",{"type":34,"value":8802}," (gain mineur sur la perf, mais l'intention devient explicite).\"",{"type":29,"tag":30,"props":8804,"children":8805},{},[8806],{"type":34,"value":8807},"Plutôt que :",{"type":29,"tag":8787,"props":8809,"children":8810},{},[8811],{"type":29,"tag":30,"props":8812,"children":8813},{},[8814],{"type":34,"value":8815},"\"C'est moche, à refaire.\"",{"type":29,"tag":30,"props":8817,"children":8818},{},[8819],{"type":34,"value":8820},"La première remarque cible le code, propose une alternative et explique le bénéfice. La seconde n'apprend rien et déclenche une réaction défensive. Sur une équipe, multiplié par cinq revues par semaine, l'écart est considérable.",{"type":29,"tag":8542,"props":8822,"children":8824},{"id":8823},"recevoir-des-critiques-sans-senflammer",[8825],{"type":34,"value":8826},"Recevoir des critiques sans s'enflammer",{"type":29,"tag":30,"props":8828,"children":8829},{},[8830],{"type":34,"value":8831},"C'est l'autre moitié du contrat. Le feedback porte sur le code, pas sur le développeur : distinction simple à énoncer, plus difficile à intérioriser. Trois réflexes utiles : considérer chaque remarque comme une donnée à évaluer, ne pas prendre personnellement ce qui ne l'est pas, demander des clarifications quand un commentaire n'est pas clair plutôt que de l'interpréter.",{"type":29,"tag":51,"props":8833,"children":8835},{"id":8834},"exemples-de-revue-de-code-en-java",[8836],{"type":34,"value":8837},"Exemples de Revue de Code en Java",{"type":29,"tag":30,"props":8839,"children":8840},{},[8841],{"type":34,"value":8842},"Pour mieux comprendre le processus de revue de code, examinons trois exemples pratiques en Java.",{"type":29,"tag":8542,"props":8844,"children":8846},{"id":8845},"cas-1-code-simple",[8847],{"type":34,"value":8848},"Cas 1 : Code Simple",{"type":29,"tag":30,"props":8850,"children":8851},{},[8852],{"type":29,"tag":447,"props":8853,"children":8854},{},[8855],{"type":34,"value":8856},"Code à réviser :",{"type":29,"tag":77,"props":8858,"children":8860},{"className":81,"code":8859,"language":80,"meta":8,"style":8},"public int sum(int a, int b) {\n    return a + b;\n}\n",[8861],{"type":29,"tag":84,"props":8862,"children":8863},{"__ignoreMap":8},[8864,8914,8938],{"type":29,"tag":88,"props":8865,"children":8866},{"class":90,"line":91},[8867,8871,8875,8880,8884,8888,8893,8897,8901,8906,8910],{"type":29,"tag":88,"props":8868,"children":8869},{"style":105},[8870],{"type":34,"value":108},{"type":29,"tag":88,"props":8872,"children":8873},{"style":105},[8874],{"type":34,"value":8608},{"type":29,"tag":88,"props":8876,"children":8877},{"style":174},[8878],{"type":34,"value":8879}," sum",{"type":29,"tag":88,"props":8881,"children":8882},{"style":122},[8883],{"type":34,"value":181},{"type":29,"tag":88,"props":8885,"children":8886},{"style":105},[8887],{"type":34,"value":8622},{"type":29,"tag":88,"props":8889,"children":8890},{"style":157},[8891],{"type":34,"value":8892}," a",{"type":29,"tag":88,"props":8894,"children":8895},{"style":122},[8896],{"type":34,"value":192},{"type":29,"tag":88,"props":8898,"children":8899},{"style":105},[8900],{"type":34,"value":8608},{"type":29,"tag":88,"props":8902,"children":8903},{"style":157},[8904],{"type":34,"value":8905}," b",{"type":29,"tag":88,"props":8907,"children":8908},{"style":122},[8909],{"type":34,"value":306},{"type":29,"tag":88,"props":8911,"children":8912},{"style":122},[8913],{"type":34,"value":125},{"type":29,"tag":88,"props":8915,"children":8916},{"class":90,"line":101},[8917,8921,8926,8930,8934],{"type":29,"tag":88,"props":8918,"children":8919},{"style":105},[8920],{"type":34,"value":1579},{"type":29,"tag":88,"props":8922,"children":8923},{"style":157},[8924],{"type":34,"value":8925}," a ",{"type":29,"tag":88,"props":8927,"children":8928},{"style":163},[8929],{"type":34,"value":5495},{"type":29,"tag":88,"props":8931,"children":8932},{"style":157},[8933],{"type":34,"value":8905},{"type":29,"tag":88,"props":8935,"children":8936},{"style":122},[8937],{"type":34,"value":424},{"type":29,"tag":88,"props":8939,"children":8940},{"class":90,"line":128},[8941],{"type":29,"tag":88,"props":8942,"children":8943},{"style":122},[8944],{"type":34,"value":442},{"type":29,"tag":30,"props":8946,"children":8947},{},[8948],{"type":29,"tag":447,"props":8949,"children":8950},{},[8951],{"type":34,"value":8952},"Feedback :",{"type":29,"tag":453,"props":8954,"children":8955},{},[8956,8966],{"type":29,"tag":457,"props":8957,"children":8958},{},[8959,8964],{"type":29,"tag":447,"props":8960,"children":8961},{},[8962],{"type":34,"value":8963},"Positif",{"type":34,"value":8965}," : \"Le code est simple et fonctionne bien pour l'addition de deux entiers.\"",{"type":29,"tag":457,"props":8967,"children":8968},{},[8969,8974,8976,8981,8983,8989,8991,8997,8998,9004],{"type":29,"tag":447,"props":8970,"children":8971},{},[8972],{"type":34,"value":8973},"Amélioration",{"type":34,"value":8975}," : \"Vous pourriez renommer les variables ",{"type":29,"tag":84,"props":8977,"children":8979},{"className":8978},[],[8980],{"type":34,"value":63},{"type":34,"value":8982}," et ",{"type":29,"tag":84,"props":8984,"children":8986},{"className":8985},[],[8987],{"type":34,"value":8988},"b",{"type":34,"value":8990}," en ",{"type":29,"tag":84,"props":8992,"children":8994},{"className":8993},[],[8995],{"type":34,"value":8996},"firstNumber",{"type":34,"value":8982},{"type":29,"tag":84,"props":8999,"children":9001},{"className":9000},[],[9002],{"type":34,"value":9003},"secondNumber",{"type":34,"value":9005}," pour plus de clarté.\"",{"type":29,"tag":8542,"props":9007,"children":9009},{"id":9008},"cas-2-code-complexe",[9010],{"type":34,"value":9011},"Cas 2 : Code Complexe",{"type":29,"tag":30,"props":9013,"children":9014},{},[9015],{"type":29,"tag":447,"props":9016,"children":9017},{},[9018],{"type":34,"value":8856},{"type":29,"tag":77,"props":9020,"children":9022},{"className":81,"code":9021,"language":80,"meta":8,"style":8},"public List\u003CInteger> findEvenNumbers(List\u003CInteger> numbers) {\n    List\u003CInteger> evenNumbers = new ArrayList\u003C>();\n    for (int number : numbers) {\n        if (number % 2 == 0) {\n            evenNumbers.add(number);\n        }\n    }\n    return evenNumbers;\n}\n",[9023],{"type":29,"tag":84,"props":9024,"children":9025},{"__ignoreMap":8},[9026,9089,9130,9168,9212,9241,9248,9255,9271],{"type":29,"tag":88,"props":9027,"children":9028},{"class":90,"line":91},[9029,9033,9037,9041,9046,9050,9055,9059,9064,9068,9072,9076,9081,9085],{"type":29,"tag":88,"props":9030,"children":9031},{"style":105},[9032],{"type":34,"value":108},{"type":29,"tag":88,"props":9034,"children":9035},{"style":151},[9036],{"type":34,"value":5355},{"type":29,"tag":88,"props":9038,"children":9039},{"style":163},[9040],{"type":34,"value":1683},{"type":29,"tag":88,"props":9042,"children":9043},{"style":157},[9044],{"type":34,"value":9045},"Integer",{"type":29,"tag":88,"props":9047,"children":9048},{"style":163},[9049],{"type":34,"value":1701},{"type":29,"tag":88,"props":9051,"children":9052},{"style":174},[9053],{"type":34,"value":9054}," findEvenNumbers",{"type":29,"tag":88,"props":9056,"children":9057},{"style":122},[9058],{"type":34,"value":181},{"type":29,"tag":88,"props":9060,"children":9061},{"style":151},[9062],{"type":34,"value":9063},"List",{"type":29,"tag":88,"props":9065,"children":9066},{"style":163},[9067],{"type":34,"value":1683},{"type":29,"tag":88,"props":9069,"children":9070},{"style":157},[9071],{"type":34,"value":9045},{"type":29,"tag":88,"props":9073,"children":9074},{"style":163},[9075],{"type":34,"value":1701},{"type":29,"tag":88,"props":9077,"children":9078},{"style":157},[9079],{"type":34,"value":9080}," numbers",{"type":29,"tag":88,"props":9082,"children":9083},{"style":122},[9084],{"type":34,"value":306},{"type":29,"tag":88,"props":9086,"children":9087},{"style":122},[9088],{"type":34,"value":125},{"type":29,"tag":88,"props":9090,"children":9091},{"class":90,"line":101},[9092,9097,9101,9105,9109,9114,9118,9122,9126],{"type":29,"tag":88,"props":9093,"children":9094},{"style":151},[9095],{"type":34,"value":9096},"    List",{"type":29,"tag":88,"props":9098,"children":9099},{"style":122},[9100],{"type":34,"value":1683},{"type":29,"tag":88,"props":9102,"children":9103},{"style":105},[9104],{"type":34,"value":9045},{"type":29,"tag":88,"props":9106,"children":9107},{"style":122},[9108],{"type":34,"value":1701},{"type":29,"tag":88,"props":9110,"children":9111},{"style":157},[9112],{"type":34,"value":9113}," evenNumbers ",{"type":29,"tag":88,"props":9115,"children":9116},{"style":163},[9117],{"type":34,"value":166},{"type":29,"tag":88,"props":9119,"children":9120},{"style":105},[9121],{"type":34,"value":171},{"type":29,"tag":88,"props":9123,"children":9124},{"style":151},[9125],{"type":34,"value":5385},{"type":29,"tag":88,"props":9127,"children":9128},{"style":122},[9129],{"type":34,"value":1724},{"type":29,"tag":88,"props":9131,"children":9132},{"class":90,"line":128},[9133,9138,9142,9146,9151,9156,9160,9164],{"type":29,"tag":88,"props":9134,"children":9135},{"style":105},[9136],{"type":34,"value":9137},"    for",{"type":29,"tag":88,"props":9139,"children":9140},{"style":122},[9141],{"type":34,"value":2891},{"type":29,"tag":88,"props":9143,"children":9144},{"style":105},[9145],{"type":34,"value":8622},{"type":29,"tag":88,"props":9147,"children":9148},{"style":157},[9149],{"type":34,"value":9150}," number ",{"type":29,"tag":88,"props":9152,"children":9153},{"style":105},[9154],{"type":34,"value":9155},":",{"type":29,"tag":88,"props":9157,"children":9158},{"style":157},[9159],{"type":34,"value":9080},{"type":29,"tag":88,"props":9161,"children":9162},{"style":122},[9163],{"type":34,"value":306},{"type":29,"tag":88,"props":9165,"children":9166},{"style":122},[9167],{"type":34,"value":125},{"type":29,"tag":88,"props":9169,"children":9170},{"class":90,"line":137},[9171,9175,9179,9184,9189,9194,9199,9204,9208],{"type":29,"tag":88,"props":9172,"children":9173},{"style":105},[9174],{"type":34,"value":2886},{"type":29,"tag":88,"props":9176,"children":9177},{"style":122},[9178],{"type":34,"value":2891},{"type":29,"tag":88,"props":9180,"children":9181},{"style":157},[9182],{"type":34,"value":9183},"number ",{"type":29,"tag":88,"props":9185,"children":9186},{"style":163},[9187],{"type":34,"value":9188},"%",{"type":29,"tag":88,"props":9190,"children":9191},{"style":195},[9192],{"type":34,"value":9193}," 2",{"type":29,"tag":88,"props":9195,"children":9196},{"style":163},[9197],{"type":34,"value":9198}," ==",{"type":29,"tag":88,"props":9200,"children":9201},{"style":195},[9202],{"type":34,"value":9203}," 0",{"type":29,"tag":88,"props":9205,"children":9206},{"style":122},[9207],{"type":34,"value":306},{"type":29,"tag":88,"props":9209,"children":9210},{"style":122},[9211],{"type":34,"value":125},{"type":29,"tag":88,"props":9213,"children":9214},{"class":90,"line":211},[9215,9220,9224,9228,9232,9237],{"type":29,"tag":88,"props":9216,"children":9217},{"style":157},[9218],{"type":34,"value":9219},"            evenNumbers",{"type":29,"tag":88,"props":9221,"children":9222},{"style":122},[9223],{"type":34,"value":338},{"type":29,"tag":88,"props":9225,"children":9226},{"style":174},[9227],{"type":34,"value":5471},{"type":29,"tag":88,"props":9229,"children":9230},{"style":122},[9231],{"type":34,"value":181},{"type":29,"tag":88,"props":9233,"children":9234},{"style":157},[9235],{"type":34,"value":9236},"number",{"type":29,"tag":88,"props":9238,"children":9239},{"style":122},[9240],{"type":34,"value":357},{"type":29,"tag":88,"props":9242,"children":9243},{"class":90,"line":262},[9244],{"type":29,"tag":88,"props":9245,"children":9246},{"style":122},[9247],{"type":34,"value":2966},{"type":29,"tag":88,"props":9249,"children":9250},{"class":90,"line":270},[9251],{"type":29,"tag":88,"props":9252,"children":9253},{"style":122},[9254],{"type":34,"value":433},{"type":29,"tag":88,"props":9256,"children":9257},{"class":90,"line":313},[9258,9262,9267],{"type":29,"tag":88,"props":9259,"children":9260},{"style":105},[9261],{"type":34,"value":1579},{"type":29,"tag":88,"props":9263,"children":9264},{"style":157},[9265],{"type":34,"value":9266}," evenNumbers",{"type":29,"tag":88,"props":9268,"children":9269},{"style":122},[9270],{"type":34,"value":424},{"type":29,"tag":88,"props":9272,"children":9273},{"class":90,"line":360},[9274],{"type":29,"tag":88,"props":9275,"children":9276},{"style":122},[9277],{"type":34,"value":442},{"type":29,"tag":30,"props":9279,"children":9280},{},[9281],{"type":29,"tag":447,"props":9282,"children":9283},{},[9284],{"type":34,"value":8952},{"type":29,"tag":453,"props":9286,"children":9287},{},[9288,9297],{"type":29,"tag":457,"props":9289,"children":9290},{},[9291,9295],{"type":29,"tag":447,"props":9292,"children":9293},{},[9294],{"type":34,"value":8963},{"type":34,"value":9296}," : \"Le code remplit bien sa fonction en trouvant tous les nombres pairs d'une liste.\"",{"type":29,"tag":457,"props":9298,"children":9299},{},[9300,9304],{"type":29,"tag":447,"props":9301,"children":9302},{},[9303],{"type":34,"value":8973},{"type":34,"value":9305}," : \"Pour simplifier, vous pourriez utiliser les streams en Java 8 :\"",{"type":29,"tag":77,"props":9307,"children":9309},{"className":81,"code":9308,"language":80,"meta":8,"style":8},"public List\u003CInteger> findEvenNumbers(List\u003CInteger> numbers) {\n    return numbers.stream()\n                  .filter(n -> n % 2 == 0)\n                  .collect(Collectors.toList());\n}\n",[9310],{"type":29,"tag":84,"props":9311,"children":9312},{"__ignoreMap":8},[9313,9372,9396,9445,9479],{"type":29,"tag":88,"props":9314,"children":9315},{"class":90,"line":91},[9316,9320,9324,9328,9332,9336,9340,9344,9348,9352,9356,9360,9364,9368],{"type":29,"tag":88,"props":9317,"children":9318},{"style":105},[9319],{"type":34,"value":108},{"type":29,"tag":88,"props":9321,"children":9322},{"style":151},[9323],{"type":34,"value":5355},{"type":29,"tag":88,"props":9325,"children":9326},{"style":163},[9327],{"type":34,"value":1683},{"type":29,"tag":88,"props":9329,"children":9330},{"style":157},[9331],{"type":34,"value":9045},{"type":29,"tag":88,"props":9333,"children":9334},{"style":163},[9335],{"type":34,"value":1701},{"type":29,"tag":88,"props":9337,"children":9338},{"style":174},[9339],{"type":34,"value":9054},{"type":29,"tag":88,"props":9341,"children":9342},{"style":122},[9343],{"type":34,"value":181},{"type":29,"tag":88,"props":9345,"children":9346},{"style":151},[9347],{"type":34,"value":9063},{"type":29,"tag":88,"props":9349,"children":9350},{"style":163},[9351],{"type":34,"value":1683},{"type":29,"tag":88,"props":9353,"children":9354},{"style":157},[9355],{"type":34,"value":9045},{"type":29,"tag":88,"props":9357,"children":9358},{"style":163},[9359],{"type":34,"value":1701},{"type":29,"tag":88,"props":9361,"children":9362},{"style":157},[9363],{"type":34,"value":9080},{"type":29,"tag":88,"props":9365,"children":9366},{"style":122},[9367],{"type":34,"value":306},{"type":29,"tag":88,"props":9369,"children":9370},{"style":122},[9371],{"type":34,"value":125},{"type":29,"tag":88,"props":9373,"children":9374},{"class":90,"line":101},[9375,9379,9383,9387,9392],{"type":29,"tag":88,"props":9376,"children":9377},{"style":105},[9378],{"type":34,"value":1579},{"type":29,"tag":88,"props":9380,"children":9381},{"style":157},[9382],{"type":34,"value":9080},{"type":29,"tag":88,"props":9384,"children":9385},{"style":122},[9386],{"type":34,"value":338},{"type":29,"tag":88,"props":9388,"children":9389},{"style":174},[9390],{"type":34,"value":9391},"stream",{"type":29,"tag":88,"props":9393,"children":9394},{"style":122},[9395],{"type":34,"value":2863},{"type":29,"tag":88,"props":9397,"children":9398},{"class":90,"line":128},[9399,9404,9409,9413,9417,9421,9425,9429,9433,9437,9441],{"type":29,"tag":88,"props":9400,"children":9401},{"style":122},[9402],{"type":34,"value":9403},"                  .",{"type":29,"tag":88,"props":9405,"children":9406},{"style":174},[9407],{"type":34,"value":9408},"filter",{"type":29,"tag":88,"props":9410,"children":9411},{"style":122},[9412],{"type":34,"value":181},{"type":29,"tag":88,"props":9414,"children":9415},{"style":157},[9416],{"type":34,"value":8652},{"type":29,"tag":88,"props":9418,"children":9419},{"style":105},[9420],{"type":34,"value":3595},{"type":29,"tag":88,"props":9422,"children":9423},{"style":157},[9424],{"type":34,"value":8704},{"type":29,"tag":88,"props":9426,"children":9427},{"style":163},[9428],{"type":34,"value":9188},{"type":29,"tag":88,"props":9430,"children":9431},{"style":195},[9432],{"type":34,"value":9193},{"type":29,"tag":88,"props":9434,"children":9435},{"style":163},[9436],{"type":34,"value":9198},{"type":29,"tag":88,"props":9438,"children":9439},{"style":195},[9440],{"type":34,"value":9203},{"type":29,"tag":88,"props":9442,"children":9443},{"style":122},[9444],{"type":34,"value":3078},{"type":29,"tag":88,"props":9446,"children":9447},{"class":90,"line":137},[9448,9452,9457,9461,9466,9470,9475],{"type":29,"tag":88,"props":9449,"children":9450},{"style":122},[9451],{"type":34,"value":9403},{"type":29,"tag":88,"props":9453,"children":9454},{"style":174},[9455],{"type":34,"value":9456},"collect",{"type":29,"tag":88,"props":9458,"children":9459},{"style":122},[9460],{"type":34,"value":181},{"type":29,"tag":88,"props":9462,"children":9463},{"style":157},[9464],{"type":34,"value":9465},"Collectors",{"type":29,"tag":88,"props":9467,"children":9468},{"style":122},[9469],{"type":34,"value":338},{"type":29,"tag":88,"props":9471,"children":9472},{"style":174},[9473],{"type":34,"value":9474},"toList",{"type":29,"tag":88,"props":9476,"children":9477},{"style":122},[9478],{"type":34,"value":2958},{"type":29,"tag":88,"props":9480,"children":9481},{"class":90,"line":211},[9482],{"type":29,"tag":88,"props":9483,"children":9484},{"style":122},[9485],{"type":34,"value":442},{"type":29,"tag":47,"props":9487,"children":9488},{},[],{"type":29,"tag":30,"props":9490,"children":9491},{},[9492],{"type":34,"value":9493},"Sur ce type de transformation, les streams Java gagnent presque toujours en lisibilité.",{"type":29,"tag":8542,"props":9495,"children":9497},{"id":9496},"cas-3-détection-de-bugs",[9498],{"type":34,"value":9499},"Cas 3 : Détection de Bugs",{"type":29,"tag":30,"props":9501,"children":9502},{},[9503],{"type":29,"tag":447,"props":9504,"children":9505},{},[9506],{"type":34,"value":8856},{"type":29,"tag":77,"props":9508,"children":9510},{"className":81,"code":9509,"language":80,"meta":8,"style":8},"public String getEmployeeStatus(Employee emp) {\n    if (emp.isActive()) {\n        return \"Active\";\n    }\n    return \"Inactive\";\n}\n",[9511],{"type":29,"tag":84,"props":9512,"children":9513},{"__ignoreMap":8},[9514,9552,9585,9601,9608,9624],{"type":29,"tag":88,"props":9515,"children":9516},{"class":90,"line":91},[9517,9521,9525,9530,9534,9539,9544,9548],{"type":29,"tag":88,"props":9518,"children":9519},{"style":105},[9520],{"type":34,"value":108},{"type":29,"tag":88,"props":9522,"children":9523},{"style":151},[9524],{"type":34,"value":281},{"type":29,"tag":88,"props":9526,"children":9527},{"style":174},[9528],{"type":34,"value":9529}," getEmployeeStatus",{"type":29,"tag":88,"props":9531,"children":9532},{"style":122},[9533],{"type":34,"value":181},{"type":29,"tag":88,"props":9535,"children":9536},{"style":151},[9537],{"type":34,"value":9538},"Employee",{"type":29,"tag":88,"props":9540,"children":9541},{"style":157},[9542],{"type":34,"value":9543}," emp",{"type":29,"tag":88,"props":9545,"children":9546},{"style":122},[9547],{"type":34,"value":306},{"type":29,"tag":88,"props":9549,"children":9550},{"style":122},[9551],{"type":34,"value":125},{"type":29,"tag":88,"props":9553,"children":9554},{"class":90,"line":101},[9555,9559,9563,9568,9572,9577,9581],{"type":29,"tag":88,"props":9556,"children":9557},{"style":105},[9558],{"type":34,"value":8643},{"type":29,"tag":88,"props":9560,"children":9561},{"style":122},[9562],{"type":34,"value":2891},{"type":29,"tag":88,"props":9564,"children":9565},{"style":157},[9566],{"type":34,"value":9567},"emp",{"type":29,"tag":88,"props":9569,"children":9570},{"style":122},[9571],{"type":34,"value":338},{"type":29,"tag":88,"props":9573,"children":9574},{"style":174},[9575],{"type":34,"value":9576},"isActive",{"type":29,"tag":88,"props":9578,"children":9579},{"style":122},[9580],{"type":34,"value":2915},{"type":29,"tag":88,"props":9582,"children":9583},{"style":122},[9584],{"type":34,"value":125},{"type":29,"tag":88,"props":9586,"children":9587},{"class":90,"line":128},[9588,9592,9597],{"type":29,"tag":88,"props":9589,"children":9590},{"style":105},[9591],{"type":34,"value":415},{"type":29,"tag":88,"props":9593,"children":9594},{"style":184},[9595],{"type":34,"value":9596}," \"Active\"",{"type":29,"tag":88,"props":9598,"children":9599},{"style":122},[9600],{"type":34,"value":424},{"type":29,"tag":88,"props":9602,"children":9603},{"class":90,"line":137},[9604],{"type":29,"tag":88,"props":9605,"children":9606},{"style":122},[9607],{"type":34,"value":433},{"type":29,"tag":88,"props":9609,"children":9610},{"class":90,"line":211},[9611,9615,9620],{"type":29,"tag":88,"props":9612,"children":9613},{"style":105},[9614],{"type":34,"value":1579},{"type":29,"tag":88,"props":9616,"children":9617},{"style":184},[9618],{"type":34,"value":9619}," \"Inactive\"",{"type":29,"tag":88,"props":9621,"children":9622},{"style":122},[9623],{"type":34,"value":424},{"type":29,"tag":88,"props":9625,"children":9626},{"class":90,"line":262},[9627],{"type":29,"tag":88,"props":9628,"children":9629},{"style":122},[9630],{"type":34,"value":442},{"type":29,"tag":30,"props":9632,"children":9633},{},[9634],{"type":29,"tag":447,"props":9635,"children":9636},{},[9637],{"type":34,"value":8952},{"type":29,"tag":453,"props":9639,"children":9640},{},[9641,9650],{"type":29,"tag":457,"props":9642,"children":9643},{},[9644,9648],{"type":29,"tag":447,"props":9645,"children":9646},{},[9647],{"type":34,"value":8963},{"type":34,"value":9649}," : \"Le code distingue correctement les employés actifs des inactifs.\"",{"type":29,"tag":457,"props":9651,"children":9652},{},[9653,9657,9659,9664,9666,9671,9673,9679],{"type":29,"tag":447,"props":9654,"children":9655},{},[9656],{"type":34,"value":8973},{"type":34,"value":9658}," : \"Attention à la nullité possible de l'objet ",{"type":29,"tag":84,"props":9660,"children":9662},{"className":9661},[],[9663],{"type":34,"value":9567},{"type":34,"value":9665},". Vous devriez vérifier si ",{"type":29,"tag":84,"props":9667,"children":9669},{"className":9668},[],[9670],{"type":34,"value":9567},{"type":34,"value":9672}," est non nul avant d'appeler ",{"type":29,"tag":84,"props":9674,"children":9676},{"className":9675},[],[9677],{"type":34,"value":9678},"emp.isActive()",{"type":34,"value":9680},".\"",{"type":29,"tag":77,"props":9682,"children":9684},{"className":81,"code":9683,"language":80,"meta":8,"style":8},"public String getEmployeeStatus(Employee emp) {\n    if (emp != null && emp.isActive()) {\n        return \"Active\";\n    }\n    return \"Inactive\";\n}\n",[9685],{"type":29,"tag":84,"props":9686,"children":9687},{"__ignoreMap":8},[9688,9723,9773,9788,9795,9810],{"type":29,"tag":88,"props":9689,"children":9690},{"class":90,"line":91},[9691,9695,9699,9703,9707,9711,9715,9719],{"type":29,"tag":88,"props":9692,"children":9693},{"style":105},[9694],{"type":34,"value":108},{"type":29,"tag":88,"props":9696,"children":9697},{"style":151},[9698],{"type":34,"value":281},{"type":29,"tag":88,"props":9700,"children":9701},{"style":174},[9702],{"type":34,"value":9529},{"type":29,"tag":88,"props":9704,"children":9705},{"style":122},[9706],{"type":34,"value":181},{"type":29,"tag":88,"props":9708,"children":9709},{"style":151},[9710],{"type":34,"value":9538},{"type":29,"tag":88,"props":9712,"children":9713},{"style":157},[9714],{"type":34,"value":9543},{"type":29,"tag":88,"props":9716,"children":9717},{"style":122},[9718],{"type":34,"value":306},{"type":29,"tag":88,"props":9720,"children":9721},{"style":122},[9722],{"type":34,"value":125},{"type":29,"tag":88,"props":9724,"children":9725},{"class":90,"line":101},[9726,9730,9734,9739,9743,9748,9753,9757,9761,9765,9769],{"type":29,"tag":88,"props":9727,"children":9728},{"style":105},[9729],{"type":34,"value":8643},{"type":29,"tag":88,"props":9731,"children":9732},{"style":122},[9733],{"type":34,"value":2891},{"type":29,"tag":88,"props":9735,"children":9736},{"style":157},[9737],{"type":34,"value":9738},"emp ",{"type":29,"tag":88,"props":9740,"children":9741},{"style":163},[9742],{"type":34,"value":7019},{"type":29,"tag":88,"props":9744,"children":9745},{"style":873},[9746],{"type":34,"value":9747}," null",{"type":29,"tag":88,"props":9749,"children":9750},{"style":163},[9751],{"type":34,"value":9752}," &&",{"type":29,"tag":88,"props":9754,"children":9755},{"style":157},[9756],{"type":34,"value":9543},{"type":29,"tag":88,"props":9758,"children":9759},{"style":122},[9760],{"type":34,"value":338},{"type":29,"tag":88,"props":9762,"children":9763},{"style":174},[9764],{"type":34,"value":9576},{"type":29,"tag":88,"props":9766,"children":9767},{"style":122},[9768],{"type":34,"value":2915},{"type":29,"tag":88,"props":9770,"children":9771},{"style":122},[9772],{"type":34,"value":125},{"type":29,"tag":88,"props":9774,"children":9775},{"class":90,"line":128},[9776,9780,9784],{"type":29,"tag":88,"props":9777,"children":9778},{"style":105},[9779],{"type":34,"value":415},{"type":29,"tag":88,"props":9781,"children":9782},{"style":184},[9783],{"type":34,"value":9596},{"type":29,"tag":88,"props":9785,"children":9786},{"style":122},[9787],{"type":34,"value":424},{"type":29,"tag":88,"props":9789,"children":9790},{"class":90,"line":137},[9791],{"type":29,"tag":88,"props":9792,"children":9793},{"style":122},[9794],{"type":34,"value":433},{"type":29,"tag":88,"props":9796,"children":9797},{"class":90,"line":211},[9798,9802,9806],{"type":29,"tag":88,"props":9799,"children":9800},{"style":105},[9801],{"type":34,"value":1579},{"type":29,"tag":88,"props":9803,"children":9804},{"style":184},[9805],{"type":34,"value":9619},{"type":29,"tag":88,"props":9807,"children":9808},{"style":122},[9809],{"type":34,"value":424},{"type":29,"tag":88,"props":9811,"children":9812},{"class":90,"line":262},[9813],{"type":29,"tag":88,"props":9814,"children":9815},{"style":122},[9816],{"type":34,"value":442},{"type":29,"tag":51,"props":9818,"children":9820},{"id":9819},"tips-et-astuces-pour-une-revue-de-code-efficace",[9821],{"type":34,"value":9822},"Tips et Astuces pour une Revue de Code Efficace",{"type":29,"tag":8542,"props":9824,"children":9826},{"id":9825},"outils-recommandés",[9827],{"type":34,"value":9828},"Outils Recommandés",{"type":29,"tag":453,"props":9830,"children":9831},{},[9832,9842,9852],{"type":29,"tag":457,"props":9833,"children":9834},{},[9835,9840],{"type":29,"tag":447,"props":9836,"children":9837},{},[9838],{"type":34,"value":9839},"GitHub",{"type":34,"value":9841}," : Parfait pour la gestion de versions et les revues de code intégrées.",{"type":29,"tag":457,"props":9843,"children":9844},{},[9845,9850],{"type":29,"tag":447,"props":9846,"children":9847},{},[9848],{"type":34,"value":9849},"Crucible",{"type":34,"value":9851}," : Un outil de revue de code collaboratif, souvent utilisé dans les équipes.",{"type":29,"tag":457,"props":9853,"children":9854},{},[9855,9864],{"type":29,"tag":447,"props":9856,"children":9857},{},[9858],{"type":29,"tag":63,"props":9859,"children":9861},{"href":9860},"\u002Ffr\u002Fdette-technique\u002Foutils-analyse-statique-2026",[9862],{"type":34,"value":9863},"SonarQube",{"type":34,"value":9865}," : Idéal pour l'analyse statique du code et la détection automatique des erreurs.",{"type":29,"tag":8542,"props":9867,"children":9869},{"id":9868},"stratégies-pour-une-revue-de-code-réussie",[9870],{"type":34,"value":9871},"Stratégies pour une Revue de Code Réussie",{"type":29,"tag":453,"props":9873,"children":9874},{},[9875,9885,9895],{"type":29,"tag":457,"props":9876,"children":9877},{},[9878,9883],{"type":29,"tag":447,"props":9879,"children":9880},{},[9881],{"type":34,"value":9882},"Fixez des limites de temps",{"type":34,"value":9884}," : Ne passez pas trop de temps sur une seule revue de code. 30 minutes est un bon point de départ.",{"type":29,"tag":457,"props":9886,"children":9887},{},[9888,9893],{"type":29,"tag":447,"props":9889,"children":9890},{},[9891],{"type":34,"value":9892},"Soyez respectueux et constructif",{"type":34,"value":9894}," : Rappelez-vous que le but est d'améliorer le code, pas de critiquer la personne.",{"type":29,"tag":457,"props":9896,"children":9897},{},[9898,9903],{"type":29,"tag":447,"props":9899,"children":9900},{},[9901],{"type":34,"value":9902},"Documentez les bonnes pratiques",{"type":34,"value":9904}," : Si un même type d'erreur revient souvent, envisagez de créer un guide de style pour votre équipe.",{"type":29,"tag":51,"props":9906,"children":9908},{"id":9907},"checklist-minimale-pour-une-revue-sérieuse",[9909],{"type":34,"value":9910},"Checklist minimale pour une revue sérieuse",{"type":29,"tag":30,"props":9912,"children":9913},{},[9914],{"type":34,"value":9915},"Les checklists à trente points ne sont jamais utilisées : trop longues à dérouler, trop génériques pour être actionnables. Voici les cinq blocs réellement à couvrir sur un changement Java, dans l'ordre de priorité.",{"type":29,"tag":30,"props":9917,"children":9918},{},[9919,9924,9926,9931],{"type":29,"tag":447,"props":9920,"children":9921},{},[9922],{"type":34,"value":9923},"1. Le code fait-il ce qui est attendu ?",{"type":34,"value":9925},"\nAvant tout le reste : la fonctionnalité couvre-t-elle les cas nominaux ",{"type":29,"tag":8474,"props":9927,"children":9928},{},[9929],{"type":34,"value":9930},"et",{"type":34,"value":9932}," les cas limites ? Les exceptions sont-elles gérées ? Le diff répond-il vraiment au besoin de la PR, ou couvre-t-il plus de scope que prévu ?",{"type":29,"tag":30,"props":9934,"children":9935},{},[9936,9941],{"type":29,"tag":447,"props":9937,"children":9938},{},[9939],{"type":34,"value":9940},"2. Tests : présents, ciblés, utiles ?",{"type":34,"value":9942},"\nPas de tests = pas de merge sur du code non trivial. Quand les tests existent, valent-ils mieux que des assertions tautologiques ? Couvrent-ils les cas qui cassent vraiment ?",{"type":29,"tag":30,"props":9944,"children":9945},{},[9946,9951],{"type":29,"tag":447,"props":9947,"children":9948},{},[9949],{"type":34,"value":9950},"3. Lisibilité et nommage",{"type":34,"value":9952},"\nUn autre développeur comprendra-t-il ce code dans six mois sans contexte ? Les noms expriment-ils l'intention ? Les méthodes longues sont-elles découpées ? Le code suit-il les conventions du projet ?",{"type":29,"tag":30,"props":9954,"children":9955},{},[9956,9961,9963,9969],{"type":29,"tag":447,"props":9957,"children":9958},{},[9959],{"type":34,"value":9960},"4. Conception et impact",{"type":34,"value":9962},"\nLe changement respecte-t-il les ",{"type":29,"tag":63,"props":9964,"children":9966},{"href":9965},"\u002Ffr\u002Farchitecture-craft\u002Fprincipes-solid-java-exemples",[9967],{"type":34,"value":9968},"principes SOLID",{"type":34,"value":9970}," et l'architecture du projet ? Introduit-il du couplage évitable ? A-t-il des effets de bord sur d'autres modules ?",{"type":29,"tag":30,"props":9972,"children":9973},{},[9974,9979],{"type":29,"tag":447,"props":9975,"children":9976},{},[9977],{"type":34,"value":9978},"5. Sécurité et performance, sur les zones sensibles",{"type":34,"value":9980},"\nValidation des entrées utilisateur, gestion des secrets, requêtes SQL paramétrées. Sur les chemins critiques : algorithmique raisonnable, pas de N+1 sur les requêtes BDD, pas d'opérations bloquantes dans des sections asynchrones.",{"type":29,"tag":8526,"props":9982,"children":9983},{"type":8528},[9984],{"type":29,"tag":30,"props":9985,"children":9986},{},[9987,9989,9995],{"type":34,"value":9988},"Téléchargez la version complète de cette checklist (PDF imprimable) en ",{"type":29,"tag":63,"props":9990,"children":9992},{"href":9991},"\u002Fressources\u002FChecklist-de-revue-de-code.pdf",[9993],{"type":34,"value":9994},"cliquant ici",{"type":34,"value":338},{"type":29,"tag":2288,"props":9997,"children":9999},{"cta":5629,"href":5630,"title":9998,"type":5632},"Une revue rigoureuse n'est qu'une pratique sur les 100 que j'applique",[10000],{"type":29,"tag":30,"props":10001,"children":10002},{},[10003],{"type":34,"value":10004},"La checklist de cet article décrit une seule discipline du craft : savoir relire du code et formuler un feedback qui fait progresser. Le Craft Bundle réunit les 100 pratiques que j'applique pour écrire et faire écrire du code propre, celles que l'IA ne vous apprendra jamais parce qu'elle ne les a jamais vues tenir en production sur la durée.",{"type":29,"tag":47,"props":10006,"children":10007},{},[],{"type":29,"tag":51,"props":10009,"children":10011},{"id":10010},"questions-fréquentes",[10012],{"type":34,"value":10013},"Questions fréquentes",{"type":29,"tag":5649,"props":10015,"children":10016},{},[10017,10022],{"type":29,"tag":5653,"props":10018,"children":10019},{},[10020],{"type":34,"value":10021},"Combien de temps consacrer à une revue ?",{"type":29,"tag":30,"props":10023,"children":10024},{},[10025],{"type":34,"value":10026},"Au-delà de 60 minutes en continu, l'attention chute et les remarques deviennent superficielles. Mieux vaut deux sessions de 30 minutes étalées qu'une marathon d'une heure et demie. Sur des PR trop grosses, demander un découpage est presque toujours la bonne réponse.",{"type":29,"tag":5649,"props":10028,"children":10029},{},[10030,10035],{"type":29,"tag":5653,"props":10031,"children":10032},{},[10033],{"type":34,"value":10034},"Que faire en cas de désaccord persistant avec un reviewer ?",{"type":29,"tag":30,"props":10036,"children":10037},{},[10038],{"type":34,"value":10039},"Sortir du commentaire écrit, passer à un échange de cinq minutes en visio ou en face à face. La plupart des désaccords viennent d'un contexte implicite que l'un des deux n'a pas. Si le désaccord persiste après échange, escalader à un troisième regard plutôt que d'enliser la PR.",{"type":29,"tag":5649,"props":10041,"children":10042},{},[10043,10048],{"type":29,"tag":5653,"props":10044,"children":10045},{},[10046],{"type":34,"value":10047},"Comment monter en compétences sur les revues ?",{"type":29,"tag":30,"props":10049,"children":10050},{},[10051],{"type":34,"value":10052},"Lire activement le code des autres, pas seulement le sien. Regarder les PR mergées sur des projets open source matures. En interne, demander à pair-reviewer avec un développeur plus senior pendant deux semaines : c'est l'accélérateur le plus efficace.",{"type":29,"tag":5649,"props":10054,"children":10055},{},[10056,10061],{"type":29,"tag":5653,"props":10057,"children":10058},{},[10059],{"type":34,"value":10060},"Quels outils pour structurer le processus ?",{"type":29,"tag":30,"props":10062,"children":10063},{},[10064,10066,10070],{"type":34,"value":10065},"GitHub ou GitLab pour la mécanique de PR. ",{"type":29,"tag":63,"props":10067,"children":10068},{"href":9860},[10069],{"type":34,"value":9863},{"type":34,"value":10071}," en complément pour l'analyse statique, qui prend en charge les vérifications mécaniques (duplication, vulnérabilités CVE, complexité cyclomatique), ce qui libère le reviewer humain pour les questions de conception.",{"type":29,"tag":2288,"props":10073,"children":10077},{"cta":10074,"href":10075,"title":10076,"type":5755},"Accéder au template gratuit →","\u002Fmes-ressources","Ressource gratuite : Faites votre propre audit engineering en 2 heures",[10078],{"type":29,"tag":30,"props":10079,"children":10080},{},[10081],{"type":34,"value":10082},"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":29,"tag":5763,"props":10084,"children":10085},{},[10086],{"type":34,"value":5767},{"title":8,"searchDepth":101,"depth":101,"links":10088},[10089,10090,10095,10098,10103,10107,10108],{"id":8483,"depth":101,"text":8486},{"id":8537,"depth":101,"text":8540,"children":10091},[10092,10093,10094],{"id":8544,"depth":128,"text":8547},{"id":8573,"depth":128,"text":8576},{"id":8744,"depth":128,"text":8747},{"id":8764,"depth":101,"text":8767,"children":10096},[10097],{"id":8823,"depth":128,"text":8826},{"id":8834,"depth":101,"text":8837,"children":10099},[10100,10101,10102],{"id":8845,"depth":128,"text":8848},{"id":9008,"depth":128,"text":9011},{"id":9496,"depth":128,"text":9499},{"id":9819,"depth":101,"text":9822,"children":10104},[10105,10106],{"id":9825,"depth":128,"text":9828},{"id":9868,"depth":128,"text":9871},{"id":9907,"depth":101,"text":9910},{"id":10010,"depth":101,"text":10013},"content:fr:dette-technique:revue-de-code-java-guide-exemples.md","fr\u002Fdette-technique\u002Frevue-de-code-java-guide-exemples.md","fr\u002Fdette-technique\u002Frevue-de-code-java-guide-exemples",{"_path":10113,"_dir":8447,"_draft":7,"_partial":7,"_locale":8,"title":10114,"description":10115,"id":3346,"date":10116,"listed":13,"nocomments":7,"hidden":7,"categories":10117,"tags":10118,"cover":10119,"readingTime":10120,"body":10125,"_type":5777,"_id":10522,"_source":5779,"_file":10523,"_stem":10524,"_extension":5782},"\u002Ffr\u002Fdette-technique\u002Floi-norvig-maitrise-theorie-pratique","Loi de Norvig, Maîtriser le Développement à travers la Pratique et la Théorie","Découvrez comment équilibrer théorie et pratique avec la Loi de Norvig, et améliorez vos compétences en tant que développeur. Comparez avec le software craftsmanship...","2024-08-28",[8447],[16,8453],"covers\u002Farticles\u002Floi-de-norvig.jpg",{"text":10121,"minutes":10122,"time":10123,"words":10124},"6 min read",5.77,346200,1154,{"type":26,"children":10126,"toc":10501},[10127,10136,10141,10153,10156,10165,10186,10195,10200,10209,10223,10232,10255,10275,10278,10287,10296,10301,10312,10317,10328,10333,10343,10354,10359,10370,10392,10403,10408,10417,10426,10429,10438,10462,10475,10488,10491],{"type":29,"tag":51,"props":10128,"children":10130},{"id":10129},"loi-de-norvig-maîtriser-le-développement-à-travers-la-pratique-et-la-théorie",[10131],{"type":29,"tag":447,"props":10132,"children":10133},{},[10134],{"type":34,"value":10135},"Loi de Norvig : Maîtriser le Développement à travers la Pratique et la Théorie",{"type":29,"tag":30,"props":10137,"children":10138},{},[10139],{"type":34,"value":10140},"Sentiment partagé par beaucoup de développeurs après quelques années de métier : plusieurs langages maîtrisés, des bugs résolus efficacement, et pourtant l'impression de stagner. \"Est-ce que je progresse vraiment ?\". Dans les DSI que j'accompagne, j'ai vu ce déséquilibre freiner des équipes entières : des développeurs compétents bloqués à un même palier, faute d'apprentissage structuré. Conséquence opérationnelle : délais de livraison qui s'allongent, dette technique qui s'accumule.",{"type":29,"tag":30,"props":10142,"children":10143},{},[10144,10146,10151],{"type":34,"value":10145},"La ",{"type":29,"tag":447,"props":10147,"children":10148},{},[10149],{"type":34,"value":10150},"Loi de Norvig",{"type":34,"value":10152}," pointe la cause : pour maîtriser une compétence technique, la pratique doit s'appuyer sur une compréhension théorique solide. La répétition seule ne franchit pas les paliers. Anders Ericsson, dont les travaux sur la pratique délibérée ont inspiré Peter Norvig, montre que c'est la qualité de l'effort qui fait la différence, pas la quantité brute d'heures.",{"type":29,"tag":47,"props":10154,"children":10155},{},[],{"type":29,"tag":51,"props":10157,"children":10159},{"id":10158},"comparaison-entre-la-loi-de-norvig-et-le-software-craftsmanship",[10160],{"type":29,"tag":447,"props":10161,"children":10162},{},[10163],{"type":34,"value":10164},"Comparaison entre la Loi de Norvig et le Software Craftsmanship",{"type":29,"tag":30,"props":10166,"children":10167},{},[10168,10169,10173,10175,10184],{"type":34,"value":10145},{"type":29,"tag":447,"props":10170,"children":10171},{},[10172],{"type":34,"value":10150},{"type":34,"value":10174}," et le ",{"type":29,"tag":447,"props":10176,"children":10177},{},[10178],{"type":29,"tag":63,"props":10179,"children":10181},{"href":10180},"\u002Ffr\u002Fdette-technique\u002Fsoftware-craftsmanship-principes-exemples-java",[10182],{"type":34,"value":10183},"software craftsmanship",{"type":34,"value":10185}," partagent un objectif commun : atteindre l'excellence dans la création de logiciels. Pourtant, ces deux concepts abordent la question de manière différente.",{"type":29,"tag":8542,"props":10187,"children":10189},{"id":10188},"loi-de-norvig-équilibre-entre-théorie-et-pratique",[10190],{"type":29,"tag":447,"props":10191,"children":10192},{},[10193],{"type":34,"value":10194},"Loi de Norvig : Équilibre entre théorie et pratique",{"type":29,"tag":30,"props":10196,"children":10197},{},[10198],{"type":34,"value":10199},"Selon Peter Norvig, il faut environ dix ans pour maîtriser un domaine technique. Cette durée n'est pas seulement une question de pratique répétée. La Loi de Norvig stipule que pour progresser, il faut non seulement pratiquer régulièrement, mais aussi approfondir les concepts théoriques sous-jacents. La pratique seule, sans compréhension de la théorie, peut entraîner des habitudes inefficaces. À l’inverse, trop se concentrer sur la théorie, sans application concrète, peut limiter la capacité à résoudre des problèmes réels.",{"type":29,"tag":8542,"props":10201,"children":10203},{"id":10202},"software-craftsmanship-lart-du-développement-logiciel",[10204],{"type":29,"tag":447,"props":10205,"children":10206},{},[10207],{"type":34,"value":10208},"Software Craftsmanship : L’art du développement logiciel",{"type":29,"tag":30,"props":10210,"children":10211},{},[10212,10214,10221],{"type":34,"value":10213},"Le ",{"type":29,"tag":447,"props":10215,"children":10216},{},[10217],{"type":29,"tag":63,"props":10218,"children":10219},{"href":10180},[10220],{"type":34,"value":10183},{"type":34,"value":10222}," est une philosophie qui prône l'idée que le développement logiciel est un artisanat. Il met l'accent sur la qualité du code, la collaboration, et l’amélioration continue à travers la pratique. Les développeurs sont encouragés à considérer leur travail comme un art, en perfectionnant constamment leurs compétences par l'expérience, la révision de code, et le mentorat.",{"type":29,"tag":8542,"props":10224,"children":10226},{"id":10225},"comparaison-clé",[10227],{"type":29,"tag":447,"props":10228,"children":10229},{},[10230],{"type":34,"value":10231},"Comparaison clé",{"type":29,"tag":453,"props":10233,"children":10234},{},[10235,10245],{"type":29,"tag":457,"props":10236,"children":10237},{},[10238,10239,10243],{"type":34,"value":10145},{"type":29,"tag":447,"props":10240,"children":10241},{},[10242],{"type":34,"value":10150},{"type":34,"value":10244}," insiste sur l’importance d’un apprentissage équilibré : pratiquer, mais aussi comprendre pourquoi vous faites ce que vous faites.",{"type":29,"tag":457,"props":10246,"children":10247},{},[10248,10249,10253],{"type":34,"value":10213},{"type":29,"tag":447,"props":10250,"children":10251},{},[10252],{"type":34,"value":10183},{"type":34,"value":10254}," se concentre plus sur l'amélioration continue à travers la pratique consciente et la qualité du travail. L'aspect théorique y est moins présent, bien qu'il soit implicite dans la quête de perfectionnement.",{"type":29,"tag":30,"props":10256,"children":10257},{},[10258,10260,10264,10266,10273],{"type":34,"value":10259},"Les deux approches reconnaissent la nécessité de persévérance et de discipline, mais là où la ",{"type":29,"tag":447,"props":10261,"children":10262},{},[10263],{"type":34,"value":10150},{"type":34,"value":10265}," vous pousse à constamment réfléchir aux principes théoriques, le ",{"type":29,"tag":447,"props":10267,"children":10268},{},[10269],{"type":29,"tag":63,"props":10270,"children":10271},{"href":10180},[10272],{"type":34,"value":10183},{"type":34,"value":10274}," vous invite à adopter une mentalité d'artisan, où la qualité du produit fini et la transmission des connaissances sont prioritaires.",{"type":29,"tag":47,"props":10276,"children":10277},{},[],{"type":29,"tag":2288,"props":10279,"children":10281},{"cta":2290,"href":2291,"title":10280,"type":2293},"Vous pratiquez beaucoup mais vous sentez que vous stagnez sur le même palier ?",[10282],{"type":29,"tag":30,"props":10283,"children":10284},{},[10285],{"type":34,"value":10286},"La pratique délibérée ne s'improvise pas seul : c'est exactement ce que je travaille avec vous en mentoring 1:1. On cible les concepts que vous répétez sans vraiment les comprendre, on relit votre code ensemble, et on transforme vos heures de code en vraie montée en niveau. Vous arrêtez de tourner en rond et vous voyez enfin pourquoi vos solutions tiennent (ou pas).",{"type":29,"tag":51,"props":10288,"children":10290},{"id":10289},"plan-daction-pour-équilibrer-théorie-et-pratique",[10291],{"type":29,"tag":447,"props":10292,"children":10293},{},[10294],{"type":34,"value":10295},"Plan d'action pour équilibrer théorie et pratique",{"type":29,"tag":30,"props":10297,"children":10298},{},[10299],{"type":34,"value":10300},"Pas d'accumulation aveugle d'heures de code. Pas non plus de bibliographie infinie sans application. Un équilibre travaillé entre les deux. Voici un plan concret en cinq axes.",{"type":29,"tag":8542,"props":10302,"children":10304},{"id":10303},"_1-pratique-délibérée-coder-avec-un-but-précis",[10305,10307],{"type":34,"value":10306},"1. ",{"type":29,"tag":447,"props":10308,"children":10309},{},[10310],{"type":34,"value":10311},"Pratique délibérée : coder avec un but précis",{"type":29,"tag":30,"props":10313,"children":10314},{},[10315],{"type":34,"value":10316},"La pratique n'est efficace que lorsqu'elle est intentionnelle. Ciblez des compétences spécifiques au lieu d'écrire du code sans réfléchir. Difficulté avec la gestion des exceptions ? Consacrez une session entière à des scénarios qui vous forcent à explorer plusieurs approches. Posez-vous les bonnes questions : \"Pourquoi cette solution marche-t-elle ici ?\", \"Quelles sont ses limites ?\". Prenez une tâche que vous faites souvent (intégration d'API, accès à une base) et explorez plusieurs implémentations en pesant les compromis de chacune.",{"type":29,"tag":8542,"props":10318,"children":10320},{"id":10319},"_2-étudier-la-théorie-comprendre-les-fondations",[10321,10323],{"type":34,"value":10322},"2. ",{"type":29,"tag":447,"props":10324,"children":10325},{},[10326],{"type":34,"value":10327},"Étudier la théorie : comprendre les fondations",{"type":29,"tag":30,"props":10329,"children":10330},{},[10331],{"type":34,"value":10332},"Pour chaque session de pratique, comprenez le concept sous-jacent. Si vous travaillez sur des algorithmes de tri, lisez ou relisez leurs principes. Pourquoi le tri rapide bat-il souvent le tri par insertion ? Comprendre les nuances théoriques vous donne le levier pour adapter les solutions à des contextes variés. Fixez-vous un objectif simple : approfondir au moins un concept théorique par semaine, via un livre, un papier ou une conférence sérieuse.",{"type":29,"tag":30,"props":10334,"children":10335},{},[10336,10341],{"type":29,"tag":447,"props":10337,"children":10338},{},[10339],{"type":34,"value":10340},"Conseil",{"type":34,"value":10342}," : un ratio de départ raisonnable est 70 % de pratique, 30 % de théorie. À ajuster selon vos besoins.",{"type":29,"tag":8542,"props":10344,"children":10346},{"id":10345},"_3-appliquer-immédiatement-la-théorie",[10347,10349],{"type":34,"value":10348},"3. ",{"type":29,"tag":447,"props":10350,"children":10351},{},[10352],{"type":34,"value":10353},"Appliquer immédiatement la théorie",{"type":29,"tag":30,"props":10355,"children":10356},{},[10357],{"type":34,"value":10358},"Un concept appris non appliqué s'évapore en quelques jours. Dès que vous découvrez quelque chose, intégrez-le à un projet pratique. Étudié les structures de données ? Implémentez-les dans une petite app où chaque fonctionnalité incarne un concept que vous voulez ancrer. C'est la meilleure garantie que vous avez vraiment compris.",{"type":29,"tag":8542,"props":10360,"children":10362},{"id":10361},"_4-revoir-partager-demander-des-retours",[10363,10365],{"type":34,"value":10364},"4. ",{"type":29,"tag":447,"props":10366,"children":10367},{},[10368],{"type":34,"value":10369},"Revoir, partager, demander des retours",{"type":29,"tag":30,"props":10371,"children":10372},{},[10373,10375,10382,10384,10390],{"type":34,"value":10374},"Le perfectionnement passe par la révision. Relisez votre code, identifiez les inefficacités, corrigez-les. C'est aussi le moment de chercher du feedback : pair, mentor, communauté. C'est là que le ",{"type":29,"tag":447,"props":10376,"children":10377},{},[10378],{"type":29,"tag":63,"props":10379,"children":10380},{"href":10180},[10381],{"type":34,"value":10183},{"type":34,"value":10383}," rejoint Norvig : amélioration continue et transmission. Un mentor accélère la progression en pointant les angles morts. Un forum ou un meetup expose à des pratiques que vous n'auriez pas explorées seul. Pratiquez régulièrement la ",{"type":29,"tag":63,"props":10385,"children":10387},{"href":10386},"\u002Ffr\u002Fintelligence-artificielle\u002Fia-code-review-retour-experience",[10388],{"type":34,"value":10389},"revue de code",{"type":34,"value":10391}," avec vos pairs.",{"type":29,"tag":8542,"props":10393,"children":10395},{"id":10394},"_5-suivre-les-progrès-et-ajuster",[10396,10398],{"type":34,"value":10397},"5. ",{"type":29,"tag":447,"props":10399,"children":10400},{},[10401],{"type":34,"value":10402},"Suivre les progrès et ajuster",{"type":29,"tag":30,"props":10404,"children":10405},{},[10406],{"type":34,"value":10407},"Fixez-vous des objectifs courts et longs termes : méthode SMART si ça vous parle (\"Implémenter trois algos de tri dans deux semaines\" plutôt que \"progresser en algorithmique\"). Tenez un journal d'apprentissage : concepts étudiés, projets réalisés, ce qui a marché, ce qui a coincé. Bilan mensuel pour réorienter la méthode si nécessaire. Et célébrez les petites victoires, la stagnation est souvent un problème de perception, pas de progrès.",{"type":29,"tag":30,"props":10409,"children":10410},{},[10411,10415],{"type":29,"tag":447,"props":10412,"children":10413},{},[10414],{"type":34,"value":10340},{"type":34,"value":10416}," : adoptez une mentalité de croissance. Chaque erreur est de l'information, pas un échec. Prenez le temps de comprendre pourquoi une difficulté est apparue et comment l'éviter ensuite.",{"type":29,"tag":2288,"props":10418,"children":10420},{"cta":5629,"href":5630,"title":10419,"type":5632},"La pratique délibérée appliquée au code propre : voici les 100 pratiques que je vise",[10421],{"type":29,"tag":30,"props":10422,"children":10423},{},[10424],{"type":34,"value":10425},"Cet article montre comment équilibrer théorie et pratique pour franchir vos paliers. Le Craft Bundle va plus loin : il réunit les 100 pratiques craft que j'applique au quotidien pour coder propre, celles que la pratique délibérée vous ferait découvrir en dix ans. Ce sont précisément les pratiques que l'IA ne vous apprendra jamais, parce qu'elle ne les a jamais vues tenir en production.",{"type":29,"tag":47,"props":10427,"children":10428},{},[],{"type":29,"tag":51,"props":10430,"children":10432},{"id":10431},"faq-sur-la-loi-de-norvig-et-le-software-craftsmanship",[10433],{"type":29,"tag":447,"props":10434,"children":10435},{},[10436],{"type":34,"value":10437},"FAQ sur la Loi de Norvig et le Software Craftsmanship",{"type":29,"tag":5649,"props":10439,"children":10440},{},[10441,10446],{"type":29,"tag":5653,"props":10442,"children":10443},{},[10444],{"type":34,"value":10445},"1. En quoi la Loi de Norvig se distingue-t-elle du software craftsmanship ?",{"type":29,"tag":30,"props":10447,"children":10448},{},[10449,10450,10454,10456,10460],{"type":34,"value":10145},{"type":29,"tag":447,"props":10451,"children":10452},{},[10453],{"type":34,"value":10150},{"type":34,"value":10455}," insiste sur l'équilibre théorie\u002Fpratique comme moteur de la maîtrise. Le ",{"type":29,"tag":447,"props":10457,"children":10458},{},[10459],{"type":34,"value":10183},{"type":34,"value":10461}," se concentre sur l'amélioration continue du code et la qualité du travail via la pratique, la collaboration et le mentorat. Les deux sont complémentaires : Norvig structure l'apprentissage, le craftsmanship installe une mentalité d'artisan.",{"type":29,"tag":5649,"props":10463,"children":10464},{},[10465,10470],{"type":29,"tag":5653,"props":10466,"children":10467},{},[10468],{"type":34,"value":10469},"2. Comment éviter de me perdre dans la théorie sans fin ?",{"type":29,"tag":30,"props":10471,"children":10472},{},[10473],{"type":34,"value":10474},"En appliquant immédiatement chaque concept étudié à un projet pratique. C'est ce qui ancre la connaissance et coupe court à l'abstraction stérile. Norvig ne dit pas \"lisez plus\", il dit \"comprenez ce que vous pratiquez\".",{"type":29,"tag":5649,"props":10476,"children":10477},{},[10478,10483],{"type":29,"tag":5653,"props":10479,"children":10480},{},[10481],{"type":34,"value":10482},"3. Quels outils ou ressources pour ce plan d'action ?",{"type":29,"tag":30,"props":10484,"children":10485},{},[10486],{"type":34,"value":10487},"Côté théorie : livres techniques de référence, papiers académiques accessibles, conférences sérieuses (Coursera, Udemy, MIT OCW selon le domaine). Côté pratique : projets personnels, challenges de code (LeetCode, HackerRank), revues de code en communauté ou avec un mentor.",{"type":29,"tag":47,"props":10489,"children":10490},{},[],{"type":29,"tag":2288,"props":10492,"children":10495},{"cta":10493,"href":10075,"title":10494,"type":5755},"Télécharger la checklist gratuite →","Ressource gratuite : Votre équipe est-elle vraiment prête pour l'IA ?",[10496],{"type":29,"tag":30,"props":10497,"children":10498},{},[10499],{"type":34,"value":10500},"25 questions, 5 dimensions, score de maturité IA sur 25. La maîtrise technique est la fondation de l'adoption de l'IA : identifiez vos 3 gaps critiques avant de scaler vos outils.",{"title":8,"searchDepth":101,"depth":101,"links":10502},[10503,10504,10509,10521],{"id":10129,"depth":101,"text":10135},{"id":10158,"depth":101,"text":10164,"children":10505},[10506,10507,10508],{"id":10188,"depth":128,"text":10194},{"id":10202,"depth":128,"text":10208},{"id":10225,"depth":128,"text":10231},{"id":10289,"depth":101,"text":10295,"children":10510},[10511,10513,10515,10517,10519],{"id":10303,"depth":128,"text":10512},"1. Pratique délibérée : coder avec un but précis",{"id":10319,"depth":128,"text":10514},"2. Étudier la théorie : comprendre les fondations",{"id":10345,"depth":128,"text":10516},"3. Appliquer immédiatement la théorie",{"id":10361,"depth":128,"text":10518},"4. Revoir, partager, demander des retours",{"id":10394,"depth":128,"text":10520},"5. Suivre les progrès et ajuster",{"id":10431,"depth":101,"text":10437},"content:fr:dette-technique:loi-norvig-maitrise-theorie-pratique.md","fr\u002Fdette-technique\u002Floi-norvig-maitrise-theorie-pratique.md","fr\u002Fdette-technique\u002Floi-norvig-maitrise-theorie-pratique",{"_path":10526,"_dir":8447,"_draft":7,"_partial":7,"_locale":8,"title":10527,"description":10528,"id":3310,"date":10529,"listed":13,"nocomments":7,"hidden":7,"categories":10530,"tags":10531,"cover":10532,"readingTime":10533,"body":10538,"_type":5777,"_id":15679,"_source":5779,"_file":15680,"_stem":15681,"_extension":5782},"\u002Ffr\u002Fdette-technique\u002Fcomment-ecrire-du-code-evolutif-en-developpement-logiciel","Comment écrire du code évolutif en développement logiciel - Bonnes pratiques et exemples Java","Découvrez comment écrire du code évolutif pour faciliter la maintenance et l'extension de vos projets. Apprenez les bonnes pratiques en développement...","2024-07-01",[8447],[16,8453],"covers\u002Farticles\u002Fcode-evolutif.jpg",{"text":10534,"minutes":10535,"time":10536,"words":10537},"14 min read",13.325,799500,2665,{"type":26,"children":10539,"toc":15658},[10540,10546,10551,10556,10559,10565,10570,10575,10582,10587,10593,10605,11003,11015,11018,11027,11033,11038,11044,11049,11409,11414,11420,11431,11552,11558,11563,11582,11829,11842,11845,11851,11856,11862,11873,12152,12158,12169,12202,12446,12452,12463,12945,12951,12963,12987,13326,13329,13335,13340,13346,13365,13371,13753,13759,13764,14255,14275,14281,14293,14298,14442,14469,14474,14492,14692,14711,14953,14959,14971,14977,15117,15123,15142,15487,15499,15508,15511,15517,15573,15586,15627,15630,15636,15641,15644,15654],{"type":29,"tag":51,"props":10541,"children":10543},{"id":10542},"comment-écrire-du-code-évolutif-en-développement-logiciel-les-bonnes-pratiques-et-exemples-en-java",[10544],{"type":34,"value":10545},"Comment écrire du code évolutif en développement logiciel : Les bonnes pratiques et exemples en Java",{"type":29,"tag":30,"props":10547,"children":10548},{},[10549],{"type":34,"value":10550},"Sur les projets long terme (j'en ai vu des dizaines dans la banque et l'assurance) un symptôme revient. Une modif anodine, et trois écrans plus loin, une régression. Le code n'a pas été conçu pour bouger. Il fonctionne, mais il résiste au changement.",{"type":29,"tag":30,"props":10552,"children":10553},{},[10554],{"type":34,"value":10555},"C'est exactement ce qu'on appelle un code non évolutif. Et c'est rattrapable, à condition de se discipliner sur quelques principes. L'article qui suit montre les pratiques que j'applique en mission, avec des exemples Java concrets.",{"type":29,"tag":47,"props":10557,"children":10558},{},[],{"type":29,"tag":51,"props":10560,"children":10562},{"id":10561},"quest-ce-que-le-code-évolutif",[10563],{"type":34,"value":10564},"Qu'est-ce que le code évolutif ?",{"type":29,"tag":30,"props":10566,"children":10567},{},[10568],{"type":34,"value":10569},"Le code évolutif se modifie sans introduire de bugs et sans casser l'existant. Vous ajoutez une fonctionnalité, corrigez une erreur, vous adaptez à un changement d'exigence, sans tout réécrire.",{"type":29,"tag":30,"props":10571,"children":10572},{},[10573],{"type":34,"value":10574},"Imaginez que vous construisez une maison. Si elle est bien conçue, vous pourrez y ajouter des étages, changer la disposition des pièces ou installer de nouvelles fenêtres sans avoir à démolir toute la structure. C'est exactement ce que vous voulez avec votre code : une base solide et flexible, capable de s'adapter aux changements.",{"type":29,"tag":10576,"props":10577,"children":10579},"h4",{"id":10578},"pourquoi-est-ce-important",[10580],{"type":34,"value":10581},"Pourquoi est-ce important ?",{"type":29,"tag":30,"props":10583,"children":10584},{},[10585],{"type":34,"value":10586},"Un code non évolutif devient rapidement un cauchemar à maintenir. Chaque modification devient risquée, car elle peut affecter des parties du programme que vous n'aviez même pas prévues. Cela augmente le coût en temps et en efforts pour ajouter des fonctionnalités ou corriger des bugs. En revanche, avec un code évolutif, vous économisez du temps à long terme et vous réduisez les risques d'introduire de nouvelles erreurs.",{"type":29,"tag":10576,"props":10588,"children":10590},{"id":10589},"exemples-de-code-non-évolutif",[10591],{"type":34,"value":10592},"Exemples de code non évolutif",{"type":29,"tag":30,"props":10594,"children":10595},{},[10596,10598,10603],{"type":34,"value":10597},"Prenons un exemple concret en Java. Imaginez que vous ayez une classe ",{"type":29,"tag":84,"props":10599,"children":10601},{"className":10600},[],[10602],{"type":34,"value":9538},{"type":34,"value":10604}," qui gère non seulement les informations de l'employé, mais aussi la génération de rapports, la gestion des salaires, et d'autres fonctionnalités. Si vous devez modifier une seule de ces fonctionnalités, vous risquez d'affecter tout le reste de la classe.",{"type":29,"tag":77,"props":10606,"children":10608},{"className":81,"code":10607,"language":80,"meta":8,"style":8},"public class Employee {\n    private String name;\n    private double salary;\n\n    public Employee(String name, double salary) {\n        this.name = name;\n        this.salary = salary;\n    }\n\n    public void generateReport() {\n        \u002F\u002F Code pour générer un rapport\n    }\n\n    public void processSalary() {\n        \u002F\u002F Code pour calculer le salaire\n    }\n\n    public void updateDetails(String newName, double newSalary) {\n        this.name = newName;\n        this.salary = newSalary;\n    }\n}\n",[10609],{"type":29,"tag":84,"props":10610,"children":10611},{"__ignoreMap":8},[10612,10632,10652,10673,10680,10723,10751,10779,10786,10793,10817,10825,10832,10839,10863,10871,10878,10885,10935,10962,10989,10996],{"type":29,"tag":88,"props":10613,"children":10614},{"class":90,"line":91},[10615,10619,10623,10628],{"type":29,"tag":88,"props":10616,"children":10617},{"style":105},[10618],{"type":34,"value":108},{"type":29,"tag":88,"props":10620,"children":10621},{"style":105},[10622],{"type":34,"value":113},{"type":29,"tag":88,"props":10624,"children":10625},{"style":116},[10626],{"type":34,"value":10627}," Employee",{"type":29,"tag":88,"props":10629,"children":10630},{"style":122},[10631],{"type":34,"value":125},{"type":29,"tag":88,"props":10633,"children":10634},{"class":90,"line":101},[10635,10639,10643,10648],{"type":29,"tag":88,"props":10636,"children":10637},{"style":105},[10638],{"type":34,"value":143},{"type":29,"tag":88,"props":10640,"children":10641},{"style":151},[10642],{"type":34,"value":281},{"type":29,"tag":88,"props":10644,"children":10645},{"style":157},[10646],{"type":34,"value":10647}," name",{"type":29,"tag":88,"props":10649,"children":10650},{"style":122},[10651],{"type":34,"value":424},{"type":29,"tag":88,"props":10653,"children":10654},{"class":90,"line":128},[10655,10659,10664,10669],{"type":29,"tag":88,"props":10656,"children":10657},{"style":105},[10658],{"type":34,"value":143},{"type":29,"tag":88,"props":10660,"children":10661},{"style":105},[10662],{"type":34,"value":10663}," double",{"type":29,"tag":88,"props":10665,"children":10666},{"style":157},[10667],{"type":34,"value":10668}," salary",{"type":29,"tag":88,"props":10670,"children":10671},{"style":122},[10672],{"type":34,"value":424},{"type":29,"tag":88,"props":10674,"children":10675},{"class":90,"line":137},[10676],{"type":29,"tag":88,"props":10677,"children":10678},{"emptyLinePlaceholder":13},[10679],{"type":34,"value":134},{"type":29,"tag":88,"props":10681,"children":10682},{"class":90,"line":211},[10683,10687,10691,10695,10699,10703,10707,10711,10715,10719],{"type":29,"tag":88,"props":10684,"children":10685},{"style":105},[10686],{"type":34,"value":276},{"type":29,"tag":88,"props":10688,"children":10689},{"style":174},[10690],{"type":34,"value":10627},{"type":29,"tag":88,"props":10692,"children":10693},{"style":122},[10694],{"type":34,"value":181},{"type":29,"tag":88,"props":10696,"children":10697},{"style":151},[10698],{"type":34,"value":695},{"type":29,"tag":88,"props":10700,"children":10701},{"style":298},[10702],{"type":34,"value":10647},{"type":29,"tag":88,"props":10704,"children":10705},{"style":122},[10706],{"type":34,"value":192},{"type":29,"tag":88,"props":10708,"children":10709},{"style":105},[10710],{"type":34,"value":10663},{"type":29,"tag":88,"props":10712,"children":10713},{"style":298},[10714],{"type":34,"value":10668},{"type":29,"tag":88,"props":10716,"children":10717},{"style":122},[10718],{"type":34,"value":306},{"type":29,"tag":88,"props":10720,"children":10721},{"style":122},[10722],{"type":34,"value":125},{"type":29,"tag":88,"props":10724,"children":10725},{"class":90,"line":262},[10726,10730,10734,10739,10743,10747],{"type":29,"tag":88,"props":10727,"children":10728},{"style":873},[10729],{"type":34,"value":876},{"type":29,"tag":88,"props":10731,"children":10732},{"style":122},[10733],{"type":34,"value":338},{"type":29,"tag":88,"props":10735,"children":10736},{"style":157},[10737],{"type":34,"value":10738},"name ",{"type":29,"tag":88,"props":10740,"children":10741},{"style":163},[10742],{"type":34,"value":166},{"type":29,"tag":88,"props":10744,"children":10745},{"style":157},[10746],{"type":34,"value":10647},{"type":29,"tag":88,"props":10748,"children":10749},{"style":122},[10750],{"type":34,"value":424},{"type":29,"tag":88,"props":10752,"children":10753},{"class":90,"line":270},[10754,10758,10762,10767,10771,10775],{"type":29,"tag":88,"props":10755,"children":10756},{"style":873},[10757],{"type":34,"value":876},{"type":29,"tag":88,"props":10759,"children":10760},{"style":122},[10761],{"type":34,"value":338},{"type":29,"tag":88,"props":10763,"children":10764},{"style":157},[10765],{"type":34,"value":10766},"salary ",{"type":29,"tag":88,"props":10768,"children":10769},{"style":163},[10770],{"type":34,"value":166},{"type":29,"tag":88,"props":10772,"children":10773},{"style":157},[10774],{"type":34,"value":10668},{"type":29,"tag":88,"props":10776,"children":10777},{"style":122},[10778],{"type":34,"value":424},{"type":29,"tag":88,"props":10780,"children":10781},{"class":90,"line":313},[10782],{"type":29,"tag":88,"props":10783,"children":10784},{"style":122},[10785],{"type":34,"value":433},{"type":29,"tag":88,"props":10787,"children":10788},{"class":90,"line":360},[10789],{"type":29,"tag":88,"props":10790,"children":10791},{"emptyLinePlaceholder":13},[10792],{"type":34,"value":134},{"type":29,"tag":88,"props":10794,"children":10795},{"class":90,"line":409},[10796,10800,10804,10809,10813],{"type":29,"tag":88,"props":10797,"children":10798},{"style":105},[10799],{"type":34,"value":276},{"type":29,"tag":88,"props":10801,"children":10802},{"style":105},[10803],{"type":34,"value":1303},{"type":29,"tag":88,"props":10805,"children":10806},{"style":174},[10807],{"type":34,"value":10808}," generateReport",{"type":29,"tag":88,"props":10810,"children":10811},{"style":122},[10812],{"type":34,"value":1470},{"type":29,"tag":88,"props":10814,"children":10815},{"style":122},[10816],{"type":34,"value":125},{"type":29,"tag":88,"props":10818,"children":10819},{"class":90,"line":427},[10820],{"type":29,"tag":88,"props":10821,"children":10822},{"style":95},[10823],{"type":34,"value":10824},"        \u002F\u002F Code pour générer un rapport\n",{"type":29,"tag":88,"props":10826,"children":10827},{"class":90,"line":436},[10828],{"type":29,"tag":88,"props":10829,"children":10830},{"style":122},[10831],{"type":34,"value":433},{"type":29,"tag":88,"props":10833,"children":10834},{"class":90,"line":767},[10835],{"type":29,"tag":88,"props":10836,"children":10837},{"emptyLinePlaceholder":13},[10838],{"type":34,"value":134},{"type":29,"tag":88,"props":10840,"children":10841},{"class":90,"line":792},[10842,10846,10850,10855,10859],{"type":29,"tag":88,"props":10843,"children":10844},{"style":105},[10845],{"type":34,"value":276},{"type":29,"tag":88,"props":10847,"children":10848},{"style":105},[10849],{"type":34,"value":1303},{"type":29,"tag":88,"props":10851,"children":10852},{"style":174},[10853],{"type":34,"value":10854}," processSalary",{"type":29,"tag":88,"props":10856,"children":10857},{"style":122},[10858],{"type":34,"value":1470},{"type":29,"tag":88,"props":10860,"children":10861},{"style":122},[10862],{"type":34,"value":125},{"type":29,"tag":88,"props":10864,"children":10865},{"class":90,"line":817},[10866],{"type":29,"tag":88,"props":10867,"children":10868},{"style":95},[10869],{"type":34,"value":10870},"        \u002F\u002F Code pour calculer le salaire\n",{"type":29,"tag":88,"props":10872,"children":10873},{"class":90,"line":825},[10874],{"type":29,"tag":88,"props":10875,"children":10876},{"style":122},[10877],{"type":34,"value":433},{"type":29,"tag":88,"props":10879,"children":10880},{"class":90,"line":869},[10881],{"type":29,"tag":88,"props":10882,"children":10883},{"emptyLinePlaceholder":13},[10884],{"type":34,"value":134},{"type":29,"tag":88,"props":10886,"children":10887},{"class":90,"line":900},[10888,10892,10896,10901,10905,10909,10914,10918,10922,10927,10931],{"type":29,"tag":88,"props":10889,"children":10890},{"style":105},[10891],{"type":34,"value":276},{"type":29,"tag":88,"props":10893,"children":10894},{"style":105},[10895],{"type":34,"value":1303},{"type":29,"tag":88,"props":10897,"children":10898},{"style":174},[10899],{"type":34,"value":10900}," updateDetails",{"type":29,"tag":88,"props":10902,"children":10903},{"style":122},[10904],{"type":34,"value":181},{"type":29,"tag":88,"props":10906,"children":10907},{"style":151},[10908],{"type":34,"value":695},{"type":29,"tag":88,"props":10910,"children":10911},{"style":298},[10912],{"type":34,"value":10913}," newName",{"type":29,"tag":88,"props":10915,"children":10916},{"style":122},[10917],{"type":34,"value":192},{"type":29,"tag":88,"props":10919,"children":10920},{"style":105},[10921],{"type":34,"value":10663},{"type":29,"tag":88,"props":10923,"children":10924},{"style":298},[10925],{"type":34,"value":10926}," newSalary",{"type":29,"tag":88,"props":10928,"children":10929},{"style":122},[10930],{"type":34,"value":306},{"type":29,"tag":88,"props":10932,"children":10933},{"style":122},[10934],{"type":34,"value":125},{"type":29,"tag":88,"props":10936,"children":10937},{"class":90,"line":929},[10938,10942,10946,10950,10954,10958],{"type":29,"tag":88,"props":10939,"children":10940},{"style":873},[10941],{"type":34,"value":876},{"type":29,"tag":88,"props":10943,"children":10944},{"style":122},[10945],{"type":34,"value":338},{"type":29,"tag":88,"props":10947,"children":10948},{"style":157},[10949],{"type":34,"value":10738},{"type":29,"tag":88,"props":10951,"children":10952},{"style":163},[10953],{"type":34,"value":166},{"type":29,"tag":88,"props":10955,"children":10956},{"style":157},[10957],{"type":34,"value":10913},{"type":29,"tag":88,"props":10959,"children":10960},{"style":122},[10961],{"type":34,"value":424},{"type":29,"tag":88,"props":10963,"children":10964},{"class":90,"line":937},[10965,10969,10973,10977,10981,10985],{"type":29,"tag":88,"props":10966,"children":10967},{"style":873},[10968],{"type":34,"value":876},{"type":29,"tag":88,"props":10970,"children":10971},{"style":122},[10972],{"type":34,"value":338},{"type":29,"tag":88,"props":10974,"children":10975},{"style":157},[10976],{"type":34,"value":10766},{"type":29,"tag":88,"props":10978,"children":10979},{"style":163},[10980],{"type":34,"value":166},{"type":29,"tag":88,"props":10982,"children":10983},{"style":157},[10984],{"type":34,"value":10926},{"type":29,"tag":88,"props":10986,"children":10987},{"style":122},[10988],{"type":34,"value":424},{"type":29,"tag":88,"props":10990,"children":10991},{"class":90,"line":945},[10992],{"type":29,"tag":88,"props":10993,"children":10994},{"style":122},[10995],{"type":34,"value":433},{"type":29,"tag":88,"props":10997,"children":10998},{"class":90,"line":981},[10999],{"type":29,"tag":88,"props":11000,"children":11001},{"style":122},[11002],{"type":34,"value":442},{"type":29,"tag":30,"props":11004,"children":11005},{},[11006,11008,11013],{"type":34,"value":11007},"Dans cet exemple, la classe ",{"type":29,"tag":84,"props":11009,"children":11011},{"className":11010},[],[11012],{"type":34,"value":9538},{"type":34,"value":11014}," fait trop de choses à la fois, ce qui la rend difficile à modifier sans risquer de casser quelque chose. Si vous devez ajuster la méthode de calcul du salaire, vous devez être très prudent pour ne pas impacter la génération de rapports ou la mise à jour des informations de l'employé. Ce type de conception est typique d'un code non évolutif.",{"type":29,"tag":47,"props":11016,"children":11017},{},[],{"type":29,"tag":2288,"props":11019,"children":11021},{"cta":2290,"href":2291,"title":11020,"type":2293},"Vous voulez écrire des classes qui se laissent modifier sans tout casser ?",[11022],{"type":29,"tag":30,"props":11023,"children":11024},{},[11025],{"type":34,"value":11026},"Découper les responsabilités au bon endroit, inverser une dépendance sans complexifier, sentir quand une classe en fait trop : ça ne se lit pas, ça se pratique. En mentoring 1:1, je relis votre code Java avec vous et on retravaille vos conceptions ensemble, jusqu'à ce que le réflexe du code évolutif devienne le vôtre.",{"type":29,"tag":51,"props":11028,"children":11030},{"id":11029},"principes-de-base-pour-écrire-du-code-évolutif",[11031],{"type":34,"value":11032},"Principes de base pour écrire du code évolutif",{"type":29,"tag":30,"props":11034,"children":11035},{},[11036],{"type":34,"value":11037},"Écrire du code évolutif repose sur quelques principes qui maintiennent une structure claire et flexible. Voici les concepts à garder en tête pour qu'un code reste facile à modifier et à étendre.",{"type":29,"tag":8542,"props":11039,"children":11041},{"id":11040},"_1-la-modularité",[11042],{"type":34,"value":11043},"1. La modularité",{"type":29,"tag":30,"props":11045,"children":11046},{},[11047],{"type":34,"value":11048},"La modularité consiste à diviser votre code en petits morceaux indépendants qui accomplissent chacun une tâche bien définie. En séparant vos fonctionnalités dans des modules distincts, vous pouvez travailler sur une partie du programme sans risquer de casser les autres. En Java, cela se traduit par la création de classes et de méthodes spécifiques qui remplissent des fonctions uniques.",{"type":29,"tag":77,"props":11050,"children":11052},{"className":81,"code":11051,"language":80,"meta":8,"style":8},"\u002F\u002F Classe pour gérer les informations de l'employé\npublic class Employee {\n    private String name;\n    private double salary;\n\n    public Employee(String name, double salary) {\n        this.name = name;\n        this.salary = salary;\n    }\n}\n\npublic class ReportGenerator {\n    public void generate(Employee employee) {\n        \u002F\u002F Code pour générer un rapport pour cet employé\n    }\n}\n\npublic class SalaryProcessor {\n    public void process(Employee employee) {\n        \u002F\u002F Code pour calculer le salaire\n    }\n}\n",[11053],{"type":29,"tag":84,"props":11054,"children":11055},{"__ignoreMap":8},[11056,11064,11083,11102,11121,11128,11171,11198,11225,11232,11239,11246,11266,11303,11311,11318,11325,11332,11352,11388,11395,11402],{"type":29,"tag":88,"props":11057,"children":11058},{"class":90,"line":91},[11059],{"type":29,"tag":88,"props":11060,"children":11061},{"style":95},[11062],{"type":34,"value":11063},"\u002F\u002F Classe pour gérer les informations de l'employé\n",{"type":29,"tag":88,"props":11065,"children":11066},{"class":90,"line":101},[11067,11071,11075,11079],{"type":29,"tag":88,"props":11068,"children":11069},{"style":105},[11070],{"type":34,"value":108},{"type":29,"tag":88,"props":11072,"children":11073},{"style":105},[11074],{"type":34,"value":113},{"type":29,"tag":88,"props":11076,"children":11077},{"style":116},[11078],{"type":34,"value":10627},{"type":29,"tag":88,"props":11080,"children":11081},{"style":122},[11082],{"type":34,"value":125},{"type":29,"tag":88,"props":11084,"children":11085},{"class":90,"line":128},[11086,11090,11094,11098],{"type":29,"tag":88,"props":11087,"children":11088},{"style":105},[11089],{"type":34,"value":143},{"type":29,"tag":88,"props":11091,"children":11092},{"style":151},[11093],{"type":34,"value":281},{"type":29,"tag":88,"props":11095,"children":11096},{"style":157},[11097],{"type":34,"value":10647},{"type":29,"tag":88,"props":11099,"children":11100},{"style":122},[11101],{"type":34,"value":424},{"type":29,"tag":88,"props":11103,"children":11104},{"class":90,"line":137},[11105,11109,11113,11117],{"type":29,"tag":88,"props":11106,"children":11107},{"style":105},[11108],{"type":34,"value":143},{"type":29,"tag":88,"props":11110,"children":11111},{"style":105},[11112],{"type":34,"value":10663},{"type":29,"tag":88,"props":11114,"children":11115},{"style":157},[11116],{"type":34,"value":10668},{"type":29,"tag":88,"props":11118,"children":11119},{"style":122},[11120],{"type":34,"value":424},{"type":29,"tag":88,"props":11122,"children":11123},{"class":90,"line":211},[11124],{"type":29,"tag":88,"props":11125,"children":11126},{"emptyLinePlaceholder":13},[11127],{"type":34,"value":134},{"type":29,"tag":88,"props":11129,"children":11130},{"class":90,"line":262},[11131,11135,11139,11143,11147,11151,11155,11159,11163,11167],{"type":29,"tag":88,"props":11132,"children":11133},{"style":105},[11134],{"type":34,"value":276},{"type":29,"tag":88,"props":11136,"children":11137},{"style":174},[11138],{"type":34,"value":10627},{"type":29,"tag":88,"props":11140,"children":11141},{"style":122},[11142],{"type":34,"value":181},{"type":29,"tag":88,"props":11144,"children":11145},{"style":151},[11146],{"type":34,"value":695},{"type":29,"tag":88,"props":11148,"children":11149},{"style":298},[11150],{"type":34,"value":10647},{"type":29,"tag":88,"props":11152,"children":11153},{"style":122},[11154],{"type":34,"value":192},{"type":29,"tag":88,"props":11156,"children":11157},{"style":105},[11158],{"type":34,"value":10663},{"type":29,"tag":88,"props":11160,"children":11161},{"style":298},[11162],{"type":34,"value":10668},{"type":29,"tag":88,"props":11164,"children":11165},{"style":122},[11166],{"type":34,"value":306},{"type":29,"tag":88,"props":11168,"children":11169},{"style":122},[11170],{"type":34,"value":125},{"type":29,"tag":88,"props":11172,"children":11173},{"class":90,"line":270},[11174,11178,11182,11186,11190,11194],{"type":29,"tag":88,"props":11175,"children":11176},{"style":873},[11177],{"type":34,"value":876},{"type":29,"tag":88,"props":11179,"children":11180},{"style":122},[11181],{"type":34,"value":338},{"type":29,"tag":88,"props":11183,"children":11184},{"style":157},[11185],{"type":34,"value":10738},{"type":29,"tag":88,"props":11187,"children":11188},{"style":163},[11189],{"type":34,"value":166},{"type":29,"tag":88,"props":11191,"children":11192},{"style":157},[11193],{"type":34,"value":10647},{"type":29,"tag":88,"props":11195,"children":11196},{"style":122},[11197],{"type":34,"value":424},{"type":29,"tag":88,"props":11199,"children":11200},{"class":90,"line":313},[11201,11205,11209,11213,11217,11221],{"type":29,"tag":88,"props":11202,"children":11203},{"style":873},[11204],{"type":34,"value":876},{"type":29,"tag":88,"props":11206,"children":11207},{"style":122},[11208],{"type":34,"value":338},{"type":29,"tag":88,"props":11210,"children":11211},{"style":157},[11212],{"type":34,"value":10766},{"type":29,"tag":88,"props":11214,"children":11215},{"style":163},[11216],{"type":34,"value":166},{"type":29,"tag":88,"props":11218,"children":11219},{"style":157},[11220],{"type":34,"value":10668},{"type":29,"tag":88,"props":11222,"children":11223},{"style":122},[11224],{"type":34,"value":424},{"type":29,"tag":88,"props":11226,"children":11227},{"class":90,"line":360},[11228],{"type":29,"tag":88,"props":11229,"children":11230},{"style":122},[11231],{"type":34,"value":433},{"type":29,"tag":88,"props":11233,"children":11234},{"class":90,"line":409},[11235],{"type":29,"tag":88,"props":11236,"children":11237},{"style":122},[11238],{"type":34,"value":442},{"type":29,"tag":88,"props":11240,"children":11241},{"class":90,"line":427},[11242],{"type":29,"tag":88,"props":11243,"children":11244},{"emptyLinePlaceholder":13},[11245],{"type":34,"value":134},{"type":29,"tag":88,"props":11247,"children":11248},{"class":90,"line":436},[11249,11253,11257,11262],{"type":29,"tag":88,"props":11250,"children":11251},{"style":105},[11252],{"type":34,"value":108},{"type":29,"tag":88,"props":11254,"children":11255},{"style":105},[11256],{"type":34,"value":113},{"type":29,"tag":88,"props":11258,"children":11259},{"style":116},[11260],{"type":34,"value":11261}," ReportGenerator",{"type":29,"tag":88,"props":11263,"children":11264},{"style":122},[11265],{"type":34,"value":125},{"type":29,"tag":88,"props":11267,"children":11268},{"class":90,"line":767},[11269,11273,11277,11282,11286,11290,11295,11299],{"type":29,"tag":88,"props":11270,"children":11271},{"style":105},[11272],{"type":34,"value":276},{"type":29,"tag":88,"props":11274,"children":11275},{"style":105},[11276],{"type":34,"value":1303},{"type":29,"tag":88,"props":11278,"children":11279},{"style":174},[11280],{"type":34,"value":11281}," generate",{"type":29,"tag":88,"props":11283,"children":11284},{"style":122},[11285],{"type":34,"value":181},{"type":29,"tag":88,"props":11287,"children":11288},{"style":151},[11289],{"type":34,"value":9538},{"type":29,"tag":88,"props":11291,"children":11292},{"style":298},[11293],{"type":34,"value":11294}," employee",{"type":29,"tag":88,"props":11296,"children":11297},{"style":122},[11298],{"type":34,"value":306},{"type":29,"tag":88,"props":11300,"children":11301},{"style":122},[11302],{"type":34,"value":125},{"type":29,"tag":88,"props":11304,"children":11305},{"class":90,"line":792},[11306],{"type":29,"tag":88,"props":11307,"children":11308},{"style":95},[11309],{"type":34,"value":11310},"        \u002F\u002F Code pour générer un rapport pour cet employé\n",{"type":29,"tag":88,"props":11312,"children":11313},{"class":90,"line":817},[11314],{"type":29,"tag":88,"props":11315,"children":11316},{"style":122},[11317],{"type":34,"value":433},{"type":29,"tag":88,"props":11319,"children":11320},{"class":90,"line":825},[11321],{"type":29,"tag":88,"props":11322,"children":11323},{"style":122},[11324],{"type":34,"value":442},{"type":29,"tag":88,"props":11326,"children":11327},{"class":90,"line":869},[11328],{"type":29,"tag":88,"props":11329,"children":11330},{"emptyLinePlaceholder":13},[11331],{"type":34,"value":134},{"type":29,"tag":88,"props":11333,"children":11334},{"class":90,"line":900},[11335,11339,11343,11348],{"type":29,"tag":88,"props":11336,"children":11337},{"style":105},[11338],{"type":34,"value":108},{"type":29,"tag":88,"props":11340,"children":11341},{"style":105},[11342],{"type":34,"value":113},{"type":29,"tag":88,"props":11344,"children":11345},{"style":116},[11346],{"type":34,"value":11347}," SalaryProcessor",{"type":29,"tag":88,"props":11349,"children":11350},{"style":122},[11351],{"type":34,"value":125},{"type":29,"tag":88,"props":11353,"children":11354},{"class":90,"line":929},[11355,11359,11363,11368,11372,11376,11380,11384],{"type":29,"tag":88,"props":11356,"children":11357},{"style":105},[11358],{"type":34,"value":276},{"type":29,"tag":88,"props":11360,"children":11361},{"style":105},[11362],{"type":34,"value":1303},{"type":29,"tag":88,"props":11364,"children":11365},{"style":174},[11366],{"type":34,"value":11367}," process",{"type":29,"tag":88,"props":11369,"children":11370},{"style":122},[11371],{"type":34,"value":181},{"type":29,"tag":88,"props":11373,"children":11374},{"style":151},[11375],{"type":34,"value":9538},{"type":29,"tag":88,"props":11377,"children":11378},{"style":298},[11379],{"type":34,"value":11294},{"type":29,"tag":88,"props":11381,"children":11382},{"style":122},[11383],{"type":34,"value":306},{"type":29,"tag":88,"props":11385,"children":11386},{"style":122},[11387],{"type":34,"value":125},{"type":29,"tag":88,"props":11389,"children":11390},{"class":90,"line":937},[11391],{"type":29,"tag":88,"props":11392,"children":11393},{"style":95},[11394],{"type":34,"value":10870},{"type":29,"tag":88,"props":11396,"children":11397},{"class":90,"line":945},[11398],{"type":29,"tag":88,"props":11399,"children":11400},{"style":122},[11401],{"type":34,"value":433},{"type":29,"tag":88,"props":11403,"children":11404},{"class":90,"line":981},[11405],{"type":29,"tag":88,"props":11406,"children":11407},{"style":122},[11408],{"type":34,"value":442},{"type":29,"tag":30,"props":11410,"children":11411},{},[11412],{"type":34,"value":11413},"Dans cet exemple, chaque classe a une responsabilité claire et distincte, ce qui facilite les modifications et les extensions futures.",{"type":29,"tag":8542,"props":11415,"children":11417},{"id":11416},"_2-le-principe-solid",[11418],{"type":34,"value":11419},"2. Le principe SOLID",{"type":29,"tag":30,"props":11421,"children":11422},{},[11423,11425,11429],{"type":34,"value":11424},"Les ",{"type":29,"tag":63,"props":11426,"children":11427},{"href":9965},[11428],{"type":34,"value":9968},{"type":34,"value":11430}," sont cinq règles de base pour la conception de logiciels évolutifs et maintenables, formalisés notamment par Robert C. Martin dans \"Clean Code\" et approfondis par Martin Fowler dans \"Refactoring\". Voici une rapide explication de chacun de ces principes :",{"type":29,"tag":453,"props":11432,"children":11433},{},[11434,11457,11492,11513,11534],{"type":29,"tag":457,"props":11435,"children":11436},{},[11437,11442,11444,11449,11451,11455],{"type":29,"tag":447,"props":11438,"children":11439},{},[11440],{"type":34,"value":11441},"S",{"type":34,"value":11443}," : ",{"type":29,"tag":447,"props":11445,"children":11446},{},[11447],{"type":34,"value":11448},"Single Responsibility Principle",{"type":34,"value":11450}," (Principe de responsabilité unique)",{"type":29,"tag":11452,"props":11453,"children":11454},"br",{},[],{"type":34,"value":11456},"\nUne classe ne doit avoir qu'une seule raison de changer, c'est-à-dire qu'elle ne doit être responsable que d'une seule fonctionnalité ou tâche.",{"type":29,"tag":457,"props":11458,"children":11459},{},[11460,11465,11466,11471,11473,11476,11478,11483,11485,11490],{"type":29,"tag":447,"props":11461,"children":11462},{},[11463],{"type":34,"value":11464},"O",{"type":34,"value":11443},{"type":29,"tag":447,"props":11467,"children":11468},{},[11469],{"type":34,"value":11470},"Open\u002FClosed Principle",{"type":34,"value":11472}," (Principe ouvert\u002Ffermé)",{"type":29,"tag":11452,"props":11474,"children":11475},{},[],{"type":34,"value":11477},"\nVotre code doit être ",{"type":29,"tag":447,"props":11479,"children":11480},{},[11481],{"type":34,"value":11482},"ouvert",{"type":34,"value":11484}," à l’extension mais ",{"type":29,"tag":447,"props":11486,"children":11487},{},[11488],{"type":34,"value":11489},"fermé",{"type":34,"value":11491}," à la modification. Cela signifie que vous devez pouvoir ajouter de nouvelles fonctionnalités sans modifier le code existant.",{"type":29,"tag":457,"props":11493,"children":11494},{},[11495,11500,11501,11506,11508,11511],{"type":29,"tag":447,"props":11496,"children":11497},{},[11498],{"type":34,"value":11499},"L",{"type":34,"value":11443},{"type":29,"tag":447,"props":11502,"children":11503},{},[11504],{"type":34,"value":11505},"Liskov Substitution Principle",{"type":34,"value":11507}," (Principe de substitution de Liskov)",{"type":29,"tag":11452,"props":11509,"children":11510},{},[],{"type":34,"value":11512},"\nLes objets d'une sous-classe doivent pouvoir remplacer les objets de leur classe parente sans altérer le comportement du programme.",{"type":29,"tag":457,"props":11514,"children":11515},{},[11516,11521,11522,11527,11529,11532],{"type":29,"tag":447,"props":11517,"children":11518},{},[11519],{"type":34,"value":11520},"I",{"type":34,"value":11443},{"type":29,"tag":447,"props":11523,"children":11524},{},[11525],{"type":34,"value":11526},"Interface Segregation Principle",{"type":34,"value":11528}," (Principe de ségrégation des interfaces)",{"type":29,"tag":11452,"props":11530,"children":11531},{},[],{"type":34,"value":11533},"\nIl est préférable de créer plusieurs interfaces spécifiques plutôt qu'une interface générale qui contient trop de méthodes inutiles pour certaines classes.",{"type":29,"tag":457,"props":11535,"children":11536},{},[11537,11542,11543,11550],{"type":29,"tag":447,"props":11538,"children":11539},{},[11540],{"type":34,"value":11541},"D",{"type":34,"value":11443},{"type":29,"tag":447,"props":11544,"children":11545},{},[11546],{"type":29,"tag":63,"props":11547,"children":11548},{"href":5},[11549],{"type":34,"value":5883},{"type":34,"value":11551}," (Principe d'inversion des dépendances)\nLes modules de haut niveau ne doivent pas dépendre des modules de bas niveau. Les deux devraient dépendre d'abstractions. En d'autres termes, utilisez des interfaces pour réduire le couplage entre les classes.",{"type":29,"tag":10576,"props":11553,"children":11555},{"id":11554},"_3-lencapsulation-et-labstraction",[11556],{"type":34,"value":11557},"3. L'encapsulation et l'abstraction",{"type":29,"tag":30,"props":11559,"children":11560},{},[11561],{"type":34,"value":11562},"L'encapsulation protège les données en les rendant inaccessibles directement depuis l'extérieur d'une classe. Vous exposez uniquement ce qui est nécessaire via des méthodes publiques. Vous contrôlez ainsi comment les autres parties du programme interagissent avec la classe, et vous pouvez la modifier sans impacter le reste.",{"type":29,"tag":30,"props":11564,"children":11565},{},[11566,11568,11573,11575,11580],{"type":34,"value":11567},"L'abstraction, quant à elle, consiste à simplifier la complexité en cachant les détails d'implémentation. En utilisant des interfaces et des classes abstraites, vous pouvez vous concentrer sur ",{"type":29,"tag":447,"props":11569,"children":11570},{},[11571],{"type":34,"value":11572},"quoi",{"type":34,"value":11574}," une classe fait, sans vous soucier de ",{"type":29,"tag":447,"props":11576,"children":11577},{},[11578],{"type":34,"value":11579},"comment",{"type":34,"value":11581}," elle le fait.",{"type":29,"tag":77,"props":11583,"children":11585},{"className":81,"code":11584,"language":80,"meta":8,"style":8},"public interface PaymentMethod {\n    void pay(double amount);\n}\n\npublic class CreditCardPayment implements PaymentMethod {\n    public void pay(double amount) {\n        \u002F\u002F Implémentation du paiement par carte de crédit\n    }\n}\n\npublic class PayPalPayment implements PaymentMethod {\n    public void pay(double amount) {\n        \u002F\u002F Implémentation du paiement via PayPal\n    }\n}\n",[11586],{"type":29,"tag":84,"props":11587,"children":11588},{"__ignoreMap":8},[11589,11609,11638,11645,11652,11680,11715,11723,11730,11737,11744,11772,11807,11815,11822],{"type":29,"tag":88,"props":11590,"children":11591},{"class":90,"line":91},[11592,11596,11600,11605],{"type":29,"tag":88,"props":11593,"children":11594},{"style":105},[11595],{"type":34,"value":108},{"type":29,"tag":88,"props":11597,"children":11598},{"style":105},[11599],{"type":34,"value":601},{"type":29,"tag":88,"props":11601,"children":11602},{"style":116},[11603],{"type":34,"value":11604}," PaymentMethod",{"type":29,"tag":88,"props":11606,"children":11607},{"style":122},[11608],{"type":34,"value":125},{"type":29,"tag":88,"props":11610,"children":11611},{"class":90,"line":101},[11612,11616,11621,11625,11630,11634],{"type":29,"tag":88,"props":11613,"children":11614},{"style":105},[11615],{"type":34,"value":681},{"type":29,"tag":88,"props":11617,"children":11618},{"style":174},[11619],{"type":34,"value":11620}," pay",{"type":29,"tag":88,"props":11622,"children":11623},{"style":122},[11624],{"type":34,"value":181},{"type":29,"tag":88,"props":11626,"children":11627},{"style":105},[11628],{"type":34,"value":11629},"double",{"type":29,"tag":88,"props":11631,"children":11632},{"style":298},[11633],{"type":34,"value":2472},{"type":29,"tag":88,"props":11635,"children":11636},{"style":122},[11637],{"type":34,"value":357},{"type":29,"tag":88,"props":11639,"children":11640},{"class":90,"line":128},[11641],{"type":29,"tag":88,"props":11642,"children":11643},{"style":122},[11644],{"type":34,"value":442},{"type":29,"tag":88,"props":11646,"children":11647},{"class":90,"line":137},[11648],{"type":29,"tag":88,"props":11649,"children":11650},{"emptyLinePlaceholder":13},[11651],{"type":34,"value":134},{"type":29,"tag":88,"props":11653,"children":11654},{"class":90,"line":211},[11655,11659,11663,11668,11672,11676],{"type":29,"tag":88,"props":11656,"children":11657},{"style":105},[11658],{"type":34,"value":108},{"type":29,"tag":88,"props":11660,"children":11661},{"style":105},[11662],{"type":34,"value":113},{"type":29,"tag":88,"props":11664,"children":11665},{"style":116},[11666],{"type":34,"value":11667}," CreditCardPayment",{"type":29,"tag":88,"props":11669,"children":11670},{"style":105},[11671],{"type":34,"value":1134},{"type":29,"tag":88,"props":11673,"children":11674},{"style":116},[11675],{"type":34,"value":11604},{"type":29,"tag":88,"props":11677,"children":11678},{"style":122},[11679],{"type":34,"value":125},{"type":29,"tag":88,"props":11681,"children":11682},{"class":90,"line":262},[11683,11687,11691,11695,11699,11703,11707,11711],{"type":29,"tag":88,"props":11684,"children":11685},{"style":105},[11686],{"type":34,"value":276},{"type":29,"tag":88,"props":11688,"children":11689},{"style":105},[11690],{"type":34,"value":1303},{"type":29,"tag":88,"props":11692,"children":11693},{"style":174},[11694],{"type":34,"value":11620},{"type":29,"tag":88,"props":11696,"children":11697},{"style":122},[11698],{"type":34,"value":181},{"type":29,"tag":88,"props":11700,"children":11701},{"style":105},[11702],{"type":34,"value":11629},{"type":29,"tag":88,"props":11704,"children":11705},{"style":298},[11706],{"type":34,"value":2472},{"type":29,"tag":88,"props":11708,"children":11709},{"style":122},[11710],{"type":34,"value":306},{"type":29,"tag":88,"props":11712,"children":11713},{"style":122},[11714],{"type":34,"value":125},{"type":29,"tag":88,"props":11716,"children":11717},{"class":90,"line":270},[11718],{"type":29,"tag":88,"props":11719,"children":11720},{"style":95},[11721],{"type":34,"value":11722},"        \u002F\u002F Implémentation du paiement par carte de crédit\n",{"type":29,"tag":88,"props":11724,"children":11725},{"class":90,"line":313},[11726],{"type":29,"tag":88,"props":11727,"children":11728},{"style":122},[11729],{"type":34,"value":433},{"type":29,"tag":88,"props":11731,"children":11732},{"class":90,"line":360},[11733],{"type":29,"tag":88,"props":11734,"children":11735},{"style":122},[11736],{"type":34,"value":442},{"type":29,"tag":88,"props":11738,"children":11739},{"class":90,"line":409},[11740],{"type":29,"tag":88,"props":11741,"children":11742},{"emptyLinePlaceholder":13},[11743],{"type":34,"value":134},{"type":29,"tag":88,"props":11745,"children":11746},{"class":90,"line":427},[11747,11751,11755,11760,11764,11768],{"type":29,"tag":88,"props":11748,"children":11749},{"style":105},[11750],{"type":34,"value":108},{"type":29,"tag":88,"props":11752,"children":11753},{"style":105},[11754],{"type":34,"value":113},{"type":29,"tag":88,"props":11756,"children":11757},{"style":116},[11758],{"type":34,"value":11759}," PayPalPayment",{"type":29,"tag":88,"props":11761,"children":11762},{"style":105},[11763],{"type":34,"value":1134},{"type":29,"tag":88,"props":11765,"children":11766},{"style":116},[11767],{"type":34,"value":11604},{"type":29,"tag":88,"props":11769,"children":11770},{"style":122},[11771],{"type":34,"value":125},{"type":29,"tag":88,"props":11773,"children":11774},{"class":90,"line":436},[11775,11779,11783,11787,11791,11795,11799,11803],{"type":29,"tag":88,"props":11776,"children":11777},{"style":105},[11778],{"type":34,"value":276},{"type":29,"tag":88,"props":11780,"children":11781},{"style":105},[11782],{"type":34,"value":1303},{"type":29,"tag":88,"props":11784,"children":11785},{"style":174},[11786],{"type":34,"value":11620},{"type":29,"tag":88,"props":11788,"children":11789},{"style":122},[11790],{"type":34,"value":181},{"type":29,"tag":88,"props":11792,"children":11793},{"style":105},[11794],{"type":34,"value":11629},{"type":29,"tag":88,"props":11796,"children":11797},{"style":298},[11798],{"type":34,"value":2472},{"type":29,"tag":88,"props":11800,"children":11801},{"style":122},[11802],{"type":34,"value":306},{"type":29,"tag":88,"props":11804,"children":11805},{"style":122},[11806],{"type":34,"value":125},{"type":29,"tag":88,"props":11808,"children":11809},{"class":90,"line":767},[11810],{"type":29,"tag":88,"props":11811,"children":11812},{"style":95},[11813],{"type":34,"value":11814},"        \u002F\u002F Implémentation du paiement via PayPal\n",{"type":29,"tag":88,"props":11816,"children":11817},{"class":90,"line":792},[11818],{"type":29,"tag":88,"props":11819,"children":11820},{"style":122},[11821],{"type":34,"value":433},{"type":29,"tag":88,"props":11823,"children":11824},{"class":90,"line":817},[11825],{"type":29,"tag":88,"props":11826,"children":11827},{"style":122},[11828],{"type":34,"value":442},{"type":29,"tag":30,"props":11830,"children":11831},{},[11832,11834,11840],{"type":34,"value":11833},"Dans cet exemple, l’interface ",{"type":29,"tag":84,"props":11835,"children":11837},{"className":11836},[],[11838],{"type":34,"value":11839},"PaymentMethod",{"type":34,"value":11841}," permet d’utiliser différentes méthodes de paiement sans changer le reste du code qui gère les paiements.",{"type":29,"tag":47,"props":11843,"children":11844},{},[],{"type":29,"tag":51,"props":11846,"children":11848},{"id":11847},"meilleures-pratiques-pour-un-code-évolutif-en-java",[11849],{"type":34,"value":11850},"Meilleures pratiques pour un code évolutif en Java",{"type":29,"tag":30,"props":11852,"children":11853},{},[11854],{"type":34,"value":11855},"Maintenant que vous avez une bonne compréhension des principes de base, voyons comment appliquer ces concepts dans un projet Java. Les bonnes pratiques suivantes vous aideront à écrire du code évolutif dans vos applications Java.",{"type":29,"tag":8542,"props":11857,"children":11859},{"id":11858},"_1-structurer-les-classes-de-manière-logique",[11860],{"type":34,"value":11861},"1. Structurer les classes de manière logique",{"type":29,"tag":30,"props":11863,"children":11864},{},[11865,11867,11872],{"type":34,"value":11866},"Une bonne organisation des classes est cruciale pour la lisibilité et l'évolutivité du code. Je vous recommande de garder vos classes focalisées sur des tâches spécifiques et d'éviter les classes dites \"god objects\" qui s'occupent de tout. Structurez vos classes de manière à ce qu'elles respectent le principe de ",{"type":29,"tag":447,"props":11868,"children":11869},{},[11870],{"type":34,"value":11871},"responsabilité unique",{"type":34,"value":338},{"type":29,"tag":77,"props":11874,"children":11876},{"className":81,"code":11875,"language":80,"meta":8,"style":8},"\u002F\u002F Classe pour gérer les informations de l'employé\npublic class Employee {\n    private String name;\n    private String department;\n\n    \u002F\u002F Getters et Setters\n}\n\n\u002F\u002F Classe pour calculer le salaire\npublic class SalaryService {\n    public double calculateSalary(Employee employee) {\n        \u002F\u002F Logique pour calculer le salaire\n    }\n}\n\n\u002F\u002F Classe pour générer un rapport\npublic class ReportService {\n    public String generateReport(Employee employee) {\n        \u002F\u002F Logique pour générer un rapport\n    }\n}\n",[11877],{"type":29,"tag":84,"props":11878,"children":11879},{"__ignoreMap":8},[11880,11887,11906,11925,11945,11952,11960,11967,11974,11982,12002,12038,12046,12053,12060,12067,12075,12095,12130,12138,12145],{"type":29,"tag":88,"props":11881,"children":11882},{"class":90,"line":91},[11883],{"type":29,"tag":88,"props":11884,"children":11885},{"style":95},[11886],{"type":34,"value":11063},{"type":29,"tag":88,"props":11888,"children":11889},{"class":90,"line":101},[11890,11894,11898,11902],{"type":29,"tag":88,"props":11891,"children":11892},{"style":105},[11893],{"type":34,"value":108},{"type":29,"tag":88,"props":11895,"children":11896},{"style":105},[11897],{"type":34,"value":113},{"type":29,"tag":88,"props":11899,"children":11900},{"style":116},[11901],{"type":34,"value":10627},{"type":29,"tag":88,"props":11903,"children":11904},{"style":122},[11905],{"type":34,"value":125},{"type":29,"tag":88,"props":11907,"children":11908},{"class":90,"line":128},[11909,11913,11917,11921],{"type":29,"tag":88,"props":11910,"children":11911},{"style":105},[11912],{"type":34,"value":143},{"type":29,"tag":88,"props":11914,"children":11915},{"style":151},[11916],{"type":34,"value":281},{"type":29,"tag":88,"props":11918,"children":11919},{"style":157},[11920],{"type":34,"value":10647},{"type":29,"tag":88,"props":11922,"children":11923},{"style":122},[11924],{"type":34,"value":424},{"type":29,"tag":88,"props":11926,"children":11927},{"class":90,"line":137},[11928,11932,11936,11941],{"type":29,"tag":88,"props":11929,"children":11930},{"style":105},[11931],{"type":34,"value":143},{"type":29,"tag":88,"props":11933,"children":11934},{"style":151},[11935],{"type":34,"value":281},{"type":29,"tag":88,"props":11937,"children":11938},{"style":157},[11939],{"type":34,"value":11940}," department",{"type":29,"tag":88,"props":11942,"children":11943},{"style":122},[11944],{"type":34,"value":424},{"type":29,"tag":88,"props":11946,"children":11947},{"class":90,"line":211},[11948],{"type":29,"tag":88,"props":11949,"children":11950},{"emptyLinePlaceholder":13},[11951],{"type":34,"value":134},{"type":29,"tag":88,"props":11953,"children":11954},{"class":90,"line":262},[11955],{"type":29,"tag":88,"props":11956,"children":11957},{"style":95},[11958],{"type":34,"value":11959},"    \u002F\u002F Getters et Setters\n",{"type":29,"tag":88,"props":11961,"children":11962},{"class":90,"line":270},[11963],{"type":29,"tag":88,"props":11964,"children":11965},{"style":122},[11966],{"type":34,"value":442},{"type":29,"tag":88,"props":11968,"children":11969},{"class":90,"line":313},[11970],{"type":29,"tag":88,"props":11971,"children":11972},{"emptyLinePlaceholder":13},[11973],{"type":34,"value":134},{"type":29,"tag":88,"props":11975,"children":11976},{"class":90,"line":360},[11977],{"type":29,"tag":88,"props":11978,"children":11979},{"style":95},[11980],{"type":34,"value":11981},"\u002F\u002F Classe pour calculer le salaire\n",{"type":29,"tag":88,"props":11983,"children":11984},{"class":90,"line":409},[11985,11989,11993,11998],{"type":29,"tag":88,"props":11986,"children":11987},{"style":105},[11988],{"type":34,"value":108},{"type":29,"tag":88,"props":11990,"children":11991},{"style":105},[11992],{"type":34,"value":113},{"type":29,"tag":88,"props":11994,"children":11995},{"style":116},[11996],{"type":34,"value":11997}," SalaryService",{"type":29,"tag":88,"props":11999,"children":12000},{"style":122},[12001],{"type":34,"value":125},{"type":29,"tag":88,"props":12003,"children":12004},{"class":90,"line":427},[12005,12009,12013,12018,12022,12026,12030,12034],{"type":29,"tag":88,"props":12006,"children":12007},{"style":105},[12008],{"type":34,"value":276},{"type":29,"tag":88,"props":12010,"children":12011},{"style":105},[12012],{"type":34,"value":10663},{"type":29,"tag":88,"props":12014,"children":12015},{"style":174},[12016],{"type":34,"value":12017}," calculateSalary",{"type":29,"tag":88,"props":12019,"children":12020},{"style":122},[12021],{"type":34,"value":181},{"type":29,"tag":88,"props":12023,"children":12024},{"style":151},[12025],{"type":34,"value":9538},{"type":29,"tag":88,"props":12027,"children":12028},{"style":298},[12029],{"type":34,"value":11294},{"type":29,"tag":88,"props":12031,"children":12032},{"style":122},[12033],{"type":34,"value":306},{"type":29,"tag":88,"props":12035,"children":12036},{"style":122},[12037],{"type":34,"value":125},{"type":29,"tag":88,"props":12039,"children":12040},{"class":90,"line":436},[12041],{"type":29,"tag":88,"props":12042,"children":12043},{"style":95},[12044],{"type":34,"value":12045},"        \u002F\u002F Logique pour calculer le salaire\n",{"type":29,"tag":88,"props":12047,"children":12048},{"class":90,"line":767},[12049],{"type":29,"tag":88,"props":12050,"children":12051},{"style":122},[12052],{"type":34,"value":433},{"type":29,"tag":88,"props":12054,"children":12055},{"class":90,"line":792},[12056],{"type":29,"tag":88,"props":12057,"children":12058},{"style":122},[12059],{"type":34,"value":442},{"type":29,"tag":88,"props":12061,"children":12062},{"class":90,"line":817},[12063],{"type":29,"tag":88,"props":12064,"children":12065},{"emptyLinePlaceholder":13},[12066],{"type":34,"value":134},{"type":29,"tag":88,"props":12068,"children":12069},{"class":90,"line":825},[12070],{"type":29,"tag":88,"props":12071,"children":12072},{"style":95},[12073],{"type":34,"value":12074},"\u002F\u002F Classe pour générer un rapport\n",{"type":29,"tag":88,"props":12076,"children":12077},{"class":90,"line":869},[12078,12082,12086,12091],{"type":29,"tag":88,"props":12079,"children":12080},{"style":105},[12081],{"type":34,"value":108},{"type":29,"tag":88,"props":12083,"children":12084},{"style":105},[12085],{"type":34,"value":113},{"type":29,"tag":88,"props":12087,"children":12088},{"style":116},[12089],{"type":34,"value":12090}," ReportService",{"type":29,"tag":88,"props":12092,"children":12093},{"style":122},[12094],{"type":34,"value":125},{"type":29,"tag":88,"props":12096,"children":12097},{"class":90,"line":900},[12098,12102,12106,12110,12114,12118,12122,12126],{"type":29,"tag":88,"props":12099,"children":12100},{"style":105},[12101],{"type":34,"value":276},{"type":29,"tag":88,"props":12103,"children":12104},{"style":151},[12105],{"type":34,"value":281},{"type":29,"tag":88,"props":12107,"children":12108},{"style":174},[12109],{"type":34,"value":10808},{"type":29,"tag":88,"props":12111,"children":12112},{"style":122},[12113],{"type":34,"value":181},{"type":29,"tag":88,"props":12115,"children":12116},{"style":151},[12117],{"type":34,"value":9538},{"type":29,"tag":88,"props":12119,"children":12120},{"style":298},[12121],{"type":34,"value":11294},{"type":29,"tag":88,"props":12123,"children":12124},{"style":122},[12125],{"type":34,"value":306},{"type":29,"tag":88,"props":12127,"children":12128},{"style":122},[12129],{"type":34,"value":125},{"type":29,"tag":88,"props":12131,"children":12132},{"class":90,"line":929},[12133],{"type":29,"tag":88,"props":12134,"children":12135},{"style":95},[12136],{"type":34,"value":12137},"        \u002F\u002F Logique pour générer un rapport\n",{"type":29,"tag":88,"props":12139,"children":12140},{"class":90,"line":937},[12141],{"type":29,"tag":88,"props":12142,"children":12143},{"style":122},[12144],{"type":34,"value":433},{"type":29,"tag":88,"props":12146,"children":12147},{"class":90,"line":945},[12148],{"type":29,"tag":88,"props":12149,"children":12150},{"style":122},[12151],{"type":34,"value":442},{"type":29,"tag":8542,"props":12153,"children":12155},{"id":12154},"_2-utiliser-des-patrons-de-conception-design-patterns",[12156],{"type":34,"value":12157},"2. Utiliser des patrons de conception (design patterns)",{"type":29,"tag":30,"props":12159,"children":12160},{},[12161,12162,12167],{"type":34,"value":11424},{"type":29,"tag":447,"props":12163,"children":12164},{},[12165],{"type":34,"value":12166},"patrons de conception",{"type":34,"value":12168}," sont des solutions éprouvées pour résoudre des problèmes courants de conception dans le développement logiciel. Voici quelques-uns des patrons les plus utiles pour écrire du code évolutif en Java :",{"type":29,"tag":453,"props":12170,"children":12171},{},[12172,12182,12192],{"type":29,"tag":457,"props":12173,"children":12174},{},[12175,12180],{"type":29,"tag":447,"props":12176,"children":12177},{},[12178],{"type":34,"value":12179},"Patron Singleton",{"type":34,"value":12181}," : Garantit qu'une classe n'a qu'une seule instance, souvent utilisé pour des services globaux.",{"type":29,"tag":457,"props":12183,"children":12184},{},[12185,12190],{"type":29,"tag":447,"props":12186,"children":12187},{},[12188],{"type":34,"value":12189},"Patron Factory",{"type":34,"value":12191}," : Encapsule la création d'objets dans une méthode ou classe dédiée. Vous changez la façon de créer les objets sans toucher à la logique métier.",{"type":29,"tag":457,"props":12193,"children":12194},{},[12195,12200],{"type":29,"tag":447,"props":12196,"children":12197},{},[12198],{"type":34,"value":12199},"Patron Observer",{"type":34,"value":12201}," : Permet à une classe d'être avertie automatiquement lorsque certaines conditions changent dans une autre classe, utile pour les systèmes d'événements.",{"type":29,"tag":77,"props":12203,"children":12205},{"className":81,"code":12204,"language":80,"meta":8,"style":8},"\u002F\u002F Exemple simple d'un Singleton en Java\npublic class DatabaseConnection {\n    private static DatabaseConnection instance;\n\n    private DatabaseConnection() {\n        \u002F\u002F Constructeur privé pour éviter l'instanciation\n\n directe\n    }\n\n    public static DatabaseConnection getInstance() {\n        if (instance == null) {\n            instance = new DatabaseConnection();\n        }\n        return instance;\n    }\n}\n",[12206],{"type":29,"tag":84,"props":12207,"children":12208},{"__ignoreMap":8},[12209,12217,12237,12262,12269,12288,12296,12303,12311,12318,12325,12353,12386,12410,12417,12432,12439],{"type":29,"tag":88,"props":12210,"children":12211},{"class":90,"line":91},[12212],{"type":29,"tag":88,"props":12213,"children":12214},{"style":95},[12215],{"type":34,"value":12216},"\u002F\u002F Exemple simple d'un Singleton en Java\n",{"type":29,"tag":88,"props":12218,"children":12219},{"class":90,"line":101},[12220,12224,12228,12233],{"type":29,"tag":88,"props":12221,"children":12222},{"style":105},[12223],{"type":34,"value":108},{"type":29,"tag":88,"props":12225,"children":12226},{"style":105},[12227],{"type":34,"value":113},{"type":29,"tag":88,"props":12229,"children":12230},{"style":116},[12231],{"type":34,"value":12232}," DatabaseConnection",{"type":29,"tag":88,"props":12234,"children":12235},{"style":122},[12236],{"type":34,"value":125},{"type":29,"tag":88,"props":12238,"children":12239},{"class":90,"line":128},[12240,12244,12249,12253,12258],{"type":29,"tag":88,"props":12241,"children":12242},{"style":105},[12243],{"type":34,"value":143},{"type":29,"tag":88,"props":12245,"children":12246},{"style":105},[12247],{"type":34,"value":12248}," static",{"type":29,"tag":88,"props":12250,"children":12251},{"style":151},[12252],{"type":34,"value":12232},{"type":29,"tag":88,"props":12254,"children":12255},{"style":157},[12256],{"type":34,"value":12257}," instance",{"type":29,"tag":88,"props":12259,"children":12260},{"style":122},[12261],{"type":34,"value":424},{"type":29,"tag":88,"props":12263,"children":12264},{"class":90,"line":137},[12265],{"type":29,"tag":88,"props":12266,"children":12267},{"emptyLinePlaceholder":13},[12268],{"type":34,"value":134},{"type":29,"tag":88,"props":12270,"children":12271},{"class":90,"line":211},[12272,12276,12280,12284],{"type":29,"tag":88,"props":12273,"children":12274},{"style":105},[12275],{"type":34,"value":143},{"type":29,"tag":88,"props":12277,"children":12278},{"style":174},[12279],{"type":34,"value":12232},{"type":29,"tag":88,"props":12281,"children":12282},{"style":122},[12283],{"type":34,"value":1470},{"type":29,"tag":88,"props":12285,"children":12286},{"style":122},[12287],{"type":34,"value":125},{"type":29,"tag":88,"props":12289,"children":12290},{"class":90,"line":262},[12291],{"type":29,"tag":88,"props":12292,"children":12293},{"style":95},[12294],{"type":34,"value":12295},"        \u002F\u002F Constructeur privé pour éviter l'instanciation\n",{"type":29,"tag":88,"props":12297,"children":12298},{"class":90,"line":270},[12299],{"type":29,"tag":88,"props":12300,"children":12301},{"emptyLinePlaceholder":13},[12302],{"type":34,"value":134},{"type":29,"tag":88,"props":12304,"children":12305},{"class":90,"line":313},[12306],{"type":29,"tag":88,"props":12307,"children":12308},{"style":157},[12309],{"type":34,"value":12310}," directe\n",{"type":29,"tag":88,"props":12312,"children":12313},{"class":90,"line":360},[12314],{"type":29,"tag":88,"props":12315,"children":12316},{"style":122},[12317],{"type":34,"value":433},{"type":29,"tag":88,"props":12319,"children":12320},{"class":90,"line":409},[12321],{"type":29,"tag":88,"props":12322,"children":12323},{"emptyLinePlaceholder":13},[12324],{"type":34,"value":134},{"type":29,"tag":88,"props":12326,"children":12327},{"class":90,"line":427},[12328,12332,12336,12340,12345,12349],{"type":29,"tag":88,"props":12329,"children":12330},{"style":105},[12331],{"type":34,"value":276},{"type":29,"tag":88,"props":12333,"children":12334},{"style":105},[12335],{"type":34,"value":12248},{"type":29,"tag":88,"props":12337,"children":12338},{"style":151},[12339],{"type":34,"value":12232},{"type":29,"tag":88,"props":12341,"children":12342},{"style":174},[12343],{"type":34,"value":12344}," getInstance",{"type":29,"tag":88,"props":12346,"children":12347},{"style":122},[12348],{"type":34,"value":1470},{"type":29,"tag":88,"props":12350,"children":12351},{"style":122},[12352],{"type":34,"value":125},{"type":29,"tag":88,"props":12354,"children":12355},{"class":90,"line":436},[12356,12360,12364,12369,12374,12378,12382],{"type":29,"tag":88,"props":12357,"children":12358},{"style":105},[12359],{"type":34,"value":2886},{"type":29,"tag":88,"props":12361,"children":12362},{"style":122},[12363],{"type":34,"value":2891},{"type":29,"tag":88,"props":12365,"children":12366},{"style":157},[12367],{"type":34,"value":12368},"instance ",{"type":29,"tag":88,"props":12370,"children":12371},{"style":163},[12372],{"type":34,"value":12373},"==",{"type":29,"tag":88,"props":12375,"children":12376},{"style":873},[12377],{"type":34,"value":9747},{"type":29,"tag":88,"props":12379,"children":12380},{"style":122},[12381],{"type":34,"value":306},{"type":29,"tag":88,"props":12383,"children":12384},{"style":122},[12385],{"type":34,"value":125},{"type":29,"tag":88,"props":12387,"children":12388},{"class":90,"line":767},[12389,12394,12398,12402,12406],{"type":29,"tag":88,"props":12390,"children":12391},{"style":157},[12392],{"type":34,"value":12393},"            instance ",{"type":29,"tag":88,"props":12395,"children":12396},{"style":163},[12397],{"type":34,"value":166},{"type":29,"tag":88,"props":12399,"children":12400},{"style":105},[12401],{"type":34,"value":171},{"type":29,"tag":88,"props":12403,"children":12404},{"style":174},[12405],{"type":34,"value":12232},{"type":29,"tag":88,"props":12407,"children":12408},{"style":122},[12409],{"type":34,"value":1810},{"type":29,"tag":88,"props":12411,"children":12412},{"class":90,"line":792},[12413],{"type":29,"tag":88,"props":12414,"children":12415},{"style":122},[12416],{"type":34,"value":2966},{"type":29,"tag":88,"props":12418,"children":12419},{"class":90,"line":817},[12420,12424,12428],{"type":29,"tag":88,"props":12421,"children":12422},{"style":105},[12423],{"type":34,"value":415},{"type":29,"tag":88,"props":12425,"children":12426},{"style":157},[12427],{"type":34,"value":12257},{"type":29,"tag":88,"props":12429,"children":12430},{"style":122},[12431],{"type":34,"value":424},{"type":29,"tag":88,"props":12433,"children":12434},{"class":90,"line":825},[12435],{"type":29,"tag":88,"props":12436,"children":12437},{"style":122},[12438],{"type":34,"value":433},{"type":29,"tag":88,"props":12440,"children":12441},{"class":90,"line":869},[12442],{"type":29,"tag":88,"props":12443,"children":12444},{"style":122},[12445],{"type":34,"value":442},{"type":29,"tag":8542,"props":12447,"children":12449},{"id":12448},"_3-favoriser-le-couplage-faible",[12450],{"type":34,"value":12451},"3. Favoriser le couplage faible",{"type":29,"tag":30,"props":12453,"children":12454},{},[12455,12456,12461],{"type":34,"value":10213},{"type":29,"tag":447,"props":12457,"children":12458},{},[12459],{"type":34,"value":12460},"couplage faible",{"type":34,"value":12462}," signifie que vos classes et modules doivent être aussi indépendants que possible. Vous pouvez alors les modifier ou les remplacer sans affecter le reste. En Java, les interfaces sont l'outil principal pour réduire le couplage entre classes.",{"type":29,"tag":77,"props":12464,"children":12466},{"className":81,"code":12465,"language":80,"meta":8,"style":8},"\u002F\u002F Interface pour la méthode de paiement\npublic interface PaymentMethod {\n    void processPayment(double amount);\n}\n\n\u002F\u002F Implémentation de la méthode de paiement par carte\npublic class CreditCardPayment implements PaymentMethod {\n    public void processPayment(double amount) {\n        \u002F\u002F Logique de paiement par carte\n    }\n}\n\n\u002F\u002F Implémentation de la méthode de paiement via PayPal\npublic class PayPalPayment implements PaymentMethod {\n    public void processPayment(double amount) {\n        \u002F\u002F Logique de paiement PayPal\n    }\n}\n\n\u002F\u002F Utilisation de la méthode de paiement sans se soucier de l'implémentation\npublic class PaymentService {\n    private PaymentMethod paymentMethod;\n\n    public PaymentService(PaymentMethod paymentMethod) {\n        this.paymentMethod = paymentMethod;\n    }\n\n    public void executePayment(double amount) {\n        paymentMethod.processPayment(amount);\n    }\n}\n",[12467],{"type":29,"tag":84,"props":12468,"children":12469},{"__ignoreMap":8},[12470,12478,12497,12525,12532,12539,12547,12574,12609,12617,12624,12631,12638,12646,12673,12708,12716,12723,12730,12737,12745,12765,12785,12792,12823,12851,12858,12865,12901,12931,12938],{"type":29,"tag":88,"props":12471,"children":12472},{"class":90,"line":91},[12473],{"type":29,"tag":88,"props":12474,"children":12475},{"style":95},[12476],{"type":34,"value":12477},"\u002F\u002F Interface pour la méthode de paiement\n",{"type":29,"tag":88,"props":12479,"children":12480},{"class":90,"line":101},[12481,12485,12489,12493],{"type":29,"tag":88,"props":12482,"children":12483},{"style":105},[12484],{"type":34,"value":108},{"type":29,"tag":88,"props":12486,"children":12487},{"style":105},[12488],{"type":34,"value":601},{"type":29,"tag":88,"props":12490,"children":12491},{"style":116},[12492],{"type":34,"value":11604},{"type":29,"tag":88,"props":12494,"children":12495},{"style":122},[12496],{"type":34,"value":125},{"type":29,"tag":88,"props":12498,"children":12499},{"class":90,"line":128},[12500,12504,12509,12513,12517,12521],{"type":29,"tag":88,"props":12501,"children":12502},{"style":105},[12503],{"type":34,"value":681},{"type":29,"tag":88,"props":12505,"children":12506},{"style":174},[12507],{"type":34,"value":12508}," processPayment",{"type":29,"tag":88,"props":12510,"children":12511},{"style":122},[12512],{"type":34,"value":181},{"type":29,"tag":88,"props":12514,"children":12515},{"style":105},[12516],{"type":34,"value":11629},{"type":29,"tag":88,"props":12518,"children":12519},{"style":298},[12520],{"type":34,"value":2472},{"type":29,"tag":88,"props":12522,"children":12523},{"style":122},[12524],{"type":34,"value":357},{"type":29,"tag":88,"props":12526,"children":12527},{"class":90,"line":137},[12528],{"type":29,"tag":88,"props":12529,"children":12530},{"style":122},[12531],{"type":34,"value":442},{"type":29,"tag":88,"props":12533,"children":12534},{"class":90,"line":211},[12535],{"type":29,"tag":88,"props":12536,"children":12537},{"emptyLinePlaceholder":13},[12538],{"type":34,"value":134},{"type":29,"tag":88,"props":12540,"children":12541},{"class":90,"line":262},[12542],{"type":29,"tag":88,"props":12543,"children":12544},{"style":95},[12545],{"type":34,"value":12546},"\u002F\u002F Implémentation de la méthode de paiement par carte\n",{"type":29,"tag":88,"props":12548,"children":12549},{"class":90,"line":270},[12550,12554,12558,12562,12566,12570],{"type":29,"tag":88,"props":12551,"children":12552},{"style":105},[12553],{"type":34,"value":108},{"type":29,"tag":88,"props":12555,"children":12556},{"style":105},[12557],{"type":34,"value":113},{"type":29,"tag":88,"props":12559,"children":12560},{"style":116},[12561],{"type":34,"value":11667},{"type":29,"tag":88,"props":12563,"children":12564},{"style":105},[12565],{"type":34,"value":1134},{"type":29,"tag":88,"props":12567,"children":12568},{"style":116},[12569],{"type":34,"value":11604},{"type":29,"tag":88,"props":12571,"children":12572},{"style":122},[12573],{"type":34,"value":125},{"type":29,"tag":88,"props":12575,"children":12576},{"class":90,"line":313},[12577,12581,12585,12589,12593,12597,12601,12605],{"type":29,"tag":88,"props":12578,"children":12579},{"style":105},[12580],{"type":34,"value":276},{"type":29,"tag":88,"props":12582,"children":12583},{"style":105},[12584],{"type":34,"value":1303},{"type":29,"tag":88,"props":12586,"children":12587},{"style":174},[12588],{"type":34,"value":12508},{"type":29,"tag":88,"props":12590,"children":12591},{"style":122},[12592],{"type":34,"value":181},{"type":29,"tag":88,"props":12594,"children":12595},{"style":105},[12596],{"type":34,"value":11629},{"type":29,"tag":88,"props":12598,"children":12599},{"style":298},[12600],{"type":34,"value":2472},{"type":29,"tag":88,"props":12602,"children":12603},{"style":122},[12604],{"type":34,"value":306},{"type":29,"tag":88,"props":12606,"children":12607},{"style":122},[12608],{"type":34,"value":125},{"type":29,"tag":88,"props":12610,"children":12611},{"class":90,"line":360},[12612],{"type":29,"tag":88,"props":12613,"children":12614},{"style":95},[12615],{"type":34,"value":12616},"        \u002F\u002F Logique de paiement par carte\n",{"type":29,"tag":88,"props":12618,"children":12619},{"class":90,"line":409},[12620],{"type":29,"tag":88,"props":12621,"children":12622},{"style":122},[12623],{"type":34,"value":433},{"type":29,"tag":88,"props":12625,"children":12626},{"class":90,"line":427},[12627],{"type":29,"tag":88,"props":12628,"children":12629},{"style":122},[12630],{"type":34,"value":442},{"type":29,"tag":88,"props":12632,"children":12633},{"class":90,"line":436},[12634],{"type":29,"tag":88,"props":12635,"children":12636},{"emptyLinePlaceholder":13},[12637],{"type":34,"value":134},{"type":29,"tag":88,"props":12639,"children":12640},{"class":90,"line":767},[12641],{"type":29,"tag":88,"props":12642,"children":12643},{"style":95},[12644],{"type":34,"value":12645},"\u002F\u002F Implémentation de la méthode de paiement via PayPal\n",{"type":29,"tag":88,"props":12647,"children":12648},{"class":90,"line":792},[12649,12653,12657,12661,12665,12669],{"type":29,"tag":88,"props":12650,"children":12651},{"style":105},[12652],{"type":34,"value":108},{"type":29,"tag":88,"props":12654,"children":12655},{"style":105},[12656],{"type":34,"value":113},{"type":29,"tag":88,"props":12658,"children":12659},{"style":116},[12660],{"type":34,"value":11759},{"type":29,"tag":88,"props":12662,"children":12663},{"style":105},[12664],{"type":34,"value":1134},{"type":29,"tag":88,"props":12666,"children":12667},{"style":116},[12668],{"type":34,"value":11604},{"type":29,"tag":88,"props":12670,"children":12671},{"style":122},[12672],{"type":34,"value":125},{"type":29,"tag":88,"props":12674,"children":12675},{"class":90,"line":817},[12676,12680,12684,12688,12692,12696,12700,12704],{"type":29,"tag":88,"props":12677,"children":12678},{"style":105},[12679],{"type":34,"value":276},{"type":29,"tag":88,"props":12681,"children":12682},{"style":105},[12683],{"type":34,"value":1303},{"type":29,"tag":88,"props":12685,"children":12686},{"style":174},[12687],{"type":34,"value":12508},{"type":29,"tag":88,"props":12689,"children":12690},{"style":122},[12691],{"type":34,"value":181},{"type":29,"tag":88,"props":12693,"children":12694},{"style":105},[12695],{"type":34,"value":11629},{"type":29,"tag":88,"props":12697,"children":12698},{"style":298},[12699],{"type":34,"value":2472},{"type":29,"tag":88,"props":12701,"children":12702},{"style":122},[12703],{"type":34,"value":306},{"type":29,"tag":88,"props":12705,"children":12706},{"style":122},[12707],{"type":34,"value":125},{"type":29,"tag":88,"props":12709,"children":12710},{"class":90,"line":825},[12711],{"type":29,"tag":88,"props":12712,"children":12713},{"style":95},[12714],{"type":34,"value":12715},"        \u002F\u002F Logique de paiement PayPal\n",{"type":29,"tag":88,"props":12717,"children":12718},{"class":90,"line":869},[12719],{"type":29,"tag":88,"props":12720,"children":12721},{"style":122},[12722],{"type":34,"value":433},{"type":29,"tag":88,"props":12724,"children":12725},{"class":90,"line":900},[12726],{"type":29,"tag":88,"props":12727,"children":12728},{"style":122},[12729],{"type":34,"value":442},{"type":29,"tag":88,"props":12731,"children":12732},{"class":90,"line":929},[12733],{"type":29,"tag":88,"props":12734,"children":12735},{"emptyLinePlaceholder":13},[12736],{"type":34,"value":134},{"type":29,"tag":88,"props":12738,"children":12739},{"class":90,"line":937},[12740],{"type":29,"tag":88,"props":12741,"children":12742},{"style":95},[12743],{"type":34,"value":12744},"\u002F\u002F Utilisation de la méthode de paiement sans se soucier de l'implémentation\n",{"type":29,"tag":88,"props":12746,"children":12747},{"class":90,"line":945},[12748,12752,12756,12761],{"type":29,"tag":88,"props":12749,"children":12750},{"style":105},[12751],{"type":34,"value":108},{"type":29,"tag":88,"props":12753,"children":12754},{"style":105},[12755],{"type":34,"value":113},{"type":29,"tag":88,"props":12757,"children":12758},{"style":116},[12759],{"type":34,"value":12760}," PaymentService",{"type":29,"tag":88,"props":12762,"children":12763},{"style":122},[12764],{"type":34,"value":125},{"type":29,"tag":88,"props":12766,"children":12767},{"class":90,"line":981},[12768,12772,12776,12781],{"type":29,"tag":88,"props":12769,"children":12770},{"style":105},[12771],{"type":34,"value":143},{"type":29,"tag":88,"props":12773,"children":12774},{"style":151},[12775],{"type":34,"value":11604},{"type":29,"tag":88,"props":12777,"children":12778},{"style":157},[12779],{"type":34,"value":12780}," paymentMethod",{"type":29,"tag":88,"props":12782,"children":12783},{"style":122},[12784],{"type":34,"value":424},{"type":29,"tag":88,"props":12786,"children":12787},{"class":90,"line":1021},[12788],{"type":29,"tag":88,"props":12789,"children":12790},{"emptyLinePlaceholder":13},[12791],{"type":34,"value":134},{"type":29,"tag":88,"props":12793,"children":12794},{"class":90,"line":1066},[12795,12799,12803,12807,12811,12815,12819],{"type":29,"tag":88,"props":12796,"children":12797},{"style":105},[12798],{"type":34,"value":276},{"type":29,"tag":88,"props":12800,"children":12801},{"style":174},[12802],{"type":34,"value":12760},{"type":29,"tag":88,"props":12804,"children":12805},{"style":122},[12806],{"type":34,"value":181},{"type":29,"tag":88,"props":12808,"children":12809},{"style":151},[12810],{"type":34,"value":11839},{"type":29,"tag":88,"props":12812,"children":12813},{"style":298},[12814],{"type":34,"value":12780},{"type":29,"tag":88,"props":12816,"children":12817},{"style":122},[12818],{"type":34,"value":306},{"type":29,"tag":88,"props":12820,"children":12821},{"style":122},[12822],{"type":34,"value":125},{"type":29,"tag":88,"props":12824,"children":12825},{"class":90,"line":1082},[12826,12830,12834,12839,12843,12847],{"type":29,"tag":88,"props":12827,"children":12828},{"style":873},[12829],{"type":34,"value":876},{"type":29,"tag":88,"props":12831,"children":12832},{"style":122},[12833],{"type":34,"value":338},{"type":29,"tag":88,"props":12835,"children":12836},{"style":157},[12837],{"type":34,"value":12838},"paymentMethod ",{"type":29,"tag":88,"props":12840,"children":12841},{"style":163},[12842],{"type":34,"value":166},{"type":29,"tag":88,"props":12844,"children":12845},{"style":157},[12846],{"type":34,"value":12780},{"type":29,"tag":88,"props":12848,"children":12849},{"style":122},[12850],{"type":34,"value":424},{"type":29,"tag":88,"props":12852,"children":12853},{"class":90,"line":1090},[12854],{"type":29,"tag":88,"props":12855,"children":12856},{"style":122},[12857],{"type":34,"value":433},{"type":29,"tag":88,"props":12859,"children":12860},{"class":90,"line":1098},[12861],{"type":29,"tag":88,"props":12862,"children":12863},{"emptyLinePlaceholder":13},[12864],{"type":34,"value":134},{"type":29,"tag":88,"props":12866,"children":12867},{"class":90,"line":1106},[12868,12872,12876,12881,12885,12889,12893,12897],{"type":29,"tag":88,"props":12869,"children":12870},{"style":105},[12871],{"type":34,"value":276},{"type":29,"tag":88,"props":12873,"children":12874},{"style":105},[12875],{"type":34,"value":1303},{"type":29,"tag":88,"props":12877,"children":12878},{"style":174},[12879],{"type":34,"value":12880}," executePayment",{"type":29,"tag":88,"props":12882,"children":12883},{"style":122},[12884],{"type":34,"value":181},{"type":29,"tag":88,"props":12886,"children":12887},{"style":105},[12888],{"type":34,"value":11629},{"type":29,"tag":88,"props":12890,"children":12891},{"style":298},[12892],{"type":34,"value":2472},{"type":29,"tag":88,"props":12894,"children":12895},{"style":122},[12896],{"type":34,"value":306},{"type":29,"tag":88,"props":12898,"children":12899},{"style":122},[12900],{"type":34,"value":125},{"type":29,"tag":88,"props":12902,"children":12903},{"class":90,"line":1115},[12904,12909,12913,12918,12922,12927],{"type":29,"tag":88,"props":12905,"children":12906},{"style":157},[12907],{"type":34,"value":12908},"        paymentMethod",{"type":29,"tag":88,"props":12910,"children":12911},{"style":122},[12912],{"type":34,"value":338},{"type":29,"tag":88,"props":12914,"children":12915},{"style":174},[12916],{"type":34,"value":12917},"processPayment",{"type":29,"tag":88,"props":12919,"children":12920},{"style":122},[12921],{"type":34,"value":181},{"type":29,"tag":88,"props":12923,"children":12924},{"style":157},[12925],{"type":34,"value":12926},"amount",{"type":29,"tag":88,"props":12928,"children":12929},{"style":122},[12930],{"type":34,"value":357},{"type":29,"tag":88,"props":12932,"children":12933},{"class":90,"line":11},[12934],{"type":29,"tag":88,"props":12935,"children":12936},{"style":122},[12937],{"type":34,"value":433},{"type":29,"tag":88,"props":12939,"children":12940},{"class":90,"line":1180},[12941],{"type":29,"tag":88,"props":12942,"children":12943},{"style":122},[12944],{"type":34,"value":442},{"type":29,"tag":8542,"props":12946,"children":12948},{"id":12947},"_4-tests-automatisés-et-tdd",[12949],{"type":34,"value":12950},"4. Tests automatisés et TDD",{"type":29,"tag":30,"props":12952,"children":12953},{},[12954,12956,12961],{"type":34,"value":12955},"Les tests sont essentiels pour garantir que votre code fonctionne correctement après chaque modification. L'écriture de ",{"type":29,"tag":447,"props":12957,"children":12958},{},[12959],{"type":34,"value":12960},"tests unitaires",{"type":34,"value":12962}," aide à s'assurer que chaque module de votre code fonctionne comme prévu, tandis que les tests d'intégration garantissent que les modules fonctionnent bien ensemble.",{"type":29,"tag":30,"props":12964,"children":12965},{},[12966,12967,12972,12974,12979,12980,12985],{"type":34,"value":10145},{"type":29,"tag":447,"props":12968,"children":12969},{},[12970],{"type":34,"value":12971},"méthodologie TDD (Test-Driven Development)",{"type":34,"value":12973}," consiste à écrire d'abord les tests avant de coder. Cela garantit que le code que vous écrivez est toujours testable et évolutif. Avec Java, des frameworks comme ",{"type":29,"tag":447,"props":12975,"children":12976},{},[12977],{"type":34,"value":12978},"JUnit",{"type":34,"value":8982},{"type":29,"tag":447,"props":12981,"children":12982},{},[12983],{"type":34,"value":12984},"Mockito",{"type":34,"value":12986}," facilitent l'écriture de tests unitaires et de tests d'intégration.",{"type":29,"tag":77,"props":12988,"children":12990},{"className":81,"code":12989,"language":80,"meta":8,"style":8},"import static org.junit.Assert.assertEquals;\nimport org.junit.Test;\n\npublic class SalaryServiceTest {\n\n    @Test\n    public void testCalculateSalary() {\n        Employee employee = new Employee(\"John\", \"IT\");\n        SalaryService salaryService = new SalaryService();\n        double salary = salaryService.calculateSalary(employee);\n\n        assertEquals(3000, salary, 0.01); \u002F\u002F Vérifie si le salaire est bien calculé\n    }\n}\n",[12991],{"type":29,"tag":84,"props":12992,"children":12993},{"__ignoreMap":8},[12994,13042,13074,13081,13101,13108,13119,13143,13190,13219,13263,13270,13312,13319],{"type":29,"tag":88,"props":12995,"children":12996},{"class":90,"line":91},[12997,13002,13006,13011,13015,13020,13024,13029,13033,13038],{"type":29,"tag":88,"props":12998,"children":12999},{"style":105},[13000],{"type":34,"value":13001},"import",{"type":29,"tag":88,"props":13003,"children":13004},{"style":105},[13005],{"type":34,"value":12248},{"type":29,"tag":88,"props":13007,"children":13008},{"style":157},[13009],{"type":34,"value":13010}," org",{"type":29,"tag":88,"props":13012,"children":13013},{"style":122},[13014],{"type":34,"value":338},{"type":29,"tag":88,"props":13016,"children":13017},{"style":157},[13018],{"type":34,"value":13019},"junit",{"type":29,"tag":88,"props":13021,"children":13022},{"style":122},[13023],{"type":34,"value":338},{"type":29,"tag":88,"props":13025,"children":13026},{"style":157},[13027],{"type":34,"value":13028},"Assert",{"type":29,"tag":88,"props":13030,"children":13031},{"style":122},[13032],{"type":34,"value":338},{"type":29,"tag":88,"props":13034,"children":13035},{"style":157},[13036],{"type":34,"value":13037},"assertEquals",{"type":29,"tag":88,"props":13039,"children":13040},{"style":122},[13041],{"type":34,"value":424},{"type":29,"tag":88,"props":13043,"children":13044},{"class":90,"line":101},[13045,13049,13053,13057,13061,13065,13070],{"type":29,"tag":88,"props":13046,"children":13047},{"style":105},[13048],{"type":34,"value":13001},{"type":29,"tag":88,"props":13050,"children":13051},{"style":157},[13052],{"type":34,"value":13010},{"type":29,"tag":88,"props":13054,"children":13055},{"style":122},[13056],{"type":34,"value":338},{"type":29,"tag":88,"props":13058,"children":13059},{"style":157},[13060],{"type":34,"value":13019},{"type":29,"tag":88,"props":13062,"children":13063},{"style":122},[13064],{"type":34,"value":338},{"type":29,"tag":88,"props":13066,"children":13067},{"style":157},[13068],{"type":34,"value":13069},"Test",{"type":29,"tag":88,"props":13071,"children":13072},{"style":122},[13073],{"type":34,"value":424},{"type":29,"tag":88,"props":13075,"children":13076},{"class":90,"line":128},[13077],{"type":29,"tag":88,"props":13078,"children":13079},{"emptyLinePlaceholder":13},[13080],{"type":34,"value":134},{"type":29,"tag":88,"props":13082,"children":13083},{"class":90,"line":137},[13084,13088,13092,13097],{"type":29,"tag":88,"props":13085,"children":13086},{"style":105},[13087],{"type":34,"value":108},{"type":29,"tag":88,"props":13089,"children":13090},{"style":105},[13091],{"type":34,"value":113},{"type":29,"tag":88,"props":13093,"children":13094},{"style":116},[13095],{"type":34,"value":13096}," SalaryServiceTest",{"type":29,"tag":88,"props":13098,"children":13099},{"style":122},[13100],{"type":34,"value":125},{"type":29,"tag":88,"props":13102,"children":13103},{"class":90,"line":211},[13104],{"type":29,"tag":88,"props":13105,"children":13106},{"emptyLinePlaceholder":13},[13107],{"type":34,"value":134},{"type":29,"tag":88,"props":13109,"children":13110},{"class":90,"line":262},[13111,13115],{"type":29,"tag":88,"props":13112,"children":13113},{"style":1974},[13114],{"type":34,"value":3302},{"type":29,"tag":88,"props":13116,"children":13117},{"style":1980},[13118],{"type":34,"value":1983},{"type":29,"tag":88,"props":13120,"children":13121},{"class":90,"line":270},[13122,13126,13130,13135,13139],{"type":29,"tag":88,"props":13123,"children":13124},{"style":105},[13125],{"type":34,"value":276},{"type":29,"tag":88,"props":13127,"children":13128},{"style":105},[13129],{"type":34,"value":1303},{"type":29,"tag":88,"props":13131,"children":13132},{"style":174},[13133],{"type":34,"value":13134}," testCalculateSalary",{"type":29,"tag":88,"props":13136,"children":13137},{"style":122},[13138],{"type":34,"value":1470},{"type":29,"tag":88,"props":13140,"children":13141},{"style":122},[13142],{"type":34,"value":125},{"type":29,"tag":88,"props":13144,"children":13145},{"class":90,"line":313},[13146,13151,13156,13160,13164,13168,13172,13177,13181,13186],{"type":29,"tag":88,"props":13147,"children":13148},{"style":151},[13149],{"type":34,"value":13150},"        Employee",{"type":29,"tag":88,"props":13152,"children":13153},{"style":157},[13154],{"type":34,"value":13155}," employee ",{"type":29,"tag":88,"props":13157,"children":13158},{"style":163},[13159],{"type":34,"value":166},{"type":29,"tag":88,"props":13161,"children":13162},{"style":105},[13163],{"type":34,"value":171},{"type":29,"tag":88,"props":13165,"children":13166},{"style":174},[13167],{"type":34,"value":10627},{"type":29,"tag":88,"props":13169,"children":13170},{"style":122},[13171],{"type":34,"value":181},{"type":29,"tag":88,"props":13173,"children":13174},{"style":184},[13175],{"type":34,"value":13176},"\"John\"",{"type":29,"tag":88,"props":13178,"children":13179},{"style":122},[13180],{"type":34,"value":192},{"type":29,"tag":88,"props":13182,"children":13183},{"style":184},[13184],{"type":34,"value":13185}," \"IT\"",{"type":29,"tag":88,"props":13187,"children":13188},{"style":122},[13189],{"type":34,"value":357},{"type":29,"tag":88,"props":13191,"children":13192},{"class":90,"line":360},[13193,13198,13203,13207,13211,13215],{"type":29,"tag":88,"props":13194,"children":13195},{"style":151},[13196],{"type":34,"value":13197},"        SalaryService",{"type":29,"tag":88,"props":13199,"children":13200},{"style":157},[13201],{"type":34,"value":13202}," salaryService ",{"type":29,"tag":88,"props":13204,"children":13205},{"style":163},[13206],{"type":34,"value":166},{"type":29,"tag":88,"props":13208,"children":13209},{"style":105},[13210],{"type":34,"value":171},{"type":29,"tag":88,"props":13212,"children":13213},{"style":174},[13214],{"type":34,"value":11997},{"type":29,"tag":88,"props":13216,"children":13217},{"style":122},[13218],{"type":34,"value":1810},{"type":29,"tag":88,"props":13220,"children":13221},{"class":90,"line":409},[13222,13227,13232,13236,13241,13245,13250,13254,13259],{"type":29,"tag":88,"props":13223,"children":13224},{"style":105},[13225],{"type":34,"value":13226},"        double",{"type":29,"tag":88,"props":13228,"children":13229},{"style":157},[13230],{"type":34,"value":13231}," salary ",{"type":29,"tag":88,"props":13233,"children":13234},{"style":163},[13235],{"type":34,"value":166},{"type":29,"tag":88,"props":13237,"children":13238},{"style":157},[13239],{"type":34,"value":13240}," salaryService",{"type":29,"tag":88,"props":13242,"children":13243},{"style":122},[13244],{"type":34,"value":338},{"type":29,"tag":88,"props":13246,"children":13247},{"style":174},[13248],{"type":34,"value":13249},"calculateSalary",{"type":29,"tag":88,"props":13251,"children":13252},{"style":122},[13253],{"type":34,"value":181},{"type":29,"tag":88,"props":13255,"children":13256},{"style":157},[13257],{"type":34,"value":13258},"employee",{"type":29,"tag":88,"props":13260,"children":13261},{"style":122},[13262],{"type":34,"value":357},{"type":29,"tag":88,"props":13264,"children":13265},{"class":90,"line":427},[13266],{"type":29,"tag":88,"props":13267,"children":13268},{"emptyLinePlaceholder":13},[13269],{"type":34,"value":134},{"type":29,"tag":88,"props":13271,"children":13272},{"class":90,"line":436},[13273,13277,13281,13286,13290,13294,13298,13303,13307],{"type":29,"tag":88,"props":13274,"children":13275},{"style":174},[13276],{"type":34,"value":4285},{"type":29,"tag":88,"props":13278,"children":13279},{"style":122},[13280],{"type":34,"value":181},{"type":29,"tag":88,"props":13282,"children":13283},{"style":195},[13284],{"type":34,"value":13285},"3000",{"type":29,"tag":88,"props":13287,"children":13288},{"style":122},[13289],{"type":34,"value":192},{"type":29,"tag":88,"props":13291,"children":13292},{"style":157},[13293],{"type":34,"value":10668},{"type":29,"tag":88,"props":13295,"children":13296},{"style":122},[13297],{"type":34,"value":192},{"type":29,"tag":88,"props":13299,"children":13300},{"style":195},[13301],{"type":34,"value":13302}," 0.01",{"type":29,"tag":88,"props":13304,"children":13305},{"style":122},[13306],{"type":34,"value":203},{"type":29,"tag":88,"props":13308,"children":13309},{"style":95},[13310],{"type":34,"value":13311}," \u002F\u002F Vérifie si le salaire est bien calculé\n",{"type":29,"tag":88,"props":13313,"children":13314},{"class":90,"line":767},[13315],{"type":29,"tag":88,"props":13316,"children":13317},{"style":122},[13318],{"type":34,"value":433},{"type":29,"tag":88,"props":13320,"children":13321},{"class":90,"line":792},[13322],{"type":29,"tag":88,"props":13323,"children":13324},{"style":122},[13325],{"type":34,"value":442},{"type":29,"tag":47,"props":13327,"children":13328},{},[],{"type":29,"tag":51,"props":13330,"children":13332},{"id":13331},"exemples-pratiques-de-code-évolutif-en-java",[13333],{"type":34,"value":13334},"Exemples pratiques de code évolutif en Java",{"type":29,"tag":30,"props":13336,"children":13337},{},[13338],{"type":34,"value":13339},"Voici des exemples concrets qui montrent comment appliquer les principes d'écriture de code évolutif en Java. Vous verrez comment améliorer du code pour le rendre plus maintenable et évolutif. J'ai vu ces patterns se répéter dans des dizaines d'équipes que j'ai accompagnées, notamment dans des DSI bancaires où la dette structurelle s'accumule vite faute de séparation des responsabilités.",{"type":29,"tag":8542,"props":13341,"children":13343},{"id":13342},"exemple-1-application-du-principe-de-responsabilité-unique-srp",[13344],{"type":34,"value":13345},"Exemple 1 : Application du principe de Responsabilité unique (SRP)",{"type":29,"tag":30,"props":13347,"children":13348},{},[13349,13351,13356,13358,13363],{"type":34,"value":13350},"Prenons un exemple de code qui viole le ",{"type":29,"tag":447,"props":13352,"children":13353},{},[13354],{"type":34,"value":13355},"principe de responsabilité unique",{"type":34,"value":13357}," (SRP). Ici, une classe ",{"type":29,"tag":84,"props":13359,"children":13361},{"className":13360},[],[13362],{"type":34,"value":2386},{"type":34,"value":13364}," fait trop de choses à la fois, notamment gérer les détails de la commande, traiter le paiement et générer des factures.",{"type":29,"tag":10576,"props":13366,"children":13368},{"id":13367},"avant-code-non-évolutif",[13369],{"type":34,"value":13370},"Avant : Code non évolutif",{"type":29,"tag":77,"props":13372,"children":13374},{"className":81,"code":13373,"language":80,"meta":8,"style":8},"public class Order {\n    private String product;\n    private int quantity;\n    private double price;\n\n    public Order(String product, int quantity, double price) {\n        this.product = product;\n        this.quantity = quantity;\n        this.price = price;\n    }\n\n    public void processOrder() {\n        \u002F\u002F Logique pour traiter la commande\n    }\n\n    public void generateInvoice() {\n        \u002F\u002F Logique pour générer une facture\n    }\n\n    public void processPayment() {\n        \u002F\u002F Logique pour traiter le paiement\n    }\n}\n",[13375],{"type":29,"tag":84,"props":13376,"children":13377},{"__ignoreMap":8},[13378,13397,13417,13437,13457,13464,13519,13547,13575,13603,13610,13617,13640,13648,13655,13662,13686,13694,13701,13708,13731,13739,13746],{"type":29,"tag":88,"props":13379,"children":13380},{"class":90,"line":91},[13381,13385,13389,13393],{"type":29,"tag":88,"props":13382,"children":13383},{"style":105},[13384],{"type":34,"value":108},{"type":29,"tag":88,"props":13386,"children":13387},{"style":105},[13388],{"type":34,"value":113},{"type":29,"tag":88,"props":13390,"children":13391},{"style":116},[13392],{"type":34,"value":2740},{"type":29,"tag":88,"props":13394,"children":13395},{"style":122},[13396],{"type":34,"value":125},{"type":29,"tag":88,"props":13398,"children":13399},{"class":90,"line":101},[13400,13404,13408,13413],{"type":29,"tag":88,"props":13401,"children":13402},{"style":105},[13403],{"type":34,"value":143},{"type":29,"tag":88,"props":13405,"children":13406},{"style":151},[13407],{"type":34,"value":281},{"type":29,"tag":88,"props":13409,"children":13410},{"style":157},[13411],{"type":34,"value":13412}," product",{"type":29,"tag":88,"props":13414,"children":13415},{"style":122},[13416],{"type":34,"value":424},{"type":29,"tag":88,"props":13418,"children":13419},{"class":90,"line":128},[13420,13424,13428,13433],{"type":29,"tag":88,"props":13421,"children":13422},{"style":105},[13423],{"type":34,"value":143},{"type":29,"tag":88,"props":13425,"children":13426},{"style":105},[13427],{"type":34,"value":8608},{"type":29,"tag":88,"props":13429,"children":13430},{"style":157},[13431],{"type":34,"value":13432}," quantity",{"type":29,"tag":88,"props":13434,"children":13435},{"style":122},[13436],{"type":34,"value":424},{"type":29,"tag":88,"props":13438,"children":13439},{"class":90,"line":137},[13440,13444,13448,13453],{"type":29,"tag":88,"props":13441,"children":13442},{"style":105},[13443],{"type":34,"value":143},{"type":29,"tag":88,"props":13445,"children":13446},{"style":105},[13447],{"type":34,"value":10663},{"type":29,"tag":88,"props":13449,"children":13450},{"style":157},[13451],{"type":34,"value":13452}," price",{"type":29,"tag":88,"props":13454,"children":13455},{"style":122},[13456],{"type":34,"value":424},{"type":29,"tag":88,"props":13458,"children":13459},{"class":90,"line":211},[13460],{"type":29,"tag":88,"props":13461,"children":13462},{"emptyLinePlaceholder":13},[13463],{"type":34,"value":134},{"type":29,"tag":88,"props":13465,"children":13466},{"class":90,"line":262},[13467,13471,13475,13479,13483,13487,13491,13495,13499,13503,13507,13511,13515],{"type":29,"tag":88,"props":13468,"children":13469},{"style":105},[13470],{"type":34,"value":276},{"type":29,"tag":88,"props":13472,"children":13473},{"style":174},[13474],{"type":34,"value":2740},{"type":29,"tag":88,"props":13476,"children":13477},{"style":122},[13478],{"type":34,"value":181},{"type":29,"tag":88,"props":13480,"children":13481},{"style":151},[13482],{"type":34,"value":695},{"type":29,"tag":88,"props":13484,"children":13485},{"style":298},[13486],{"type":34,"value":13412},{"type":29,"tag":88,"props":13488,"children":13489},{"style":122},[13490],{"type":34,"value":192},{"type":29,"tag":88,"props":13492,"children":13493},{"style":105},[13494],{"type":34,"value":8608},{"type":29,"tag":88,"props":13496,"children":13497},{"style":298},[13498],{"type":34,"value":13432},{"type":29,"tag":88,"props":13500,"children":13501},{"style":122},[13502],{"type":34,"value":192},{"type":29,"tag":88,"props":13504,"children":13505},{"style":105},[13506],{"type":34,"value":10663},{"type":29,"tag":88,"props":13508,"children":13509},{"style":298},[13510],{"type":34,"value":13452},{"type":29,"tag":88,"props":13512,"children":13513},{"style":122},[13514],{"type":34,"value":306},{"type":29,"tag":88,"props":13516,"children":13517},{"style":122},[13518],{"type":34,"value":125},{"type":29,"tag":88,"props":13520,"children":13521},{"class":90,"line":270},[13522,13526,13530,13535,13539,13543],{"type":29,"tag":88,"props":13523,"children":13524},{"style":873},[13525],{"type":34,"value":876},{"type":29,"tag":88,"props":13527,"children":13528},{"style":122},[13529],{"type":34,"value":338},{"type":29,"tag":88,"props":13531,"children":13532},{"style":157},[13533],{"type":34,"value":13534},"product ",{"type":29,"tag":88,"props":13536,"children":13537},{"style":163},[13538],{"type":34,"value":166},{"type":29,"tag":88,"props":13540,"children":13541},{"style":157},[13542],{"type":34,"value":13412},{"type":29,"tag":88,"props":13544,"children":13545},{"style":122},[13546],{"type":34,"value":424},{"type":29,"tag":88,"props":13548,"children":13549},{"class":90,"line":313},[13550,13554,13558,13563,13567,13571],{"type":29,"tag":88,"props":13551,"children":13552},{"style":873},[13553],{"type":34,"value":876},{"type":29,"tag":88,"props":13555,"children":13556},{"style":122},[13557],{"type":34,"value":338},{"type":29,"tag":88,"props":13559,"children":13560},{"style":157},[13561],{"type":34,"value":13562},"quantity ",{"type":29,"tag":88,"props":13564,"children":13565},{"style":163},[13566],{"type":34,"value":166},{"type":29,"tag":88,"props":13568,"children":13569},{"style":157},[13570],{"type":34,"value":13432},{"type":29,"tag":88,"props":13572,"children":13573},{"style":122},[13574],{"type":34,"value":424},{"type":29,"tag":88,"props":13576,"children":13577},{"class":90,"line":360},[13578,13582,13586,13591,13595,13599],{"type":29,"tag":88,"props":13579,"children":13580},{"style":873},[13581],{"type":34,"value":876},{"type":29,"tag":88,"props":13583,"children":13584},{"style":122},[13585],{"type":34,"value":338},{"type":29,"tag":88,"props":13587,"children":13588},{"style":157},[13589],{"type":34,"value":13590},"price ",{"type":29,"tag":88,"props":13592,"children":13593},{"style":163},[13594],{"type":34,"value":166},{"type":29,"tag":88,"props":13596,"children":13597},{"style":157},[13598],{"type":34,"value":13452},{"type":29,"tag":88,"props":13600,"children":13601},{"style":122},[13602],{"type":34,"value":424},{"type":29,"tag":88,"props":13604,"children":13605},{"class":90,"line":409},[13606],{"type":29,"tag":88,"props":13607,"children":13608},{"style":122},[13609],{"type":34,"value":433},{"type":29,"tag":88,"props":13611,"children":13612},{"class":90,"line":427},[13613],{"type":29,"tag":88,"props":13614,"children":13615},{"emptyLinePlaceholder":13},[13616],{"type":34,"value":134},{"type":29,"tag":88,"props":13618,"children":13619},{"class":90,"line":436},[13620,13624,13628,13632,13636],{"type":29,"tag":88,"props":13621,"children":13622},{"style":105},[13623],{"type":34,"value":276},{"type":29,"tag":88,"props":13625,"children":13626},{"style":105},[13627],{"type":34,"value":1303},{"type":29,"tag":88,"props":13629,"children":13630},{"style":174},[13631],{"type":34,"value":6016},{"type":29,"tag":88,"props":13633,"children":13634},{"style":122},[13635],{"type":34,"value":1470},{"type":29,"tag":88,"props":13637,"children":13638},{"style":122},[13639],{"type":34,"value":125},{"type":29,"tag":88,"props":13641,"children":13642},{"class":90,"line":767},[13643],{"type":29,"tag":88,"props":13644,"children":13645},{"style":95},[13646],{"type":34,"value":13647},"        \u002F\u002F Logique pour traiter la commande\n",{"type":29,"tag":88,"props":13649,"children":13650},{"class":90,"line":792},[13651],{"type":29,"tag":88,"props":13652,"children":13653},{"style":122},[13654],{"type":34,"value":433},{"type":29,"tag":88,"props":13656,"children":13657},{"class":90,"line":817},[13658],{"type":29,"tag":88,"props":13659,"children":13660},{"emptyLinePlaceholder":13},[13661],{"type":34,"value":134},{"type":29,"tag":88,"props":13663,"children":13664},{"class":90,"line":825},[13665,13669,13673,13678,13682],{"type":29,"tag":88,"props":13666,"children":13667},{"style":105},[13668],{"type":34,"value":276},{"type":29,"tag":88,"props":13670,"children":13671},{"style":105},[13672],{"type":34,"value":1303},{"type":29,"tag":88,"props":13674,"children":13675},{"style":174},[13676],{"type":34,"value":13677}," generateInvoice",{"type":29,"tag":88,"props":13679,"children":13680},{"style":122},[13681],{"type":34,"value":1470},{"type":29,"tag":88,"props":13683,"children":13684},{"style":122},[13685],{"type":34,"value":125},{"type":29,"tag":88,"props":13687,"children":13688},{"class":90,"line":869},[13689],{"type":29,"tag":88,"props":13690,"children":13691},{"style":95},[13692],{"type":34,"value":13693},"        \u002F\u002F Logique pour générer une facture\n",{"type":29,"tag":88,"props":13695,"children":13696},{"class":90,"line":900},[13697],{"type":29,"tag":88,"props":13698,"children":13699},{"style":122},[13700],{"type":34,"value":433},{"type":29,"tag":88,"props":13702,"children":13703},{"class":90,"line":929},[13704],{"type":29,"tag":88,"props":13705,"children":13706},{"emptyLinePlaceholder":13},[13707],{"type":34,"value":134},{"type":29,"tag":88,"props":13709,"children":13710},{"class":90,"line":937},[13711,13715,13719,13723,13727],{"type":29,"tag":88,"props":13712,"children":13713},{"style":105},[13714],{"type":34,"value":276},{"type":29,"tag":88,"props":13716,"children":13717},{"style":105},[13718],{"type":34,"value":1303},{"type":29,"tag":88,"props":13720,"children":13721},{"style":174},[13722],{"type":34,"value":12508},{"type":29,"tag":88,"props":13724,"children":13725},{"style":122},[13726],{"type":34,"value":1470},{"type":29,"tag":88,"props":13728,"children":13729},{"style":122},[13730],{"type":34,"value":125},{"type":29,"tag":88,"props":13732,"children":13733},{"class":90,"line":945},[13734],{"type":29,"tag":88,"props":13735,"children":13736},{"style":95},[13737],{"type":34,"value":13738},"        \u002F\u002F Logique pour traiter le paiement\n",{"type":29,"tag":88,"props":13740,"children":13741},{"class":90,"line":981},[13742],{"type":29,"tag":88,"props":13743,"children":13744},{"style":122},[13745],{"type":34,"value":433},{"type":29,"tag":88,"props":13747,"children":13748},{"class":90,"line":1021},[13749],{"type":29,"tag":88,"props":13750,"children":13751},{"style":122},[13752],{"type":34,"value":442},{"type":29,"tag":10576,"props":13754,"children":13756},{"id":13755},"après-code-évolutif",[13757],{"type":34,"value":13758},"Après : Code évolutif",{"type":29,"tag":30,"props":13760,"children":13761},{},[13762],{"type":34,"value":13763},"Voici une version améliorée en appliquant le principe de responsabilité unique. Chaque classe a désormais un rôle distinct.",{"type":29,"tag":77,"props":13765,"children":13767},{"className":81,"code":13766,"language":80,"meta":8,"style":8},"public class Order {\n    private String product;\n    private int quantity;\n    private double price;\n\n    public Order(String product, int quantity, double price) {\n        this.product = product;\n        this.quantity = quantity;\n        this.price = price;\n    }\n\n    \u002F\u002F Méthode pour obtenir le prix total de la commande\n    public double getTotalPrice() {\n        return quantity * price;\n    }\n}\n\n\u002F\u002F Classe pour traiter le paiement\npublic class PaymentService {\n    public void processPayment(Order order) {\n        \u002F\u002F Logique pour traiter le paiement\n    }\n}\n\n\u002F\u002F Classe pour générer une facture\npublic class InvoiceService {\n    public void generateInvoice(Order order) {\n        \u002F\u002F Logique pour générer une facture\n    }\n}\n",[13768],{"type":29,"tag":84,"props":13769,"children":13770},{"__ignoreMap":8},[13771,13790,13809,13828,13847,13854,13909,13936,13963,13990,13997,14004,14012,14036,14060,14067,14074,14081,14089,14108,14143,14150,14157,14164,14171,14179,14199,14234,14241,14248],{"type":29,"tag":88,"props":13772,"children":13773},{"class":90,"line":91},[13774,13778,13782,13786],{"type":29,"tag":88,"props":13775,"children":13776},{"style":105},[13777],{"type":34,"value":108},{"type":29,"tag":88,"props":13779,"children":13780},{"style":105},[13781],{"type":34,"value":113},{"type":29,"tag":88,"props":13783,"children":13784},{"style":116},[13785],{"type":34,"value":2740},{"type":29,"tag":88,"props":13787,"children":13788},{"style":122},[13789],{"type":34,"value":125},{"type":29,"tag":88,"props":13791,"children":13792},{"class":90,"line":101},[13793,13797,13801,13805],{"type":29,"tag":88,"props":13794,"children":13795},{"style":105},[13796],{"type":34,"value":143},{"type":29,"tag":88,"props":13798,"children":13799},{"style":151},[13800],{"type":34,"value":281},{"type":29,"tag":88,"props":13802,"children":13803},{"style":157},[13804],{"type":34,"value":13412},{"type":29,"tag":88,"props":13806,"children":13807},{"style":122},[13808],{"type":34,"value":424},{"type":29,"tag":88,"props":13810,"children":13811},{"class":90,"line":128},[13812,13816,13820,13824],{"type":29,"tag":88,"props":13813,"children":13814},{"style":105},[13815],{"type":34,"value":143},{"type":29,"tag":88,"props":13817,"children":13818},{"style":105},[13819],{"type":34,"value":8608},{"type":29,"tag":88,"props":13821,"children":13822},{"style":157},[13823],{"type":34,"value":13432},{"type":29,"tag":88,"props":13825,"children":13826},{"style":122},[13827],{"type":34,"value":424},{"type":29,"tag":88,"props":13829,"children":13830},{"class":90,"line":137},[13831,13835,13839,13843],{"type":29,"tag":88,"props":13832,"children":13833},{"style":105},[13834],{"type":34,"value":143},{"type":29,"tag":88,"props":13836,"children":13837},{"style":105},[13838],{"type":34,"value":10663},{"type":29,"tag":88,"props":13840,"children":13841},{"style":157},[13842],{"type":34,"value":13452},{"type":29,"tag":88,"props":13844,"children":13845},{"style":122},[13846],{"type":34,"value":424},{"type":29,"tag":88,"props":13848,"children":13849},{"class":90,"line":211},[13850],{"type":29,"tag":88,"props":13851,"children":13852},{"emptyLinePlaceholder":13},[13853],{"type":34,"value":134},{"type":29,"tag":88,"props":13855,"children":13856},{"class":90,"line":262},[13857,13861,13865,13869,13873,13877,13881,13885,13889,13893,13897,13901,13905],{"type":29,"tag":88,"props":13858,"children":13859},{"style":105},[13860],{"type":34,"value":276},{"type":29,"tag":88,"props":13862,"children":13863},{"style":174},[13864],{"type":34,"value":2740},{"type":29,"tag":88,"props":13866,"children":13867},{"style":122},[13868],{"type":34,"value":181},{"type":29,"tag":88,"props":13870,"children":13871},{"style":151},[13872],{"type":34,"value":695},{"type":29,"tag":88,"props":13874,"children":13875},{"style":298},[13876],{"type":34,"value":13412},{"type":29,"tag":88,"props":13878,"children":13879},{"style":122},[13880],{"type":34,"value":192},{"type":29,"tag":88,"props":13882,"children":13883},{"style":105},[13884],{"type":34,"value":8608},{"type":29,"tag":88,"props":13886,"children":13887},{"style":298},[13888],{"type":34,"value":13432},{"type":29,"tag":88,"props":13890,"children":13891},{"style":122},[13892],{"type":34,"value":192},{"type":29,"tag":88,"props":13894,"children":13895},{"style":105},[13896],{"type":34,"value":10663},{"type":29,"tag":88,"props":13898,"children":13899},{"style":298},[13900],{"type":34,"value":13452},{"type":29,"tag":88,"props":13902,"children":13903},{"style":122},[13904],{"type":34,"value":306},{"type":29,"tag":88,"props":13906,"children":13907},{"style":122},[13908],{"type":34,"value":125},{"type":29,"tag":88,"props":13910,"children":13911},{"class":90,"line":270},[13912,13916,13920,13924,13928,13932],{"type":29,"tag":88,"props":13913,"children":13914},{"style":873},[13915],{"type":34,"value":876},{"type":29,"tag":88,"props":13917,"children":13918},{"style":122},[13919],{"type":34,"value":338},{"type":29,"tag":88,"props":13921,"children":13922},{"style":157},[13923],{"type":34,"value":13534},{"type":29,"tag":88,"props":13925,"children":13926},{"style":163},[13927],{"type":34,"value":166},{"type":29,"tag":88,"props":13929,"children":13930},{"style":157},[13931],{"type":34,"value":13412},{"type":29,"tag":88,"props":13933,"children":13934},{"style":122},[13935],{"type":34,"value":424},{"type":29,"tag":88,"props":13937,"children":13938},{"class":90,"line":313},[13939,13943,13947,13951,13955,13959],{"type":29,"tag":88,"props":13940,"children":13941},{"style":873},[13942],{"type":34,"value":876},{"type":29,"tag":88,"props":13944,"children":13945},{"style":122},[13946],{"type":34,"value":338},{"type":29,"tag":88,"props":13948,"children":13949},{"style":157},[13950],{"type":34,"value":13562},{"type":29,"tag":88,"props":13952,"children":13953},{"style":163},[13954],{"type":34,"value":166},{"type":29,"tag":88,"props":13956,"children":13957},{"style":157},[13958],{"type":34,"value":13432},{"type":29,"tag":88,"props":13960,"children":13961},{"style":122},[13962],{"type":34,"value":424},{"type":29,"tag":88,"props":13964,"children":13965},{"class":90,"line":360},[13966,13970,13974,13978,13982,13986],{"type":29,"tag":88,"props":13967,"children":13968},{"style":873},[13969],{"type":34,"value":876},{"type":29,"tag":88,"props":13971,"children":13972},{"style":122},[13973],{"type":34,"value":338},{"type":29,"tag":88,"props":13975,"children":13976},{"style":157},[13977],{"type":34,"value":13590},{"type":29,"tag":88,"props":13979,"children":13980},{"style":163},[13981],{"type":34,"value":166},{"type":29,"tag":88,"props":13983,"children":13984},{"style":157},[13985],{"type":34,"value":13452},{"type":29,"tag":88,"props":13987,"children":13988},{"style":122},[13989],{"type":34,"value":424},{"type":29,"tag":88,"props":13991,"children":13992},{"class":90,"line":409},[13993],{"type":29,"tag":88,"props":13994,"children":13995},{"style":122},[13996],{"type":34,"value":433},{"type":29,"tag":88,"props":13998,"children":13999},{"class":90,"line":427},[14000],{"type":29,"tag":88,"props":14001,"children":14002},{"emptyLinePlaceholder":13},[14003],{"type":34,"value":134},{"type":29,"tag":88,"props":14005,"children":14006},{"class":90,"line":436},[14007],{"type":29,"tag":88,"props":14008,"children":14009},{"style":95},[14010],{"type":34,"value":14011},"    \u002F\u002F Méthode pour obtenir le prix total de la commande\n",{"type":29,"tag":88,"props":14013,"children":14014},{"class":90,"line":767},[14015,14019,14023,14028,14032],{"type":29,"tag":88,"props":14016,"children":14017},{"style":105},[14018],{"type":34,"value":276},{"type":29,"tag":88,"props":14020,"children":14021},{"style":105},[14022],{"type":34,"value":10663},{"type":29,"tag":88,"props":14024,"children":14025},{"style":174},[14026],{"type":34,"value":14027}," getTotalPrice",{"type":29,"tag":88,"props":14029,"children":14030},{"style":122},[14031],{"type":34,"value":1470},{"type":29,"tag":88,"props":14033,"children":14034},{"style":122},[14035],{"type":34,"value":125},{"type":29,"tag":88,"props":14037,"children":14038},{"class":90,"line":792},[14039,14043,14048,14052,14056],{"type":29,"tag":88,"props":14040,"children":14041},{"style":105},[14042],{"type":34,"value":415},{"type":29,"tag":88,"props":14044,"children":14045},{"style":157},[14046],{"type":34,"value":14047}," quantity ",{"type":29,"tag":88,"props":14049,"children":14050},{"style":163},[14051],{"type":34,"value":8709},{"type":29,"tag":88,"props":14053,"children":14054},{"style":157},[14055],{"type":34,"value":13452},{"type":29,"tag":88,"props":14057,"children":14058},{"style":122},[14059],{"type":34,"value":424},{"type":29,"tag":88,"props":14061,"children":14062},{"class":90,"line":817},[14063],{"type":29,"tag":88,"props":14064,"children":14065},{"style":122},[14066],{"type":34,"value":433},{"type":29,"tag":88,"props":14068,"children":14069},{"class":90,"line":825},[14070],{"type":29,"tag":88,"props":14071,"children":14072},{"style":122},[14073],{"type":34,"value":442},{"type":29,"tag":88,"props":14075,"children":14076},{"class":90,"line":869},[14077],{"type":29,"tag":88,"props":14078,"children":14079},{"emptyLinePlaceholder":13},[14080],{"type":34,"value":134},{"type":29,"tag":88,"props":14082,"children":14083},{"class":90,"line":900},[14084],{"type":29,"tag":88,"props":14085,"children":14086},{"style":95},[14087],{"type":34,"value":14088},"\u002F\u002F Classe pour traiter le paiement\n",{"type":29,"tag":88,"props":14090,"children":14091},{"class":90,"line":929},[14092,14096,14100,14104],{"type":29,"tag":88,"props":14093,"children":14094},{"style":105},[14095],{"type":34,"value":108},{"type":29,"tag":88,"props":14097,"children":14098},{"style":105},[14099],{"type":34,"value":113},{"type":29,"tag":88,"props":14101,"children":14102},{"style":116},[14103],{"type":34,"value":12760},{"type":29,"tag":88,"props":14105,"children":14106},{"style":122},[14107],{"type":34,"value":125},{"type":29,"tag":88,"props":14109,"children":14110},{"class":90,"line":937},[14111,14115,14119,14123,14127,14131,14135,14139],{"type":29,"tag":88,"props":14112,"children":14113},{"style":105},[14114],{"type":34,"value":276},{"type":29,"tag":88,"props":14116,"children":14117},{"style":105},[14118],{"type":34,"value":1303},{"type":29,"tag":88,"props":14120,"children":14121},{"style":174},[14122],{"type":34,"value":12508},{"type":29,"tag":88,"props":14124,"children":14125},{"style":122},[14126],{"type":34,"value":181},{"type":29,"tag":88,"props":14128,"children":14129},{"style":151},[14130],{"type":34,"value":2386},{"type":29,"tag":88,"props":14132,"children":14133},{"style":298},[14134],{"type":34,"value":4310},{"type":29,"tag":88,"props":14136,"children":14137},{"style":122},[14138],{"type":34,"value":306},{"type":29,"tag":88,"props":14140,"children":14141},{"style":122},[14142],{"type":34,"value":125},{"type":29,"tag":88,"props":14144,"children":14145},{"class":90,"line":945},[14146],{"type":29,"tag":88,"props":14147,"children":14148},{"style":95},[14149],{"type":34,"value":13738},{"type":29,"tag":88,"props":14151,"children":14152},{"class":90,"line":981},[14153],{"type":29,"tag":88,"props":14154,"children":14155},{"style":122},[14156],{"type":34,"value":433},{"type":29,"tag":88,"props":14158,"children":14159},{"class":90,"line":1021},[14160],{"type":29,"tag":88,"props":14161,"children":14162},{"style":122},[14163],{"type":34,"value":442},{"type":29,"tag":88,"props":14165,"children":14166},{"class":90,"line":1066},[14167],{"type":29,"tag":88,"props":14168,"children":14169},{"emptyLinePlaceholder":13},[14170],{"type":34,"value":134},{"type":29,"tag":88,"props":14172,"children":14173},{"class":90,"line":1082},[14174],{"type":29,"tag":88,"props":14175,"children":14176},{"style":95},[14177],{"type":34,"value":14178},"\u002F\u002F Classe pour générer une facture\n",{"type":29,"tag":88,"props":14180,"children":14181},{"class":90,"line":1090},[14182,14186,14190,14195],{"type":29,"tag":88,"props":14183,"children":14184},{"style":105},[14185],{"type":34,"value":108},{"type":29,"tag":88,"props":14187,"children":14188},{"style":105},[14189],{"type":34,"value":113},{"type":29,"tag":88,"props":14191,"children":14192},{"style":116},[14193],{"type":34,"value":14194}," InvoiceService",{"type":29,"tag":88,"props":14196,"children":14197},{"style":122},[14198],{"type":34,"value":125},{"type":29,"tag":88,"props":14200,"children":14201},{"class":90,"line":1098},[14202,14206,14210,14214,14218,14222,14226,14230],{"type":29,"tag":88,"props":14203,"children":14204},{"style":105},[14205],{"type":34,"value":276},{"type":29,"tag":88,"props":14207,"children":14208},{"style":105},[14209],{"type":34,"value":1303},{"type":29,"tag":88,"props":14211,"children":14212},{"style":174},[14213],{"type":34,"value":13677},{"type":29,"tag":88,"props":14215,"children":14216},{"style":122},[14217],{"type":34,"value":181},{"type":29,"tag":88,"props":14219,"children":14220},{"style":151},[14221],{"type":34,"value":2386},{"type":29,"tag":88,"props":14223,"children":14224},{"style":298},[14225],{"type":34,"value":4310},{"type":29,"tag":88,"props":14227,"children":14228},{"style":122},[14229],{"type":34,"value":306},{"type":29,"tag":88,"props":14231,"children":14232},{"style":122},[14233],{"type":34,"value":125},{"type":29,"tag":88,"props":14235,"children":14236},{"class":90,"line":1106},[14237],{"type":29,"tag":88,"props":14238,"children":14239},{"style":95},[14240],{"type":34,"value":13693},{"type":29,"tag":88,"props":14242,"children":14243},{"class":90,"line":1115},[14244],{"type":29,"tag":88,"props":14245,"children":14246},{"style":122},[14247],{"type":34,"value":433},{"type":29,"tag":88,"props":14249,"children":14250},{"class":90,"line":11},[14251],{"type":29,"tag":88,"props":14252,"children":14253},{"style":122},[14254],{"type":34,"value":442},{"type":29,"tag":30,"props":14256,"children":14257},{},[14258,14260,14266,14268,14273],{"type":34,"value":14259},"Maintenant, si vous avez besoin de changer la façon dont les paiements sont gérés, vous pouvez le faire dans la classe ",{"type":29,"tag":84,"props":14261,"children":14263},{"className":14262},[],[14264],{"type":34,"value":14265},"PaymentService",{"type":34,"value":14267}," sans toucher à la classe ",{"type":29,"tag":84,"props":14269,"children":14271},{"className":14270},[],[14272],{"type":34,"value":2386},{"type":34,"value":14274},". Cela rend le code beaucoup plus évolutif.",{"type":29,"tag":8542,"props":14276,"children":14278},{"id":14277},"exemple-2-gestion-des-dépendances-avec-inversion-de-dépendances",[14279],{"type":34,"value":14280},"Exemple 2 : Gestion des dépendances avec inversion de dépendances",{"type":29,"tag":30,"props":14282,"children":14283},{},[14284,14286,14291],{"type":34,"value":14285},"Dans cet exemple, nous allons améliorer la gestion des dépendances en appliquant le ",{"type":29,"tag":447,"props":14287,"children":14288},{},[14289],{"type":34,"value":14290},"principe d'inversion des dépendances",{"type":34,"value":14292},". Nous allons partir d'une classe qui crée elle-même ses dépendances, ce qui la rend rigide et difficile à tester.",{"type":29,"tag":10576,"props":14294,"children":14296},{"id":14295},"avant-code-non-évolutif-1",[14297],{"type":34,"value":13370},{"type":29,"tag":77,"props":14299,"children":14301},{"className":81,"code":14300,"language":80,"meta":8,"style":8},"public class ShoppingCart {\n    private PaymentService paymentService = new PaymentService();\n\n    public void checkout(Order order) {\n        paymentService.processPayment(order);\n    }\n}\n",[14302],{"type":29,"tag":84,"props":14303,"children":14304},{"__ignoreMap":8},[14305,14325,14357,14364,14400,14428,14435],{"type":29,"tag":88,"props":14306,"children":14307},{"class":90,"line":91},[14308,14312,14316,14321],{"type":29,"tag":88,"props":14309,"children":14310},{"style":105},[14311],{"type":34,"value":108},{"type":29,"tag":88,"props":14313,"children":14314},{"style":105},[14315],{"type":34,"value":113},{"type":29,"tag":88,"props":14317,"children":14318},{"style":116},[14319],{"type":34,"value":14320}," ShoppingCart",{"type":29,"tag":88,"props":14322,"children":14323},{"style":122},[14324],{"type":34,"value":125},{"type":29,"tag":88,"props":14326,"children":14327},{"class":90,"line":101},[14328,14332,14336,14341,14345,14349,14353],{"type":29,"tag":88,"props":14329,"children":14330},{"style":105},[14331],{"type":34,"value":143},{"type":29,"tag":88,"props":14333,"children":14334},{"style":151},[14335],{"type":34,"value":12760},{"type":29,"tag":88,"props":14337,"children":14338},{"style":157},[14339],{"type":34,"value":14340}," paymentService ",{"type":29,"tag":88,"props":14342,"children":14343},{"style":163},[14344],{"type":34,"value":166},{"type":29,"tag":88,"props":14346,"children":14347},{"style":105},[14348],{"type":34,"value":171},{"type":29,"tag":88,"props":14350,"children":14351},{"style":174},[14352],{"type":34,"value":12760},{"type":29,"tag":88,"props":14354,"children":14355},{"style":122},[14356],{"type":34,"value":1810},{"type":29,"tag":88,"props":14358,"children":14359},{"class":90,"line":128},[14360],{"type":29,"tag":88,"props":14361,"children":14362},{"emptyLinePlaceholder":13},[14363],{"type":34,"value":134},{"type":29,"tag":88,"props":14365,"children":14366},{"class":90,"line":137},[14367,14371,14375,14380,14384,14388,14392,14396],{"type":29,"tag":88,"props":14368,"children":14369},{"style":105},[14370],{"type":34,"value":276},{"type":29,"tag":88,"props":14372,"children":14373},{"style":105},[14374],{"type":34,"value":1303},{"type":29,"tag":88,"props":14376,"children":14377},{"style":174},[14378],{"type":34,"value":14379}," checkout",{"type":29,"tag":88,"props":14381,"children":14382},{"style":122},[14383],{"type":34,"value":181},{"type":29,"tag":88,"props":14385,"children":14386},{"style":151},[14387],{"type":34,"value":2386},{"type":29,"tag":88,"props":14389,"children":14390},{"style":298},[14391],{"type":34,"value":4310},{"type":29,"tag":88,"props":14393,"children":14394},{"style":122},[14395],{"type":34,"value":306},{"type":29,"tag":88,"props":14397,"children":14398},{"style":122},[14399],{"type":34,"value":125},{"type":29,"tag":88,"props":14401,"children":14402},{"class":90,"line":211},[14403,14408,14412,14416,14420,14424],{"type":29,"tag":88,"props":14404,"children":14405},{"style":157},[14406],{"type":34,"value":14407},"        paymentService",{"type":29,"tag":88,"props":14409,"children":14410},{"style":122},[14411],{"type":34,"value":338},{"type":29,"tag":88,"props":14413,"children":14414},{"style":174},[14415],{"type":34,"value":12917},{"type":29,"tag":88,"props":14417,"children":14418},{"style":122},[14419],{"type":34,"value":181},{"type":29,"tag":88,"props":14421,"children":14422},{"style":157},[14423],{"type":34,"value":5182},{"type":29,"tag":88,"props":14425,"children":14426},{"style":122},[14427],{"type":34,"value":357},{"type":29,"tag":88,"props":14429,"children":14430},{"class":90,"line":262},[14431],{"type":29,"tag":88,"props":14432,"children":14433},{"style":122},[14434],{"type":34,"value":433},{"type":29,"tag":88,"props":14436,"children":14437},{"class":90,"line":270},[14438],{"type":29,"tag":88,"props":14439,"children":14440},{"style":122},[14441],{"type":34,"value":442},{"type":29,"tag":30,"props":14443,"children":14444},{},[14445,14447,14453,14455,14460,14462,14467],{"type":34,"value":14446},"Dans ce cas, la classe ",{"type":29,"tag":84,"props":14448,"children":14450},{"className":14449},[],[14451],{"type":34,"value":14452},"ShoppingCart",{"type":34,"value":14454}," est fortement couplée à ",{"type":29,"tag":84,"props":14456,"children":14458},{"className":14457},[],[14459],{"type":34,"value":14265},{"type":34,"value":14461},", ce qui rend difficile l'ajout d'une nouvelle méthode de paiement, ou le test de ",{"type":29,"tag":84,"props":14463,"children":14465},{"className":14464},[],[14466],{"type":34,"value":14452},{"type":34,"value":14468}," en isolation.",{"type":29,"tag":10576,"props":14470,"children":14472},{"id":14471},"après-code-évolutif-1",[14473],{"type":34,"value":13758},{"type":29,"tag":30,"props":14475,"children":14476},{},[14477,14479,14484,14486,14491],{"type":34,"value":14478},"Nous allons inverser la dépendance en passant la méthode de paiement comme paramètre dans le constructeur de ",{"type":29,"tag":84,"props":14480,"children":14482},{"className":14481},[],[14483],{"type":34,"value":14452},{"type":34,"value":14485},". Cela permet de changer facilement l'implémentation du paiement sans modifier ",{"type":29,"tag":84,"props":14487,"children":14489},{"className":14488},[],[14490],{"type":34,"value":14452},{"type":34,"value":338},{"type":29,"tag":77,"props":14493,"children":14495},{"className":81,"code":14494,"language":80,"meta":8,"style":8},"public class ShoppingCart {\n    private PaymentMethod paymentMethod;\n\n    public ShoppingCart(PaymentMethod paymentMethod) {\n        this.paymentMethod = paymentMethod;\n    }\n\n    public void checkout(Order order) {\n        paymentMethod.processPayment(order);\n    }\n}\n",[14496],{"type":29,"tag":84,"props":14497,"children":14498},{"__ignoreMap":8},[14499,14518,14537,14544,14575,14602,14609,14616,14651,14678,14685],{"type":29,"tag":88,"props":14500,"children":14501},{"class":90,"line":91},[14502,14506,14510,14514],{"type":29,"tag":88,"props":14503,"children":14504},{"style":105},[14505],{"type":34,"value":108},{"type":29,"tag":88,"props":14507,"children":14508},{"style":105},[14509],{"type":34,"value":113},{"type":29,"tag":88,"props":14511,"children":14512},{"style":116},[14513],{"type":34,"value":14320},{"type":29,"tag":88,"props":14515,"children":14516},{"style":122},[14517],{"type":34,"value":125},{"type":29,"tag":88,"props":14519,"children":14520},{"class":90,"line":101},[14521,14525,14529,14533],{"type":29,"tag":88,"props":14522,"children":14523},{"style":105},[14524],{"type":34,"value":143},{"type":29,"tag":88,"props":14526,"children":14527},{"style":151},[14528],{"type":34,"value":11604},{"type":29,"tag":88,"props":14530,"children":14531},{"style":157},[14532],{"type":34,"value":12780},{"type":29,"tag":88,"props":14534,"children":14535},{"style":122},[14536],{"type":34,"value":424},{"type":29,"tag":88,"props":14538,"children":14539},{"class":90,"line":128},[14540],{"type":29,"tag":88,"props":14541,"children":14542},{"emptyLinePlaceholder":13},[14543],{"type":34,"value":134},{"type":29,"tag":88,"props":14545,"children":14546},{"class":90,"line":137},[14547,14551,14555,14559,14563,14567,14571],{"type":29,"tag":88,"props":14548,"children":14549},{"style":105},[14550],{"type":34,"value":276},{"type":29,"tag":88,"props":14552,"children":14553},{"style":174},[14554],{"type":34,"value":14320},{"type":29,"tag":88,"props":14556,"children":14557},{"style":122},[14558],{"type":34,"value":181},{"type":29,"tag":88,"props":14560,"children":14561},{"style":151},[14562],{"type":34,"value":11839},{"type":29,"tag":88,"props":14564,"children":14565},{"style":298},[14566],{"type":34,"value":12780},{"type":29,"tag":88,"props":14568,"children":14569},{"style":122},[14570],{"type":34,"value":306},{"type":29,"tag":88,"props":14572,"children":14573},{"style":122},[14574],{"type":34,"value":125},{"type":29,"tag":88,"props":14576,"children":14577},{"class":90,"line":211},[14578,14582,14586,14590,14594,14598],{"type":29,"tag":88,"props":14579,"children":14580},{"style":873},[14581],{"type":34,"value":876},{"type":29,"tag":88,"props":14583,"children":14584},{"style":122},[14585],{"type":34,"value":338},{"type":29,"tag":88,"props":14587,"children":14588},{"style":157},[14589],{"type":34,"value":12838},{"type":29,"tag":88,"props":14591,"children":14592},{"style":163},[14593],{"type":34,"value":166},{"type":29,"tag":88,"props":14595,"children":14596},{"style":157},[14597],{"type":34,"value":12780},{"type":29,"tag":88,"props":14599,"children":14600},{"style":122},[14601],{"type":34,"value":424},{"type":29,"tag":88,"props":14603,"children":14604},{"class":90,"line":262},[14605],{"type":29,"tag":88,"props":14606,"children":14607},{"style":122},[14608],{"type":34,"value":433},{"type":29,"tag":88,"props":14610,"children":14611},{"class":90,"line":270},[14612],{"type":29,"tag":88,"props":14613,"children":14614},{"emptyLinePlaceholder":13},[14615],{"type":34,"value":134},{"type":29,"tag":88,"props":14617,"children":14618},{"class":90,"line":313},[14619,14623,14627,14631,14635,14639,14643,14647],{"type":29,"tag":88,"props":14620,"children":14621},{"style":105},[14622],{"type":34,"value":276},{"type":29,"tag":88,"props":14624,"children":14625},{"style":105},[14626],{"type":34,"value":1303},{"type":29,"tag":88,"props":14628,"children":14629},{"style":174},[14630],{"type":34,"value":14379},{"type":29,"tag":88,"props":14632,"children":14633},{"style":122},[14634],{"type":34,"value":181},{"type":29,"tag":88,"props":14636,"children":14637},{"style":151},[14638],{"type":34,"value":2386},{"type":29,"tag":88,"props":14640,"children":14641},{"style":298},[14642],{"type":34,"value":4310},{"type":29,"tag":88,"props":14644,"children":14645},{"style":122},[14646],{"type":34,"value":306},{"type":29,"tag":88,"props":14648,"children":14649},{"style":122},[14650],{"type":34,"value":125},{"type":29,"tag":88,"props":14652,"children":14653},{"class":90,"line":360},[14654,14658,14662,14666,14670,14674],{"type":29,"tag":88,"props":14655,"children":14656},{"style":157},[14657],{"type":34,"value":12908},{"type":29,"tag":88,"props":14659,"children":14660},{"style":122},[14661],{"type":34,"value":338},{"type":29,"tag":88,"props":14663,"children":14664},{"style":174},[14665],{"type":34,"value":12917},{"type":29,"tag":88,"props":14667,"children":14668},{"style":122},[14669],{"type":34,"value":181},{"type":29,"tag":88,"props":14671,"children":14672},{"style":157},[14673],{"type":34,"value":5182},{"type":29,"tag":88,"props":14675,"children":14676},{"style":122},[14677],{"type":34,"value":357},{"type":29,"tag":88,"props":14679,"children":14680},{"class":90,"line":409},[14681],{"type":29,"tag":88,"props":14682,"children":14683},{"style":122},[14684],{"type":34,"value":433},{"type":29,"tag":88,"props":14686,"children":14687},{"class":90,"line":427},[14688],{"type":29,"tag":88,"props":14689,"children":14690},{"style":122},[14691],{"type":34,"value":442},{"type":29,"tag":30,"props":14693,"children":14694},{},[14695,14697,14702,14704,14709],{"type":34,"value":14696},"Maintenant, ",{"type":29,"tag":84,"props":14698,"children":14700},{"className":14699},[],[14701],{"type":34,"value":14452},{"type":34,"value":14703}," peut accepter n'importe quelle implémentation de ",{"type":29,"tag":84,"props":14705,"children":14707},{"className":14706},[],[14708],{"type":34,"value":11839},{"type":34,"value":14710}," (carte de crédit, PayPal, etc.), ce qui rend le code beaucoup plus flexible et facile à maintenir.",{"type":29,"tag":77,"props":14712,"children":14714},{"className":81,"code":14713,"language":80,"meta":8,"style":8},"public interface PaymentMethod {\n    void processPayment(Order order);\n}\n\npublic class CreditCardPayment implements PaymentMethod {\n    public void processPayment(Order order) {\n        \u002F\u002F Logique pour traiter le paiement par carte\n    }\n}\n\npublic class PayPalPayment implements PaymentMethod {\n    public void processPayment(Order order) {\n        \u002F\u002F Logique pour traiter le paiement via PayPal\n    }\n}\n",[14715],{"type":29,"tag":84,"props":14716,"children":14717},{"__ignoreMap":8},[14718,14737,14764,14771,14778,14805,14840,14848,14855,14862,14869,14896,14931,14939,14946],{"type":29,"tag":88,"props":14719,"children":14720},{"class":90,"line":91},[14721,14725,14729,14733],{"type":29,"tag":88,"props":14722,"children":14723},{"style":105},[14724],{"type":34,"value":108},{"type":29,"tag":88,"props":14726,"children":14727},{"style":105},[14728],{"type":34,"value":601},{"type":29,"tag":88,"props":14730,"children":14731},{"style":116},[14732],{"type":34,"value":11604},{"type":29,"tag":88,"props":14734,"children":14735},{"style":122},[14736],{"type":34,"value":125},{"type":29,"tag":88,"props":14738,"children":14739},{"class":90,"line":101},[14740,14744,14748,14752,14756,14760],{"type":29,"tag":88,"props":14741,"children":14742},{"style":105},[14743],{"type":34,"value":681},{"type":29,"tag":88,"props":14745,"children":14746},{"style":174},[14747],{"type":34,"value":12508},{"type":29,"tag":88,"props":14749,"children":14750},{"style":122},[14751],{"type":34,"value":181},{"type":29,"tag":88,"props":14753,"children":14754},{"style":151},[14755],{"type":34,"value":2386},{"type":29,"tag":88,"props":14757,"children":14758},{"style":298},[14759],{"type":34,"value":4310},{"type":29,"tag":88,"props":14761,"children":14762},{"style":122},[14763],{"type":34,"value":357},{"type":29,"tag":88,"props":14765,"children":14766},{"class":90,"line":128},[14767],{"type":29,"tag":88,"props":14768,"children":14769},{"style":122},[14770],{"type":34,"value":442},{"type":29,"tag":88,"props":14772,"children":14773},{"class":90,"line":137},[14774],{"type":29,"tag":88,"props":14775,"children":14776},{"emptyLinePlaceholder":13},[14777],{"type":34,"value":134},{"type":29,"tag":88,"props":14779,"children":14780},{"class":90,"line":211},[14781,14785,14789,14793,14797,14801],{"type":29,"tag":88,"props":14782,"children":14783},{"style":105},[14784],{"type":34,"value":108},{"type":29,"tag":88,"props":14786,"children":14787},{"style":105},[14788],{"type":34,"value":113},{"type":29,"tag":88,"props":14790,"children":14791},{"style":116},[14792],{"type":34,"value":11667},{"type":29,"tag":88,"props":14794,"children":14795},{"style":105},[14796],{"type":34,"value":1134},{"type":29,"tag":88,"props":14798,"children":14799},{"style":116},[14800],{"type":34,"value":11604},{"type":29,"tag":88,"props":14802,"children":14803},{"style":122},[14804],{"type":34,"value":125},{"type":29,"tag":88,"props":14806,"children":14807},{"class":90,"line":262},[14808,14812,14816,14820,14824,14828,14832,14836],{"type":29,"tag":88,"props":14809,"children":14810},{"style":105},[14811],{"type":34,"value":276},{"type":29,"tag":88,"props":14813,"children":14814},{"style":105},[14815],{"type":34,"value":1303},{"type":29,"tag":88,"props":14817,"children":14818},{"style":174},[14819],{"type":34,"value":12508},{"type":29,"tag":88,"props":14821,"children":14822},{"style":122},[14823],{"type":34,"value":181},{"type":29,"tag":88,"props":14825,"children":14826},{"style":151},[14827],{"type":34,"value":2386},{"type":29,"tag":88,"props":14829,"children":14830},{"style":298},[14831],{"type":34,"value":4310},{"type":29,"tag":88,"props":14833,"children":14834},{"style":122},[14835],{"type":34,"value":306},{"type":29,"tag":88,"props":14837,"children":14838},{"style":122},[14839],{"type":34,"value":125},{"type":29,"tag":88,"props":14841,"children":14842},{"class":90,"line":270},[14843],{"type":29,"tag":88,"props":14844,"children":14845},{"style":95},[14846],{"type":34,"value":14847},"        \u002F\u002F Logique pour traiter le paiement par carte\n",{"type":29,"tag":88,"props":14849,"children":14850},{"class":90,"line":313},[14851],{"type":29,"tag":88,"props":14852,"children":14853},{"style":122},[14854],{"type":34,"value":433},{"type":29,"tag":88,"props":14856,"children":14857},{"class":90,"line":360},[14858],{"type":29,"tag":88,"props":14859,"children":14860},{"style":122},[14861],{"type":34,"value":442},{"type":29,"tag":88,"props":14863,"children":14864},{"class":90,"line":409},[14865],{"type":29,"tag":88,"props":14866,"children":14867},{"emptyLinePlaceholder":13},[14868],{"type":34,"value":134},{"type":29,"tag":88,"props":14870,"children":14871},{"class":90,"line":427},[14872,14876,14880,14884,14888,14892],{"type":29,"tag":88,"props":14873,"children":14874},{"style":105},[14875],{"type":34,"value":108},{"type":29,"tag":88,"props":14877,"children":14878},{"style":105},[14879],{"type":34,"value":113},{"type":29,"tag":88,"props":14881,"children":14882},{"style":116},[14883],{"type":34,"value":11759},{"type":29,"tag":88,"props":14885,"children":14886},{"style":105},[14887],{"type":34,"value":1134},{"type":29,"tag":88,"props":14889,"children":14890},{"style":116},[14891],{"type":34,"value":11604},{"type":29,"tag":88,"props":14893,"children":14894},{"style":122},[14895],{"type":34,"value":125},{"type":29,"tag":88,"props":14897,"children":14898},{"class":90,"line":436},[14899,14903,14907,14911,14915,14919,14923,14927],{"type":29,"tag":88,"props":14900,"children":14901},{"style":105},[14902],{"type":34,"value":276},{"type":29,"tag":88,"props":14904,"children":14905},{"style":105},[14906],{"type":34,"value":1303},{"type":29,"tag":88,"props":14908,"children":14909},{"style":174},[14910],{"type":34,"value":12508},{"type":29,"tag":88,"props":14912,"children":14913},{"style":122},[14914],{"type":34,"value":181},{"type":29,"tag":88,"props":14916,"children":14917},{"style":151},[14918],{"type":34,"value":2386},{"type":29,"tag":88,"props":14920,"children":14921},{"style":298},[14922],{"type":34,"value":4310},{"type":29,"tag":88,"props":14924,"children":14925},{"style":122},[14926],{"type":34,"value":306},{"type":29,"tag":88,"props":14928,"children":14929},{"style":122},[14930],{"type":34,"value":125},{"type":29,"tag":88,"props":14932,"children":14933},{"class":90,"line":767},[14934],{"type":29,"tag":88,"props":14935,"children":14936},{"style":95},[14937],{"type":34,"value":14938},"        \u002F\u002F Logique pour traiter le paiement via PayPal\n",{"type":29,"tag":88,"props":14940,"children":14941},{"class":90,"line":792},[14942],{"type":29,"tag":88,"props":14943,"children":14944},{"style":122},[14945],{"type":34,"value":433},{"type":29,"tag":88,"props":14947,"children":14948},{"class":90,"line":817},[14949],{"type":29,"tag":88,"props":14950,"children":14951},{"style":122},[14952],{"type":34,"value":442},{"type":29,"tag":8542,"props":14954,"children":14956},{"id":14955},"exemple-3-testabilité-et-utilisation-de-tdd",[14957],{"type":34,"value":14958},"Exemple 3 : Testabilité et utilisation de TDD",{"type":29,"tag":30,"props":14960,"children":14961},{},[14962,14964,14969],{"type":34,"value":14963},"L'évolutivité ne concerne pas seulement le code de production, mais aussi les tests. Un code bien conçu doit être facilement testable. L'approche ",{"type":29,"tag":447,"props":14965,"children":14966},{},[14967],{"type":34,"value":14968},"Test-Driven Development (TDD)",{"type":34,"value":14970}," aide à garantir que chaque modification du code est couverte par des tests unitaires, réduisant ainsi le risque d'introduire des bugs.",{"type":29,"tag":10576,"props":14972,"children":14974},{"id":14973},"avant-code-non-testé",[14975],{"type":34,"value":14976},"Avant : Code non testé",{"type":29,"tag":77,"props":14978,"children":14980},{"className":81,"code":14979,"language":80,"meta":8,"style":8},"public class DiscountService {\n    public double applyDiscount(Order order, double discountRate) {\n        return order.getTotalPrice() * (1 - discountRate);\n    }\n}\n",[14981],{"type":29,"tag":84,"props":14982,"children":14983},{"__ignoreMap":8},[14984,15004,15053,15103,15110],{"type":29,"tag":88,"props":14985,"children":14986},{"class":90,"line":91},[14987,14991,14995,15000],{"type":29,"tag":88,"props":14988,"children":14989},{"style":105},[14990],{"type":34,"value":108},{"type":29,"tag":88,"props":14992,"children":14993},{"style":105},[14994],{"type":34,"value":113},{"type":29,"tag":88,"props":14996,"children":14997},{"style":116},[14998],{"type":34,"value":14999}," DiscountService",{"type":29,"tag":88,"props":15001,"children":15002},{"style":122},[15003],{"type":34,"value":125},{"type":29,"tag":88,"props":15005,"children":15006},{"class":90,"line":101},[15007,15011,15015,15020,15024,15028,15032,15036,15040,15045,15049],{"type":29,"tag":88,"props":15008,"children":15009},{"style":105},[15010],{"type":34,"value":276},{"type":29,"tag":88,"props":15012,"children":15013},{"style":105},[15014],{"type":34,"value":10663},{"type":29,"tag":88,"props":15016,"children":15017},{"style":174},[15018],{"type":34,"value":15019}," applyDiscount",{"type":29,"tag":88,"props":15021,"children":15022},{"style":122},[15023],{"type":34,"value":181},{"type":29,"tag":88,"props":15025,"children":15026},{"style":151},[15027],{"type":34,"value":2386},{"type":29,"tag":88,"props":15029,"children":15030},{"style":298},[15031],{"type":34,"value":4310},{"type":29,"tag":88,"props":15033,"children":15034},{"style":122},[15035],{"type":34,"value":192},{"type":29,"tag":88,"props":15037,"children":15038},{"style":105},[15039],{"type":34,"value":10663},{"type":29,"tag":88,"props":15041,"children":15042},{"style":298},[15043],{"type":34,"value":15044}," discountRate",{"type":29,"tag":88,"props":15046,"children":15047},{"style":122},[15048],{"type":34,"value":306},{"type":29,"tag":88,"props":15050,"children":15051},{"style":122},[15052],{"type":34,"value":125},{"type":29,"tag":88,"props":15054,"children":15055},{"class":90,"line":128},[15056,15060,15064,15068,15073,15077,15082,15086,15090,15095,15099],{"type":29,"tag":88,"props":15057,"children":15058},{"style":105},[15059],{"type":34,"value":415},{"type":29,"tag":88,"props":15061,"children":15062},{"style":157},[15063],{"type":34,"value":4310},{"type":29,"tag":88,"props":15065,"children":15066},{"style":122},[15067],{"type":34,"value":338},{"type":29,"tag":88,"props":15069,"children":15070},{"style":174},[15071],{"type":34,"value":15072},"getTotalPrice",{"type":29,"tag":88,"props":15074,"children":15075},{"style":122},[15076],{"type":34,"value":1470},{"type":29,"tag":88,"props":15078,"children":15079},{"style":163},[15080],{"type":34,"value":15081}," *",{"type":29,"tag":88,"props":15083,"children":15084},{"style":122},[15085],{"type":34,"value":2891},{"type":29,"tag":88,"props":15087,"children":15088},{"style":195},[15089],{"type":34,"value":2275},{"type":29,"tag":88,"props":15091,"children":15092},{"style":163},[15093],{"type":34,"value":15094}," -",{"type":29,"tag":88,"props":15096,"children":15097},{"style":157},[15098],{"type":34,"value":15044},{"type":29,"tag":88,"props":15100,"children":15101},{"style":122},[15102],{"type":34,"value":357},{"type":29,"tag":88,"props":15104,"children":15105},{"class":90,"line":137},[15106],{"type":29,"tag":88,"props":15107,"children":15108},{"style":122},[15109],{"type":34,"value":433},{"type":29,"tag":88,"props":15111,"children":15112},{"class":90,"line":211},[15113],{"type":29,"tag":88,"props":15114,"children":15115},{"style":122},[15116],{"type":34,"value":442},{"type":29,"tag":10576,"props":15118,"children":15120},{"id":15119},"après-ajout-de-tests-unitaires",[15121],{"type":34,"value":15122},"Après : Ajout de tests unitaires",{"type":29,"tag":30,"props":15124,"children":15125},{},[15126,15128,15132,15134,15140],{"type":34,"value":15127},"En utilisant ",{"type":29,"tag":447,"props":15129,"children":15130},{},[15131],{"type":34,"value":12978},{"type":34,"value":15133},", nous pouvons écrire un test unitaire pour garantir que la méthode ",{"type":29,"tag":84,"props":15135,"children":15137},{"className":15136},[],[15138],{"type":34,"value":15139},"applyDiscount",{"type":34,"value":15141}," fonctionne correctement, même après des modifications.",{"type":29,"tag":77,"props":15143,"children":15145},{"className":81,"code":15144,"language":80,"meta":8,"style":8},"import static org.junit.Assert.assertEquals;\nimport org.junit.Test;\n\npublic class DiscountServiceTest {\n\n    @Test\n    public void testApplyDiscount() {\n        Order order = new Order(\"Laptop\", 2, 1000);\n        DiscountService discountService = new DiscountService();\n        double discountedPrice = discountService.applyDiscount(order, 0.1); \u002F\u002F 10% de réduction\n\n        assertEquals(1800, discountedPrice, 0.01);\n    }\n}\n",[15146],{"type":29,"tag":84,"props":15147,"children":15148},{"__ignoreMap":8},[15149,15192,15223,15230,15250,15257,15268,15292,15345,15374,15429,15436,15473,15480],{"type":29,"tag":88,"props":15150,"children":15151},{"class":90,"line":91},[15152,15156,15160,15164,15168,15172,15176,15180,15184,15188],{"type":29,"tag":88,"props":15153,"children":15154},{"style":105},[15155],{"type":34,"value":13001},{"type":29,"tag":88,"props":15157,"children":15158},{"style":105},[15159],{"type":34,"value":12248},{"type":29,"tag":88,"props":15161,"children":15162},{"style":157},[15163],{"type":34,"value":13010},{"type":29,"tag":88,"props":15165,"children":15166},{"style":122},[15167],{"type":34,"value":338},{"type":29,"tag":88,"props":15169,"children":15170},{"style":157},[15171],{"type":34,"value":13019},{"type":29,"tag":88,"props":15173,"children":15174},{"style":122},[15175],{"type":34,"value":338},{"type":29,"tag":88,"props":15177,"children":15178},{"style":157},[15179],{"type":34,"value":13028},{"type":29,"tag":88,"props":15181,"children":15182},{"style":122},[15183],{"type":34,"value":338},{"type":29,"tag":88,"props":15185,"children":15186},{"style":157},[15187],{"type":34,"value":13037},{"type":29,"tag":88,"props":15189,"children":15190},{"style":122},[15191],{"type":34,"value":424},{"type":29,"tag":88,"props":15193,"children":15194},{"class":90,"line":101},[15195,15199,15203,15207,15211,15215,15219],{"type":29,"tag":88,"props":15196,"children":15197},{"style":105},[15198],{"type":34,"value":13001},{"type":29,"tag":88,"props":15200,"children":15201},{"style":157},[15202],{"type":34,"value":13010},{"type":29,"tag":88,"props":15204,"children":15205},{"style":122},[15206],{"type":34,"value":338},{"type":29,"tag":88,"props":15208,"children":15209},{"style":157},[15210],{"type":34,"value":13019},{"type":29,"tag":88,"props":15212,"children":15213},{"style":122},[15214],{"type":34,"value":338},{"type":29,"tag":88,"props":15216,"children":15217},{"style":157},[15218],{"type":34,"value":13069},{"type":29,"tag":88,"props":15220,"children":15221},{"style":122},[15222],{"type":34,"value":424},{"type":29,"tag":88,"props":15224,"children":15225},{"class":90,"line":128},[15226],{"type":29,"tag":88,"props":15227,"children":15228},{"emptyLinePlaceholder":13},[15229],{"type":34,"value":134},{"type":29,"tag":88,"props":15231,"children":15232},{"class":90,"line":137},[15233,15237,15241,15246],{"type":29,"tag":88,"props":15234,"children":15235},{"style":105},[15236],{"type":34,"value":108},{"type":29,"tag":88,"props":15238,"children":15239},{"style":105},[15240],{"type":34,"value":113},{"type":29,"tag":88,"props":15242,"children":15243},{"style":116},[15244],{"type":34,"value":15245}," DiscountServiceTest",{"type":29,"tag":88,"props":15247,"children":15248},{"style":122},[15249],{"type":34,"value":125},{"type":29,"tag":88,"props":15251,"children":15252},{"class":90,"line":211},[15253],{"type":29,"tag":88,"props":15254,"children":15255},{"emptyLinePlaceholder":13},[15256],{"type":34,"value":134},{"type":29,"tag":88,"props":15258,"children":15259},{"class":90,"line":262},[15260,15264],{"type":29,"tag":88,"props":15261,"children":15262},{"style":1974},[15263],{"type":34,"value":3302},{"type":29,"tag":88,"props":15265,"children":15266},{"style":1980},[15267],{"type":34,"value":1983},{"type":29,"tag":88,"props":15269,"children":15270},{"class":90,"line":270},[15271,15275,15279,15284,15288],{"type":29,"tag":88,"props":15272,"children":15273},{"style":105},[15274],{"type":34,"value":276},{"type":29,"tag":88,"props":15276,"children":15277},{"style":105},[15278],{"type":34,"value":1303},{"type":29,"tag":88,"props":15280,"children":15281},{"style":174},[15282],{"type":34,"value":15283}," testApplyDiscount",{"type":29,"tag":88,"props":15285,"children":15286},{"style":122},[15287],{"type":34,"value":1470},{"type":29,"tag":88,"props":15289,"children":15290},{"style":122},[15291],{"type":34,"value":125},{"type":29,"tag":88,"props":15293,"children":15294},{"class":90,"line":313},[15295,15299,15303,15307,15311,15315,15319,15324,15328,15332,15336,15341],{"type":29,"tag":88,"props":15296,"children":15297},{"style":151},[15298],{"type":34,"value":4176},{"type":29,"tag":88,"props":15300,"children":15301},{"style":157},[15302],{"type":34,"value":4181},{"type":29,"tag":88,"props":15304,"children":15305},{"style":163},[15306],{"type":34,"value":166},{"type":29,"tag":88,"props":15308,"children":15309},{"style":105},[15310],{"type":34,"value":171},{"type":29,"tag":88,"props":15312,"children":15313},{"style":174},[15314],{"type":34,"value":2740},{"type":29,"tag":88,"props":15316,"children":15317},{"style":122},[15318],{"type":34,"value":181},{"type":29,"tag":88,"props":15320,"children":15321},{"style":184},[15322],{"type":34,"value":15323},"\"Laptop\"",{"type":29,"tag":88,"props":15325,"children":15326},{"style":122},[15327],{"type":34,"value":192},{"type":29,"tag":88,"props":15329,"children":15330},{"style":195},[15331],{"type":34,"value":9193},{"type":29,"tag":88,"props":15333,"children":15334},{"style":122},[15335],{"type":34,"value":192},{"type":29,"tag":88,"props":15337,"children":15338},{"style":195},[15339],{"type":34,"value":15340}," 1000",{"type":29,"tag":88,"props":15342,"children":15343},{"style":122},[15344],{"type":34,"value":357},{"type":29,"tag":88,"props":15346,"children":15347},{"class":90,"line":360},[15348,15353,15358,15362,15366,15370],{"type":29,"tag":88,"props":15349,"children":15350},{"style":151},[15351],{"type":34,"value":15352},"        DiscountService",{"type":29,"tag":88,"props":15354,"children":15355},{"style":157},[15356],{"type":34,"value":15357}," discountService ",{"type":29,"tag":88,"props":15359,"children":15360},{"style":163},[15361],{"type":34,"value":166},{"type":29,"tag":88,"props":15363,"children":15364},{"style":105},[15365],{"type":34,"value":171},{"type":29,"tag":88,"props":15367,"children":15368},{"style":174},[15369],{"type":34,"value":14999},{"type":29,"tag":88,"props":15371,"children":15372},{"style":122},[15373],{"type":34,"value":1810},{"type":29,"tag":88,"props":15375,"children":15376},{"class":90,"line":409},[15377,15381,15386,15390,15395,15399,15403,15407,15411,15415,15420,15424],{"type":29,"tag":88,"props":15378,"children":15379},{"style":105},[15380],{"type":34,"value":13226},{"type":29,"tag":88,"props":15382,"children":15383},{"style":157},[15384],{"type":34,"value":15385}," discountedPrice ",{"type":29,"tag":88,"props":15387,"children":15388},{"style":163},[15389],{"type":34,"value":166},{"type":29,"tag":88,"props":15391,"children":15392},{"style":157},[15393],{"type":34,"value":15394}," discountService",{"type":29,"tag":88,"props":15396,"children":15397},{"style":122},[15398],{"type":34,"value":338},{"type":29,"tag":88,"props":15400,"children":15401},{"style":174},[15402],{"type":34,"value":15139},{"type":29,"tag":88,"props":15404,"children":15405},{"style":122},[15406],{"type":34,"value":181},{"type":29,"tag":88,"props":15408,"children":15409},{"style":157},[15410],{"type":34,"value":5182},{"type":29,"tag":88,"props":15412,"children":15413},{"style":122},[15414],{"type":34,"value":192},{"type":29,"tag":88,"props":15416,"children":15417},{"style":195},[15418],{"type":34,"value":15419}," 0.1",{"type":29,"tag":88,"props":15421,"children":15422},{"style":122},[15423],{"type":34,"value":203},{"type":29,"tag":88,"props":15425,"children":15426},{"style":95},[15427],{"type":34,"value":15428}," \u002F\u002F 10% de réduction\n",{"type":29,"tag":88,"props":15430,"children":15431},{"class":90,"line":427},[15432],{"type":29,"tag":88,"props":15433,"children":15434},{"emptyLinePlaceholder":13},[15435],{"type":34,"value":134},{"type":29,"tag":88,"props":15437,"children":15438},{"class":90,"line":436},[15439,15443,15447,15452,15456,15461,15465,15469],{"type":29,"tag":88,"props":15440,"children":15441},{"style":174},[15442],{"type":34,"value":4285},{"type":29,"tag":88,"props":15444,"children":15445},{"style":122},[15446],{"type":34,"value":181},{"type":29,"tag":88,"props":15448,"children":15449},{"style":195},[15450],{"type":34,"value":15451},"1800",{"type":29,"tag":88,"props":15453,"children":15454},{"style":122},[15455],{"type":34,"value":192},{"type":29,"tag":88,"props":15457,"children":15458},{"style":157},[15459],{"type":34,"value":15460}," discountedPrice",{"type":29,"tag":88,"props":15462,"children":15463},{"style":122},[15464],{"type":34,"value":192},{"type":29,"tag":88,"props":15466,"children":15467},{"style":195},[15468],{"type":34,"value":13302},{"type":29,"tag":88,"props":15470,"children":15471},{"style":122},[15472],{"type":34,"value":357},{"type":29,"tag":88,"props":15474,"children":15475},{"class":90,"line":767},[15476],{"type":29,"tag":88,"props":15477,"children":15478},{"style":122},[15479],{"type":34,"value":433},{"type":29,"tag":88,"props":15481,"children":15482},{"class":90,"line":792},[15483],{"type":29,"tag":88,"props":15484,"children":15485},{"style":122},[15486],{"type":34,"value":442},{"type":29,"tag":30,"props":15488,"children":15489},{},[15490,15492,15497],{"type":34,"value":15491},"Grâce à ce test, nous pouvons modifier la méthode ",{"type":29,"tag":84,"props":15493,"children":15495},{"className":15494},[],[15496],{"type":34,"value":15139},{"type":34,"value":15498}," sans crainte, car les tests nous avertiront immédiatement si quelque chose casse.",{"type":29,"tag":2288,"props":15500,"children":15502},{"cta":5629,"href":5630,"title":15501,"type":5632},"Le code évolutif n'est qu'une pratique parmi 100",[15503],{"type":29,"tag":30,"props":15504,"children":15505},{},[15506],{"type":34,"value":15507},"Cet article détaille une pratique : concevoir des classes qui acceptent le changement. Le Craft Bundle réunit les 100 pratiques que j'applique pour coder propre, du découpage des responsabilités au refactoring sûr en passant par les tests qui sécurisent vos évolutions. Ce sont les réflexes que l'IA ne vous apprendra jamais, parce qu'elle ne les a jamais vus tenir dans la durée sur un vrai projet.",{"type":29,"tag":47,"props":15509,"children":15510},{},[],{"type":29,"tag":51,"props":15512,"children":15514},{"id":15513},"faq-réponses-aux-questions-fréquentes",[15515],{"type":34,"value":15516},"FAQ : Réponses aux questions fréquentes",{"type":29,"tag":5649,"props":15518,"children":15519},{},[15520,15525,15530],{"type":29,"tag":5653,"props":15521,"children":15522},{},[15523],{"type":34,"value":15524},"1. Quels sont les signes d’un code non évolutif ?",{"type":29,"tag":30,"props":15526,"children":15527},{},[15528],{"type":34,"value":15529},"Un code non évolutif se reconnaît par plusieurs symptômes :",{"type":29,"tag":453,"props":15531,"children":15532},{},[15533,15543,15553,15563],{"type":29,"tag":457,"props":15534,"children":15535},{},[15536,15541],{"type":29,"tag":447,"props":15537,"children":15538},{},[15539],{"type":34,"value":15540},"Dépendances rigides",{"type":34,"value":15542}," : Vous devez souvent modifier plusieurs fichiers ou classes pour introduire un simple changement.",{"type":29,"tag":457,"props":15544,"children":15545},{},[15546,15551],{"type":29,"tag":447,"props":15547,"children":15548},{},[15549],{"type":34,"value":15550},"Classes surchargées",{"type":34,"value":15552}," : Certaines classes ou méthodes semblent faire trop de choses à la fois, ce qui les rend difficiles à maintenir et à comprendre.",{"type":29,"tag":457,"props":15554,"children":15555},{},[15556,15561],{"type":29,"tag":447,"props":15557,"children":15558},{},[15559],{"type":34,"value":15560},"Régression fréquente",{"type":34,"value":15562}," : À chaque fois que vous modifiez le code, vous cassez des fonctionnalités existantes.",{"type":29,"tag":457,"props":15564,"children":15565},{},[15566,15571],{"type":29,"tag":447,"props":15567,"children":15568},{},[15569],{"type":34,"value":15570},"Manque de tests",{"type":34,"value":15572}," : Vous ne pouvez pas facilement tester certaines parties de votre code, ou les tests ne couvrent pas assez de cas, rendant le refactoring risqué.",{"type":29,"tag":5649,"props":15574,"children":15575},{},[15576,15581],{"type":29,"tag":5653,"props":15577,"children":15578},{},[15579],{"type":34,"value":15580},"2. Est-ce que toutes les parties d'un projet doivent être évolutives dès le début ?",{"type":29,"tag":30,"props":15582,"children":15583},{},[15584],{"type":34,"value":15585},"Pas nécessairement. Priorisez les parties qui vont évoluer : code critique, modules avec beaucoup d'interactions, zones soumises à des modifications fréquentes. Le code très spécifique ou temporaire peut rester plus simple : ne payez pas le coût d'abstraction pour du jetable.",{"type":29,"tag":5649,"props":15587,"children":15588},{},[15589,15594],{"type":29,"tag":5653,"props":15590,"children":15591},{},[15592],{"type":34,"value":15593},"3. Quelles erreurs courantes éviter ?",{"type":29,"tag":453,"props":15595,"children":15596},{},[15597,15607,15617],{"type":29,"tag":457,"props":15598,"children":15599},{},[15600,15605],{"type":29,"tag":447,"props":15601,"children":15602},{},[15603],{"type":34,"value":15604},"Sur-conception",{"type":34,"value":15606}," : anticiper chaque changement possible mène à un code trop abstrait. Restez pragmatique, faites évoluer au fur et à mesure des besoins réels.",{"type":29,"tag":457,"props":15608,"children":15609},{},[15610,15615],{"type":29,"tag":447,"props":15611,"children":15612},{},[15613],{"type":34,"value":15614},"Ignorer les tests",{"type":34,"value":15616}," : écrire du code évolutif sans tests solides est contradictoire. Les tests sont le filet qui rend le refactoring possible.",{"type":29,"tag":457,"props":15618,"children":15619},{},[15620,15625],{"type":29,"tag":447,"props":15621,"children":15622},{},[15623],{"type":34,"value":15624},"Manque de documentation",{"type":34,"value":15626}," : un code évolutif que personne ne sait étendre devient contre-productif. Documentez ce qui est non trivial.",{"type":29,"tag":47,"props":15628,"children":15629},{},[],{"type":29,"tag":51,"props":15631,"children":15633},{"id":15632},"conclusion",[15634],{"type":34,"value":15635},"Conclusion",{"type":29,"tag":30,"props":15637,"children":15638},{},[15639],{"type":34,"value":15640},"En appliquant les bonnes pratiques et les principes présentés ici, vous pouvez rendre votre code beaucoup plus évolutif. Cela vous permettra d'ajouter de nouvelles fonctionnalités, de corriger des erreurs et de maintenir votre logiciel plus facilement, sans avoir à craindre de tout casser. Avec des exemples concrets en Java, vous avez maintenant les outils nécessaires pour appliquer ces concepts à vos propres projets et améliorer la qualité et la longévité de votre code.",{"type":29,"tag":47,"props":15642,"children":15643},{},[],{"type":29,"tag":2288,"props":15645,"children":15648},{"cta":15646,"href":10075,"title":15647,"type":5755},"Télécharger le guide gratuit →","Ressource gratuite : De 6 semaines à 8 jours de lead time en 90 jours",[15649],{"type":29,"tag":30,"props":15650,"children":15651},{},[15652],{"type":34,"value":15653},"Le framework 4 phases appliqué dans 12 équipes engineering, avec des exemples before\u002Fafter chiffrés. Un code évolutif est la clé d'un lead time court : découvrez comment y parvenir.",{"type":29,"tag":5763,"props":15655,"children":15656},{},[15657],{"type":34,"value":5767},{"title":8,"searchDepth":101,"depth":101,"links":15659},[15660,15661,15662,15666,15672,15677,15678],{"id":10542,"depth":101,"text":10545},{"id":10561,"depth":101,"text":10564},{"id":11029,"depth":101,"text":11032,"children":15663},[15664,15665],{"id":11040,"depth":128,"text":11043},{"id":11416,"depth":128,"text":11419},{"id":11847,"depth":101,"text":11850,"children":15667},[15668,15669,15670,15671],{"id":11858,"depth":128,"text":11861},{"id":12154,"depth":128,"text":12157},{"id":12448,"depth":128,"text":12451},{"id":12947,"depth":128,"text":12950},{"id":13331,"depth":101,"text":13334,"children":15673},[15674,15675,15676],{"id":13342,"depth":128,"text":13345},{"id":14277,"depth":128,"text":14280},{"id":14955,"depth":128,"text":14958},{"id":15513,"depth":101,"text":15516},{"id":15632,"depth":101,"text":15635},"content:fr:dette-technique:comment-ecrire-du-code-evolutif-en-developpement-logiciel.md","fr\u002Fdette-technique\u002Fcomment-ecrire-du-code-evolutif-en-developpement-logiciel.md","fr\u002Fdette-technique\u002Fcomment-ecrire-du-code-evolutif-en-developpement-logiciel",{"_path":15683,"_dir":8447,"_draft":7,"_partial":7,"_locale":8,"title":15684,"description":15685,"id":1426,"date":15686,"listed":13,"nocomments":7,"hidden":7,"categories":15687,"tags":15688,"cover":15689,"readingTime":15690,"body":15695,"_type":5777,"_id":16933,"_source":5779,"_file":16934,"_stem":16935,"_extension":5782},"\u002Ffr\u002Fdette-technique\u002Fguide-code-lisible-software-craftsmanship","Le Guide du Code Lisible, Améliorer la Qualité Logicielle en Software Craftsmanship","Découvrez comment la lisibilité du code est essentielle en software craftsmanship. Apprenez des techniques pratiques pour écrire un code lisible, clair...","2024-06-27",[8447],[16,8453],"covers\u002Farticles\u002Fqualite-de-code.jpg",{"text":15691,"minutes":15692,"time":15693,"words":15694},"11 min read",10.28,616800,2056,{"type":26,"children":15696,"toc":16924},[15697,15703,15730,15741,15746,15752,15757,15762,15859,15864,15960,15965,15996,16001,16010,16016,16027,16033,16069,16074,16080,16085,16090,16096,16101,16106,16215,16220,16382,16387,16392,16398,16403,16409,16428,16433,16585,16590,16621,16626,16631,16637,16642,16647,16665,16671,16676,16681,16686,16691,16697,16702,16707,16712,16718,16723,16729,16734,16744,16757,16763,16768,16777,16783,16788,16797,16803,16808,16817,16820,16824,16837,16864,16877,16890,16893,16912,16920],{"type":29,"tag":51,"props":15698,"children":15700},{"id":15699},"pourquoi-la-lisibilité-nest-jamais-facultative",[15701],{"type":34,"value":15702},"Pourquoi la lisibilité n'est jamais facultative",{"type":29,"tag":30,"props":15704,"children":15705},{},[15706,15708,15714,15715,15721,15722,15728],{"type":34,"value":15707},"Mission chez Canal+, équipe d'une vingtaine de développeurs sur une plateforme de diffusion. Premier code parcouru le matin de l'arrivée : trois mille lignes, des variables ",{"type":29,"tag":84,"props":15709,"children":15711},{"className":15710},[],[15712],{"type":34,"value":15713},"var1",{"type":34,"value":544},{"type":29,"tag":84,"props":15716,"children":15718},{"className":15717},[],[15719],{"type":34,"value":15720},"tmp2",{"type":34,"value":544},{"type":29,"tag":84,"props":15723,"children":15725},{"className":15724},[],[15726],{"type":34,"value":15727},"data",{"type":34,"value":15729},", des méthodes de quatre-vingts lignes sans nom évocateur, zéro commentaire utile. Pour comprendre ce que faisait une simple fonction de validation d'abonnement, il fallait remonter à travers quatre fichiers et déchiffrer un état partagé entre objets non typés. Même histoire chez Crédit Agricole Assurances quelques mois plus tard sur un module de tarification.",{"type":29,"tag":30,"props":15731,"children":15732},{},[15733,15735,15739],{"type":34,"value":15734},"Dans les deux cas, l'équipe livrait du code qui fonctionnait, et perdait collectivement plusieurs heures par jour à le déchiffrer pour pouvoir le modifier. La lisibilité n'est pas une question de goût esthétique : c'est ce qui détermine la vitesse à laquelle votre équipe peut évoluer le code sans casser autre chose. C'est aussi ce qui sépare le ",{"type":29,"tag":447,"props":15736,"children":15737},{},[15738],{"type":34,"value":10183},{"type":34,"value":15740}," d'une production logicielle à courte vue.",{"type":29,"tag":30,"props":15742,"children":15743},{},[15744],{"type":34,"value":15745},"Cet article rassemble ce qui fait la différence entre un code qu'on relit avec aisance six mois plus tard et un code qu'on n'ose plus toucher : les principes, les pratiques, les objections que vous entendrez en équipe et la manière d'y répondre.",{"type":29,"tag":51,"props":15747,"children":15749},{"id":15748},"reconnaître-un-code-lisible",[15750],{"type":34,"value":15751},"Reconnaître un code lisible",{"type":29,"tag":30,"props":15753,"children":15754},{},[15755],{"type":34,"value":15756},"Un code lisible se laisse comprendre rapidement, sans archéologie ni devinette sur les intentions de l'auteur. Chaque élément (nom de variable, signature de méthode, structure de bloc) porte sa charge d'information.",{"type":29,"tag":30,"props":15758,"children":15759},{},[15760],{"type":34,"value":15761},"L'exemple canonique :",{"type":29,"tag":77,"props":15763,"children":15765},{"className":81,"code":15764,"language":80,"meta":8,"style":8},"int a = 3;  \nint b = 5;  \nint c = a * b;\n",[15766],{"type":29,"tag":84,"props":15767,"children":15768},{"__ignoreMap":8},[15769,15798,15827],{"type":29,"tag":88,"props":15770,"children":15771},{"class":90,"line":91},[15772,15776,15780,15784,15789,15793],{"type":29,"tag":88,"props":15773,"children":15774},{"style":105},[15775],{"type":34,"value":8622},{"type":29,"tag":88,"props":15777,"children":15778},{"style":157},[15779],{"type":34,"value":8925},{"type":29,"tag":88,"props":15781,"children":15782},{"style":163},[15783],{"type":34,"value":166},{"type":29,"tag":88,"props":15785,"children":15786},{"style":195},[15787],{"type":34,"value":15788}," 3",{"type":29,"tag":88,"props":15790,"children":15791},{"style":122},[15792],{"type":34,"value":5988},{"type":29,"tag":88,"props":15794,"children":15795},{"style":157},[15796],{"type":34,"value":15797},"  \n",{"type":29,"tag":88,"props":15799,"children":15800},{"class":90,"line":101},[15801,15805,15810,15814,15819,15823],{"type":29,"tag":88,"props":15802,"children":15803},{"style":105},[15804],{"type":34,"value":8622},{"type":29,"tag":88,"props":15806,"children":15807},{"style":157},[15808],{"type":34,"value":15809}," b ",{"type":29,"tag":88,"props":15811,"children":15812},{"style":163},[15813],{"type":34,"value":166},{"type":29,"tag":88,"props":15815,"children":15816},{"style":195},[15817],{"type":34,"value":15818}," 5",{"type":29,"tag":88,"props":15820,"children":15821},{"style":122},[15822],{"type":34,"value":5988},{"type":29,"tag":88,"props":15824,"children":15825},{"style":157},[15826],{"type":34,"value":15797},{"type":29,"tag":88,"props":15828,"children":15829},{"class":90,"line":128},[15830,15834,15839,15843,15847,15851,15855],{"type":29,"tag":88,"props":15831,"children":15832},{"style":105},[15833],{"type":34,"value":8622},{"type":29,"tag":88,"props":15835,"children":15836},{"style":157},[15837],{"type":34,"value":15838}," c ",{"type":29,"tag":88,"props":15840,"children":15841},{"style":163},[15842],{"type":34,"value":166},{"type":29,"tag":88,"props":15844,"children":15845},{"style":157},[15846],{"type":34,"value":8925},{"type":29,"tag":88,"props":15848,"children":15849},{"style":163},[15850],{"type":34,"value":8709},{"type":29,"tag":88,"props":15852,"children":15853},{"style":157},[15854],{"type":34,"value":8905},{"type":29,"tag":88,"props":15856,"children":15857},{"style":122},[15858],{"type":34,"value":424},{"type":29,"tag":30,"props":15860,"children":15861},{},[15862],{"type":34,"value":15863},"vs.",{"type":29,"tag":77,"props":15865,"children":15867},{"className":81,"code":15866,"language":80,"meta":8,"style":8},"int largeur = 3;  \nint hauteur = 5;  \nint surface = largeur * hauteur;\n",[15868],{"type":29,"tag":84,"props":15869,"children":15870},{"__ignoreMap":8},[15871,15899,15927],{"type":29,"tag":88,"props":15872,"children":15873},{"class":90,"line":91},[15874,15878,15883,15887,15891,15895],{"type":29,"tag":88,"props":15875,"children":15876},{"style":105},[15877],{"type":34,"value":8622},{"type":29,"tag":88,"props":15879,"children":15880},{"style":157},[15881],{"type":34,"value":15882}," largeur ",{"type":29,"tag":88,"props":15884,"children":15885},{"style":163},[15886],{"type":34,"value":166},{"type":29,"tag":88,"props":15888,"children":15889},{"style":195},[15890],{"type":34,"value":15788},{"type":29,"tag":88,"props":15892,"children":15893},{"style":122},[15894],{"type":34,"value":5988},{"type":29,"tag":88,"props":15896,"children":15897},{"style":157},[15898],{"type":34,"value":15797},{"type":29,"tag":88,"props":15900,"children":15901},{"class":90,"line":101},[15902,15906,15911,15915,15919,15923],{"type":29,"tag":88,"props":15903,"children":15904},{"style":105},[15905],{"type":34,"value":8622},{"type":29,"tag":88,"props":15907,"children":15908},{"style":157},[15909],{"type":34,"value":15910}," hauteur ",{"type":29,"tag":88,"props":15912,"children":15913},{"style":163},[15914],{"type":34,"value":166},{"type":29,"tag":88,"props":15916,"children":15917},{"style":195},[15918],{"type":34,"value":15818},{"type":29,"tag":88,"props":15920,"children":15921},{"style":122},[15922],{"type":34,"value":5988},{"type":29,"tag":88,"props":15924,"children":15925},{"style":157},[15926],{"type":34,"value":15797},{"type":29,"tag":88,"props":15928,"children":15929},{"class":90,"line":128},[15930,15934,15939,15943,15947,15951,15956],{"type":29,"tag":88,"props":15931,"children":15932},{"style":105},[15933],{"type":34,"value":8622},{"type":29,"tag":88,"props":15935,"children":15936},{"style":157},[15937],{"type":34,"value":15938}," surface ",{"type":29,"tag":88,"props":15940,"children":15941},{"style":163},[15942],{"type":34,"value":166},{"type":29,"tag":88,"props":15944,"children":15945},{"style":157},[15946],{"type":34,"value":15882},{"type":29,"tag":88,"props":15948,"children":15949},{"style":163},[15950],{"type":34,"value":8709},{"type":29,"tag":88,"props":15952,"children":15953},{"style":157},[15954],{"type":34,"value":15955}," hauteur",{"type":29,"tag":88,"props":15957,"children":15958},{"style":122},[15959],{"type":34,"value":424},{"type":29,"tag":30,"props":15961,"children":15962},{},[15963],{"type":34,"value":15964},"Aucun commentaire ne devient nécessaire dans la seconde version : le code raconte lui-même ce qu'il calcule. La lisibilité commence là, dans le choix précis du nom de chaque variable.",{"type":29,"tag":8526,"props":15966,"children":15967},{"type":8528},[15968],{"type":29,"tag":30,"props":15969,"children":15970},{},[15971,15973,15979,15981,15987,15989,15995],{"type":34,"value":15972},"Règle pratique : un nom de variable doit décrire son rôle, pas son type. ",{"type":29,"tag":84,"props":15974,"children":15976},{"className":15975},[],[15977],{"type":34,"value":15978},"nombreDeLignes",{"type":34,"value":15980}," vaut mieux que ",{"type":29,"tag":84,"props":15982,"children":15984},{"className":15983},[],[15985],{"type":34,"value":15986},"n",{"type":34,"value":15988}," ou que ",{"type":29,"tag":84,"props":15990,"children":15992},{"className":15991},[],[15993],{"type":34,"value":15994},"intLignes",{"type":34,"value":338},{"type":29,"tag":30,"props":15997,"children":15998},{},[15999],{"type":34,"value":16000},"Les bénéfices se mesurent à la durée de vie du projet : maintenance plus rapide, onboarding raccourci, moins de bugs introduits par incompréhension. À l'inverse, un code illisible alimente directement la dette technique : chaque modification devient un pari, chaque arrivée d'un nouveau développeur coûte deux semaines de plus que prévu.",{"type":29,"tag":2288,"props":16002,"children":16004},{"cta":2290,"href":2291,"title":16003,"type":2293},"Vous voulez écrire un code que vos collègues comprennent en trois secondes ?",[16005],{"type":29,"tag":30,"props":16006,"children":16007},{},[16008],{"type":34,"value":16009},"Choisir le bon nom, découper une fonction, isoler une condition : ces réflexes ne s'acquièrent pas en lisant un article, ils se travaillent sur votre propre code. En mentoring 1:1, je relis vos PR avec vous et on retravaille ensemble les passages où la lisibilité décroche, jusqu'à ce que ces choix deviennent un automatisme.",{"type":29,"tag":51,"props":16011,"children":16013},{"id":16012},"trois-piliers-concrets",[16014],{"type":34,"value":16015},"Trois piliers concrets",{"type":29,"tag":30,"props":16017,"children":16018},{},[16019,16021,16025],{"type":34,"value":16020},"Le nommage ne suffit pas. Trois principes structurent la lisibilité, appliqués ensemble, ils transforment durablement la qualité du code. Robert C. Martin le formule dans ",{"type":29,"tag":8474,"props":16022,"children":16023},{},[16024],{"type":34,"value":8478},{"type":34,"value":16026}," : un bon code se lit comme de la prose.",{"type":29,"tag":10576,"props":16028,"children":16030},{"id":16029},"_1-nommer-pour-révéler-lintention",[16031],{"type":34,"value":16032},"1. Nommer pour révéler l'intention",{"type":29,"tag":30,"props":16034,"children":16035},{},[16036,16038,16044,16046,16052,16054,16060,16061,16067],{"type":34,"value":16037},"Variables, fonctions, classes : chaque nom doit décrire ce que représente la chose, pas comment elle est implémentée. ",{"type":29,"tag":84,"props":16039,"children":16041},{"className":16040},[],[16042],{"type":34,"value":16043},"additionnerNombres",{"type":34,"value":16045}," parle, ",{"type":29,"tag":84,"props":16047,"children":16049},{"className":16048},[],[16050],{"type":34,"value":16051},"calculer",{"type":34,"value":16053}," reste mystérieux. ",{"type":29,"tag":84,"props":16055,"children":16057},{"className":16056},[],[16058],{"type":34,"value":16059},"compteurDeLignes",{"type":34,"value":16045},{"type":29,"tag":84,"props":16062,"children":16064},{"className":16063},[],[16065],{"type":34,"value":16066},"i",{"type":34,"value":16068}," oblige à remonter trois lignes plus haut pour savoir.",{"type":29,"tag":30,"props":16070,"children":16071},{},[16072],{"type":34,"value":16073},"Règle des trois secondes : si la fonction ou la variable n'est pas comprise en trois secondes par un développeur de l'équipe, le nom est à reprendre.",{"type":29,"tag":10576,"props":16075,"children":16077},{"id":16076},"_2-structure-et-organisation-du-code",[16078],{"type":34,"value":16079},"2. Structure et organisation du code",{"type":29,"tag":30,"props":16081,"children":16082},{},[16083],{"type":34,"value":16084},"La manière dont votre code est structuré a un impact direct sur sa lisibilité. Il est essentiel de séparer les préoccupations et de diviser le code en petites fonctions ou méthodes qui réalisent chacune une tâche bien précise. Une règle simple : chaque fonction ne devrait faire qu'une seule chose. Si vous constatez que votre fonction fait plusieurs actions, il est probablement temps de la diviser en plusieurs fonctions plus petites.",{"type":29,"tag":30,"props":16086,"children":16087},{},[16088],{"type":34,"value":16089},"De plus, un bon formatage (indentation, espaces, sauts de ligne) améliore la lisibilité. Un code compact et mal organisé, sans espaces entre les blocs logiques, devient rapidement difficile à suivre.",{"type":29,"tag":10576,"props":16091,"children":16093},{"id":16092},"_3-limiter-la-complexité-cognitive",[16094],{"type":34,"value":16095},"3. Limiter la complexité cognitive",{"type":29,"tag":30,"props":16097,"children":16098},{},[16099],{"type":34,"value":16100},"La complexité cognitive correspond à la charge mentale nécessaire pour comprendre un morceau de code. Plus un code est complexe, plus il est difficile à lire et à maintenir. Pour réduire cette complexité, je vous recommande d'éviter les longues chaînes de conditions, les boucles imbriquées et les instructions trop denses.",{"type":29,"tag":30,"props":16102,"children":16103},{},[16104],{"type":34,"value":16105},"Par exemple, au lieu de ceci :",{"type":29,"tag":77,"props":16107,"children":16109},{"className":81,"code":16108,"language":80,"meta":8,"style":8},"if (x > 10 && y \u003C 5 || (z == 3 && !a)) {\n    \u002F\u002F code\n}\n",[16110],{"type":29,"tag":84,"props":16111,"children":16112},{"__ignoreMap":8},[16113,16200,16208],{"type":29,"tag":88,"props":16114,"children":16115},{"class":90,"line":91},[16116,16121,16125,16130,16134,16139,16143,16148,16152,16156,16161,16165,16170,16174,16178,16182,16187,16191,16196],{"type":29,"tag":88,"props":16117,"children":16118},{"style":105},[16119],{"type":34,"value":16120},"if",{"type":29,"tag":88,"props":16122,"children":16123},{"style":122},[16124],{"type":34,"value":2891},{"type":29,"tag":88,"props":16126,"children":16127},{"style":157},[16128],{"type":34,"value":16129},"x ",{"type":29,"tag":88,"props":16131,"children":16132},{"style":163},[16133],{"type":34,"value":1701},{"type":29,"tag":88,"props":16135,"children":16136},{"style":195},[16137],{"type":34,"value":16138}," 10",{"type":29,"tag":88,"props":16140,"children":16141},{"style":163},[16142],{"type":34,"value":9752},{"type":29,"tag":88,"props":16144,"children":16145},{"style":157},[16146],{"type":34,"value":16147}," y ",{"type":29,"tag":88,"props":16149,"children":16150},{"style":163},[16151],{"type":34,"value":1683},{"type":29,"tag":88,"props":16153,"children":16154},{"style":195},[16155],{"type":34,"value":15818},{"type":29,"tag":88,"props":16157,"children":16158},{"style":163},[16159],{"type":34,"value":16160}," ||",{"type":29,"tag":88,"props":16162,"children":16163},{"style":122},[16164],{"type":34,"value":2891},{"type":29,"tag":88,"props":16166,"children":16167},{"style":157},[16168],{"type":34,"value":16169},"z ",{"type":29,"tag":88,"props":16171,"children":16172},{"style":163},[16173],{"type":34,"value":12373},{"type":29,"tag":88,"props":16175,"children":16176},{"style":195},[16177],{"type":34,"value":15788},{"type":29,"tag":88,"props":16179,"children":16180},{"style":163},[16181],{"type":34,"value":9752},{"type":29,"tag":88,"props":16183,"children":16184},{"style":163},[16185],{"type":34,"value":16186}," !",{"type":29,"tag":88,"props":16188,"children":16189},{"style":157},[16190],{"type":34,"value":63},{"type":29,"tag":88,"props":16192,"children":16193},{"style":122},[16194],{"type":34,"value":16195},"))",{"type":29,"tag":88,"props":16197,"children":16198},{"style":122},[16199],{"type":34,"value":125},{"type":29,"tag":88,"props":16201,"children":16202},{"class":90,"line":101},[16203],{"type":29,"tag":88,"props":16204,"children":16205},{"style":95},[16206],{"type":34,"value":16207},"    \u002F\u002F code\n",{"type":29,"tag":88,"props":16209,"children":16210},{"class":90,"line":128},[16211],{"type":29,"tag":88,"props":16212,"children":16213},{"style":122},[16214],{"type":34,"value":442},{"type":29,"tag":30,"props":16216,"children":16217},{},[16218],{"type":34,"value":16219},"Vous pouvez simplifier la logique en extrayant des morceaux de code dans des fonctions ou en les assignant à des variables explicites :",{"type":29,"tag":77,"props":16221,"children":16223},{"className":81,"code":16222,"language":80,"meta":8,"style":8},"boolean condition1 = (x > 10 && y \u003C 5);\nboolean condition2 = (z == 3 && !a);\n\nif (condition1 || condition2) {\n    \u002F\u002F code\n}\n",[16224],{"type":29,"tag":84,"props":16225,"children":16226},{"__ignoreMap":8},[16227,16279,16327,16334,16368,16375],{"type":29,"tag":88,"props":16228,"children":16229},{"class":90,"line":91},[16230,16234,16239,16243,16247,16251,16255,16259,16263,16267,16271,16275],{"type":29,"tag":88,"props":16231,"children":16232},{"style":105},[16233],{"type":34,"value":3742},{"type":29,"tag":88,"props":16235,"children":16236},{"style":157},[16237],{"type":34,"value":16238}," condition1 ",{"type":29,"tag":88,"props":16240,"children":16241},{"style":163},[16242],{"type":34,"value":166},{"type":29,"tag":88,"props":16244,"children":16245},{"style":122},[16246],{"type":34,"value":2891},{"type":29,"tag":88,"props":16248,"children":16249},{"style":157},[16250],{"type":34,"value":16129},{"type":29,"tag":88,"props":16252,"children":16253},{"style":163},[16254],{"type":34,"value":1701},{"type":29,"tag":88,"props":16256,"children":16257},{"style":195},[16258],{"type":34,"value":16138},{"type":29,"tag":88,"props":16260,"children":16261},{"style":163},[16262],{"type":34,"value":9752},{"type":29,"tag":88,"props":16264,"children":16265},{"style":157},[16266],{"type":34,"value":16147},{"type":29,"tag":88,"props":16268,"children":16269},{"style":163},[16270],{"type":34,"value":1683},{"type":29,"tag":88,"props":16272,"children":16273},{"style":195},[16274],{"type":34,"value":15818},{"type":29,"tag":88,"props":16276,"children":16277},{"style":122},[16278],{"type":34,"value":357},{"type":29,"tag":88,"props":16280,"children":16281},{"class":90,"line":101},[16282,16286,16291,16295,16299,16303,16307,16311,16315,16319,16323],{"type":29,"tag":88,"props":16283,"children":16284},{"style":105},[16285],{"type":34,"value":3742},{"type":29,"tag":88,"props":16287,"children":16288},{"style":157},[16289],{"type":34,"value":16290}," condition2 ",{"type":29,"tag":88,"props":16292,"children":16293},{"style":163},[16294],{"type":34,"value":166},{"type":29,"tag":88,"props":16296,"children":16297},{"style":122},[16298],{"type":34,"value":2891},{"type":29,"tag":88,"props":16300,"children":16301},{"style":157},[16302],{"type":34,"value":16169},{"type":29,"tag":88,"props":16304,"children":16305},{"style":163},[16306],{"type":34,"value":12373},{"type":29,"tag":88,"props":16308,"children":16309},{"style":195},[16310],{"type":34,"value":15788},{"type":29,"tag":88,"props":16312,"children":16313},{"style":163},[16314],{"type":34,"value":9752},{"type":29,"tag":88,"props":16316,"children":16317},{"style":163},[16318],{"type":34,"value":16186},{"type":29,"tag":88,"props":16320,"children":16321},{"style":157},[16322],{"type":34,"value":63},{"type":29,"tag":88,"props":16324,"children":16325},{"style":122},[16326],{"type":34,"value":357},{"type":29,"tag":88,"props":16328,"children":16329},{"class":90,"line":128},[16330],{"type":29,"tag":88,"props":16331,"children":16332},{"emptyLinePlaceholder":13},[16333],{"type":34,"value":134},{"type":29,"tag":88,"props":16335,"children":16336},{"class":90,"line":137},[16337,16341,16345,16350,16355,16360,16364],{"type":29,"tag":88,"props":16338,"children":16339},{"style":105},[16340],{"type":34,"value":16120},{"type":29,"tag":88,"props":16342,"children":16343},{"style":122},[16344],{"type":34,"value":2891},{"type":29,"tag":88,"props":16346,"children":16347},{"style":157},[16348],{"type":34,"value":16349},"condition1 ",{"type":29,"tag":88,"props":16351,"children":16352},{"style":163},[16353],{"type":34,"value":16354},"||",{"type":29,"tag":88,"props":16356,"children":16357},{"style":157},[16358],{"type":34,"value":16359}," condition2",{"type":29,"tag":88,"props":16361,"children":16362},{"style":122},[16363],{"type":34,"value":306},{"type":29,"tag":88,"props":16365,"children":16366},{"style":122},[16367],{"type":34,"value":125},{"type":29,"tag":88,"props":16369,"children":16370},{"class":90,"line":211},[16371],{"type":29,"tag":88,"props":16372,"children":16373},{"style":95},[16374],{"type":34,"value":16207},{"type":29,"tag":88,"props":16376,"children":16377},{"class":90,"line":262},[16378],{"type":29,"tag":88,"props":16379,"children":16380},{"style":122},[16381],{"type":34,"value":442},{"type":29,"tag":30,"props":16383,"children":16384},{},[16385],{"type":34,"value":16386},"Ce code est plus facile à lire et à comprendre car chaque condition a été isolée dans une variable qui a un nom clair.",{"type":29,"tag":30,"props":16388,"children":16389},{},[16390],{"type":34,"value":16391},"Découper les conditions complexes en variables nommées reste l'une des transformations les plus rentables : zéro impact sur la perf, gain massif sur la lisibilité.",{"type":29,"tag":51,"props":16393,"children":16395},{"id":16394},"outils-et-pratiques-pour-améliorer-la-lisibilité-du-code",[16396],{"type":34,"value":16397},"Outils et pratiques pour améliorer la lisibilité du code",{"type":29,"tag":30,"props":16399,"children":16400},{},[16401],{"type":34,"value":16402},"Même avec de bonnes intentions, il peut parfois être difficile de maintenir un haut niveau de lisibilité dans le code. Heureusement, il existe des outils et des pratiques éprouvées qui peuvent vous aider à écrire du code plus lisible au quotidien.",{"type":29,"tag":10576,"props":16404,"children":16406},{"id":16405},"_1-commentaires-pertinents-et-documentation",[16407],{"type":34,"value":16408},"1. Commentaires pertinents et documentation",{"type":29,"tag":30,"props":16410,"children":16411},{},[16412,16414,16419,16421,16426],{"type":34,"value":16413},"Bien que le code doit idéalement s’expliquer par lui-même, les commentaires restent un outil précieux lorsqu'ils sont utilisés de manière judicieuse. Un bon commentaire doit expliquer ",{"type":29,"tag":8474,"props":16415,"children":16416},{},[16417],{"type":34,"value":16418},"pourquoi",{"type":34,"value":16420}," une certaine approche a été choisie, et non ",{"type":29,"tag":8474,"props":16422,"children":16423},{},[16424],{"type":34,"value":16425},"ce que",{"type":34,"value":16427}," fait le code. Un commentaire qui se contente de paraphraser le code n’ajoute aucune valeur.",{"type":29,"tag":30,"props":16429,"children":16430},{},[16431],{"type":34,"value":16432},"Exemple de commentaire utile :",{"type":29,"tag":77,"props":16434,"children":16436},{"className":81,"code":16435,"language":80,"meta":8,"style":8},"\u002F\u002F Vérifie si le montant de la commande dépasse le seuil pour la livraison gratuite.\n\u002F\u002F Ce seuil est défini en fonction d'une promotion actuelle (20% de réduction) pour encourager les commandes de plus de 50€.\nif (commande.getMontantTotal() > 50) {\n    commande.setLivraisonGratuite(true);\n} else {\n    commande.setFraisLivraison(7.99);\n}\n\n",[16437],{"type":29,"tag":84,"props":16438,"children":16439},{"__ignoreMap":8},[16440,16448,16456,16503,16532,16549,16578],{"type":29,"tag":88,"props":16441,"children":16442},{"class":90,"line":91},[16443],{"type":29,"tag":88,"props":16444,"children":16445},{"style":95},[16446],{"type":34,"value":16447},"\u002F\u002F Vérifie si le montant de la commande dépasse le seuil pour la livraison gratuite.\n",{"type":29,"tag":88,"props":16449,"children":16450},{"class":90,"line":101},[16451],{"type":29,"tag":88,"props":16452,"children":16453},{"style":95},[16454],{"type":34,"value":16455},"\u002F\u002F Ce seuil est défini en fonction d'une promotion actuelle (20% de réduction) pour encourager les commandes de plus de 50€.\n",{"type":29,"tag":88,"props":16457,"children":16458},{"class":90,"line":128},[16459,16463,16467,16472,16476,16481,16485,16490,16495,16499],{"type":29,"tag":88,"props":16460,"children":16461},{"style":105},[16462],{"type":34,"value":16120},{"type":29,"tag":88,"props":16464,"children":16465},{"style":122},[16466],{"type":34,"value":2891},{"type":29,"tag":88,"props":16468,"children":16469},{"style":157},[16470],{"type":34,"value":16471},"commande",{"type":29,"tag":88,"props":16473,"children":16474},{"style":122},[16475],{"type":34,"value":338},{"type":29,"tag":88,"props":16477,"children":16478},{"style":174},[16479],{"type":34,"value":16480},"getMontantTotal",{"type":29,"tag":88,"props":16482,"children":16483},{"style":122},[16484],{"type":34,"value":1470},{"type":29,"tag":88,"props":16486,"children":16487},{"style":163},[16488],{"type":34,"value":16489}," >",{"type":29,"tag":88,"props":16491,"children":16492},{"style":195},[16493],{"type":34,"value":16494}," 50",{"type":29,"tag":88,"props":16496,"children":16497},{"style":122},[16498],{"type":34,"value":306},{"type":29,"tag":88,"props":16500,"children":16501},{"style":122},[16502],{"type":34,"value":125},{"type":29,"tag":88,"props":16504,"children":16505},{"class":90,"line":137},[16506,16511,16515,16520,16524,16528],{"type":29,"tag":88,"props":16507,"children":16508},{"style":157},[16509],{"type":34,"value":16510},"    commande",{"type":29,"tag":88,"props":16512,"children":16513},{"style":122},[16514],{"type":34,"value":338},{"type":29,"tag":88,"props":16516,"children":16517},{"style":174},[16518],{"type":34,"value":16519},"setLivraisonGratuite",{"type":29,"tag":88,"props":16521,"children":16522},{"style":122},[16523],{"type":34,"value":181},{"type":29,"tag":88,"props":16525,"children":16526},{"style":873},[16527],{"type":34,"value":4110},{"type":29,"tag":88,"props":16529,"children":16530},{"style":122},[16531],{"type":34,"value":357},{"type":29,"tag":88,"props":16533,"children":16534},{"class":90,"line":211},[16535,16540,16545],{"type":29,"tag":88,"props":16536,"children":16537},{"style":122},[16538],{"type":34,"value":16539},"}",{"type":29,"tag":88,"props":16541,"children":16542},{"style":105},[16543],{"type":34,"value":16544}," else",{"type":29,"tag":88,"props":16546,"children":16547},{"style":122},[16548],{"type":34,"value":125},{"type":29,"tag":88,"props":16550,"children":16551},{"class":90,"line":262},[16552,16556,16560,16565,16569,16574],{"type":29,"tag":88,"props":16553,"children":16554},{"style":157},[16555],{"type":34,"value":16510},{"type":29,"tag":88,"props":16557,"children":16558},{"style":122},[16559],{"type":34,"value":338},{"type":29,"tag":88,"props":16561,"children":16562},{"style":174},[16563],{"type":34,"value":16564},"setFraisLivraison",{"type":29,"tag":88,"props":16566,"children":16567},{"style":122},[16568],{"type":34,"value":181},{"type":29,"tag":88,"props":16570,"children":16571},{"style":195},[16572],{"type":34,"value":16573},"7.99",{"type":29,"tag":88,"props":16575,"children":16576},{"style":122},[16577],{"type":34,"value":357},{"type":29,"tag":88,"props":16579,"children":16580},{"class":90,"line":270},[16581],{"type":29,"tag":88,"props":16582,"children":16583},{"style":122},[16584],{"type":34,"value":442},{"type":29,"tag":30,"props":16586,"children":16587},{},[16588],{"type":34,"value":16589},"Exemple de commentaire inutile :",{"type":29,"tag":77,"props":16591,"children":16593},{"className":81,"code":16592,"language":80,"meta":8,"style":8},"\u002F\u002F Incrémente la variable i\ni++;\n",[16594],{"type":29,"tag":84,"props":16595,"children":16596},{"__ignoreMap":8},[16597,16605],{"type":29,"tag":88,"props":16598,"children":16599},{"class":90,"line":91},[16600],{"type":29,"tag":88,"props":16601,"children":16602},{"style":95},[16603],{"type":34,"value":16604},"\u002F\u002F Incrémente la variable i\n",{"type":29,"tag":88,"props":16606,"children":16607},{"class":90,"line":101},[16608,16612,16617],{"type":29,"tag":88,"props":16609,"children":16610},{"style":157},[16611],{"type":34,"value":16066},{"type":29,"tag":88,"props":16613,"children":16614},{"style":163},[16615],{"type":34,"value":16616},"++",{"type":29,"tag":88,"props":16618,"children":16619},{"style":122},[16620],{"type":34,"value":424},{"type":29,"tag":30,"props":16622,"children":16623},{},[16624],{"type":34,"value":16625},"En plus des commentaires, une documentation claire et concise est essentielle, surtout pour les projets de grande envergure. Les outils comme Javadoc, Doxygen ou encore Sphinx (pour Python) peuvent vous aider à générer une documentation directement à partir de votre code.",{"type":29,"tag":30,"props":16627,"children":16628},{},[16629],{"type":34,"value":16630},"La règle inverse vaut aussi : un commentaire qui paraphrase le code n'ajoute rien et fait du bruit. Mieux vaut un code explicite que dix commentaires redondants.",{"type":29,"tag":10576,"props":16632,"children":16634},{"id":16633},"_2-revue-de-code-entre-pairs",[16635],{"type":34,"value":16636},"2. Revue de code entre pairs",{"type":29,"tag":30,"props":16638,"children":16639},{},[16640],{"type":34,"value":16641},"La revue de code est l’une des pratiques les plus efficaces pour garantir la lisibilité du code. Lorsqu’un autre développeur examine votre travail, il peut repérer des parties de code qui vous paraissent évidentes mais qui ne le sont pas pour quelqu’un d’autre. Les critiques constructives permettent d’améliorer non seulement le code, mais aussi les compétences de chacun dans l’équipe.",{"type":29,"tag":30,"props":16643,"children":16644},{},[16645],{"type":34,"value":16646},"Quelques points à aborder lors d’une revue de code :",{"type":29,"tag":453,"props":16648,"children":16649},{},[16650,16655,16660],{"type":29,"tag":457,"props":16651,"children":16652},{},[16653],{"type":34,"value":16654},"Est-ce que les noms des variables et des fonctions sont explicites ?",{"type":29,"tag":457,"props":16656,"children":16657},{},[16658],{"type":34,"value":16659},"Est-ce que la logique est claire et facile à suivre ?",{"type":29,"tag":457,"props":16661,"children":16662},{},[16663],{"type":34,"value":16664},"Y a-t-il des parties du code qui pourraient être simplifiées ou réorganisées ?",{"type":29,"tag":10576,"props":16666,"children":16668},{"id":16667},"_3-tests-automatisés-pour-renforcer-la-clarté",[16669],{"type":34,"value":16670},"3. Tests automatisés pour renforcer la clarté",{"type":29,"tag":30,"props":16672,"children":16673},{},[16674],{"type":34,"value":16675},"Les tests automatisés, en particulier les tests unitaires, contribuent également à rendre le code plus lisible. En rédigeant des tests, vous êtes amené à réfléchir à la manière dont chaque partie de votre code doit se comporter. Un test bien écrit fonctionne comme une",{"type":29,"tag":30,"props":16677,"children":16678},{},[16679],{"type":34,"value":16680},"forme de documentation vivante : il montre comment les différentes fonctions interagissent et ce qu’on attend d’elles.",{"type":29,"tag":30,"props":16682,"children":16683},{},[16684],{"type":34,"value":16685},"Les tests servent aussi de filet contre les régressions : une suite complète garantit qu'un code remanié continue de se comporter comme attendu.",{"type":29,"tag":30,"props":16687,"children":16688},{},[16689],{"type":34,"value":16690},"Un test difficile à écrire est presque toujours le signe d'un code trop couplé ou trop dense. Cette difficulté est un signal, pas un obstacle à contourner.",{"type":29,"tag":10576,"props":16692,"children":16694},{"id":16693},"_4-linters-et-formatteurs-automatiques",[16695],{"type":34,"value":16696},"4. Linters et formatteurs automatiques",{"type":29,"tag":30,"props":16698,"children":16699},{},[16700],{"type":34,"value":16701},"Des outils comme les linters (par exemple, ESLint pour JavaScript, Pylint pour Python) et les formatteurs de code (comme Prettier ou Black) sont très utiles pour imposer des standards de qualité dans le code. Ces outils vérifient automatiquement la cohérence du style et peuvent même corriger certaines erreurs de formatage, rendant le code plus propre et lisible sans effort manuel.",{"type":29,"tag":30,"props":16703,"children":16704},{},[16705],{"type":34,"value":16706},"Ils assurent aussi que tous les membres d'une équipe respectent les mêmes conventions, ce qui améliore encore la lisibilité générale du projet.",{"type":29,"tag":30,"props":16708,"children":16709},{},[16710],{"type":34,"value":16711},"Les règles par défaut des linters sont rarement adaptées : prendre une demi-journée pour configurer un set cohérent avec les conventions de l'équipe évite ensuite des semaines de débats stériles en revue.",{"type":29,"tag":51,"props":16713,"children":16715},{"id":16714},"objections-courantes-et-comment-les-surmonter",[16716],{"type":34,"value":16717},"Objections courantes et comment les surmonter",{"type":29,"tag":30,"props":16719,"children":16720},{},[16721],{"type":34,"value":16722},"Malgré l’importance de la lisibilité du code, de nombreux développeurs hésitent à y consacrer du temps, principalement en raison de contraintes de temps ou de priorités mal définies. Voici quelques-unes des objections les plus courantes et des réponses pour les surmonter.",{"type":29,"tag":10576,"props":16724,"children":16726},{"id":16725},"objection-1-je-nai-pas-le-temps-de-rendre-mon-code-lisible",[16727],{"type":34,"value":16728},"Objection 1 : \"Je n’ai pas le temps de rendre mon code lisible.\"",{"type":29,"tag":30,"props":16730,"children":16731},{},[16732],{"type":34,"value":16733},"C’est probablement l’objection la plus fréquente. Lorsque vous travaillez sous pression pour respecter des délais, il peut sembler plus rapide de sacrifier la lisibilité au profit de l’efficacité immédiate. Cependant, c’est un piège à long terme.",{"type":29,"tag":30,"props":16735,"children":16736},{},[16737,16742],{"type":29,"tag":447,"props":16738,"children":16739},{},[16740],{"type":34,"value":16741},"Réponse",{"type":34,"value":16743}," : Écrire du code lisible fait gagner du temps à long terme. Un code clair nécessite moins de corrections et est plus facile à maintenir, surtout dans des projets de longue durée où vous devez souvent revenir sur du code ancien. Les quelques minutes que vous passez à choisir de bons noms de variables ou à bien structurer votre code peuvent vous épargner des heures de débogage plus tard.",{"type":29,"tag":8787,"props":16745,"children":16746},{},[16747],{"type":29,"tag":30,"props":16748,"children":16749},{},[16750,16755],{"type":29,"tag":447,"props":16751,"children":16752},{},[16753],{"type":34,"value":16754},"💡 Astuce",{"type":34,"value":16756}," : Considérez la lisibilité comme un investissement. Un code mal structuré aujourd’hui coûtera beaucoup plus cher en maintenance demain.",{"type":29,"tag":10576,"props":16758,"children":16760},{"id":16759},"objection-2-tant-que-ça-fonctionne-peu-importe-si-le-code-est-un-peu-désordonné",[16761],{"type":34,"value":16762},"Objection 2 : \"Tant que ça fonctionne, peu importe si le code est un peu désordonné.\"",{"type":29,"tag":30,"props":16764,"children":16765},{},[16766],{"type":34,"value":16767},"Certains développeurs pensent que la lisibilité est un détail secondaire tant que le code \"fait le job\". Après tout, si le logiciel fonctionne correctement, pourquoi se soucier de l’apparence du code ?",{"type":29,"tag":30,"props":16769,"children":16770},{},[16771,16775],{"type":29,"tag":447,"props":16772,"children":16773},{},[16774],{"type":34,"value":16741},{"type":34,"value":16776}," : Un code qui fonctionne aujourd'hui, mais qui est difficile à lire, est une bombe à retardement. La plupart des bugs apparaissent lors de la maintenance ou des modifications du code. Si le code est difficile à comprendre, chaque modification devient risquée, augmentant les chances d’introduire de nouvelles erreurs.",{"type":29,"tag":10576,"props":16778,"children":16780},{"id":16779},"objection-3-ce-nest-pas-mon-problème-si-les-autres-ne-comprennent-pas-mon-code",[16781],{"type":34,"value":16782},"Objection 3 : \"Ce n’est pas mon problème si les autres ne comprennent pas mon code.\"",{"type":29,"tag":30,"props":16784,"children":16785},{},[16786],{"type":34,"value":16787},"Certains développeurs pensent que chaque personne devrait être responsable de comprendre le code, quelle que soit sa lisibilité. Ils estiment que tant qu'ils comprennent ce qu’ils ont écrit, c’est suffisant.",{"type":29,"tag":30,"props":16789,"children":16790},{},[16791,16795],{"type":29,"tag":447,"props":16792,"children":16793},{},[16794],{"type":34,"value":16741},{"type":34,"value":16796}," : Travailler en équipe repose sur la collaboration, et un code illisible devient un obstacle à la productivité collective. Lorsque d'autres membres de l'équipe doivent passer du temps à déchiffrer votre code, cela réduit leur efficacité et génère de la frustration.",{"type":29,"tag":51,"props":16798,"children":16800},{"id":16799},"investissement-pas-dépense",[16801],{"type":34,"value":16802},"Investissement, pas dépense",{"type":29,"tag":30,"props":16804,"children":16805},{},[16806],{"type":34,"value":16807},"La lisibilité paraît coûteuse sur le moment : quelques minutes pour trouver le bon nom, dix minutes pour découper une fonction, une demi-heure pour clarifier une condition. Sur la durée d'un projet, ce sont les heures les mieux investies. Chaque ligne lisible évite cinq lectures laborieuses futures et trois bugs introduits par incompréhension. C'est ce calcul, fait mille fois sur un sprint, qui distingue une équipe qui accélère d'une équipe qui s'enlise.",{"type":29,"tag":2288,"props":16809,"children":16811},{"cta":5629,"href":5630,"title":16810,"type":5632},"La lisibilité n'est qu'une pratique parmi les 100 qui font un code propre",[16812],{"type":29,"tag":30,"props":16813,"children":16814},{},[16815],{"type":34,"value":16816},"Nommer pour révéler l'intention, c'est une seule des pratiques décrites ici. Le Craft Bundle réunit les 100 pratiques craft que j'applique au quotidien pour écrire un code propre et durable, celles que l'IA ne vous apprendra jamais parce qu'elle ne les a jamais vues tenir en production sur le long terme.",{"type":29,"tag":47,"props":16818,"children":16819},{},[],{"type":29,"tag":51,"props":16821,"children":16822},{"id":10010},[16823],{"type":34,"value":10013},{"type":29,"tag":5649,"props":16825,"children":16826},{},[16827,16832],{"type":29,"tag":5653,"props":16828,"children":16829},{},[16830],{"type":34,"value":16831},"Code fonctionnel et code lisible : où est la différence ?",{"type":29,"tag":30,"props":16833,"children":16834},{},[16835],{"type":34,"value":16836},"Un code fonctionnel fait ce qu'on attend de lui mais peut rester opaque. Un code lisible s'ajoute à ça : il se laisse comprendre rapidement par un autre développeur, sans explication orale supplémentaire. La distinction n'est pas cosmétique : c'est elle qui détermine la vitesse d'évolution du projet sur la durée.",{"type":29,"tag":5649,"props":16838,"children":16839},{},[16840,16845],{"type":29,"tag":5653,"props":16841,"children":16842},{},[16843],{"type":34,"value":16844},"Faut-il commenter chaque ligne ?",{"type":29,"tag":30,"props":16846,"children":16847},{},[16848,16850,16854,16856,16862],{"type":34,"value":16849},"Non. Les commentaires utiles expliquent ",{"type":29,"tag":8474,"props":16851,"children":16852},{},[16853],{"type":34,"value":16418},{"type":34,"value":16855}," : la raison d'une décision technique, le contexte d'une contrainte métier, la subtilité d'une convention. Les commentaires qui paraphrasent le code (",{"type":29,"tag":84,"props":16857,"children":16859},{"className":16858},[],[16860],{"type":34,"value":16861},"\u002F\u002F incrémente i",{"type":34,"value":16863},") sont du bruit. Un bon code se passe d'eux dans 90 % des cas.",{"type":29,"tag":5649,"props":16865,"children":16866},{},[16867,16872],{"type":29,"tag":5653,"props":16868,"children":16869},{},[16870],{"type":34,"value":16871},"Si je suis seul sur un projet, est-ce vraiment nécessaire ?",{"type":29,"tag":30,"props":16873,"children":16874},{},[16875],{"type":34,"value":16876},"Oui. Le \"vous dans six mois\" est un autre développeur, qui n'a plus accès au contexte mental que vous aviez à l'écriture. Tous les développeurs solo expérimentés finissent par confirmer cette règle après avoir relu leur propre code un an plus tard.",{"type":29,"tag":5649,"props":16878,"children":16879},{},[16880,16885],{"type":29,"tag":5653,"props":16881,"children":16882},{},[16883],{"type":34,"value":16884},"Quels outils pour faciliter ?",{"type":29,"tag":30,"props":16886,"children":16887},{},[16888],{"type":34,"value":16889},"Linters et formatteurs adaptés au langage (Checkstyle, ESLint, Prettier) pour la cohérence mécanique. Tests unitaires comme documentation vivante. Revues de code régulières pour le reste : c'est l'outil le plus puissant, parce qu'il révèle ce que l'auteur ne peut pas voir par lui-même.",{"type":29,"tag":47,"props":16891,"children":16892},{},[],{"type":29,"tag":30,"props":16894,"children":16895},{},[16896,16898,16902,16904,16910],{"type":34,"value":16897},"Un code lisible est aussi un code qui passe la ",{"type":29,"tag":63,"props":16899,"children":16900},{"href":10386},[16901],{"type":34,"value":10389},{"type":34,"value":16903}," sans friction et qui s'inscrit dans les pratiques d'une ",{"type":29,"tag":63,"props":16905,"children":16907},{"href":16906},"\u002Ffr\u002Fdette-technique\u002Fdefinition-of-done-qualite",[16908],{"type":34,"value":16909},"Definition of Done",{"type":34,"value":16911}," exigeante : ces deux pratiques se renforcent mutuellement.",{"type":29,"tag":2288,"props":16913,"children":16914},{"cta":10074,"href":10075,"title":10076,"type":5755},[16915],{"type":29,"tag":30,"props":16916,"children":16917},{},[16918],{"type":34,"value":16919},"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":29,"tag":5763,"props":16921,"children":16922},{},[16923],{"type":34,"value":5767},{"title":8,"searchDepth":101,"depth":101,"links":16925},[16926,16927,16928,16929,16930,16931,16932],{"id":15699,"depth":101,"text":15702},{"id":15748,"depth":101,"text":15751},{"id":16012,"depth":101,"text":16015},{"id":16394,"depth":101,"text":16397},{"id":16714,"depth":101,"text":16717},{"id":16799,"depth":101,"text":16802},{"id":10010,"depth":101,"text":10013},"content:fr:dette-technique:guide-code-lisible-software-craftsmanship.md","fr\u002Fdette-technique\u002Fguide-code-lisible-software-craftsmanship.md","fr\u002Fdette-technique\u002Fguide-code-lisible-software-craftsmanship",{"_path":10180,"_dir":8447,"_draft":7,"_partial":7,"_locale":8,"title":16937,"description":16938,"id":1611,"date":16939,"listed":13,"nocomments":7,"hidden":7,"categories":16940,"tags":16941,"cover":16942,"readingTime":16943,"body":16947,"_type":5777,"_id":19379,"_source":5779,"_file":19380,"_stem":19381,"_extension":5782},"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.","2024-05-25",[8447],[16,8453],"covers\u002Farticles\u002Fsoftware-craftsmanship.jpg",{"text":21,"minutes":16944,"time":16945,"words":16946},8.885,533100,1777,{"type":26,"children":16948,"toc":19368},[16949,16955,16961,16966,16978,16981,16987,17005,17011,17023,17029,17048,17066,17069,17078,17084,17094,17867,17870,17876,17887,17893,17898,17921,17929,18144,18152,18491,18496,18499,18505,18510,18518,18653,18658,18661,18667,18680,18685,18692,18798,18805,18915,18920,18923,18929,18953,18956,18962,18967,18973,18996,19002,19203,19209,19232,19235,19241,19251,19261,19264,19270,19275,19284,19287,19291,19316,19329,19342,19345,19349,19354,19364],{"type":29,"tag":8542,"props":16950,"children":16952},{"id":16951},"software-craftsmanship-guide-complet-pour-un-code-propre-et-maintenable",[16953],{"type":34,"value":16954},"Software Craftsmanship : Guide Complet pour un Code Propre et Maintenable",{"type":29,"tag":10576,"props":16956,"children":16958},{"id":16957},"introduction-quest-ce-que-le-software-craftsmanship",[16959],{"type":34,"value":16960},"Introduction : Qu'est-ce que le Software Craftsmanship ?",{"type":29,"tag":30,"props":16962,"children":16963},{},[16964],{"type":34,"value":16965},"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":29,"tag":30,"props":16967,"children":16968},{},[16969,16971,16976],{"type":34,"value":16970},"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":29,"tag":447,"props":16972,"children":16973},{},[16974],{"type":34,"value":16975},"Software Craftsmanship",{"type":34,"value":16977}," 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":29,"tag":47,"props":16979,"children":16980},{},[],{"type":29,"tag":8542,"props":16982,"children":16984},{"id":16983},"les-origines-du-software-craftsmanship",[16985],{"type":34,"value":16986},"Les origines du Software Craftsmanship",{"type":29,"tag":30,"props":16988,"children":16989},{},[16990,16992,16996,16998,17003],{"type":34,"value":16991},"Le mouvement ",{"type":29,"tag":447,"props":16993,"children":16994},{},[16995],{"type":34,"value":16975},{"type":34,"value":16997}," 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":29,"tag":447,"props":16999,"children":17000},{},[17001],{"type":34,"value":17002},"agiles",{"type":34,"value":17004}," mal interprétées.",{"type":29,"tag":10576,"props":17006,"children":17008},{"id":17007},"_1-le-manifeste-agile-2001",[17009],{"type":34,"value":17010},"1. Le Manifeste Agile (2001)",{"type":29,"tag":30,"props":17012,"children":17013},{},[17014,17016,17021],{"type":34,"value":17015},"Tout commence en 2001 avec le ",{"type":29,"tag":447,"props":17017,"children":17018},{},[17019],{"type":34,"value":17020},"Manifeste Agile",{"type":34,"value":17022}," 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":29,"tag":10576,"props":17024,"children":17026},{"id":17025},"_2-le-manifeste-du-software-craftsmanship-2009",[17027],{"type":34,"value":17028},"2. Le Manifeste du Software Craftsmanship (2009)",{"type":29,"tag":30,"props":17030,"children":17031},{},[17032,17034,17039,17041,17046],{"type":34,"value":17033},"En 2009, un groupe de développeurs autour de ",{"type":29,"tag":447,"props":17035,"children":17036},{},[17037],{"type":34,"value":17038},"Robert C. Martin",{"type":34,"value":17040}," (Uncle Bob) publie le ",{"type":29,"tag":447,"props":17042,"children":17043},{},[17044],{"type":34,"value":17045},"Manifeste du Software Craftsmanship",{"type":34,"value":17047},". 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":29,"tag":30,"props":17049,"children":17050},{},[17051,17053,17057,17059,17064],{"type":34,"value":17052},"L’extension est naturelle : l’agilité dit ",{"type":29,"tag":8474,"props":17054,"children":17055},{},[17056],{"type":34,"value":11579},{"type":34,"value":17058}," livrer, le craftsmanship dit ",{"type":29,"tag":8474,"props":17060,"children":17061},{},[17062],{"type":34,"value":17063},"à quelle qualité",{"type":34,"value":17065},". Sans cette deuxième conversation, les sprints rapides finissent en sprints rapides vers le mur.",{"type":29,"tag":47,"props":17067,"children":17068},{},[],{"type":29,"tag":2288,"props":17070,"children":17072},{"cta":2290,"href":2291,"title":17071,"type":2293},"Vous voulez écrire un code dont vous n'avez plus honte en revue ?",[17073],{"type":29,"tag":30,"props":17074,"children":17075},{},[17076],{"type":34,"value":17077},"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":29,"tag":8542,"props":17079,"children":17081},{"id":17080},"les-principes-fondamentaux-du-software-craftsmanship",[17082],{"type":34,"value":17083},"Les principes fondamentaux du Software Craftsmanship",{"type":29,"tag":30,"props":17085,"children":17086},{},[17087,17088,17092],{"type":34,"value":10213},{"type":29,"tag":447,"props":17089,"children":17090},{},[17091],{"type":34,"value":16975},{"type":34,"value":17093}," 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":29,"tag":17095,"props":17096,"children":17097},"ol",{},[17098,17313,17544,17857],{"type":29,"tag":457,"props":17099,"children":17100},{},[17101,17106,17108,17111,17116,17283],{"type":29,"tag":447,"props":17102,"children":17103},{},[17104],{"type":34,"value":17105},"Code propre (Clean Code)",{"type":34,"value":17107},"\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":29,"tag":11452,"props":17109,"children":17110},{},[],{"type":29,"tag":8474,"props":17112,"children":17113},{},[17114],{"type":34,"value":17115},"Exemple Java :",{"type":29,"tag":77,"props":17117,"children":17119},{"className":81,"code":17118,"language":80,"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",[17120],{"type":29,"tag":84,"props":17121,"children":17122},{"__ignoreMap":8},[17123,17143,17192,17269,17276],{"type":29,"tag":88,"props":17124,"children":17125},{"class":90,"line":91},[17126,17130,17134,17139],{"type":29,"tag":88,"props":17127,"children":17128},{"style":105},[17129],{"type":34,"value":108},{"type":29,"tag":88,"props":17131,"children":17132},{"style":105},[17133],{"type":34,"value":113},{"type":29,"tag":88,"props":17135,"children":17136},{"style":116},[17137],{"type":34,"value":17138}," Calculateur",{"type":29,"tag":88,"props":17140,"children":17141},{"style":122},[17142],{"type":34,"value":125},{"type":29,"tag":88,"props":17144,"children":17145},{"class":90,"line":101},[17146,17150,17154,17159,17163,17167,17171,17175,17179,17184,17188],{"type":29,"tag":88,"props":17147,"children":17148},{"style":105},[17149],{"type":34,"value":276},{"type":29,"tag":88,"props":17151,"children":17152},{"style":105},[17153],{"type":34,"value":10663},{"type":29,"tag":88,"props":17155,"children":17156},{"style":174},[17157],{"type":34,"value":17158}," calculerMoyenne",{"type":29,"tag":88,"props":17160,"children":17161},{"style":122},[17162],{"type":34,"value":181},{"type":29,"tag":88,"props":17164,"children":17165},{"style":151},[17166],{"type":34,"value":9063},{"type":29,"tag":88,"props":17168,"children":17169},{"style":122},[17170],{"type":34,"value":1683},{"type":29,"tag":88,"props":17172,"children":17173},{"style":105},[17174],{"type":34,"value":9045},{"type":29,"tag":88,"props":17176,"children":17177},{"style":122},[17178],{"type":34,"value":1701},{"type":29,"tag":88,"props":17180,"children":17181},{"style":298},[17182],{"type":34,"value":17183}," nombres",{"type":29,"tag":88,"props":17185,"children":17186},{"style":122},[17187],{"type":34,"value":306},{"type":29,"tag":88,"props":17189,"children":17190},{"style":122},[17191],{"type":34,"value":125},{"type":29,"tag":88,"props":17193,"children":17194},{"class":90,"line":128},[17195,17199,17203,17207,17211,17215,17220,17224,17228,17233,17238,17242,17247,17251,17256,17260,17265],{"type":29,"tag":88,"props":17196,"children":17197},{"style":105},[17198],{"type":34,"value":415},{"type":29,"tag":88,"props":17200,"children":17201},{"style":157},[17202],{"type":34,"value":17183},{"type":29,"tag":88,"props":17204,"children":17205},{"style":122},[17206],{"type":34,"value":338},{"type":29,"tag":88,"props":17208,"children":17209},{"style":174},[17210],{"type":34,"value":9391},{"type":29,"tag":88,"props":17212,"children":17213},{"style":122},[17214],{"type":34,"value":1800},{"type":29,"tag":88,"props":17216,"children":17217},{"style":174},[17218],{"type":34,"value":17219},"mapToInt",{"type":29,"tag":88,"props":17221,"children":17222},{"style":122},[17223],{"type":34,"value":181},{"type":29,"tag":88,"props":17225,"children":17226},{"style":157},[17227],{"type":34,"value":9045},{"type":29,"tag":88,"props":17229,"children":17230},{"style":105},[17231],{"type":34,"value":17232},"::",{"type":29,"tag":88,"props":17234,"children":17235},{"style":157},[17236],{"type":34,"value":17237},"intValue",{"type":29,"tag":88,"props":17239,"children":17240},{"style":122},[17241],{"type":34,"value":8127},{"type":29,"tag":88,"props":17243,"children":17244},{"style":174},[17245],{"type":34,"value":17246},"average",{"type":29,"tag":88,"props":17248,"children":17249},{"style":122},[17250],{"type":34,"value":1800},{"type":29,"tag":88,"props":17252,"children":17253},{"style":174},[17254],{"type":34,"value":17255},"orElse",{"type":29,"tag":88,"props":17257,"children":17258},{"style":122},[17259],{"type":34,"value":181},{"type":29,"tag":88,"props":17261,"children":17262},{"style":195},[17263],{"type":34,"value":17264},"0",{"type":29,"tag":88,"props":17266,"children":17267},{"style":122},[17268],{"type":34,"value":357},{"type":29,"tag":88,"props":17270,"children":17271},{"class":90,"line":137},[17272],{"type":29,"tag":88,"props":17273,"children":17274},{"style":122},[17275],{"type":34,"value":433},{"type":29,"tag":88,"props":17277,"children":17278},{"class":90,"line":211},[17279],{"type":29,"tag":88,"props":17280,"children":17281},{"style":122},[17282],{"type":34,"value":442},{"type":29,"tag":8526,"props":17284,"children":17285},{"type":8528},[17286],{"type":29,"tag":30,"props":17287,"children":17288},{},[17289,17291,17297,17298,17304,17305,17311],{"type":34,"value":17290},"Le nom d’une méthode doit décrire son intention sans ambiguïté. ",{"type":29,"tag":84,"props":17292,"children":17294},{"className":17293},[],[17295],{"type":34,"value":17296},"calculerMoyenne",{"type":34,"value":16045},{"type":29,"tag":84,"props":17299,"children":17301},{"className":17300},[],[17302],{"type":34,"value":17303},"calc",{"type":34,"value":5730},{"type":29,"tag":84,"props":17306,"children":17308},{"className":17307},[],[17309],{"type":34,"value":17310},"moy",{"type":34,"value":17312}," obligent à ouvrir l’implémentation pour deviner.",{"type":29,"tag":457,"props":17314,"children":17315},{},[17316,17321,17323,17328,17330,17333,17338],{"type":29,"tag":447,"props":17317,"children":17318},{},[17319],{"type":34,"value":17320},"Tests automatisés",{"type":34,"value":17322},"\nLe développement piloté par les tests (",{"type":29,"tag":447,"props":17324,"children":17325},{},[17326],{"type":34,"value":17327},"TDD",{"type":34,"value":17329},") 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":29,"tag":11452,"props":17331,"children":17332},{},[],{"type":29,"tag":8474,"props":17334,"children":17335},{},[17336],{"type":34,"value":17337},"Exemple Java avec JUnit :",{"type":29,"tag":77,"props":17339,"children":17341},{"className":81,"code":17340,"language":80,"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",[17342],{"type":29,"tag":84,"props":17343,"children":17344},{"__ignoreMap":8},[17345,17356,17380,17409,17482,17537],{"type":29,"tag":88,"props":17346,"children":17347},{"class":90,"line":91},[17348,17352],{"type":29,"tag":88,"props":17349,"children":17350},{"style":1974},[17351],{"type":34,"value":1977},{"type":29,"tag":88,"props":17353,"children":17354},{"style":1980},[17355],{"type":34,"value":1983},{"type":29,"tag":88,"props":17357,"children":17358},{"class":90,"line":101},[17359,17363,17367,17372,17376],{"type":29,"tag":88,"props":17360,"children":17361},{"style":105},[17362],{"type":34,"value":108},{"type":29,"tag":88,"props":17364,"children":17365},{"style":105},[17366],{"type":34,"value":1303},{"type":29,"tag":88,"props":17368,"children":17369},{"style":174},[17370],{"type":34,"value":17371}," testCalculerMoyenne",{"type":29,"tag":88,"props":17373,"children":17374},{"style":122},[17375],{"type":34,"value":1470},{"type":29,"tag":88,"props":17377,"children":17378},{"style":122},[17379],{"type":34,"value":125},{"type":29,"tag":88,"props":17381,"children":17382},{"class":90,"line":128},[17383,17388,17393,17397,17401,17405],{"type":29,"tag":88,"props":17384,"children":17385},{"style":151},[17386],{"type":34,"value":17387},"    Calculateur",{"type":29,"tag":88,"props":17389,"children":17390},{"style":157},[17391],{"type":34,"value":17392}," calc ",{"type":29,"tag":88,"props":17394,"children":17395},{"style":163},[17396],{"type":34,"value":166},{"type":29,"tag":88,"props":17398,"children":17399},{"style":105},[17400],{"type":34,"value":171},{"type":29,"tag":88,"props":17402,"children":17403},{"style":174},[17404],{"type":34,"value":17138},{"type":29,"tag":88,"props":17406,"children":17407},{"style":122},[17408],{"type":34,"value":1810},{"type":29,"tag":88,"props":17410,"children":17411},{"class":90,"line":137},[17412,17416,17420,17424,17428,17433,17437,17442,17446,17451,17455,17460,17464,17469,17473,17478],{"type":29,"tag":88,"props":17413,"children":17414},{"style":151},[17415],{"type":34,"value":9096},{"type":29,"tag":88,"props":17417,"children":17418},{"style":122},[17419],{"type":34,"value":1683},{"type":29,"tag":88,"props":17421,"children":17422},{"style":105},[17423],{"type":34,"value":9045},{"type":29,"tag":88,"props":17425,"children":17426},{"style":122},[17427],{"type":34,"value":1701},{"type":29,"tag":88,"props":17429,"children":17430},{"style":157},[17431],{"type":34,"value":17432}," nombres ",{"type":29,"tag":88,"props":17434,"children":17435},{"style":163},[17436],{"type":34,"value":166},{"type":29,"tag":88,"props":17438,"children":17439},{"style":157},[17440],{"type":34,"value":17441}," Arrays",{"type":29,"tag":88,"props":17443,"children":17444},{"style":122},[17445],{"type":34,"value":338},{"type":29,"tag":88,"props":17447,"children":17448},{"style":174},[17449],{"type":34,"value":17450},"asList",{"type":29,"tag":88,"props":17452,"children":17453},{"style":122},[17454],{"type":34,"value":181},{"type":29,"tag":88,"props":17456,"children":17457},{"style":195},[17458],{"type":34,"value":17459},"2",{"type":29,"tag":88,"props":17461,"children":17462},{"style":122},[17463],{"type":34,"value":192},{"type":29,"tag":88,"props":17465,"children":17466},{"style":195},[17467],{"type":34,"value":17468}," 4",{"type":29,"tag":88,"props":17470,"children":17471},{"style":122},[17472],{"type":34,"value":192},{"type":29,"tag":88,"props":17474,"children":17475},{"style":195},[17476],{"type":34,"value":17477}," 6",{"type":29,"tag":88,"props":17479,"children":17480},{"style":122},[17481],{"type":34,"value":357},{"type":29,"tag":88,"props":17483,"children":17484},{"class":90,"line":211},[17485,17490,17494,17499,17503,17508,17512,17516,17520,17525,17529,17533],{"type":29,"tag":88,"props":17486,"children":17487},{"style":174},[17488],{"type":34,"value":17489},"    assertEquals",{"type":29,"tag":88,"props":17491,"children":17492},{"style":122},[17493],{"type":34,"value":181},{"type":29,"tag":88,"props":17495,"children":17496},{"style":195},[17497],{"type":34,"value":17498},"4.0",{"type":29,"tag":88,"props":17500,"children":17501},{"style":122},[17502],{"type":34,"value":192},{"type":29,"tag":88,"props":17504,"children":17505},{"style":157},[17506],{"type":34,"value":17507}," calc",{"type":29,"tag":88,"props":17509,"children":17510},{"style":122},[17511],{"type":34,"value":338},{"type":29,"tag":88,"props":17513,"children":17514},{"style":174},[17515],{"type":34,"value":17296},{"type":29,"tag":88,"props":17517,"children":17518},{"style":122},[17519],{"type":34,"value":181},{"type":29,"tag":88,"props":17521,"children":17522},{"style":157},[17523],{"type":34,"value":17524},"nombres",{"type":29,"tag":88,"props":17526,"children":17527},{"style":122},[17528],{"type":34,"value":4242},{"type":29,"tag":88,"props":17530,"children":17531},{"style":195},[17532],{"type":34,"value":13302},{"type":29,"tag":88,"props":17534,"children":17535},{"style":122},[17536],{"type":34,"value":357},{"type":29,"tag":88,"props":17538,"children":17539},{"class":90,"line":262},[17540],{"type":29,"tag":88,"props":17541,"children":17542},{"style":122},[17543],{"type":34,"value":442},{"type":29,"tag":457,"props":17545,"children":17546},{},[17547,17552,17554,17557,17562,17731,17734,17739],{"type":29,"tag":447,"props":17548,"children":17549},{},[17550],{"type":34,"value":17551},"Refactoring constant",{"type":34,"value":17553},"\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":29,"tag":11452,"props":17555,"children":17556},{},[],{"type":29,"tag":8474,"props":17558,"children":17559},{},[17560],{"type":34,"value":17561},"Avant :",{"type":29,"tag":77,"props":17563,"children":17565},{"className":81,"code":17564,"language":80,"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",[17566],{"type":29,"tag":84,"props":17567,"children":17568},{"__ignoreMap":8},[17569,17618,17643,17679,17701,17708,17724],{"type":29,"tag":88,"props":17570,"children":17571},{"class":90,"line":91},[17572,17576,17580,17585,17589,17593,17597,17601,17605,17610,17614],{"type":29,"tag":88,"props":17573,"children":17574},{"style":105},[17575],{"type":34,"value":108},{"type":29,"tag":88,"props":17577,"children":17578},{"style":105},[17579],{"type":34,"value":10663},{"type":29,"tag":88,"props":17581,"children":17582},{"style":174},[17583],{"type":34,"value":17584}," calculerTotal",{"type":29,"tag":88,"props":17586,"children":17587},{"style":122},[17588],{"type":34,"value":181},{"type":29,"tag":88,"props":17590,"children":17591},{"style":151},[17592],{"type":34,"value":9063},{"type":29,"tag":88,"props":17594,"children":17595},{"style":163},[17596],{"type":34,"value":1683},{"type":29,"tag":88,"props":17598,"children":17599},{"style":157},[17600],{"type":34,"value":9045},{"type":29,"tag":88,"props":17602,"children":17603},{"style":163},[17604],{"type":34,"value":1701},{"type":29,"tag":88,"props":17606,"children":17607},{"style":157},[17608],{"type":34,"value":17609}," prix",{"type":29,"tag":88,"props":17611,"children":17612},{"style":122},[17613],{"type":34,"value":306},{"type":29,"tag":88,"props":17615,"children":17616},{"style":122},[17617],{"type":34,"value":125},{"type":29,"tag":88,"props":17619,"children":17620},{"class":90,"line":101},[17621,17626,17631,17635,17639],{"type":29,"tag":88,"props":17622,"children":17623},{"style":105},[17624],{"type":34,"value":17625},"    double",{"type":29,"tag":88,"props":17627,"children":17628},{"style":157},[17629],{"type":34,"value":17630}," total ",{"type":29,"tag":88,"props":17632,"children":17633},{"style":163},[17634],{"type":34,"value":166},{"type":29,"tag":88,"props":17636,"children":17637},{"style":195},[17638],{"type":34,"value":9203},{"type":29,"tag":88,"props":17640,"children":17641},{"style":122},[17642],{"type":34,"value":424},{"type":29,"tag":88,"props":17644,"children":17645},{"class":90,"line":128},[17646,17650,17654,17658,17663,17667,17671,17675],{"type":29,"tag":88,"props":17647,"children":17648},{"style":105},[17649],{"type":34,"value":9137},{"type":29,"tag":88,"props":17651,"children":17652},{"style":122},[17653],{"type":34,"value":2891},{"type":29,"tag":88,"props":17655,"children":17656},{"style":105},[17657],{"type":34,"value":8622},{"type":29,"tag":88,"props":17659,"children":17660},{"style":157},[17661],{"type":34,"value":17662}," prixUnitaire ",{"type":29,"tag":88,"props":17664,"children":17665},{"style":105},[17666],{"type":34,"value":9155},{"type":29,"tag":88,"props":17668,"children":17669},{"style":157},[17670],{"type":34,"value":17609},{"type":29,"tag":88,"props":17672,"children":17673},{"style":122},[17674],{"type":34,"value":306},{"type":29,"tag":88,"props":17676,"children":17677},{"style":122},[17678],{"type":34,"value":125},{"type":29,"tag":88,"props":17680,"children":17681},{"class":90,"line":137},[17682,17687,17692,17697],{"type":29,"tag":88,"props":17683,"children":17684},{"style":157},[17685],{"type":34,"value":17686},"        total ",{"type":29,"tag":88,"props":17688,"children":17689},{"style":163},[17690],{"type":34,"value":17691},"+=",{"type":29,"tag":88,"props":17693,"children":17694},{"style":157},[17695],{"type":34,"value":17696}," prixUnitaire",{"type":29,"tag":88,"props":17698,"children":17699},{"style":122},[17700],{"type":34,"value":424},{"type":29,"tag":88,"props":17702,"children":17703},{"class":90,"line":211},[17704],{"type":29,"tag":88,"props":17705,"children":17706},{"style":122},[17707],{"type":34,"value":433},{"type":29,"tag":88,"props":17709,"children":17710},{"class":90,"line":262},[17711,17715,17720],{"type":29,"tag":88,"props":17712,"children":17713},{"style":105},[17714],{"type":34,"value":1579},{"type":29,"tag":88,"props":17716,"children":17717},{"style":157},[17718],{"type":34,"value":17719}," total",{"type":29,"tag":88,"props":17721,"children":17722},{"style":122},[17723],{"type":34,"value":424},{"type":29,"tag":88,"props":17725,"children":17726},{"class":90,"line":270},[17727],{"type":29,"tag":88,"props":17728,"children":17729},{"style":122},[17730],{"type":34,"value":442},{"type":29,"tag":11452,"props":17732,"children":17733},{},[],{"type":29,"tag":8474,"props":17735,"children":17736},{},[17737],{"type":34,"value":17738},"Après :",{"type":29,"tag":77,"props":17740,"children":17742},{"className":81,"code":17741,"language":80,"meta":8,"style":8},"public double calculerTotal(List\u003CInteger> prix) {\n    return prix.stream().mapToDouble(Integer::intValue).sum();\n}\n",[17743],{"type":29,"tag":84,"props":17744,"children":17745},{"__ignoreMap":8},[17746,17793,17850],{"type":29,"tag":88,"props":17747,"children":17748},{"class":90,"line":91},[17749,17753,17757,17761,17765,17769,17773,17777,17781,17785,17789],{"type":29,"tag":88,"props":17750,"children":17751},{"style":105},[17752],{"type":34,"value":108},{"type":29,"tag":88,"props":17754,"children":17755},{"style":105},[17756],{"type":34,"value":10663},{"type":29,"tag":88,"props":17758,"children":17759},{"style":174},[17760],{"type":34,"value":17584},{"type":29,"tag":88,"props":17762,"children":17763},{"style":122},[17764],{"type":34,"value":181},{"type":29,"tag":88,"props":17766,"children":17767},{"style":151},[17768],{"type":34,"value":9063},{"type":29,"tag":88,"props":17770,"children":17771},{"style":163},[17772],{"type":34,"value":1683},{"type":29,"tag":88,"props":17774,"children":17775},{"style":157},[17776],{"type":34,"value":9045},{"type":29,"tag":88,"props":17778,"children":17779},{"style":163},[17780],{"type":34,"value":1701},{"type":29,"tag":88,"props":17782,"children":17783},{"style":157},[17784],{"type":34,"value":17609},{"type":29,"tag":88,"props":17786,"children":17787},{"style":122},[17788],{"type":34,"value":306},{"type":29,"tag":88,"props":17790,"children":17791},{"style":122},[17792],{"type":34,"value":125},{"type":29,"tag":88,"props":17794,"children":17795},{"class":90,"line":101},[17796,17800,17804,17808,17812,17816,17821,17825,17829,17833,17837,17841,17846],{"type":29,"tag":88,"props":17797,"children":17798},{"style":105},[17799],{"type":34,"value":1579},{"type":29,"tag":88,"props":17801,"children":17802},{"style":157},[17803],{"type":34,"value":17609},{"type":29,"tag":88,"props":17805,"children":17806},{"style":122},[17807],{"type":34,"value":338},{"type":29,"tag":88,"props":17809,"children":17810},{"style":174},[17811],{"type":34,"value":9391},{"type":29,"tag":88,"props":17813,"children":17814},{"style":122},[17815],{"type":34,"value":1800},{"type":29,"tag":88,"props":17817,"children":17818},{"style":174},[17819],{"type":34,"value":17820},"mapToDouble",{"type":29,"tag":88,"props":17822,"children":17823},{"style":122},[17824],{"type":34,"value":181},{"type":29,"tag":88,"props":17826,"children":17827},{"style":157},[17828],{"type":34,"value":9045},{"type":29,"tag":88,"props":17830,"children":17831},{"style":105},[17832],{"type":34,"value":17232},{"type":29,"tag":88,"props":17834,"children":17835},{"style":157},[17836],{"type":34,"value":17237},{"type":29,"tag":88,"props":17838,"children":17839},{"style":122},[17840],{"type":34,"value":8127},{"type":29,"tag":88,"props":17842,"children":17843},{"style":174},[17844],{"type":34,"value":17845},"sum",{"type":29,"tag":88,"props":17847,"children":17848},{"style":122},[17849],{"type":34,"value":1810},{"type":29,"tag":88,"props":17851,"children":17852},{"class":90,"line":128},[17853],{"type":29,"tag":88,"props":17854,"children":17855},{"style":122},[17856],{"type":34,"value":442},{"type":29,"tag":457,"props":17858,"children":17859},{},[17860,17865],{"type":29,"tag":447,"props":17861,"children":17862},{},[17863],{"type":34,"value":17864},"Apprendre et transmettre",{"type":34,"value":17866},"\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":29,"tag":47,"props":17868,"children":17869},{},[],{"type":29,"tag":8542,"props":17871,"children":17873},{"id":17872},"comment-appliquer-ces-principes-dans-votre-code-au-quotidien-avec-exemples-java",[17874],{"type":34,"value":17875},"Comment appliquer ces principes dans votre code au quotidien (avec exemples Java)",{"type":29,"tag":30,"props":17877,"children":17878},{},[17879,17881,17885],{"type":34,"value":17880},"Voyons ",{"type":29,"tag":447,"props":17882,"children":17883},{},[17884],{"type":34,"value":11579},{"type":34,"value":17886}," appliquer de manière concrète ces principes dans votre développement quotidien.",{"type":29,"tag":10576,"props":17888,"children":17890},{"id":17889},"_1-code-propre-structure-et-lisibilité",[17891],{"type":34,"value":17892},"1. Code propre : Structure et lisibilité",{"type":29,"tag":30,"props":17894,"children":17895},{},[17896],{"type":34,"value":17897},"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":29,"tag":453,"props":17899,"children":17900},{},[17901,17911],{"type":29,"tag":457,"props":17902,"children":17903},{},[17904,17909],{"type":29,"tag":447,"props":17905,"children":17906},{},[17907],{"type":34,"value":17908},"Utilisez des noms de variables explicites.",{"type":34,"value":17910}," Les noms doivent décrire clairement leur rôle.",{"type":29,"tag":457,"props":17912,"children":17913},{},[17914,17919],{"type":29,"tag":447,"props":17915,"children":17916},{},[17917],{"type":34,"value":17918},"Découpez votre code en petites fonctions",{"type":34,"value":17920},". Chacune doit accomplir une seule tâche.",{"type":29,"tag":30,"props":17922,"children":17923},{},[17924],{"type":29,"tag":447,"props":17925,"children":17926},{},[17927],{"type":34,"value":17928},"Exemple de mauvaise pratique :",{"type":29,"tag":77,"props":17930,"children":17932},{"className":81,"code":17931,"language":80,"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",[17933],{"type":29,"tag":84,"props":17934,"children":17935},{"__ignoreMap":8},[17936,17985,18021,18075,18123,18130,18137],{"type":29,"tag":88,"props":17937,"children":17938},{"class":90,"line":91},[17939,17943,17947,17952,17956,17960,17964,17968,17972,17977,17981],{"type":29,"tag":88,"props":17940,"children":17941},{"style":105},[17942],{"type":34,"value":108},{"type":29,"tag":88,"props":17944,"children":17945},{"style":105},[17946],{"type":34,"value":1303},{"type":29,"tag":88,"props":17948,"children":17949},{"style":174},[17950],{"type":34,"value":17951}," traiterDonnées",{"type":29,"tag":88,"props":17953,"children":17954},{"style":122},[17955],{"type":34,"value":181},{"type":29,"tag":88,"props":17957,"children":17958},{"style":151},[17959],{"type":34,"value":9063},{"type":29,"tag":88,"props":17961,"children":17962},{"style":163},[17963],{"type":34,"value":1683},{"type":29,"tag":88,"props":17965,"children":17966},{"style":157},[17967],{"type":34,"value":695},{"type":29,"tag":88,"props":17969,"children":17970},{"style":163},[17971],{"type":34,"value":1701},{"type":29,"tag":88,"props":17973,"children":17974},{"style":157},[17975],{"type":34,"value":17976}," données",{"type":29,"tag":88,"props":17978,"children":17979},{"style":122},[17980],{"type":34,"value":306},{"type":29,"tag":88,"props":17982,"children":17983},{"style":122},[17984],{"type":34,"value":125},{"type":29,"tag":88,"props":17986,"children":17987},{"class":90,"line":101},[17988,17992,17996,18000,18005,18009,18013,18017],{"type":29,"tag":88,"props":17989,"children":17990},{"style":105},[17991],{"type":34,"value":9137},{"type":29,"tag":88,"props":17993,"children":17994},{"style":122},[17995],{"type":34,"value":2891},{"type":29,"tag":88,"props":17997,"children":17998},{"style":151},[17999],{"type":34,"value":695},{"type":29,"tag":88,"props":18001,"children":18002},{"style":157},[18003],{"type":34,"value":18004}," d ",{"type":29,"tag":88,"props":18006,"children":18007},{"style":105},[18008],{"type":34,"value":9155},{"type":29,"tag":88,"props":18010,"children":18011},{"style":157},[18012],{"type":34,"value":17976},{"type":29,"tag":88,"props":18014,"children":18015},{"style":122},[18016],{"type":34,"value":306},{"type":29,"tag":88,"props":18018,"children":18019},{"style":122},[18020],{"type":34,"value":125},{"type":29,"tag":88,"props":18022,"children":18023},{"class":90,"line":128},[18024,18028,18032,18037,18041,18045,18049,18053,18058,18062,18067,18071],{"type":29,"tag":88,"props":18025,"children":18026},{"style":105},[18027],{"type":34,"value":2886},{"type":29,"tag":88,"props":18029,"children":18030},{"style":122},[18031],{"type":34,"value":2891},{"type":29,"tag":88,"props":18033,"children":18034},{"style":157},[18035],{"type":34,"value":18036},"d ",{"type":29,"tag":88,"props":18038,"children":18039},{"style":163},[18040],{"type":34,"value":7019},{"type":29,"tag":88,"props":18042,"children":18043},{"style":873},[18044],{"type":34,"value":9747},{"type":29,"tag":88,"props":18046,"children":18047},{"style":163},[18048],{"type":34,"value":9752},{"type":29,"tag":88,"props":18050,"children":18051},{"style":163},[18052],{"type":34,"value":16186},{"type":29,"tag":88,"props":18054,"children":18055},{"style":157},[18056],{"type":34,"value":18057},"d",{"type":29,"tag":88,"props":18059,"children":18060},{"style":122},[18061],{"type":34,"value":338},{"type":29,"tag":88,"props":18063,"children":18064},{"style":174},[18065],{"type":34,"value":18066},"isEmpty",{"type":29,"tag":88,"props":18068,"children":18069},{"style":122},[18070],{"type":34,"value":2915},{"type":29,"tag":88,"props":18072,"children":18073},{"style":122},[18074],{"type":34,"value":125},{"type":29,"tag":88,"props":18076,"children":18077},{"class":90,"line":137},[18078,18083,18087,18092,18096,18101,18105,18110,18114,18119],{"type":29,"tag":88,"props":18079,"children":18080},{"style":157},[18081],{"type":34,"value":18082},"            System",{"type":29,"tag":88,"props":18084,"children":18085},{"style":122},[18086],{"type":34,"value":338},{"type":29,"tag":88,"props":18088,"children":18089},{"style":157},[18090],{"type":34,"value":18091},"out",{"type":29,"tag":88,"props":18093,"children":18094},{"style":122},[18095],{"type":34,"value":338},{"type":29,"tag":88,"props":18097,"children":18098},{"style":174},[18099],{"type":34,"value":18100},"println",{"type":29,"tag":88,"props":18102,"children":18103},{"style":122},[18104],{"type":34,"value":181},{"type":29,"tag":88,"props":18106,"children":18107},{"style":184},[18108],{"type":34,"value":18109},"\"Donnée : \"",{"type":29,"tag":88,"props":18111,"children":18112},{"style":163},[18113],{"type":34,"value":5485},{"type":29,"tag":88,"props":18115,"children":18116},{"style":157},[18117],{"type":34,"value":18118}," d",{"type":29,"tag":88,"props":18120,"children":18121},{"style":122},[18122],{"type":34,"value":357},{"type":29,"tag":88,"props":18124,"children":18125},{"class":90,"line":211},[18126],{"type":29,"tag":88,"props":18127,"children":18128},{"style":122},[18129],{"type":34,"value":2966},{"type":29,"tag":88,"props":18131,"children":18132},{"class":90,"line":262},[18133],{"type":29,"tag":88,"props":18134,"children":18135},{"style":122},[18136],{"type":34,"value":433},{"type":29,"tag":88,"props":18138,"children":18139},{"class":90,"line":270},[18140],{"type":29,"tag":88,"props":18141,"children":18142},{"style":122},[18143],{"type":34,"value":442},{"type":29,"tag":30,"props":18145,"children":18146},{},[18147],{"type":29,"tag":447,"props":18148,"children":18149},{},[18150],{"type":34,"value":18151},"Exemple amélioré :",{"type":29,"tag":77,"props":18153,"children":18155},{"className":81,"code":18154,"language":80,"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",[18156],{"type":29,"tag":84,"props":18157,"children":18158},{"__ignoreMap":8},[18159,18207,18227,18260,18293,18300,18307,18345,18390,18397,18404,18440,18484],{"type":29,"tag":88,"props":18160,"children":18161},{"class":90,"line":91},[18162,18166,18170,18175,18179,18183,18187,18191,18195,18199,18203],{"type":29,"tag":88,"props":18163,"children":18164},{"style":105},[18165],{"type":34,"value":108},{"type":29,"tag":88,"props":18167,"children":18168},{"style":105},[18169],{"type":34,"value":1303},{"type":29,"tag":88,"props":18171,"children":18172},{"style":174},[18173],{"type":34,"value":18174}," afficherDonnéesNonNulles",{"type":29,"tag":88,"props":18176,"children":18177},{"style":122},[18178],{"type":34,"value":181},{"type":29,"tag":88,"props":18180,"children":18181},{"style":151},[18182],{"type":34,"value":9063},{"type":29,"tag":88,"props":18184,"children":18185},{"style":163},[18186],{"type":34,"value":1683},{"type":29,"tag":88,"props":18188,"children":18189},{"style":157},[18190],{"type":34,"value":695},{"type":29,"tag":88,"props":18192,"children":18193},{"style":163},[18194],{"type":34,"value":1701},{"type":29,"tag":88,"props":18196,"children":18197},{"style":157},[18198],{"type":34,"value":17976},{"type":29,"tag":88,"props":18200,"children":18201},{"style":122},[18202],{"type":34,"value":306},{"type":29,"tag":88,"props":18204,"children":18205},{"style":122},[18206],{"type":34,"value":125},{"type":29,"tag":88,"props":18208,"children":18209},{"class":90,"line":101},[18210,18215,18219,18223],{"type":29,"tag":88,"props":18211,"children":18212},{"style":157},[18213],{"type":34,"value":18214},"    données",{"type":29,"tag":88,"props":18216,"children":18217},{"style":122},[18218],{"type":34,"value":338},{"type":29,"tag":88,"props":18220,"children":18221},{"style":174},[18222],{"type":34,"value":9391},{"type":29,"tag":88,"props":18224,"children":18225},{"style":122},[18226],{"type":34,"value":2863},{"type":29,"tag":88,"props":18228,"children":18229},{"class":90,"line":128},[18230,18235,18239,18243,18247,18251,18256],{"type":29,"tag":88,"props":18231,"children":18232},{"style":122},[18233],{"type":34,"value":18234},"           .",{"type":29,"tag":88,"props":18236,"children":18237},{"style":174},[18238],{"type":34,"value":9408},{"type":29,"tag":88,"props":18240,"children":18241},{"style":122},[18242],{"type":34,"value":181},{"type":29,"tag":88,"props":18244,"children":18245},{"style":873},[18246],{"type":34,"value":7006},{"type":29,"tag":88,"props":18248,"children":18249},{"style":105},[18250],{"type":34,"value":17232},{"type":29,"tag":88,"props":18252,"children":18253},{"style":157},[18254],{"type":34,"value":18255},"estValide",{"type":29,"tag":88,"props":18257,"children":18258},{"style":122},[18259],{"type":34,"value":3078},{"type":29,"tag":88,"props":18261,"children":18262},{"class":90,"line":137},[18263,18267,18272,18276,18280,18284,18289],{"type":29,"tag":88,"props":18264,"children":18265},{"style":122},[18266],{"type":34,"value":18234},{"type":29,"tag":88,"props":18268,"children":18269},{"style":174},[18270],{"type":34,"value":18271},"forEach",{"type":29,"tag":88,"props":18273,"children":18274},{"style":122},[18275],{"type":34,"value":181},{"type":29,"tag":88,"props":18277,"children":18278},{"style":873},[18279],{"type":34,"value":7006},{"type":29,"tag":88,"props":18281,"children":18282},{"style":105},[18283],{"type":34,"value":17232},{"type":29,"tag":88,"props":18285,"children":18286},{"style":157},[18287],{"type":34,"value":18288},"afficherDonnée",{"type":29,"tag":88,"props":18290,"children":18291},{"style":122},[18292],{"type":34,"value":357},{"type":29,"tag":88,"props":18294,"children":18295},{"class":90,"line":211},[18296],{"type":29,"tag":88,"props":18297,"children":18298},{"style":122},[18299],{"type":34,"value":442},{"type":29,"tag":88,"props":18301,"children":18302},{"class":90,"line":262},[18303],{"type":29,"tag":88,"props":18304,"children":18305},{"emptyLinePlaceholder":13},[18306],{"type":34,"value":134},{"type":29,"tag":88,"props":18308,"children":18309},{"class":90,"line":270},[18310,18315,18319,18324,18328,18332,18337,18341],{"type":29,"tag":88,"props":18311,"children":18312},{"style":105},[18313],{"type":34,"value":18314},"private",{"type":29,"tag":88,"props":18316,"children":18317},{"style":105},[18318],{"type":34,"value":1889},{"type":29,"tag":88,"props":18320,"children":18321},{"style":174},[18322],{"type":34,"value":18323}," estValide",{"type":29,"tag":88,"props":18325,"children":18326},{"style":122},[18327],{"type":34,"value":181},{"type":29,"tag":88,"props":18329,"children":18330},{"style":151},[18331],{"type":34,"value":695},{"type":29,"tag":88,"props":18333,"children":18334},{"style":157},[18335],{"type":34,"value":18336}," donnée",{"type":29,"tag":88,"props":18338,"children":18339},{"style":122},[18340],{"type":34,"value":306},{"type":29,"tag":88,"props":18342,"children":18343},{"style":122},[18344],{"type":34,"value":125},{"type":29,"tag":88,"props":18346,"children":18347},{"class":90,"line":313},[18348,18352,18357,18361,18365,18369,18373,18378,18382,18386],{"type":29,"tag":88,"props":18349,"children":18350},{"style":105},[18351],{"type":34,"value":1579},{"type":29,"tag":88,"props":18353,"children":18354},{"style":157},[18355],{"type":34,"value":18356}," donnée ",{"type":29,"tag":88,"props":18358,"children":18359},{"style":163},[18360],{"type":34,"value":7019},{"type":29,"tag":88,"props":18362,"children":18363},{"style":873},[18364],{"type":34,"value":9747},{"type":29,"tag":88,"props":18366,"children":18367},{"style":163},[18368],{"type":34,"value":9752},{"type":29,"tag":88,"props":18370,"children":18371},{"style":163},[18372],{"type":34,"value":16186},{"type":29,"tag":88,"props":18374,"children":18375},{"style":157},[18376],{"type":34,"value":18377},"donnée",{"type":29,"tag":88,"props":18379,"children":18380},{"style":122},[18381],{"type":34,"value":338},{"type":29,"tag":88,"props":18383,"children":18384},{"style":174},[18385],{"type":34,"value":18066},{"type":29,"tag":88,"props":18387,"children":18388},{"style":122},[18389],{"type":34,"value":1810},{"type":29,"tag":88,"props":18391,"children":18392},{"class":90,"line":360},[18393],{"type":29,"tag":88,"props":18394,"children":18395},{"style":122},[18396],{"type":34,"value":442},{"type":29,"tag":88,"props":18398,"children":18399},{"class":90,"line":409},[18400],{"type":29,"tag":88,"props":18401,"children":18402},{"emptyLinePlaceholder":13},[18403],{"type":34,"value":134},{"type":29,"tag":88,"props":18405,"children":18406},{"class":90,"line":427},[18407,18411,18415,18420,18424,18428,18432,18436],{"type":29,"tag":88,"props":18408,"children":18409},{"style":105},[18410],{"type":34,"value":18314},{"type":29,"tag":88,"props":18412,"children":18413},{"style":105},[18414],{"type":34,"value":1303},{"type":29,"tag":88,"props":18416,"children":18417},{"style":174},[18418],{"type":34,"value":18419}," afficherDonnée",{"type":29,"tag":88,"props":18421,"children":18422},{"style":122},[18423],{"type":34,"value":181},{"type":29,"tag":88,"props":18425,"children":18426},{"style":151},[18427],{"type":34,"value":695},{"type":29,"tag":88,"props":18429,"children":18430},{"style":157},[18431],{"type":34,"value":18336},{"type":29,"tag":88,"props":18433,"children":18434},{"style":122},[18435],{"type":34,"value":306},{"type":29,"tag":88,"props":18437,"children":18438},{"style":122},[18439],{"type":34,"value":125},{"type":29,"tag":88,"props":18441,"children":18442},{"class":90,"line":436},[18443,18448,18452,18456,18460,18464,18468,18472,18476,18480],{"type":29,"tag":88,"props":18444,"children":18445},{"style":157},[18446],{"type":34,"value":18447},"    System",{"type":29,"tag":88,"props":18449,"children":18450},{"style":122},[18451],{"type":34,"value":338},{"type":29,"tag":88,"props":18453,"children":18454},{"style":157},[18455],{"type":34,"value":18091},{"type":29,"tag":88,"props":18457,"children":18458},{"style":122},[18459],{"type":34,"value":338},{"type":29,"tag":88,"props":18461,"children":18462},{"style":174},[18463],{"type":34,"value":18100},{"type":29,"tag":88,"props":18465,"children":18466},{"style":122},[18467],{"type":34,"value":181},{"type":29,"tag":88,"props":18469,"children":18470},{"style":184},[18471],{"type":34,"value":18109},{"type":29,"tag":88,"props":18473,"children":18474},{"style":163},[18475],{"type":34,"value":5485},{"type":29,"tag":88,"props":18477,"children":18478},{"style":157},[18479],{"type":34,"value":18336},{"type":29,"tag":88,"props":18481,"children":18482},{"style":122},[18483],{"type":34,"value":357},{"type":29,"tag":88,"props":18485,"children":18486},{"class":90,"line":767},[18487],{"type":29,"tag":88,"props":18488,"children":18489},{"style":122},[18490],{"type":34,"value":442},{"type":29,"tag":30,"props":18492,"children":18493},{},[18494],{"type":34,"value":18495},"Les méthodes privées extraites portent la complexité par petits morceaux nommés, là où une boucle imbriquée la cachait.",{"type":29,"tag":47,"props":18497,"children":18498},{},[],{"type":29,"tag":10576,"props":18500,"children":18502},{"id":18501},"_2-tests-automatisés-assurer-la-qualité-de-votre-code-dès-le-départ",[18503],{"type":34,"value":18504},"2. Tests automatisés : Assurer la qualité de votre code dès le départ",{"type":29,"tag":30,"props":18506,"children":18507},{},[18508],{"type":34,"value":18509},"Les tests garantissent que votre code fonctionne comme prévu à chaque étape, et surtout, ils rendent le refactoring possible sans crainte.",{"type":29,"tag":30,"props":18511,"children":18512},{},[18513],{"type":29,"tag":447,"props":18514,"children":18515},{},[18516],{"type":34,"value":18517},"Exemple avec JUnit :",{"type":29,"tag":77,"props":18519,"children":18521},{"className":81,"code":18520,"language":80,"meta":8,"style":8},"@Test\npublic void testEstValide() {\n    assertTrue(estValide(\"ValidData\"));\n    assertFalse(estValide(\"\"));\n    assertFalse(estValide(null));\n}\n",[18522],{"type":29,"tag":84,"props":18523,"children":18524},{"__ignoreMap":8},[18525,18536,18560,18589,18618,18646],{"type":29,"tag":88,"props":18526,"children":18527},{"class":90,"line":91},[18528,18532],{"type":29,"tag":88,"props":18529,"children":18530},{"style":1974},[18531],{"type":34,"value":1977},{"type":29,"tag":88,"props":18533,"children":18534},{"style":1980},[18535],{"type":34,"value":1983},{"type":29,"tag":88,"props":18537,"children":18538},{"class":90,"line":101},[18539,18543,18547,18552,18556],{"type":29,"tag":88,"props":18540,"children":18541},{"style":105},[18542],{"type":34,"value":108},{"type":29,"tag":88,"props":18544,"children":18545},{"style":105},[18546],{"type":34,"value":1303},{"type":29,"tag":88,"props":18548,"children":18549},{"style":174},[18550],{"type":34,"value":18551}," testEstValide",{"type":29,"tag":88,"props":18553,"children":18554},{"style":122},[18555],{"type":34,"value":1470},{"type":29,"tag":88,"props":18557,"children":18558},{"style":122},[18559],{"type":34,"value":125},{"type":29,"tag":88,"props":18561,"children":18562},{"class":90,"line":128},[18563,18568,18572,18576,18580,18585],{"type":29,"tag":88,"props":18564,"children":18565},{"style":174},[18566],{"type":34,"value":18567},"    assertTrue",{"type":29,"tag":88,"props":18569,"children":18570},{"style":122},[18571],{"type":34,"value":181},{"type":29,"tag":88,"props":18573,"children":18574},{"style":174},[18575],{"type":34,"value":18255},{"type":29,"tag":88,"props":18577,"children":18578},{"style":122},[18579],{"type":34,"value":181},{"type":29,"tag":88,"props":18581,"children":18582},{"style":184},[18583],{"type":34,"value":18584},"\"ValidData\"",{"type":29,"tag":88,"props":18586,"children":18587},{"style":122},[18588],{"type":34,"value":1415},{"type":29,"tag":88,"props":18590,"children":18591},{"class":90,"line":137},[18592,18597,18601,18605,18609,18614],{"type":29,"tag":88,"props":18593,"children":18594},{"style":174},[18595],{"type":34,"value":18596},"    assertFalse",{"type":29,"tag":88,"props":18598,"children":18599},{"style":122},[18600],{"type":34,"value":181},{"type":29,"tag":88,"props":18602,"children":18603},{"style":174},[18604],{"type":34,"value":18255},{"type":29,"tag":88,"props":18606,"children":18607},{"style":122},[18608],{"type":34,"value":181},{"type":29,"tag":88,"props":18610,"children":18611},{"style":184},[18612],{"type":34,"value":18613},"\"\"",{"type":29,"tag":88,"props":18615,"children":18616},{"style":122},[18617],{"type":34,"value":1415},{"type":29,"tag":88,"props":18619,"children":18620},{"class":90,"line":211},[18621,18625,18629,18633,18637,18642],{"type":29,"tag":88,"props":18622,"children":18623},{"style":174},[18624],{"type":34,"value":18596},{"type":29,"tag":88,"props":18626,"children":18627},{"style":122},[18628],{"type":34,"value":181},{"type":29,"tag":88,"props":18630,"children":18631},{"style":174},[18632],{"type":34,"value":18255},{"type":29,"tag":88,"props":18634,"children":18635},{"style":122},[18636],{"type":34,"value":181},{"type":29,"tag":88,"props":18638,"children":18639},{"style":873},[18640],{"type":34,"value":18641},"null",{"type":29,"tag":88,"props":18643,"children":18644},{"style":122},[18645],{"type":34,"value":1415},{"type":29,"tag":88,"props":18647,"children":18648},{"class":90,"line":262},[18649],{"type":29,"tag":88,"props":18650,"children":18651},{"style":122},[18652],{"type":34,"value":442},{"type":29,"tag":30,"props":18654,"children":18655},{},[18656],{"type":34,"value":18657},"Cette approche valide la logique à chaque modification, sans dépendre d’un test manuel oublié. À coupler systématiquement avec un pipeline CI\u002FCD qui rejoue la suite à chaque commit. Sinon les tests existent sans vraiment exister.",{"type":29,"tag":47,"props":18659,"children":18660},{},[],{"type":29,"tag":10576,"props":18662,"children":18664},{"id":18663},"_3-refactoring-améliorer-sans-casser",[18665],{"type":34,"value":18666},"3. Refactoring : Améliorer sans casser",{"type":29,"tag":30,"props":18668,"children":18669},{},[18670,18672,18678],{"type":34,"value":18671},"Refactorer, c’est nettoyer sans modifier le comportement observable. Une boucle remplacée par un stream, une concaténation transformée en ",{"type":29,"tag":84,"props":18673,"children":18675},{"className":18674},[],[18676],{"type":34,"value":18677},"String.format",{"type":34,"value":18679},", une méthode extraite pour clarifier une intention. Petits gestes, effet cumulé considérable sur la durée de vie de la base.",{"type":29,"tag":30,"props":18681,"children":18682},{},[18683],{"type":34,"value":18684},"Exemple typique :",{"type":29,"tag":30,"props":18686,"children":18687},{},[18688],{"type":29,"tag":447,"props":18689,"children":18690},{},[18691],{"type":34,"value":17561},{"type":29,"tag":77,"props":18693,"children":18695},{"className":81,"code":18694,"language":80,"meta":8,"style":8},"public String construireMessage(String nom, int age) {\n    return \"Nom: \" + nom + \", Age: \" + age;\n}\n",[18696],{"type":29,"tag":84,"props":18697,"children":18698},{"__ignoreMap":8},[18699,18749,18791],{"type":29,"tag":88,"props":18700,"children":18701},{"class":90,"line":91},[18702,18706,18710,18715,18719,18723,18728,18732,18736,18741,18745],{"type":29,"tag":88,"props":18703,"children":18704},{"style":105},[18705],{"type":34,"value":108},{"type":29,"tag":88,"props":18707,"children":18708},{"style":151},[18709],{"type":34,"value":281},{"type":29,"tag":88,"props":18711,"children":18712},{"style":174},[18713],{"type":34,"value":18714}," construireMessage",{"type":29,"tag":88,"props":18716,"children":18717},{"style":122},[18718],{"type":34,"value":181},{"type":29,"tag":88,"props":18720,"children":18721},{"style":151},[18722],{"type":34,"value":695},{"type":29,"tag":88,"props":18724,"children":18725},{"style":157},[18726],{"type":34,"value":18727}," nom",{"type":29,"tag":88,"props":18729,"children":18730},{"style":122},[18731],{"type":34,"value":192},{"type":29,"tag":88,"props":18733,"children":18734},{"style":105},[18735],{"type":34,"value":8608},{"type":29,"tag":88,"props":18737,"children":18738},{"style":157},[18739],{"type":34,"value":18740}," age",{"type":29,"tag":88,"props":18742,"children":18743},{"style":122},[18744],{"type":34,"value":306},{"type":29,"tag":88,"props":18746,"children":18747},{"style":122},[18748],{"type":34,"value":125},{"type":29,"tag":88,"props":18750,"children":18751},{"class":90,"line":101},[18752,18756,18761,18765,18770,18774,18779,18783,18787],{"type":29,"tag":88,"props":18753,"children":18754},{"style":105},[18755],{"type":34,"value":1579},{"type":29,"tag":88,"props":18757,"children":18758},{"style":184},[18759],{"type":34,"value":18760}," \"Nom: \"",{"type":29,"tag":88,"props":18762,"children":18763},{"style":163},[18764],{"type":34,"value":5485},{"type":29,"tag":88,"props":18766,"children":18767},{"style":157},[18768],{"type":34,"value":18769}," nom ",{"type":29,"tag":88,"props":18771,"children":18772},{"style":163},[18773],{"type":34,"value":5495},{"type":29,"tag":88,"props":18775,"children":18776},{"style":184},[18777],{"type":34,"value":18778}," \", Age: \"",{"type":29,"tag":88,"props":18780,"children":18781},{"style":163},[18782],{"type":34,"value":5485},{"type":29,"tag":88,"props":18784,"children":18785},{"style":157},[18786],{"type":34,"value":18740},{"type":29,"tag":88,"props":18788,"children":18789},{"style":122},[18790],{"type":34,"value":424},{"type":29,"tag":88,"props":18792,"children":18793},{"class":90,"line":128},[18794],{"type":29,"tag":88,"props":18795,"children":18796},{"style":122},[18797],{"type":34,"value":442},{"type":29,"tag":30,"props":18799,"children":18800},{},[18801],{"type":29,"tag":447,"props":18802,"children":18803},{},[18804],{"type":34,"value":17738},{"type":29,"tag":77,"props":18806,"children":18808},{"className":81,"code":18807,"language":80,"meta":8,"style":8},"public String construireMessage(String nom, int age) {\n    return String.format(\"Nom: %s, Age: %d\", nom, age);\n}\n",[18809],{"type":29,"tag":84,"props":18810,"children":18811},{"__ignoreMap":8},[18812,18859,18908],{"type":29,"tag":88,"props":18813,"children":18814},{"class":90,"line":91},[18815,18819,18823,18827,18831,18835,18839,18843,18847,18851,18855],{"type":29,"tag":88,"props":18816,"children":18817},{"style":105},[18818],{"type":34,"value":108},{"type":29,"tag":88,"props":18820,"children":18821},{"style":151},[18822],{"type":34,"value":281},{"type":29,"tag":88,"props":18824,"children":18825},{"style":174},[18826],{"type":34,"value":18714},{"type":29,"tag":88,"props":18828,"children":18829},{"style":122},[18830],{"type":34,"value":181},{"type":29,"tag":88,"props":18832,"children":18833},{"style":151},[18834],{"type":34,"value":695},{"type":29,"tag":88,"props":18836,"children":18837},{"style":157},[18838],{"type":34,"value":18727},{"type":29,"tag":88,"props":18840,"children":18841},{"style":122},[18842],{"type":34,"value":192},{"type":29,"tag":88,"props":18844,"children":18845},{"style":105},[18846],{"type":34,"value":8608},{"type":29,"tag":88,"props":18848,"children":18849},{"style":157},[18850],{"type":34,"value":18740},{"type":29,"tag":88,"props":18852,"children":18853},{"style":122},[18854],{"type":34,"value":306},{"type":29,"tag":88,"props":18856,"children":18857},{"style":122},[18858],{"type":34,"value":125},{"type":29,"tag":88,"props":18860,"children":18861},{"class":90,"line":101},[18862,18866,18870,18874,18879,18883,18888,18892,18896,18900,18904],{"type":29,"tag":88,"props":18863,"children":18864},{"style":105},[18865],{"type":34,"value":1579},{"type":29,"tag":88,"props":18867,"children":18868},{"style":157},[18869],{"type":34,"value":281},{"type":29,"tag":88,"props":18871,"children":18872},{"style":122},[18873],{"type":34,"value":338},{"type":29,"tag":88,"props":18875,"children":18876},{"style":174},[18877],{"type":34,"value":18878},"format",{"type":29,"tag":88,"props":18880,"children":18881},{"style":122},[18882],{"type":34,"value":181},{"type":29,"tag":88,"props":18884,"children":18885},{"style":184},[18886],{"type":34,"value":18887},"\"Nom: %s, Age: %d\"",{"type":29,"tag":88,"props":18889,"children":18890},{"style":122},[18891],{"type":34,"value":192},{"type":29,"tag":88,"props":18893,"children":18894},{"style":157},[18895],{"type":34,"value":18727},{"type":29,"tag":88,"props":18897,"children":18898},{"style":122},[18899],{"type":34,"value":192},{"type":29,"tag":88,"props":18901,"children":18902},{"style":157},[18903],{"type":34,"value":18740},{"type":29,"tag":88,"props":18905,"children":18906},{"style":122},[18907],{"type":34,"value":357},{"type":29,"tag":88,"props":18909,"children":18910},{"class":90,"line":128},[18911],{"type":29,"tag":88,"props":18912,"children":18913},{"style":122},[18914],{"type":34,"value":442},{"type":29,"tag":30,"props":18916,"children":18917},{},[18918],{"type":34,"value":18919},"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":29,"tag":47,"props":18921,"children":18922},{},[],{"type":29,"tag":10576,"props":18924,"children":18926},{"id":18925},"_4-apprentissage-continu-et-pair-programming",[18927],{"type":34,"value":18928},"4. Apprentissage continu et Pair Programming",{"type":29,"tag":30,"props":18930,"children":18931},{},[18932,18933,18942,18944,18951],{"type":34,"value":10213},{"type":29,"tag":447,"props":18934,"children":18935},{},[18936],{"type":29,"tag":63,"props":18937,"children":18939},{"href":18938},"\u002Ffr\u002Fdette-technique\u002Fpair-programming-roi-conditions",[18940],{"type":34,"value":18941},"pair programming",{"type":34,"value":18943}," et la ",{"type":29,"tag":447,"props":18945,"children":18946},{},[18947],{"type":29,"tag":63,"props":18948,"children":18949},{"href":10386},[18950],{"type":34,"value":10389},{"type":34,"value":18952}," 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":29,"tag":47,"props":18954,"children":18955},{},[],{"type":29,"tag":8542,"props":18957,"children":18959},{"id":18958},"outils-et-pratiques-recommandés",[18960],{"type":34,"value":18961},"Outils et pratiques recommandés",{"type":29,"tag":30,"props":18963,"children":18964},{},[18965],{"type":34,"value":18966},"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":29,"tag":10576,"props":18968,"children":18970},{"id":18969},"code-propre",[18971],{"type":34,"value":18972},"Code propre",{"type":29,"tag":453,"props":18974,"children":18975},{},[18976,18986],{"type":29,"tag":457,"props":18977,"children":18978},{},[18979,18984],{"type":29,"tag":447,"props":18980,"children":18981},{},[18982],{"type":34,"value":18983},"SonarLint",{"type":34,"value":18985}," : analyse statique en temps réel dans l’IDE. Détecte duplications, code mort, bugs probables. Indispensable.",{"type":29,"tag":457,"props":18987,"children":18988},{},[18989,18994],{"type":29,"tag":447,"props":18990,"children":18991},{},[18992],{"type":34,"value":18993},"Checkstyle",{"type":34,"value":18995}," : 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":29,"tag":10576,"props":18997,"children":18999},{"id":18998},"tests",[19000],{"type":34,"value":19001},"Tests",{"type":29,"tag":453,"props":19003,"children":19004},{},[19005,19014],{"type":29,"tag":457,"props":19006,"children":19007},{},[19008,19012],{"type":29,"tag":447,"props":19009,"children":19010},{},[19011],{"type":34,"value":12978},{"type":34,"value":19013}," : bibliothèque de tests unitaires standard de l’écosystème Java.",{"type":29,"tag":457,"props":19015,"children":19016},{},[19017,19021,19023],{"type":29,"tag":447,"props":19018,"children":19019},{},[19020],{"type":34,"value":12984},{"type":34,"value":19022}," : simulation de dépendances externes (bases, services web) pour isoler le composant testé.",{"type":29,"tag":77,"props":19024,"children":19026},{"className":81,"code":19025,"language":80,"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",[19027],{"type":29,"tag":84,"props":19028,"children":19029},{"__ignoreMap":8},[19030,19041,19065,19107,19154,19161,19196],{"type":29,"tag":88,"props":19031,"children":19032},{"class":90,"line":91},[19033,19037],{"type":29,"tag":88,"props":19034,"children":19035},{"style":1974},[19036],{"type":34,"value":1977},{"type":29,"tag":88,"props":19038,"children":19039},{"style":1980},[19040],{"type":34,"value":1983},{"type":29,"tag":88,"props":19042,"children":19043},{"class":90,"line":101},[19044,19048,19052,19057,19061],{"type":29,"tag":88,"props":19045,"children":19046},{"style":105},[19047],{"type":34,"value":108},{"type":29,"tag":88,"props":19049,"children":19050},{"style":105},[19051],{"type":34,"value":1303},{"type":29,"tag":88,"props":19053,"children":19054},{"style":174},[19055],{"type":34,"value":19056}," testAvecMock",{"type":29,"tag":88,"props":19058,"children":19059},{"style":122},[19060],{"type":34,"value":1470},{"type":29,"tag":88,"props":19062,"children":19063},{"style":122},[19064],{"type":34,"value":125},{"type":29,"tag":88,"props":19066,"children":19067},{"class":90,"line":128},[19068,19073,19077,19081,19086,19090,19095,19099,19103],{"type":29,"tag":88,"props":19069,"children":19070},{"style":151},[19071],{"type":34,"value":19072},"    MyService",{"type":29,"tag":88,"props":19074,"children":19075},{"style":157},[19076],{"type":34,"value":2074},{"type":29,"tag":88,"props":19078,"children":19079},{"style":163},[19080],{"type":34,"value":166},{"type":29,"tag":88,"props":19082,"children":19083},{"style":174},[19084],{"type":34,"value":19085}," mock",{"type":29,"tag":88,"props":19087,"children":19088},{"style":122},[19089],{"type":34,"value":181},{"type":29,"tag":88,"props":19091,"children":19092},{"style":157},[19093],{"type":34,"value":19094},"MyService",{"type":29,"tag":88,"props":19096,"children":19097},{"style":122},[19098],{"type":34,"value":338},{"type":29,"tag":88,"props":19100,"children":19101},{"style":157},[19102],{"type":34,"value":1225},{"type":29,"tag":88,"props":19104,"children":19105},{"style":122},[19106],{"type":34,"value":357},{"type":29,"tag":88,"props":19108,"children":19109},{"class":90,"line":137},[19110,19115,19119,19124,19128,19132,19136,19141,19145,19150],{"type":29,"tag":88,"props":19111,"children":19112},{"style":174},[19113],{"type":34,"value":19114},"    when",{"type":29,"tag":88,"props":19116,"children":19117},{"style":122},[19118],{"type":34,"value":181},{"type":29,"tag":88,"props":19120,"children":19121},{"style":157},[19122],{"type":34,"value":19123},"service",{"type":29,"tag":88,"props":19125,"children":19126},{"style":122},[19127],{"type":34,"value":338},{"type":29,"tag":88,"props":19129,"children":19130},{"style":174},[19131],{"type":34,"value":16051},{"type":29,"tag":88,"props":19133,"children":19134},{"style":122},[19135],{"type":34,"value":2261},{"type":29,"tag":88,"props":19137,"children":19138},{"style":174},[19139],{"type":34,"value":19140},"thenReturn",{"type":29,"tag":88,"props":19142,"children":19143},{"style":122},[19144],{"type":34,"value":181},{"type":29,"tag":88,"props":19146,"children":19147},{"style":195},[19148],{"type":34,"value":19149},"42",{"type":29,"tag":88,"props":19151,"children":19152},{"style":122},[19153],{"type":34,"value":357},{"type":29,"tag":88,"props":19155,"children":19156},{"class":90,"line":211},[19157],{"type":29,"tag":88,"props":19158,"children":19159},{"emptyLinePlaceholder":13},[19160],{"type":34,"value":134},{"type":29,"tag":88,"props":19162,"children":19163},{"class":90,"line":262},[19164,19168,19172,19176,19180,19184,19188,19192],{"type":29,"tag":88,"props":19165,"children":19166},{"style":174},[19167],{"type":34,"value":17489},{"type":29,"tag":88,"props":19169,"children":19170},{"style":122},[19171],{"type":34,"value":181},{"type":29,"tag":88,"props":19173,"children":19174},{"style":195},[19175],{"type":34,"value":19149},{"type":29,"tag":88,"props":19177,"children":19178},{"style":122},[19179],{"type":34,"value":192},{"type":29,"tag":88,"props":19181,"children":19182},{"style":157},[19183],{"type":34,"value":2133},{"type":29,"tag":88,"props":19185,"children":19186},{"style":122},[19187],{"type":34,"value":338},{"type":29,"tag":88,"props":19189,"children":19190},{"style":174},[19191],{"type":34,"value":16051},{"type":29,"tag":88,"props":19193,"children":19194},{"style":122},[19195],{"type":34,"value":2958},{"type":29,"tag":88,"props":19197,"children":19198},{"class":90,"line":270},[19199],{"type":29,"tag":88,"props":19200,"children":19201},{"style":122},[19202],{"type":34,"value":442},{"type":29,"tag":10576,"props":19204,"children":19206},{"id":19205},"refactoring",[19207],{"type":34,"value":19208},"Refactoring",{"type":29,"tag":453,"props":19210,"children":19211},{},[19212,19222],{"type":29,"tag":457,"props":19213,"children":19214},{},[19215,19220],{"type":29,"tag":447,"props":19216,"children":19217},{},[19218],{"type":34,"value":19219},"IntelliJ IDEA",{"type":34,"value":19221}," : refactorings intégrés (rename, extract method, inline, move). Apprendre les raccourcis change le quotidien.",{"type":29,"tag":457,"props":19223,"children":19224},{},[19225,19230],{"type":29,"tag":447,"props":19226,"children":19227},{},[19228],{"type":34,"value":19229},"PMD",{"type":34,"value":19231}," : analyse statique complémentaire à SonarLint, particulièrement utile pour repérer les zones candidates au refactoring.",{"type":29,"tag":47,"props":19233,"children":19234},{},[],{"type":29,"tag":8542,"props":19236,"children":19238},{"id":19237},"deux-histoires-qui-finissent-mal",[19239],{"type":34,"value":19240},"Deux histoires qui finissent mal",{"type":29,"tag":30,"props":19242,"children":19243},{},[19244,19249],{"type":29,"tag":447,"props":19245,"children":19246},{},[19247],{"type":34,"value":19248},"Refactoring sans tests, équipe assurance, 2019.",{"type":34,"value":19250}," 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":29,"tag":30,"props":19252,"children":19253},{},[19254,19259],{"type":29,"tag":447,"props":19255,"children":19256},{},[19257],{"type":34,"value":19258},"Tests \"à faire plus tard\", scale-up média, 2021.",{"type":34,"value":19260}," 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":29,"tag":47,"props":19262,"children":19263},{},[],{"type":29,"tag":8542,"props":19265,"children":19267},{"id":19266},"quelques-repères-pour-progresser",[19268],{"type":34,"value":19269},"Quelques repères pour progresser",{"type":29,"tag":30,"props":19271,"children":19272},{},[19273],{"type":34,"value":19274},"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":29,"tag":2288,"props":19276,"children":19278},{"cta":5629,"href":5630,"title":19277,"type":5632},"Le clean code n'est qu'une pratique parmi 100",[19279],{"type":29,"tag":30,"props":19280,"children":19281},{},[19282],{"type":34,"value":19283},"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":29,"tag":47,"props":19285,"children":19286},{},[],{"type":29,"tag":8542,"props":19288,"children":19289},{"id":10010},[19290],{"type":34,"value":10013},{"type":29,"tag":5649,"props":19292,"children":19293},{},[19294,19299],{"type":29,"tag":5653,"props":19295,"children":19296},{},[19297],{"type":34,"value":19298},"Craftsmanship et agilité : opposition ou complémentarité ?",{"type":29,"tag":30,"props":19300,"children":19301},{},[19302,19304,19308,19310,19314],{"type":34,"value":19303},"Complémentarité. L’agilité organise ",{"type":29,"tag":8474,"props":19305,"children":19306},{},[19307],{"type":34,"value":11579},{"type":34,"value":19309}," on livre, le craftsmanship définit ",{"type":29,"tag":8474,"props":19311,"children":19312},{},[19313],{"type":34,"value":17063},{"type":34,"value":19315},". 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":29,"tag":5649,"props":19317,"children":19318},{},[19319,19324],{"type":29,"tag":5653,"props":19320,"children":19321},{},[19322],{"type":34,"value":19323},"TDD ralentit-il vraiment le développement ?",{"type":29,"tag":30,"props":19325,"children":19326},{},[19327],{"type":34,"value":19328},"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":29,"tag":5649,"props":19330,"children":19331},{},[19332,19337],{"type":29,"tag":5653,"props":19333,"children":19334},{},[19335],{"type":34,"value":19336},"Faut-il tout tester ?",{"type":29,"tag":30,"props":19338,"children":19339},{},[19340],{"type":34,"value":19341},"Non. Cibler les composants critiques, la logique métier, les zones à fort taux de modification. Les getters\u002Fsetters 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":29,"tag":47,"props":19343,"children":19344},{},[],{"type":29,"tag":8542,"props":19346,"children":19347},{"id":15632},[19348],{"type":34,"value":15635},{"type":29,"tag":30,"props":19350,"children":19351},{},[19352],{"type":34,"value":19353},"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":29,"tag":2288,"props":19355,"children":19358},{"cta":19356,"href":10075,"title":19357,"type":5755},"Accéder à l'assessment gratuit →","Ressource gratuite : Votre équipe livre-t-elle aussi vite qu'elle le pourrait ?",[19359],{"type":29,"tag":30,"props":19360,"children":19361},{},[19362],{"type":34,"value":19363},"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":29,"tag":5763,"props":19365,"children":19366},{},[19367],{"type":34,"value":5767},{"title":8,"searchDepth":101,"depth":101,"links":19369},[19370,19371,19372,19373,19374,19375,19376,19377,19378],{"id":16951,"depth":128,"text":16954},{"id":16983,"depth":128,"text":16986},{"id":17080,"depth":128,"text":17083},{"id":17872,"depth":128,"text":17875},{"id":18958,"depth":128,"text":18961},{"id":19237,"depth":128,"text":19240},{"id":19266,"depth":128,"text":19269},{"id":10010,"depth":128,"text":10013},{"id":15632,"depth":128,"text":15635},"content:fr:dette-technique:software-craftsmanship-principes-exemples-java.md","fr\u002Fdette-technique\u002Fsoftware-craftsmanship-principes-exemples-java.md","fr\u002Fdette-technique\u002Fsoftware-craftsmanship-principes-exemples-java",{"_path":9965,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":19383,"description":19384,"id":3288,"date":19385,"listed":13,"nocomments":7,"hidden":7,"categories":19386,"tags":19387,"cover":19388,"readingTime":19389,"body":19394,"_type":5777,"_id":25463,"_source":5779,"_file":25464,"_stem":25465,"_extension":5782},"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...","2024-05-22",[6],[16,8453],"covers\u002Farticles\u002Fsolid-principles.jpg",{"text":19390,"minutes":19391,"time":19392,"words":19393},"16 min read",15.03,901800,3006,{"type":26,"children":19395,"toc":25437},[19396,19402,19407,19419,19424,19429,19487,19493,19498,19501,19507,19519,19525,19530,19536,19555,19561,19881,19892,19898,19903,20255,20258,20271,20280,20286,20305,20310,20315,20320,20325,20331,20344,20607,20633,20639,20644,21052,21064,21191,21202,21533,21536,21549,21555,21560,21565,21570,21575,21596,21602,21620,22200,22234,22240,22245,22736,22739,22752,22758,22763,22768,22773,22778,22791,22797,22802,22884,22912,22917,23176,23195,23201,23213,23384,23389,23824,23827,23840,23846,23851,23856,23861,23866,23878,23884,23896,24212,24238,24244,24257,24839,24879,25185,25188,25201,25207,25352,25361,25364,25370,25383,25396,25409,25422,25425,25433],{"type":29,"tag":51,"props":19397,"children":19399},{"id":19398},"principes-solid-les-fondements-de-la-programmation-orientée-objet",[19400],{"type":34,"value":19401},"Principes SOLID : Les fondements de la programmation orientée objet",{"type":29,"tag":30,"props":19403,"children":19404},{},[19405],{"type":34,"value":19406},"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":29,"tag":30,"props":19408,"children":19409},{},[19410,19412,19417],{"type":34,"value":19411},"Les cinq principes SOLID, formalisés par Robert C. Martin dans ",{"type":29,"tag":8474,"props":19413,"children":19414},{},[19415],{"type":34,"value":19416},"Agile Software Development: Principles, Patterns, and Practices",{"type":34,"value":19418},", 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":29,"tag":30,"props":19420,"children":19421},{},[19422],{"type":34,"value":19423},"Cet article couvre ce que sont ces principes, pourquoi ils structurent une architecture saine, et comment les appliquer concrètement en Java.",{"type":29,"tag":30,"props":19425,"children":19426},{},[19427],{"type":34,"value":19428},"Les principes SOLID sont les suivants :",{"type":29,"tag":17095,"props":19430,"children":19431},{},[19432,19443,19454,19465,19476],{"type":29,"tag":457,"props":19433,"children":19434},{},[19435,19441],{"type":29,"tag":63,"props":19436,"children":19438},{"href":19437},"\u002Ffr\u002Farchitecture-craft\u002Fprincipe-srp-software-craftsmanship-exemples-java",[19439],{"type":34,"value":19440},"Le principe de responsabilité unique (SRP)",{"type":34,"value":19442}," : une classe ne doit avoir qu'une seule raison de changer. Une classe, une responsabilité : pas un fourre-tout fonctionnel.",{"type":29,"tag":457,"props":19444,"children":19445},{},[19446,19452],{"type":29,"tag":63,"props":19447,"children":19449},{"href":19448},"\u002Ffr\u002Farchitecture-craft\u002Fprincipe-ocp-software-craftsmanship-exemples-java",[19450],{"type":34,"value":19451},"Le principe d'ouverture\u002Ffermeture (OCP)",{"type":34,"value":19453}," : 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":29,"tag":457,"props":19455,"children":19456},{},[19457,19463],{"type":29,"tag":63,"props":19458,"children":19460},{"href":19459},"\u002Ffr\u002Farchitecture-craft\u002Fprincipe-substitution-liskov-lsp-java",[19461],{"type":34,"value":19462},"Le principe de substitution de Liskov (LSP)",{"type":34,"value":19464}," : 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":29,"tag":457,"props":19466,"children":19467},{},[19468,19474],{"type":29,"tag":63,"props":19469,"children":19471},{"href":19470},"\u002Ffr\u002Farchitecture-craft\u002Fprincipe-isp-software-craftsmanship-exemples-java",[19472],{"type":34,"value":19473},"Le principe de ségrégation des interfaces (ISP)",{"type":34,"value":19475}," : les interfaces doivent être spécifiques aux besoins des clients. Plusieurs interfaces ciblées valent mieux qu'une interface fourre-tout.",{"type":29,"tag":457,"props":19477,"children":19478},{},[19479,19485],{"type":29,"tag":63,"props":19480,"children":19482},{"href":19481},"\u002Ffr\u002Farchitecture-craft\u002Fprincipe-inversion-dependances-dip-java-guide-complet",[19483],{"type":34,"value":19484},"Le principe d'inversion de dépendance (DIP)",{"type":34,"value":19486}," : 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":29,"tag":51,"props":19488,"children":19490},{"id":19489},"comprendre-et-appliquer-les-principes-solid-en-java",[19491],{"type":34,"value":19492},"Comprendre et appliquer les principes SOLID en Java",{"type":29,"tag":30,"props":19494,"children":19495},{},[19496],{"type":34,"value":19497},"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":29,"tag":47,"props":19499,"children":19500},{},[],{"type":29,"tag":51,"props":19502,"children":19504},{"id":19503},"_1-principe-de-responsabilité-unique-single-responsibility-principle-srp",[19505],{"type":34,"value":19506},"1. Principe de Responsabilité Unique (Single Responsibility Principle - SRP)",{"type":29,"tag":30,"props":19508,"children":19509},{},[19510,19512,19517],{"type":34,"value":19511},"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":29,"tag":447,"props":19513,"children":19514},{},[19515],{"type":34,"value":19516},"qu'une seule raison de changer",{"type":34,"value":19518},". En d'autres termes, chaque classe doit se concentrer sur une seule tâche ou responsabilité.",{"type":29,"tag":8542,"props":19520,"children":19522},{"id":19521},"pourquoi-cest-important",[19523],{"type":34,"value":19524},"Pourquoi c'est important ?",{"type":29,"tag":30,"props":19526,"children":19527},{},[19528],{"type":34,"value":19529},"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":29,"tag":8542,"props":19531,"children":19533},{"id":19532},"exemple-concret-en-java",[19534],{"type":34,"value":19535},"Exemple concret en Java",{"type":29,"tag":30,"props":19537,"children":19538},{},[19539,19541,19547,19549,19553],{"type":34,"value":19540},"Imaginons un système qui gère des rapports. Nous avons une classe ",{"type":29,"tag":84,"props":19542,"children":19544},{"className":19543},[],[19545],{"type":34,"value":19546},"Report",{"type":34,"value":19548}," 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":29,"tag":447,"props":19550,"children":19551},{},[19552],{"type":34,"value":9930},{"type":34,"value":19554}," le sauvegarder en PDF.",{"type":29,"tag":10576,"props":19556,"children":19558},{"id":19557},"exemple-sans-srp",[19559],{"type":34,"value":19560},"Exemple sans SRP :",{"type":29,"tag":77,"props":19562,"children":19564},{"className":81,"code":19563,"language":80,"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        \u002F\u002F 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        \u002F\u002F Logique d'enregistrement en PDF\n        System.out.println(\"Enregistrement du rapport en PDF sous : \" + filename);\n    }\n}\n",[19565],{"type":29,"tag":84,"props":19566,"children":19567},{"__ignoreMap":8},[19568,19588,19608,19615,19646,19674,19681,19688,19711,19719,19764,19771,19778,19815,19823,19867,19874],{"type":29,"tag":88,"props":19569,"children":19570},{"class":90,"line":91},[19571,19575,19579,19584],{"type":29,"tag":88,"props":19572,"children":19573},{"style":105},[19574],{"type":34,"value":108},{"type":29,"tag":88,"props":19576,"children":19577},{"style":105},[19578],{"type":34,"value":113},{"type":29,"tag":88,"props":19580,"children":19581},{"style":116},[19582],{"type":34,"value":19583}," Report",{"type":29,"tag":88,"props":19585,"children":19586},{"style":122},[19587],{"type":34,"value":125},{"type":29,"tag":88,"props":19589,"children":19590},{"class":90,"line":101},[19591,19595,19599,19604],{"type":29,"tag":88,"props":19592,"children":19593},{"style":105},[19594],{"type":34,"value":143},{"type":29,"tag":88,"props":19596,"children":19597},{"style":151},[19598],{"type":34,"value":281},{"type":29,"tag":88,"props":19600,"children":19601},{"style":157},[19602],{"type":34,"value":19603}," content",{"type":29,"tag":88,"props":19605,"children":19606},{"style":122},[19607],{"type":34,"value":424},{"type":29,"tag":88,"props":19609,"children":19610},{"class":90,"line":128},[19611],{"type":29,"tag":88,"props":19612,"children":19613},{"emptyLinePlaceholder":13},[19614],{"type":34,"value":134},{"type":29,"tag":88,"props":19616,"children":19617},{"class":90,"line":137},[19618,19622,19626,19630,19634,19638,19642],{"type":29,"tag":88,"props":19619,"children":19620},{"style":105},[19621],{"type":34,"value":276},{"type":29,"tag":88,"props":19623,"children":19624},{"style":174},[19625],{"type":34,"value":19583},{"type":29,"tag":88,"props":19627,"children":19628},{"style":122},[19629],{"type":34,"value":181},{"type":29,"tag":88,"props":19631,"children":19632},{"style":151},[19633],{"type":34,"value":695},{"type":29,"tag":88,"props":19635,"children":19636},{"style":298},[19637],{"type":34,"value":19603},{"type":29,"tag":88,"props":19639,"children":19640},{"style":122},[19641],{"type":34,"value":306},{"type":29,"tag":88,"props":19643,"children":19644},{"style":122},[19645],{"type":34,"value":125},{"type":29,"tag":88,"props":19647,"children":19648},{"class":90,"line":211},[19649,19653,19657,19662,19666,19670],{"type":29,"tag":88,"props":19650,"children":19651},{"style":873},[19652],{"type":34,"value":876},{"type":29,"tag":88,"props":19654,"children":19655},{"style":122},[19656],{"type":34,"value":338},{"type":29,"tag":88,"props":19658,"children":19659},{"style":157},[19660],{"type":34,"value":19661},"content ",{"type":29,"tag":88,"props":19663,"children":19664},{"style":163},[19665],{"type":34,"value":166},{"type":29,"tag":88,"props":19667,"children":19668},{"style":157},[19669],{"type":34,"value":19603},{"type":29,"tag":88,"props":19671,"children":19672},{"style":122},[19673],{"type":34,"value":424},{"type":29,"tag":88,"props":19675,"children":19676},{"class":90,"line":262},[19677],{"type":29,"tag":88,"props":19678,"children":19679},{"style":122},[19680],{"type":34,"value":433},{"type":29,"tag":88,"props":19682,"children":19683},{"class":90,"line":270},[19684],{"type":29,"tag":88,"props":19685,"children":19686},{"emptyLinePlaceholder":13},[19687],{"type":34,"value":134},{"type":29,"tag":88,"props":19689,"children":19690},{"class":90,"line":313},[19691,19695,19699,19703,19707],{"type":29,"tag":88,"props":19692,"children":19693},{"style":105},[19694],{"type":34,"value":276},{"type":29,"tag":88,"props":19696,"children":19697},{"style":105},[19698],{"type":34,"value":1303},{"type":29,"tag":88,"props":19700,"children":19701},{"style":174},[19702],{"type":34,"value":10808},{"type":29,"tag":88,"props":19704,"children":19705},{"style":122},[19706],{"type":34,"value":1470},{"type":29,"tag":88,"props":19708,"children":19709},{"style":122},[19710],{"type":34,"value":125},{"type":29,"tag":88,"props":19712,"children":19713},{"class":90,"line":360},[19714],{"type":29,"tag":88,"props":19715,"children":19716},{"style":95},[19717],{"type":34,"value":19718},"        \u002F\u002F Logique de génération de rapport\n",{"type":29,"tag":88,"props":19720,"children":19721},{"class":90,"line":409},[19722,19727,19731,19735,19739,19743,19747,19752,19756,19760],{"type":29,"tag":88,"props":19723,"children":19724},{"style":157},[19725],{"type":34,"value":19726},"        System",{"type":29,"tag":88,"props":19728,"children":19729},{"style":122},[19730],{"type":34,"value":338},{"type":29,"tag":88,"props":19732,"children":19733},{"style":157},[19734],{"type":34,"value":18091},{"type":29,"tag":88,"props":19736,"children":19737},{"style":122},[19738],{"type":34,"value":338},{"type":29,"tag":88,"props":19740,"children":19741},{"style":174},[19742],{"type":34,"value":18100},{"type":29,"tag":88,"props":19744,"children":19745},{"style":122},[19746],{"type":34,"value":181},{"type":29,"tag":88,"props":19748,"children":19749},{"style":184},[19750],{"type":34,"value":19751},"\"Génération du rapport : \"",{"type":29,"tag":88,"props":19753,"children":19754},{"style":163},[19755],{"type":34,"value":5485},{"type":29,"tag":88,"props":19757,"children":19758},{"style":157},[19759],{"type":34,"value":19603},{"type":29,"tag":88,"props":19761,"children":19762},{"style":122},[19763],{"type":34,"value":357},{"type":29,"tag":88,"props":19765,"children":19766},{"class":90,"line":427},[19767],{"type":29,"tag":88,"props":19768,"children":19769},{"style":122},[19770],{"type":34,"value":433},{"type":29,"tag":88,"props":19772,"children":19773},{"class":90,"line":436},[19774],{"type":29,"tag":88,"props":19775,"children":19776},{"emptyLinePlaceholder":13},[19777],{"type":34,"value":134},{"type":29,"tag":88,"props":19779,"children":19780},{"class":90,"line":767},[19781,19785,19789,19794,19798,19802,19807,19811],{"type":29,"tag":88,"props":19782,"children":19783},{"style":105},[19784],{"type":34,"value":276},{"type":29,"tag":88,"props":19786,"children":19787},{"style":105},[19788],{"type":34,"value":1303},{"type":29,"tag":88,"props":19790,"children":19791},{"style":174},[19792],{"type":34,"value":19793}," saveToPDF",{"type":29,"tag":88,"props":19795,"children":19796},{"style":122},[19797],{"type":34,"value":181},{"type":29,"tag":88,"props":19799,"children":19800},{"style":151},[19801],{"type":34,"value":695},{"type":29,"tag":88,"props":19803,"children":19804},{"style":298},[19805],{"type":34,"value":19806}," filename",{"type":29,"tag":88,"props":19808,"children":19809},{"style":122},[19810],{"type":34,"value":306},{"type":29,"tag":88,"props":19812,"children":19813},{"style":122},[19814],{"type":34,"value":125},{"type":29,"tag":88,"props":19816,"children":19817},{"class":90,"line":792},[19818],{"type":29,"tag":88,"props":19819,"children":19820},{"style":95},[19821],{"type":34,"value":19822},"        \u002F\u002F Logique d'enregistrement en PDF\n",{"type":29,"tag":88,"props":19824,"children":19825},{"class":90,"line":817},[19826,19830,19834,19838,19842,19846,19850,19855,19859,19863],{"type":29,"tag":88,"props":19827,"children":19828},{"style":157},[19829],{"type":34,"value":19726},{"type":29,"tag":88,"props":19831,"children":19832},{"style":122},[19833],{"type":34,"value":338},{"type":29,"tag":88,"props":19835,"children":19836},{"style":157},[19837],{"type":34,"value":18091},{"type":29,"tag":88,"props":19839,"children":19840},{"style":122},[19841],{"type":34,"value":338},{"type":29,"tag":88,"props":19843,"children":19844},{"style":174},[19845],{"type":34,"value":18100},{"type":29,"tag":88,"props":19847,"children":19848},{"style":122},[19849],{"type":34,"value":181},{"type":29,"tag":88,"props":19851,"children":19852},{"style":184},[19853],{"type":34,"value":19854},"\"Enregistrement du rapport en PDF sous : \"",{"type":29,"tag":88,"props":19856,"children":19857},{"style":163},[19858],{"type":34,"value":5485},{"type":29,"tag":88,"props":19860,"children":19861},{"style":157},[19862],{"type":34,"value":19806},{"type":29,"tag":88,"props":19864,"children":19865},{"style":122},[19866],{"type":34,"value":357},{"type":29,"tag":88,"props":19868,"children":19869},{"class":90,"line":825},[19870],{"type":29,"tag":88,"props":19871,"children":19872},{"style":122},[19873],{"type":34,"value":433},{"type":29,"tag":88,"props":19875,"children":19876},{"class":90,"line":869},[19877],{"type":29,"tag":88,"props":19878,"children":19879},{"style":122},[19880],{"type":34,"value":442},{"type":29,"tag":30,"props":19882,"children":19883},{},[19884,19885,19890],{"type":34,"value":11007},{"type":29,"tag":84,"props":19886,"children":19888},{"className":19887},[],[19889],{"type":34,"value":19546},{"type":34,"value":19891}," 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":29,"tag":10576,"props":19893,"children":19895},{"id":19894},"exemple-avec-srp-appliqué",[19896],{"type":34,"value":19897},"Exemple avec SRP appliqué :",{"type":29,"tag":30,"props":19899,"children":19900},{},[19901],{"type":34,"value":19902},"Pour corriger cela, on peut diviser les responsabilités en deux classes distinctes.",{"type":29,"tag":77,"props":19904,"children":19906},{"className":81,"code":19905,"language":80,"meta":8,"style":8},"\u002F\u002F 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\u002F\u002F 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",[19907],{"type":29,"tag":84,"props":19908,"children":19909},{"__ignoreMap":8},[19910,19918,19937,19956,19963,19994,20021,20028,20035,20058,20101,20108,20115,20122,20130,20150,20198,20241,20248],{"type":29,"tag":88,"props":19911,"children":19912},{"class":90,"line":91},[19913],{"type":29,"tag":88,"props":19914,"children":19915},{"style":95},[19916],{"type":34,"value":19917},"\u002F\u002F Classe qui se charge uniquement de la génération du rapport\n",{"type":29,"tag":88,"props":19919,"children":19920},{"class":90,"line":101},[19921,19925,19929,19933],{"type":29,"tag":88,"props":19922,"children":19923},{"style":105},[19924],{"type":34,"value":108},{"type":29,"tag":88,"props":19926,"children":19927},{"style":105},[19928],{"type":34,"value":113},{"type":29,"tag":88,"props":19930,"children":19931},{"style":116},[19932],{"type":34,"value":19583},{"type":29,"tag":88,"props":19934,"children":19935},{"style":122},[19936],{"type":34,"value":125},{"type":29,"tag":88,"props":19938,"children":19939},{"class":90,"line":128},[19940,19944,19948,19952],{"type":29,"tag":88,"props":19941,"children":19942},{"style":105},[19943],{"type":34,"value":143},{"type":29,"tag":88,"props":19945,"children":19946},{"style":151},[19947],{"type":34,"value":281},{"type":29,"tag":88,"props":19949,"children":19950},{"style":157},[19951],{"type":34,"value":19603},{"type":29,"tag":88,"props":19953,"children":19954},{"style":122},[19955],{"type":34,"value":424},{"type":29,"tag":88,"props":19957,"children":19958},{"class":90,"line":137},[19959],{"type":29,"tag":88,"props":19960,"children":19961},{"emptyLinePlaceholder":13},[19962],{"type":34,"value":134},{"type":29,"tag":88,"props":19964,"children":19965},{"class":90,"line":211},[19966,19970,19974,19978,19982,19986,19990],{"type":29,"tag":88,"props":19967,"children":19968},{"style":105},[19969],{"type":34,"value":276},{"type":29,"tag":88,"props":19971,"children":19972},{"style":174},[19973],{"type":34,"value":19583},{"type":29,"tag":88,"props":19975,"children":19976},{"style":122},[19977],{"type":34,"value":181},{"type":29,"tag":88,"props":19979,"children":19980},{"style":151},[19981],{"type":34,"value":695},{"type":29,"tag":88,"props":19983,"children":19984},{"style":298},[19985],{"type":34,"value":19603},{"type":29,"tag":88,"props":19987,"children":19988},{"style":122},[19989],{"type":34,"value":306},{"type":29,"tag":88,"props":19991,"children":19992},{"style":122},[19993],{"type":34,"value":125},{"type":29,"tag":88,"props":19995,"children":19996},{"class":90,"line":262},[19997,20001,20005,20009,20013,20017],{"type":29,"tag":88,"props":19998,"children":19999},{"style":873},[20000],{"type":34,"value":876},{"type":29,"tag":88,"props":20002,"children":20003},{"style":122},[20004],{"type":34,"value":338},{"type":29,"tag":88,"props":20006,"children":20007},{"style":157},[20008],{"type":34,"value":19661},{"type":29,"tag":88,"props":20010,"children":20011},{"style":163},[20012],{"type":34,"value":166},{"type":29,"tag":88,"props":20014,"children":20015},{"style":157},[20016],{"type":34,"value":19603},{"type":29,"tag":88,"props":20018,"children":20019},{"style":122},[20020],{"type":34,"value":424},{"type":29,"tag":88,"props":20022,"children":20023},{"class":90,"line":270},[20024],{"type":29,"tag":88,"props":20025,"children":20026},{"style":122},[20027],{"type":34,"value":433},{"type":29,"tag":88,"props":20029,"children":20030},{"class":90,"line":313},[20031],{"type":29,"tag":88,"props":20032,"children":20033},{"emptyLinePlaceholder":13},[20034],{"type":34,"value":134},{"type":29,"tag":88,"props":20036,"children":20037},{"class":90,"line":360},[20038,20042,20046,20050,20054],{"type":29,"tag":88,"props":20039,"children":20040},{"style":105},[20041],{"type":34,"value":276},{"type":29,"tag":88,"props":20043,"children":20044},{"style":105},[20045],{"type":34,"value":1303},{"type":29,"tag":88,"props":20047,"children":20048},{"style":174},[20049],{"type":34,"value":10808},{"type":29,"tag":88,"props":20051,"children":20052},{"style":122},[20053],{"type":34,"value":1470},{"type":29,"tag":88,"props":20055,"children":20056},{"style":122},[20057],{"type":34,"value":125},{"type":29,"tag":88,"props":20059,"children":20060},{"class":90,"line":409},[20061,20065,20069,20073,20077,20081,20085,20089,20093,20097],{"type":29,"tag":88,"props":20062,"children":20063},{"style":157},[20064],{"type":34,"value":19726},{"type":29,"tag":88,"props":20066,"children":20067},{"style":122},[20068],{"type":34,"value":338},{"type":29,"tag":88,"props":20070,"children":20071},{"style":157},[20072],{"type":34,"value":18091},{"type":29,"tag":88,"props":20074,"children":20075},{"style":122},[20076],{"type":34,"value":338},{"type":29,"tag":88,"props":20078,"children":20079},{"style":174},[20080],{"type":34,"value":18100},{"type":29,"tag":88,"props":20082,"children":20083},{"style":122},[20084],{"type":34,"value":181},{"type":29,"tag":88,"props":20086,"children":20087},{"style":184},[20088],{"type":34,"value":19751},{"type":29,"tag":88,"props":20090,"children":20091},{"style":163},[20092],{"type":34,"value":5485},{"type":29,"tag":88,"props":20094,"children":20095},{"style":157},[20096],{"type":34,"value":19603},{"type":29,"tag":88,"props":20098,"children":20099},{"style":122},[20100],{"type":34,"value":357},{"type":29,"tag":88,"props":20102,"children":20103},{"class":90,"line":427},[20104],{"type":29,"tag":88,"props":20105,"children":20106},{"style":122},[20107],{"type":34,"value":433},{"type":29,"tag":88,"props":20109,"children":20110},{"class":90,"line":436},[20111],{"type":29,"tag":88,"props":20112,"children":20113},{"style":122},[20114],{"type":34,"value":442},{"type":29,"tag":88,"props":20116,"children":20117},{"class":90,"line":767},[20118],{"type":29,"tag":88,"props":20119,"children":20120},{"emptyLinePlaceholder":13},[20121],{"type":34,"value":134},{"type":29,"tag":88,"props":20123,"children":20124},{"class":90,"line":792},[20125],{"type":29,"tag":88,"props":20126,"children":20127},{"style":95},[20128],{"type":34,"value":20129},"\u002F\u002F Classe qui se charge uniquement de l'enregistrement du rapport\n",{"type":29,"tag":88,"props":20131,"children":20132},{"class":90,"line":817},[20133,20137,20141,20146],{"type":29,"tag":88,"props":20134,"children":20135},{"style":105},[20136],{"type":34,"value":108},{"type":29,"tag":88,"props":20138,"children":20139},{"style":105},[20140],{"type":34,"value":113},{"type":29,"tag":88,"props":20142,"children":20143},{"style":116},[20144],{"type":34,"value":20145}," ReportSaver",{"type":29,"tag":88,"props":20147,"children":20148},{"style":122},[20149],{"type":34,"value":125},{"type":29,"tag":88,"props":20151,"children":20152},{"class":90,"line":825},[20153,20157,20161,20165,20169,20173,20178,20182,20186,20190,20194],{"type":29,"tag":88,"props":20154,"children":20155},{"style":105},[20156],{"type":34,"value":276},{"type":29,"tag":88,"props":20158,"children":20159},{"style":105},[20160],{"type":34,"value":1303},{"type":29,"tag":88,"props":20162,"children":20163},{"style":174},[20164],{"type":34,"value":19793},{"type":29,"tag":88,"props":20166,"children":20167},{"style":122},[20168],{"type":34,"value":181},{"type":29,"tag":88,"props":20170,"children":20171},{"style":151},[20172],{"type":34,"value":19546},{"type":29,"tag":88,"props":20174,"children":20175},{"style":298},[20176],{"type":34,"value":20177}," report",{"type":29,"tag":88,"props":20179,"children":20180},{"style":122},[20181],{"type":34,"value":192},{"type":29,"tag":88,"props":20183,"children":20184},{"style":151},[20185],{"type":34,"value":281},{"type":29,"tag":88,"props":20187,"children":20188},{"style":298},[20189],{"type":34,"value":19806},{"type":29,"tag":88,"props":20191,"children":20192},{"style":122},[20193],{"type":34,"value":306},{"type":29,"tag":88,"props":20195,"children":20196},{"style":122},[20197],{"type":34,"value":125},{"type":29,"tag":88,"props":20199,"children":20200},{"class":90,"line":869},[20201,20205,20209,20213,20217,20221,20225,20229,20233,20237],{"type":29,"tag":88,"props":20202,"children":20203},{"style":157},[20204],{"type":34,"value":19726},{"type":29,"tag":88,"props":20206,"children":20207},{"style":122},[20208],{"type":34,"value":338},{"type":29,"tag":88,"props":20210,"children":20211},{"style":157},[20212],{"type":34,"value":18091},{"type":29,"tag":88,"props":20214,"children":20215},{"style":122},[20216],{"type":34,"value":338},{"type":29,"tag":88,"props":20218,"children":20219},{"style":174},[20220],{"type":34,"value":18100},{"type":29,"tag":88,"props":20222,"children":20223},{"style":122},[20224],{"type":34,"value":181},{"type":29,"tag":88,"props":20226,"children":20227},{"style":184},[20228],{"type":34,"value":19854},{"type":29,"tag":88,"props":20230,"children":20231},{"style":163},[20232],{"type":34,"value":5485},{"type":29,"tag":88,"props":20234,"children":20235},{"style":157},[20236],{"type":34,"value":19806},{"type":29,"tag":88,"props":20238,"children":20239},{"style":122},[20240],{"type":34,"value":357},{"type":29,"tag":88,"props":20242,"children":20243},{"class":90,"line":900},[20244],{"type":29,"tag":88,"props":20245,"children":20246},{"style":122},[20247],{"type":34,"value":433},{"type":29,"tag":88,"props":20249,"children":20250},{"class":90,"line":929},[20251],{"type":29,"tag":88,"props":20252,"children":20253},{"style":122},[20254],{"type":34,"value":442},{"type":29,"tag":47,"props":20256,"children":20257},{},[],{"type":29,"tag":8526,"props":20259,"children":20260},{"type":8528},[20261],{"type":29,"tag":30,"props":20262,"children":20263},{},[20264,20269],{"type":29,"tag":447,"props":20265,"children":20266},{},[20267],{"type":34,"value":20268},"Gardez vos classes petites",{"type":34,"value":20270},". 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":29,"tag":2288,"props":20272,"children":20274},{"cta":2290,"href":2291,"title":20273,"type":2293},"Vous voulez savoir, en regardant une classe, où SOLID doit s'appliquer et où il ne sert à rien ?",[20275],{"type":29,"tag":30,"props":20276,"children":20277},{},[20278],{"type":34,"value":20279},"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":29,"tag":51,"props":20281,"children":20283},{"id":20282},"_2-principe-ouvertfermé-openclosed-principle-ocp",[20284],{"type":34,"value":20285},"2. Principe Ouvert\u002FFermé (Open\u002FClosed Principle - OCP)",{"type":29,"tag":30,"props":20287,"children":20288},{},[20289,20291,20296,20298,20303],{"type":34,"value":20290},"Le principe Ouvert\u002FFermé stipule qu’une entité (classe, module, fonction, etc.) doit être ",{"type":29,"tag":447,"props":20292,"children":20293},{},[20294],{"type":34,"value":20295},"ouverte à l’extension",{"type":34,"value":20297}," mais ",{"type":29,"tag":447,"props":20299,"children":20300},{},[20301],{"type":34,"value":20302},"fermée à la modification",{"type":34,"value":20304},". 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":29,"tag":8542,"props":20306,"children":20308},{"id":20307},"pourquoi-cest-important-1",[20309],{"type":34,"value":19524},{"type":29,"tag":30,"props":20311,"children":20312},{},[20313],{"type":34,"value":20314},"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":29,"tag":8542,"props":20316,"children":20318},{"id":20317},"exemple-concret-en-java-1",[20319],{"type":34,"value":19535},{"type":29,"tag":30,"props":20321,"children":20322},{},[20323],{"type":34,"value":20324},"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":29,"tag":10576,"props":20326,"children":20328},{"id":20327},"exemple-sans-ocp",[20329],{"type":34,"value":20330},"Exemple sans OCP :",{"type":29,"tag":30,"props":20332,"children":20333},{},[20334,20336,20342],{"type":34,"value":20335},"Voici une implémentation où la classe ",{"type":29,"tag":84,"props":20337,"children":20339},{"className":20338},[],[20340],{"type":34,"value":20341},"PaymentProcessor",{"type":34,"value":20343}," gère directement les différentes méthodes de paiement :",{"type":29,"tag":77,"props":20345,"children":20347},{"className":81,"code":20346,"language":80,"meta":8,"style":8},"public class PaymentProcessor {\n    public void processPayment(String type) {\n        if (type.equals(\"creditCard\")) {\n            \u002F\u002F Traitement paiement par carte bancaire\n            System.out.println(\"Paiement par carte bancaire\");\n        } else if (type.equals(\"paypal\")) {\n            \u002F\u002F Traitement paiement PayPal\n            System.out.println(\"Paiement via PayPal\");\n        }\n    }\n}\n",[20348],{"type":29,"tag":84,"props":20349,"children":20350},{"__ignoreMap":8},[20351,20371,20407,20449,20457,20493,20542,20550,20586,20593,20600],{"type":29,"tag":88,"props":20352,"children":20353},{"class":90,"line":91},[20354,20358,20362,20367],{"type":29,"tag":88,"props":20355,"children":20356},{"style":105},[20357],{"type":34,"value":108},{"type":29,"tag":88,"props":20359,"children":20360},{"style":105},[20361],{"type":34,"value":113},{"type":29,"tag":88,"props":20363,"children":20364},{"style":116},[20365],{"type":34,"value":20366}," PaymentProcessor",{"type":29,"tag":88,"props":20368,"children":20369},{"style":122},[20370],{"type":34,"value":125},{"type":29,"tag":88,"props":20372,"children":20373},{"class":90,"line":101},[20374,20378,20382,20386,20390,20394,20399,20403],{"type":29,"tag":88,"props":20375,"children":20376},{"style":105},[20377],{"type":34,"value":276},{"type":29,"tag":88,"props":20379,"children":20380},{"style":105},[20381],{"type":34,"value":1303},{"type":29,"tag":88,"props":20383,"children":20384},{"style":174},[20385],{"type":34,"value":12508},{"type":29,"tag":88,"props":20387,"children":20388},{"style":122},[20389],{"type":34,"value":181},{"type":29,"tag":88,"props":20391,"children":20392},{"style":151},[20393],{"type":34,"value":695},{"type":29,"tag":88,"props":20395,"children":20396},{"style":298},[20397],{"type":34,"value":20398}," type",{"type":29,"tag":88,"props":20400,"children":20401},{"style":122},[20402],{"type":34,"value":306},{"type":29,"tag":88,"props":20404,"children":20405},{"style":122},[20406],{"type":34,"value":125},{"type":29,"tag":88,"props":20408,"children":20409},{"class":90,"line":128},[20410,20414,20418,20423,20427,20432,20436,20441,20445],{"type":29,"tag":88,"props":20411,"children":20412},{"style":105},[20413],{"type":34,"value":2886},{"type":29,"tag":88,"props":20415,"children":20416},{"style":122},[20417],{"type":34,"value":2891},{"type":29,"tag":88,"props":20419,"children":20420},{"style":157},[20421],{"type":34,"value":20422},"type",{"type":29,"tag":88,"props":20424,"children":20425},{"style":122},[20426],{"type":34,"value":338},{"type":29,"tag":88,"props":20428,"children":20429},{"style":174},[20430],{"type":34,"value":20431},"equals",{"type":29,"tag":88,"props":20433,"children":20434},{"style":122},[20435],{"type":34,"value":181},{"type":29,"tag":88,"props":20437,"children":20438},{"style":184},[20439],{"type":34,"value":20440},"\"creditCard\"",{"type":29,"tag":88,"props":20442,"children":20443},{"style":122},[20444],{"type":34,"value":16195},{"type":29,"tag":88,"props":20446,"children":20447},{"style":122},[20448],{"type":34,"value":125},{"type":29,"tag":88,"props":20450,"children":20451},{"class":90,"line":137},[20452],{"type":29,"tag":88,"props":20453,"children":20454},{"style":95},[20455],{"type":34,"value":20456},"            \u002F\u002F Traitement paiement par carte bancaire\n",{"type":29,"tag":88,"props":20458,"children":20459},{"class":90,"line":211},[20460,20464,20468,20472,20476,20480,20484,20489],{"type":29,"tag":88,"props":20461,"children":20462},{"style":157},[20463],{"type":34,"value":18082},{"type":29,"tag":88,"props":20465,"children":20466},{"style":122},[20467],{"type":34,"value":338},{"type":29,"tag":88,"props":20469,"children":20470},{"style":157},[20471],{"type":34,"value":18091},{"type":29,"tag":88,"props":20473,"children":20474},{"style":122},[20475],{"type":34,"value":338},{"type":29,"tag":88,"props":20477,"children":20478},{"style":174},[20479],{"type":34,"value":18100},{"type":29,"tag":88,"props":20481,"children":20482},{"style":122},[20483],{"type":34,"value":181},{"type":29,"tag":88,"props":20485,"children":20486},{"style":184},[20487],{"type":34,"value":20488},"\"Paiement par carte bancaire\"",{"type":29,"tag":88,"props":20490,"children":20491},{"style":122},[20492],{"type":34,"value":357},{"type":29,"tag":88,"props":20494,"children":20495},{"class":90,"line":262},[20496,20500,20504,20509,20513,20517,20521,20525,20529,20534,20538],{"type":29,"tag":88,"props":20497,"children":20498},{"style":122},[20499],{"type":34,"value":8169},{"type":29,"tag":88,"props":20501,"children":20502},{"style":105},[20503],{"type":34,"value":16544},{"type":29,"tag":88,"props":20505,"children":20506},{"style":105},[20507],{"type":34,"value":20508}," if",{"type":29,"tag":88,"props":20510,"children":20511},{"style":122},[20512],{"type":34,"value":2891},{"type":29,"tag":88,"props":20514,"children":20515},{"style":157},[20516],{"type":34,"value":20422},{"type":29,"tag":88,"props":20518,"children":20519},{"style":122},[20520],{"type":34,"value":338},{"type":29,"tag":88,"props":20522,"children":20523},{"style":174},[20524],{"type":34,"value":20431},{"type":29,"tag":88,"props":20526,"children":20527},{"style":122},[20528],{"type":34,"value":181},{"type":29,"tag":88,"props":20530,"children":20531},{"style":184},[20532],{"type":34,"value":20533},"\"paypal\"",{"type":29,"tag":88,"props":20535,"children":20536},{"style":122},[20537],{"type":34,"value":16195},{"type":29,"tag":88,"props":20539,"children":20540},{"style":122},[20541],{"type":34,"value":125},{"type":29,"tag":88,"props":20543,"children":20544},{"class":90,"line":270},[20545],{"type":29,"tag":88,"props":20546,"children":20547},{"style":95},[20548],{"type":34,"value":20549},"            \u002F\u002F Traitement paiement PayPal\n",{"type":29,"tag":88,"props":20551,"children":20552},{"class":90,"line":313},[20553,20557,20561,20565,20569,20573,20577,20582],{"type":29,"tag":88,"props":20554,"children":20555},{"style":157},[20556],{"type":34,"value":18082},{"type":29,"tag":88,"props":20558,"children":20559},{"style":122},[20560],{"type":34,"value":338},{"type":29,"tag":88,"props":20562,"children":20563},{"style":157},[20564],{"type":34,"value":18091},{"type":29,"tag":88,"props":20566,"children":20567},{"style":122},[20568],{"type":34,"value":338},{"type":29,"tag":88,"props":20570,"children":20571},{"style":174},[20572],{"type":34,"value":18100},{"type":29,"tag":88,"props":20574,"children":20575},{"style":122},[20576],{"type":34,"value":181},{"type":29,"tag":88,"props":20578,"children":20579},{"style":184},[20580],{"type":34,"value":20581},"\"Paiement via PayPal\"",{"type":29,"tag":88,"props":20583,"children":20584},{"style":122},[20585],{"type":34,"value":357},{"type":29,"tag":88,"props":20587,"children":20588},{"class":90,"line":360},[20589],{"type":29,"tag":88,"props":20590,"children":20591},{"style":122},[20592],{"type":34,"value":2966},{"type":29,"tag":88,"props":20594,"children":20595},{"class":90,"line":409},[20596],{"type":29,"tag":88,"props":20597,"children":20598},{"style":122},[20599],{"type":34,"value":433},{"type":29,"tag":88,"props":20601,"children":20602},{"class":90,"line":427},[20603],{"type":29,"tag":88,"props":20604,"children":20605},{"style":122},[20606],{"type":34,"value":442},{"type":29,"tag":30,"props":20608,"children":20609},{},[20610,20612,20617,20618,20623,20625,20631],{"type":34,"value":20611},"Dans ce cas, si l'on veut ajouter un nouveau moyen de paiement, comme un portefeuille électronique, il faudrait ",{"type":29,"tag":447,"props":20613,"children":20614},{},[20615],{"type":34,"value":20616},"modifier la classe",{"type":34,"value":5536},{"type":29,"tag":84,"props":20619,"children":20621},{"className":20620},[],[20622],{"type":34,"value":20341},{"type":34,"value":20624}," en ajoutant une nouvelle condition ",{"type":29,"tag":84,"props":20626,"children":20628},{"className":20627},[],[20629],{"type":34,"value":20630},"else if",{"type":34,"value":20632},". Cela enfreint le principe OCP, car on doit toucher au code existant pour ajouter une nouvelle fonctionnalité.",{"type":29,"tag":10576,"props":20634,"children":20636},{"id":20635},"exemple-avec-ocp-appliqué",[20637],{"type":34,"value":20638},"Exemple avec OCP appliqué :",{"type":29,"tag":30,"props":20640,"children":20641},{},[20642],{"type":34,"value":20643},"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":29,"tag":77,"props":20645,"children":20647},{"className":81,"code":20646,"language":80,"meta":8,"style":8},"\u002F\u002F Interface de stratégie de paiement\npublic interface PaymentMethod {\n    void processPayment();\n}\n\n\u002F\u002F 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\u002F\u002F 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\u002F\u002F Classe de traitement des paiements qui respecte OCP\npublic class PaymentProcessor {\n    public void processPayment(PaymentMethod paymentMethod) {\n        paymentMethod.processPayment();\n    }\n}\n",[20648],{"type":29,"tag":84,"props":20649,"children":20650},{"__ignoreMap":8},[20651,20659,20678,20693,20700,20707,20715,20742,20753,20776,20811,20818,20825,20832,20840,20867,20878,20901,20936,20943,20950,20957,20965,20984,21019,21038,21045],{"type":29,"tag":88,"props":20652,"children":20653},{"class":90,"line":91},[20654],{"type":29,"tag":88,"props":20655,"children":20656},{"style":95},[20657],{"type":34,"value":20658},"\u002F\u002F Interface de stratégie de paiement\n",{"type":29,"tag":88,"props":20660,"children":20661},{"class":90,"line":101},[20662,20666,20670,20674],{"type":29,"tag":88,"props":20663,"children":20664},{"style":105},[20665],{"type":34,"value":108},{"type":29,"tag":88,"props":20667,"children":20668},{"style":105},[20669],{"type":34,"value":601},{"type":29,"tag":88,"props":20671,"children":20672},{"style":116},[20673],{"type":34,"value":11604},{"type":29,"tag":88,"props":20675,"children":20676},{"style":122},[20677],{"type":34,"value":125},{"type":29,"tag":88,"props":20679,"children":20680},{"class":90,"line":128},[20681,20685,20689],{"type":29,"tag":88,"props":20682,"children":20683},{"style":105},[20684],{"type":34,"value":681},{"type":29,"tag":88,"props":20686,"children":20687},{"style":174},[20688],{"type":34,"value":12508},{"type":29,"tag":88,"props":20690,"children":20691},{"style":122},[20692],{"type":34,"value":1810},{"type":29,"tag":88,"props":20694,"children":20695},{"class":90,"line":137},[20696],{"type":29,"tag":88,"props":20697,"children":20698},{"style":122},[20699],{"type":34,"value":442},{"type":29,"tag":88,"props":20701,"children":20702},{"class":90,"line":211},[20703],{"type":29,"tag":88,"props":20704,"children":20705},{"emptyLinePlaceholder":13},[20706],{"type":34,"value":134},{"type":29,"tag":88,"props":20708,"children":20709},{"class":90,"line":262},[20710],{"type":29,"tag":88,"props":20711,"children":20712},{"style":95},[20713],{"type":34,"value":20714},"\u002F\u002F Implémentation pour la carte bancaire\n",{"type":29,"tag":88,"props":20716,"children":20717},{"class":90,"line":270},[20718,20722,20726,20730,20734,20738],{"type":29,"tag":88,"props":20719,"children":20720},{"style":105},[20721],{"type":34,"value":108},{"type":29,"tag":88,"props":20723,"children":20724},{"style":105},[20725],{"type":34,"value":113},{"type":29,"tag":88,"props":20727,"children":20728},{"style":116},[20729],{"type":34,"value":11667},{"type":29,"tag":88,"props":20731,"children":20732},{"style":105},[20733],{"type":34,"value":1134},{"type":29,"tag":88,"props":20735,"children":20736},{"style":116},[20737],{"type":34,"value":11604},{"type":29,"tag":88,"props":20739,"children":20740},{"style":122},[20741],{"type":34,"value":125},{"type":29,"tag":88,"props":20743,"children":20744},{"class":90,"line":313},[20745,20749],{"type":29,"tag":88,"props":20746,"children":20747},{"style":1974},[20748],{"type":34,"value":3302},{"type":29,"tag":88,"props":20750,"children":20751},{"style":1980},[20752],{"type":34,"value":3307},{"type":29,"tag":88,"props":20754,"children":20755},{"class":90,"line":360},[20756,20760,20764,20768,20772],{"type":29,"tag":88,"props":20757,"children":20758},{"style":105},[20759],{"type":34,"value":276},{"type":29,"tag":88,"props":20761,"children":20762},{"style":105},[20763],{"type":34,"value":1303},{"type":29,"tag":88,"props":20765,"children":20766},{"style":174},[20767],{"type":34,"value":12508},{"type":29,"tag":88,"props":20769,"children":20770},{"style":122},[20771],{"type":34,"value":1470},{"type":29,"tag":88,"props":20773,"children":20774},{"style":122},[20775],{"type":34,"value":125},{"type":29,"tag":88,"props":20777,"children":20778},{"class":90,"line":409},[20779,20783,20787,20791,20795,20799,20803,20807],{"type":29,"tag":88,"props":20780,"children":20781},{"style":157},[20782],{"type":34,"value":19726},{"type":29,"tag":88,"props":20784,"children":20785},{"style":122},[20786],{"type":34,"value":338},{"type":29,"tag":88,"props":20788,"children":20789},{"style":157},[20790],{"type":34,"value":18091},{"type":29,"tag":88,"props":20792,"children":20793},{"style":122},[20794],{"type":34,"value":338},{"type":29,"tag":88,"props":20796,"children":20797},{"style":174},[20798],{"type":34,"value":18100},{"type":29,"tag":88,"props":20800,"children":20801},{"style":122},[20802],{"type":34,"value":181},{"type":29,"tag":88,"props":20804,"children":20805},{"style":184},[20806],{"type":34,"value":20488},{"type":29,"tag":88,"props":20808,"children":20809},{"style":122},[20810],{"type":34,"value":357},{"type":29,"tag":88,"props":20812,"children":20813},{"class":90,"line":427},[20814],{"type":29,"tag":88,"props":20815,"children":20816},{"style":122},[20817],{"type":34,"value":433},{"type":29,"tag":88,"props":20819,"children":20820},{"class":90,"line":436},[20821],{"type":29,"tag":88,"props":20822,"children":20823},{"style":122},[20824],{"type":34,"value":442},{"type":29,"tag":88,"props":20826,"children":20827},{"class":90,"line":767},[20828],{"type":29,"tag":88,"props":20829,"children":20830},{"emptyLinePlaceholder":13},[20831],{"type":34,"value":134},{"type":29,"tag":88,"props":20833,"children":20834},{"class":90,"line":792},[20835],{"type":29,"tag":88,"props":20836,"children":20837},{"style":95},[20838],{"type":34,"value":20839},"\u002F\u002F Implémentation pour PayPal\n",{"type":29,"tag":88,"props":20841,"children":20842},{"class":90,"line":817},[20843,20847,20851,20855,20859,20863],{"type":29,"tag":88,"props":20844,"children":20845},{"style":105},[20846],{"type":34,"value":108},{"type":29,"tag":88,"props":20848,"children":20849},{"style":105},[20850],{"type":34,"value":113},{"type":29,"tag":88,"props":20852,"children":20853},{"style":116},[20854],{"type":34,"value":11759},{"type":29,"tag":88,"props":20856,"children":20857},{"style":105},[20858],{"type":34,"value":1134},{"type":29,"tag":88,"props":20860,"children":20861},{"style":116},[20862],{"type":34,"value":11604},{"type":29,"tag":88,"props":20864,"children":20865},{"style":122},[20866],{"type":34,"value":125},{"type":29,"tag":88,"props":20868,"children":20869},{"class":90,"line":825},[20870,20874],{"type":29,"tag":88,"props":20871,"children":20872},{"style":1974},[20873],{"type":34,"value":3302},{"type":29,"tag":88,"props":20875,"children":20876},{"style":1980},[20877],{"type":34,"value":3307},{"type":29,"tag":88,"props":20879,"children":20880},{"class":90,"line":869},[20881,20885,20889,20893,20897],{"type":29,"tag":88,"props":20882,"children":20883},{"style":105},[20884],{"type":34,"value":276},{"type":29,"tag":88,"props":20886,"children":20887},{"style":105},[20888],{"type":34,"value":1303},{"type":29,"tag":88,"props":20890,"children":20891},{"style":174},[20892],{"type":34,"value":12508},{"type":29,"tag":88,"props":20894,"children":20895},{"style":122},[20896],{"type":34,"value":1470},{"type":29,"tag":88,"props":20898,"children":20899},{"style":122},[20900],{"type":34,"value":125},{"type":29,"tag":88,"props":20902,"children":20903},{"class":90,"line":900},[20904,20908,20912,20916,20920,20924,20928,20932],{"type":29,"tag":88,"props":20905,"children":20906},{"style":157},[20907],{"type":34,"value":19726},{"type":29,"tag":88,"props":20909,"children":20910},{"style":122},[20911],{"type":34,"value":338},{"type":29,"tag":88,"props":20913,"children":20914},{"style":157},[20915],{"type":34,"value":18091},{"type":29,"tag":88,"props":20917,"children":20918},{"style":122},[20919],{"type":34,"value":338},{"type":29,"tag":88,"props":20921,"children":20922},{"style":174},[20923],{"type":34,"value":18100},{"type":29,"tag":88,"props":20925,"children":20926},{"style":122},[20927],{"type":34,"value":181},{"type":29,"tag":88,"props":20929,"children":20930},{"style":184},[20931],{"type":34,"value":20581},{"type":29,"tag":88,"props":20933,"children":20934},{"style":122},[20935],{"type":34,"value":357},{"type":29,"tag":88,"props":20937,"children":20938},{"class":90,"line":929},[20939],{"type":29,"tag":88,"props":20940,"children":20941},{"style":122},[20942],{"type":34,"value":433},{"type":29,"tag":88,"props":20944,"children":20945},{"class":90,"line":937},[20946],{"type":29,"tag":88,"props":20947,"children":20948},{"style":122},[20949],{"type":34,"value":442},{"type":29,"tag":88,"props":20951,"children":20952},{"class":90,"line":945},[20953],{"type":29,"tag":88,"props":20954,"children":20955},{"emptyLinePlaceholder":13},[20956],{"type":34,"value":134},{"type":29,"tag":88,"props":20958,"children":20959},{"class":90,"line":981},[20960],{"type":29,"tag":88,"props":20961,"children":20962},{"style":95},[20963],{"type":34,"value":20964},"\u002F\u002F Classe de traitement des paiements qui respecte OCP\n",{"type":29,"tag":88,"props":20966,"children":20967},{"class":90,"line":1021},[20968,20972,20976,20980],{"type":29,"tag":88,"props":20969,"children":20970},{"style":105},[20971],{"type":34,"value":108},{"type":29,"tag":88,"props":20973,"children":20974},{"style":105},[20975],{"type":34,"value":113},{"type":29,"tag":88,"props":20977,"children":20978},{"style":116},[20979],{"type":34,"value":20366},{"type":29,"tag":88,"props":20981,"children":20982},{"style":122},[20983],{"type":34,"value":125},{"type":29,"tag":88,"props":20985,"children":20986},{"class":90,"line":1066},[20987,20991,20995,20999,21003,21007,21011,21015],{"type":29,"tag":88,"props":20988,"children":20989},{"style":105},[20990],{"type":34,"value":276},{"type":29,"tag":88,"props":20992,"children":20993},{"style":105},[20994],{"type":34,"value":1303},{"type":29,"tag":88,"props":20996,"children":20997},{"style":174},[20998],{"type":34,"value":12508},{"type":29,"tag":88,"props":21000,"children":21001},{"style":122},[21002],{"type":34,"value":181},{"type":29,"tag":88,"props":21004,"children":21005},{"style":151},[21006],{"type":34,"value":11839},{"type":29,"tag":88,"props":21008,"children":21009},{"style":298},[21010],{"type":34,"value":12780},{"type":29,"tag":88,"props":21012,"children":21013},{"style":122},[21014],{"type":34,"value":306},{"type":29,"tag":88,"props":21016,"children":21017},{"style":122},[21018],{"type":34,"value":125},{"type":29,"tag":88,"props":21020,"children":21021},{"class":90,"line":1082},[21022,21026,21030,21034],{"type":29,"tag":88,"props":21023,"children":21024},{"style":157},[21025],{"type":34,"value":12908},{"type":29,"tag":88,"props":21027,"children":21028},{"style":122},[21029],{"type":34,"value":338},{"type":29,"tag":88,"props":21031,"children":21032},{"style":174},[21033],{"type":34,"value":12917},{"type":29,"tag":88,"props":21035,"children":21036},{"style":122},[21037],{"type":34,"value":1810},{"type":29,"tag":88,"props":21039,"children":21040},{"class":90,"line":1090},[21041],{"type":29,"tag":88,"props":21042,"children":21043},{"style":122},[21044],{"type":34,"value":433},{"type":29,"tag":88,"props":21046,"children":21047},{"class":90,"line":1098},[21048],{"type":29,"tag":88,"props":21049,"children":21050},{"style":122},[21051],{"type":34,"value":442},{"type":29,"tag":30,"props":21053,"children":21054},{},[21055,21057,21062],{"type":34,"value":21056},"Pour ajouter une nouvelle méthode de paiement, il suffit simplement de créer une nouvelle classe qui implémente l'interface ",{"type":29,"tag":84,"props":21058,"children":21060},{"className":21059},[],[21061],{"type":34,"value":11839},{"type":34,"value":21063}," :",{"type":29,"tag":77,"props":21065,"children":21067},{"className":81,"code":21066,"language":80,"meta":8,"style":8},"\u002F\u002F 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",[21068],{"type":29,"tag":84,"props":21069,"children":21070},{"__ignoreMap":8},[21071,21079,21107,21118,21141,21177,21184],{"type":29,"tag":88,"props":21072,"children":21073},{"class":90,"line":91},[21074],{"type":29,"tag":88,"props":21075,"children":21076},{"style":95},[21077],{"type":34,"value":21078},"\u002F\u002F Nouvelle implémentation pour portefeuille électronique (e-wallet)\n",{"type":29,"tag":88,"props":21080,"children":21081},{"class":90,"line":101},[21082,21086,21090,21095,21099,21103],{"type":29,"tag":88,"props":21083,"children":21084},{"style":105},[21085],{"type":34,"value":108},{"type":29,"tag":88,"props":21087,"children":21088},{"style":105},[21089],{"type":34,"value":113},{"type":29,"tag":88,"props":21091,"children":21092},{"style":116},[21093],{"type":34,"value":21094}," EWalletPayment",{"type":29,"tag":88,"props":21096,"children":21097},{"style":105},[21098],{"type":34,"value":1134},{"type":29,"tag":88,"props":21100,"children":21101},{"style":116},[21102],{"type":34,"value":11604},{"type":29,"tag":88,"props":21104,"children":21105},{"style":122},[21106],{"type":34,"value":125},{"type":29,"tag":88,"props":21108,"children":21109},{"class":90,"line":128},[21110,21114],{"type":29,"tag":88,"props":21111,"children":21112},{"style":1974},[21113],{"type":34,"value":3302},{"type":29,"tag":88,"props":21115,"children":21116},{"style":1980},[21117],{"type":34,"value":3307},{"type":29,"tag":88,"props":21119,"children":21120},{"class":90,"line":137},[21121,21125,21129,21133,21137],{"type":29,"tag":88,"props":21122,"children":21123},{"style":105},[21124],{"type":34,"value":276},{"type":29,"tag":88,"props":21126,"children":21127},{"style":105},[21128],{"type":34,"value":1303},{"type":29,"tag":88,"props":21130,"children":21131},{"style":174},[21132],{"type":34,"value":12508},{"type":29,"tag":88,"props":21134,"children":21135},{"style":122},[21136],{"type":34,"value":1470},{"type":29,"tag":88,"props":21138,"children":21139},{"style":122},[21140],{"type":34,"value":125},{"type":29,"tag":88,"props":21142,"children":21143},{"class":90,"line":211},[21144,21148,21152,21156,21160,21164,21168,21173],{"type":29,"tag":88,"props":21145,"children":21146},{"style":157},[21147],{"type":34,"value":19726},{"type":29,"tag":88,"props":21149,"children":21150},{"style":122},[21151],{"type":34,"value":338},{"type":29,"tag":88,"props":21153,"children":21154},{"style":157},[21155],{"type":34,"value":18091},{"type":29,"tag":88,"props":21157,"children":21158},{"style":122},[21159],{"type":34,"value":338},{"type":29,"tag":88,"props":21161,"children":21162},{"style":174},[21163],{"type":34,"value":18100},{"type":29,"tag":88,"props":21165,"children":21166},{"style":122},[21167],{"type":34,"value":181},{"type":29,"tag":88,"props":21169,"children":21170},{"style":184},[21171],{"type":34,"value":21172},"\"Paiement via portefeuille électronique\"",{"type":29,"tag":88,"props":21174,"children":21175},{"style":122},[21176],{"type":34,"value":357},{"type":29,"tag":88,"props":21178,"children":21179},{"class":90,"line":262},[21180],{"type":29,"tag":88,"props":21181,"children":21182},{"style":122},[21183],{"type":34,"value":433},{"type":29,"tag":88,"props":21185,"children":21186},{"class":90,"line":270},[21187],{"type":29,"tag":88,"props":21188,"children":21189},{"style":122},[21190],{"type":34,"value":442},{"type":29,"tag":30,"props":21192,"children":21193},{},[21194,21196,21201],{"type":34,"value":21195},"On peut maintenant utiliser cette nouvelle méthode de paiement sans toucher à la classe ",{"type":29,"tag":84,"props":21197,"children":21199},{"className":21198},[],[21200],{"type":34,"value":20341},{"type":34,"value":21063},{"type":29,"tag":77,"props":21203,"children":21205},{"className":81,"code":21204,"language":80,"meta":8,"style":8},"public class Main {\n    public static void main(String[] args) {\n        PaymentProcessor processor = new PaymentProcessor();\n\n        \u002F\u002F Utilisation de la carte bancaire\n        PaymentMethod creditCard = new CreditCardPayment();\n        processor.processPayment(creditCard);\n\n        \u002F\u002F Utilisation de PayPal\n        PaymentMethod paypal = new PayPalPayment();\n        processor.processPayment(paypal);\n\n        \u002F\u002F Utilisation d'un portefeuille électronique\n        PaymentMethod ewallet = new EWalletPayment();\n        processor.processPayment(ewallet);\n    }\n}\n",[21206],{"type":29,"tag":84,"props":21207,"children":21208},{"__ignoreMap":8},[21209,21229,21275,21304,21311,21319,21348,21377,21384,21392,21420,21448,21455,21463,21491,21519,21526],{"type":29,"tag":88,"props":21210,"children":21211},{"class":90,"line":91},[21212,21216,21220,21225],{"type":29,"tag":88,"props":21213,"children":21214},{"style":105},[21215],{"type":34,"value":108},{"type":29,"tag":88,"props":21217,"children":21218},{"style":105},[21219],{"type":34,"value":113},{"type":29,"tag":88,"props":21221,"children":21222},{"style":116},[21223],{"type":34,"value":21224}," Main",{"type":29,"tag":88,"props":21226,"children":21227},{"style":122},[21228],{"type":34,"value":125},{"type":29,"tag":88,"props":21230,"children":21231},{"class":90,"line":101},[21232,21236,21240,21244,21249,21253,21257,21262,21267,21271],{"type":29,"tag":88,"props":21233,"children":21234},{"style":105},[21235],{"type":34,"value":276},{"type":29,"tag":88,"props":21237,"children":21238},{"style":105},[21239],{"type":34,"value":12248},{"type":29,"tag":88,"props":21241,"children":21242},{"style":105},[21243],{"type":34,"value":1303},{"type":29,"tag":88,"props":21245,"children":21246},{"style":174},[21247],{"type":34,"value":21248}," main",{"type":29,"tag":88,"props":21250,"children":21251},{"style":122},[21252],{"type":34,"value":181},{"type":29,"tag":88,"props":21254,"children":21255},{"style":105},[21256],{"type":34,"value":695},{"type":29,"tag":88,"props":21258,"children":21259},{"style":122},[21260],{"type":34,"value":21261},"[]",{"type":29,"tag":88,"props":21263,"children":21264},{"style":298},[21265],{"type":34,"value":21266}," args",{"type":29,"tag":88,"props":21268,"children":21269},{"style":122},[21270],{"type":34,"value":306},{"type":29,"tag":88,"props":21272,"children":21273},{"style":122},[21274],{"type":34,"value":125},{"type":29,"tag":88,"props":21276,"children":21277},{"class":90,"line":128},[21278,21283,21288,21292,21296,21300],{"type":29,"tag":88,"props":21279,"children":21280},{"style":151},[21281],{"type":34,"value":21282},"        PaymentProcessor",{"type":29,"tag":88,"props":21284,"children":21285},{"style":157},[21286],{"type":34,"value":21287}," processor ",{"type":29,"tag":88,"props":21289,"children":21290},{"style":163},[21291],{"type":34,"value":166},{"type":29,"tag":88,"props":21293,"children":21294},{"style":105},[21295],{"type":34,"value":171},{"type":29,"tag":88,"props":21297,"children":21298},{"style":174},[21299],{"type":34,"value":20366},{"type":29,"tag":88,"props":21301,"children":21302},{"style":122},[21303],{"type":34,"value":1810},{"type":29,"tag":88,"props":21305,"children":21306},{"class":90,"line":137},[21307],{"type":29,"tag":88,"props":21308,"children":21309},{"emptyLinePlaceholder":13},[21310],{"type":34,"value":134},{"type":29,"tag":88,"props":21312,"children":21313},{"class":90,"line":211},[21314],{"type":29,"tag":88,"props":21315,"children":21316},{"style":95},[21317],{"type":34,"value":21318},"        \u002F\u002F Utilisation de la carte bancaire\n",{"type":29,"tag":88,"props":21320,"children":21321},{"class":90,"line":262},[21322,21327,21332,21336,21340,21344],{"type":29,"tag":88,"props":21323,"children":21324},{"style":151},[21325],{"type":34,"value":21326},"        PaymentMethod",{"type":29,"tag":88,"props":21328,"children":21329},{"style":157},[21330],{"type":34,"value":21331}," creditCard ",{"type":29,"tag":88,"props":21333,"children":21334},{"style":163},[21335],{"type":34,"value":166},{"type":29,"tag":88,"props":21337,"children":21338},{"style":105},[21339],{"type":34,"value":171},{"type":29,"tag":88,"props":21341,"children":21342},{"style":174},[21343],{"type":34,"value":11667},{"type":29,"tag":88,"props":21345,"children":21346},{"style":122},[21347],{"type":34,"value":1810},{"type":29,"tag":88,"props":21349,"children":21350},{"class":90,"line":270},[21351,21356,21360,21364,21368,21373],{"type":29,"tag":88,"props":21352,"children":21353},{"style":157},[21354],{"type":34,"value":21355},"        processor",{"type":29,"tag":88,"props":21357,"children":21358},{"style":122},[21359],{"type":34,"value":338},{"type":29,"tag":88,"props":21361,"children":21362},{"style":174},[21363],{"type":34,"value":12917},{"type":29,"tag":88,"props":21365,"children":21366},{"style":122},[21367],{"type":34,"value":181},{"type":29,"tag":88,"props":21369,"children":21370},{"style":157},[21371],{"type":34,"value":21372},"creditCard",{"type":29,"tag":88,"props":21374,"children":21375},{"style":122},[21376],{"type":34,"value":357},{"type":29,"tag":88,"props":21378,"children":21379},{"class":90,"line":313},[21380],{"type":29,"tag":88,"props":21381,"children":21382},{"emptyLinePlaceholder":13},[21383],{"type":34,"value":134},{"type":29,"tag":88,"props":21385,"children":21386},{"class":90,"line":360},[21387],{"type":29,"tag":88,"props":21388,"children":21389},{"style":95},[21390],{"type":34,"value":21391},"        \u002F\u002F Utilisation de PayPal\n",{"type":29,"tag":88,"props":21393,"children":21394},{"class":90,"line":409},[21395,21399,21404,21408,21412,21416],{"type":29,"tag":88,"props":21396,"children":21397},{"style":151},[21398],{"type":34,"value":21326},{"type":29,"tag":88,"props":21400,"children":21401},{"style":157},[21402],{"type":34,"value":21403}," paypal ",{"type":29,"tag":88,"props":21405,"children":21406},{"style":163},[21407],{"type":34,"value":166},{"type":29,"tag":88,"props":21409,"children":21410},{"style":105},[21411],{"type":34,"value":171},{"type":29,"tag":88,"props":21413,"children":21414},{"style":174},[21415],{"type":34,"value":11759},{"type":29,"tag":88,"props":21417,"children":21418},{"style":122},[21419],{"type":34,"value":1810},{"type":29,"tag":88,"props":21421,"children":21422},{"class":90,"line":427},[21423,21427,21431,21435,21439,21444],{"type":29,"tag":88,"props":21424,"children":21425},{"style":157},[21426],{"type":34,"value":21355},{"type":29,"tag":88,"props":21428,"children":21429},{"style":122},[21430],{"type":34,"value":338},{"type":29,"tag":88,"props":21432,"children":21433},{"style":174},[21434],{"type":34,"value":12917},{"type":29,"tag":88,"props":21436,"children":21437},{"style":122},[21438],{"type":34,"value":181},{"type":29,"tag":88,"props":21440,"children":21441},{"style":157},[21442],{"type":34,"value":21443},"paypal",{"type":29,"tag":88,"props":21445,"children":21446},{"style":122},[21447],{"type":34,"value":357},{"type":29,"tag":88,"props":21449,"children":21450},{"class":90,"line":436},[21451],{"type":29,"tag":88,"props":21452,"children":21453},{"emptyLinePlaceholder":13},[21454],{"type":34,"value":134},{"type":29,"tag":88,"props":21456,"children":21457},{"class":90,"line":767},[21458],{"type":29,"tag":88,"props":21459,"children":21460},{"style":95},[21461],{"type":34,"value":21462},"        \u002F\u002F Utilisation d'un portefeuille électronique\n",{"type":29,"tag":88,"props":21464,"children":21465},{"class":90,"line":792},[21466,21470,21475,21479,21483,21487],{"type":29,"tag":88,"props":21467,"children":21468},{"style":151},[21469],{"type":34,"value":21326},{"type":29,"tag":88,"props":21471,"children":21472},{"style":157},[21473],{"type":34,"value":21474}," ewallet ",{"type":29,"tag":88,"props":21476,"children":21477},{"style":163},[21478],{"type":34,"value":166},{"type":29,"tag":88,"props":21480,"children":21481},{"style":105},[21482],{"type":34,"value":171},{"type":29,"tag":88,"props":21484,"children":21485},{"style":174},[21486],{"type":34,"value":21094},{"type":29,"tag":88,"props":21488,"children":21489},{"style":122},[21490],{"type":34,"value":1810},{"type":29,"tag":88,"props":21492,"children":21493},{"class":90,"line":817},[21494,21498,21502,21506,21510,21515],{"type":29,"tag":88,"props":21495,"children":21496},{"style":157},[21497],{"type":34,"value":21355},{"type":29,"tag":88,"props":21499,"children":21500},{"style":122},[21501],{"type":34,"value":338},{"type":29,"tag":88,"props":21503,"children":21504},{"style":174},[21505],{"type":34,"value":12917},{"type":29,"tag":88,"props":21507,"children":21508},{"style":122},[21509],{"type":34,"value":181},{"type":29,"tag":88,"props":21511,"children":21512},{"style":157},[21513],{"type":34,"value":21514},"ewallet",{"type":29,"tag":88,"props":21516,"children":21517},{"style":122},[21518],{"type":34,"value":357},{"type":29,"tag":88,"props":21520,"children":21521},{"class":90,"line":825},[21522],{"type":29,"tag":88,"props":21523,"children":21524},{"style":122},[21525],{"type":34,"value":433},{"type":29,"tag":88,"props":21527,"children":21528},{"class":90,"line":869},[21529],{"type":29,"tag":88,"props":21530,"children":21531},{"style":122},[21532],{"type":34,"value":442},{"type":29,"tag":47,"props":21534,"children":21535},{},[],{"type":29,"tag":8526,"props":21537,"children":21538},{"type":8528},[21539],{"type":29,"tag":30,"props":21540,"children":21541},{},[21542,21547],{"type":29,"tag":447,"props":21543,"children":21544},{},[21545],{"type":34,"value":21546},"Utilisez des interfaces ou des classes abstraites",{"type":34,"value":21548}," pour éviter de toucher au code déjà testé. C'est ce qui rend l'extension de l'application possible sans régression.",{"type":29,"tag":51,"props":21550,"children":21552},{"id":21551},"_3-principe-de-substitution-de-liskov-liskov-substitution-principle-lsp",[21553],{"type":34,"value":21554},"3. Principe de Substitution de Liskov (Liskov Substitution Principle - LSP)",{"type":29,"tag":30,"props":21556,"children":21557},{},[21558],{"type":34,"value":21559},"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":29,"tag":8542,"props":21561,"children":21563},{"id":21562},"pourquoi-cest-important-2",[21564],{"type":34,"value":19524},{"type":29,"tag":30,"props":21566,"children":21567},{},[21568],{"type":34,"value":21569},"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":29,"tag":8542,"props":21571,"children":21573},{"id":21572},"exemple-concret-en-java-2",[21574],{"type":34,"value":19535},{"type":29,"tag":30,"props":21576,"children":21577},{},[21578,21580,21586,21588,21594],{"type":34,"value":21579},"Imaginons que nous ayons une classe ",{"type":29,"tag":84,"props":21581,"children":21583},{"className":21582},[],[21584],{"type":34,"value":21585},"Rectangle",{"type":34,"value":21587}," et une sous-classe ",{"type":29,"tag":84,"props":21589,"children":21591},{"className":21590},[],[21592],{"type":34,"value":21593},"Square",{"type":34,"value":21595}," (carré), puisque, mathématiquement, un carré est un cas particulier de rectangle.",{"type":29,"tag":10576,"props":21597,"children":21599},{"id":21598},"exemple-sans-lsp",[21600],{"type":34,"value":21601},"Exemple sans LSP :",{"type":29,"tag":30,"props":21603,"children":21604},{},[21605,21607,21612,21614,21619],{"type":34,"value":21606},"Voici une implémentation basique où ",{"type":29,"tag":84,"props":21608,"children":21610},{"className":21609},[],[21611],{"type":34,"value":21593},{"type":34,"value":21613}," hérite de ",{"type":29,"tag":84,"props":21615,"children":21617},{"className":21616},[],[21618],{"type":34,"value":21585},{"type":34,"value":21063},{"type":29,"tag":77,"props":21621,"children":21623},{"className":81,"code":21622,"language":80,"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; \u002F\u002F Contraintes du carré\n    }\n\n    @Override\n    public void setHeight(int height) {\n        this.height = height;\n        this.width = height; \u002F\u002F Contraintes du carré\n    }\n}\n",[21624],{"type":29,"tag":84,"props":21625,"children":21626},{"__ignoreMap":8},[21627,21647,21668,21688,21695,21731,21759,21766,21773,21780,21787,21823,21851,21858,21865,21889,21913,21920,21927,21934,21963,21974,22009,22036,22068,22075,22082,22093,22128,22155,22186,22193],{"type":29,"tag":88,"props":21628,"children":21629},{"class":90,"line":91},[21630,21634,21638,21643],{"type":29,"tag":88,"props":21631,"children":21632},{"style":105},[21633],{"type":34,"value":108},{"type":29,"tag":88,"props":21635,"children":21636},{"style":105},[21637],{"type":34,"value":113},{"type":29,"tag":88,"props":21639,"children":21640},{"style":116},[21641],{"type":34,"value":21642}," Rectangle",{"type":29,"tag":88,"props":21644,"children":21645},{"style":122},[21646],{"type":34,"value":125},{"type":29,"tag":88,"props":21648,"children":21649},{"class":90,"line":101},[21650,21655,21659,21664],{"type":29,"tag":88,"props":21651,"children":21652},{"style":105},[21653],{"type":34,"value":21654},"    protected",{"type":29,"tag":88,"props":21656,"children":21657},{"style":105},[21658],{"type":34,"value":8608},{"type":29,"tag":88,"props":21660,"children":21661},{"style":157},[21662],{"type":34,"value":21663}," width",{"type":29,"tag":88,"props":21665,"children":21666},{"style":122},[21667],{"type":34,"value":424},{"type":29,"tag":88,"props":21669,"children":21670},{"class":90,"line":128},[21671,21675,21679,21684],{"type":29,"tag":88,"props":21672,"children":21673},{"style":105},[21674],{"type":34,"value":21654},{"type":29,"tag":88,"props":21676,"children":21677},{"style":105},[21678],{"type":34,"value":8608},{"type":29,"tag":88,"props":21680,"children":21681},{"style":157},[21682],{"type":34,"value":21683}," height",{"type":29,"tag":88,"props":21685,"children":21686},{"style":122},[21687],{"type":34,"value":424},{"type":29,"tag":88,"props":21689,"children":21690},{"class":90,"line":137},[21691],{"type":29,"tag":88,"props":21692,"children":21693},{"emptyLinePlaceholder":13},[21694],{"type":34,"value":134},{"type":29,"tag":88,"props":21696,"children":21697},{"class":90,"line":211},[21698,21702,21706,21711,21715,21719,21723,21727],{"type":29,"tag":88,"props":21699,"children":21700},{"style":105},[21701],{"type":34,"value":276},{"type":29,"tag":88,"props":21703,"children":21704},{"style":105},[21705],{"type":34,"value":1303},{"type":29,"tag":88,"props":21707,"children":21708},{"style":174},[21709],{"type":34,"value":21710}," setWidth",{"type":29,"tag":88,"props":21712,"children":21713},{"style":122},[21714],{"type":34,"value":181},{"type":29,"tag":88,"props":21716,"children":21717},{"style":105},[21718],{"type":34,"value":8622},{"type":29,"tag":88,"props":21720,"children":21721},{"style":298},[21722],{"type":34,"value":21663},{"type":29,"tag":88,"props":21724,"children":21725},{"style":122},[21726],{"type":34,"value":306},{"type":29,"tag":88,"props":21728,"children":21729},{"style":122},[21730],{"type":34,"value":125},{"type":29,"tag":88,"props":21732,"children":21733},{"class":90,"line":262},[21734,21738,21742,21747,21751,21755],{"type":29,"tag":88,"props":21735,"children":21736},{"style":873},[21737],{"type":34,"value":876},{"type":29,"tag":88,"props":21739,"children":21740},{"style":122},[21741],{"type":34,"value":338},{"type":29,"tag":88,"props":21743,"children":21744},{"style":157},[21745],{"type":34,"value":21746},"width ",{"type":29,"tag":88,"props":21748,"children":21749},{"style":163},[21750],{"type":34,"value":166},{"type":29,"tag":88,"props":21752,"children":21753},{"style":157},[21754],{"type":34,"value":21663},{"type":29,"tag":88,"props":21756,"children":21757},{"style":122},[21758],{"type":34,"value":424},{"type":29,"tag":88,"props":21760,"children":21761},{"class":90,"line":270},[21762],{"type":29,"tag":88,"props":21763,"children":21764},{"style":122},[21765],{"type":34,"value":433},{"type":29,"tag":88,"props":21767,"children":21768},{"class":90,"line":313},[21769],{"type":29,"tag":88,"props":21770,"children":21771},{"emptyLinePlaceholder":13},[21772],{"type":34,"value":134},{"type":29,"tag":88,"props":21774,"children":21775},{"class":90,"line":360},[21776],{"type":29,"tag":88,"props":21777,"children":21778},{"emptyLinePlaceholder":13},[21779],{"type":34,"value":134},{"type":29,"tag":88,"props":21781,"children":21782},{"class":90,"line":409},[21783],{"type":29,"tag":88,"props":21784,"children":21785},{"emptyLinePlaceholder":13},[21786],{"type":34,"value":134},{"type":29,"tag":88,"props":21788,"children":21789},{"class":90,"line":427},[21790,21794,21798,21803,21807,21811,21815,21819],{"type":29,"tag":88,"props":21791,"children":21792},{"style":105},[21793],{"type":34,"value":276},{"type":29,"tag":88,"props":21795,"children":21796},{"style":105},[21797],{"type":34,"value":1303},{"type":29,"tag":88,"props":21799,"children":21800},{"style":174},[21801],{"type":34,"value":21802}," setHeight",{"type":29,"tag":88,"props":21804,"children":21805},{"style":122},[21806],{"type":34,"value":181},{"type":29,"tag":88,"props":21808,"children":21809},{"style":105},[21810],{"type":34,"value":8622},{"type":29,"tag":88,"props":21812,"children":21813},{"style":298},[21814],{"type":34,"value":21683},{"type":29,"tag":88,"props":21816,"children":21817},{"style":122},[21818],{"type":34,"value":306},{"type":29,"tag":88,"props":21820,"children":21821},{"style":122},[21822],{"type":34,"value":125},{"type":29,"tag":88,"props":21824,"children":21825},{"class":90,"line":436},[21826,21830,21834,21839,21843,21847],{"type":29,"tag":88,"props":21827,"children":21828},{"style":873},[21829],{"type":34,"value":876},{"type":29,"tag":88,"props":21831,"children":21832},{"style":122},[21833],{"type":34,"value":338},{"type":29,"tag":88,"props":21835,"children":21836},{"style":157},[21837],{"type":34,"value":21838},"height ",{"type":29,"tag":88,"props":21840,"children":21841},{"style":163},[21842],{"type":34,"value":166},{"type":29,"tag":88,"props":21844,"children":21845},{"style":157},[21846],{"type":34,"value":21683},{"type":29,"tag":88,"props":21848,"children":21849},{"style":122},[21850],{"type":34,"value":424},{"type":29,"tag":88,"props":21852,"children":21853},{"class":90,"line":767},[21854],{"type":29,"tag":88,"props":21855,"children":21856},{"style":122},[21857],{"type":34,"value":433},{"type":29,"tag":88,"props":21859,"children":21860},{"class":90,"line":792},[21861],{"type":29,"tag":88,"props":21862,"children":21863},{"emptyLinePlaceholder":13},[21864],{"type":34,"value":134},{"type":29,"tag":88,"props":21866,"children":21867},{"class":90,"line":817},[21868,21872,21876,21881,21885],{"type":29,"tag":88,"props":21869,"children":21870},{"style":105},[21871],{"type":34,"value":276},{"type":29,"tag":88,"props":21873,"children":21874},{"style":105},[21875],{"type":34,"value":8608},{"type":29,"tag":88,"props":21877,"children":21878},{"style":174},[21879],{"type":34,"value":21880}," getArea",{"type":29,"tag":88,"props":21882,"children":21883},{"style":122},[21884],{"type":34,"value":1470},{"type":29,"tag":88,"props":21886,"children":21887},{"style":122},[21888],{"type":34,"value":125},{"type":29,"tag":88,"props":21890,"children":21891},{"class":90,"line":825},[21892,21896,21901,21905,21909],{"type":29,"tag":88,"props":21893,"children":21894},{"style":105},[21895],{"type":34,"value":415},{"type":29,"tag":88,"props":21897,"children":21898},{"style":157},[21899],{"type":34,"value":21900}," width ",{"type":29,"tag":88,"props":21902,"children":21903},{"style":163},[21904],{"type":34,"value":8709},{"type":29,"tag":88,"props":21906,"children":21907},{"style":157},[21908],{"type":34,"value":21683},{"type":29,"tag":88,"props":21910,"children":21911},{"style":122},[21912],{"type":34,"value":424},{"type":29,"tag":88,"props":21914,"children":21915},{"class":90,"line":869},[21916],{"type":29,"tag":88,"props":21917,"children":21918},{"style":122},[21919],{"type":34,"value":433},{"type":29,"tag":88,"props":21921,"children":21922},{"class":90,"line":900},[21923],{"type":29,"tag":88,"props":21924,"children":21925},{"style":122},[21926],{"type":34,"value":442},{"type":29,"tag":88,"props":21928,"children":21929},{"class":90,"line":929},[21930],{"type":29,"tag":88,"props":21931,"children":21932},{"emptyLinePlaceholder":13},[21933],{"type":34,"value":134},{"type":29,"tag":88,"props":21935,"children":21936},{"class":90,"line":937},[21937,21941,21945,21950,21955,21959],{"type":29,"tag":88,"props":21938,"children":21939},{"style":105},[21940],{"type":34,"value":108},{"type":29,"tag":88,"props":21942,"children":21943},{"style":105},[21944],{"type":34,"value":113},{"type":29,"tag":88,"props":21946,"children":21947},{"style":116},[21948],{"type":34,"value":21949}," Square",{"type":29,"tag":88,"props":21951,"children":21952},{"style":105},[21953],{"type":34,"value":21954}," extends",{"type":29,"tag":88,"props":21956,"children":21957},{"style":116},[21958],{"type":34,"value":21642},{"type":29,"tag":88,"props":21960,"children":21961},{"style":122},[21962],{"type":34,"value":125},{"type":29,"tag":88,"props":21964,"children":21965},{"class":90,"line":945},[21966,21970],{"type":29,"tag":88,"props":21967,"children":21968},{"style":1974},[21969],{"type":34,"value":3302},{"type":29,"tag":88,"props":21971,"children":21972},{"style":1980},[21973],{"type":34,"value":3307},{"type":29,"tag":88,"props":21975,"children":21976},{"class":90,"line":981},[21977,21981,21985,21989,21993,21997,22001,22005],{"type":29,"tag":88,"props":21978,"children":21979},{"style":105},[21980],{"type":34,"value":276},{"type":29,"tag":88,"props":21982,"children":21983},{"style":105},[21984],{"type":34,"value":1303},{"type":29,"tag":88,"props":21986,"children":21987},{"style":174},[21988],{"type":34,"value":21710},{"type":29,"tag":88,"props":21990,"children":21991},{"style":122},[21992],{"type":34,"value":181},{"type":29,"tag":88,"props":21994,"children":21995},{"style":105},[21996],{"type":34,"value":8622},{"type":29,"tag":88,"props":21998,"children":21999},{"style":298},[22000],{"type":34,"value":21663},{"type":29,"tag":88,"props":22002,"children":22003},{"style":122},[22004],{"type":34,"value":306},{"type":29,"tag":88,"props":22006,"children":22007},{"style":122},[22008],{"type":34,"value":125},{"type":29,"tag":88,"props":22010,"children":22011},{"class":90,"line":1021},[22012,22016,22020,22024,22028,22032],{"type":29,"tag":88,"props":22013,"children":22014},{"style":873},[22015],{"type":34,"value":876},{"type":29,"tag":88,"props":22017,"children":22018},{"style":122},[22019],{"type":34,"value":338},{"type":29,"tag":88,"props":22021,"children":22022},{"style":157},[22023],{"type":34,"value":21746},{"type":29,"tag":88,"props":22025,"children":22026},{"style":163},[22027],{"type":34,"value":166},{"type":29,"tag":88,"props":22029,"children":22030},{"style":157},[22031],{"type":34,"value":21663},{"type":29,"tag":88,"props":22033,"children":22034},{"style":122},[22035],{"type":34,"value":424},{"type":29,"tag":88,"props":22037,"children":22038},{"class":90,"line":1066},[22039,22043,22047,22051,22055,22059,22063],{"type":29,"tag":88,"props":22040,"children":22041},{"style":873},[22042],{"type":34,"value":876},{"type":29,"tag":88,"props":22044,"children":22045},{"style":122},[22046],{"type":34,"value":338},{"type":29,"tag":88,"props":22048,"children":22049},{"style":157},[22050],{"type":34,"value":21838},{"type":29,"tag":88,"props":22052,"children":22053},{"style":163},[22054],{"type":34,"value":166},{"type":29,"tag":88,"props":22056,"children":22057},{"style":157},[22058],{"type":34,"value":21663},{"type":29,"tag":88,"props":22060,"children":22061},{"style":122},[22062],{"type":34,"value":5988},{"type":29,"tag":88,"props":22064,"children":22065},{"style":95},[22066],{"type":34,"value":22067}," \u002F\u002F Contraintes du carré\n",{"type":29,"tag":88,"props":22069,"children":22070},{"class":90,"line":1082},[22071],{"type":29,"tag":88,"props":22072,"children":22073},{"style":122},[22074],{"type":34,"value":433},{"type":29,"tag":88,"props":22076,"children":22077},{"class":90,"line":1090},[22078],{"type":29,"tag":88,"props":22079,"children":22080},{"emptyLinePlaceholder":13},[22081],{"type":34,"value":134},{"type":29,"tag":88,"props":22083,"children":22084},{"class":90,"line":1098},[22085,22089],{"type":29,"tag":88,"props":22086,"children":22087},{"style":1974},[22088],{"type":34,"value":3302},{"type":29,"tag":88,"props":22090,"children":22091},{"style":1980},[22092],{"type":34,"value":3307},{"type":29,"tag":88,"props":22094,"children":22095},{"class":90,"line":1106},[22096,22100,22104,22108,22112,22116,22120,22124],{"type":29,"tag":88,"props":22097,"children":22098},{"style":105},[22099],{"type":34,"value":276},{"type":29,"tag":88,"props":22101,"children":22102},{"style":105},[22103],{"type":34,"value":1303},{"type":29,"tag":88,"props":22105,"children":22106},{"style":174},[22107],{"type":34,"value":21802},{"type":29,"tag":88,"props":22109,"children":22110},{"style":122},[22111],{"type":34,"value":181},{"type":29,"tag":88,"props":22113,"children":22114},{"style":105},[22115],{"type":34,"value":8622},{"type":29,"tag":88,"props":22117,"children":22118},{"style":298},[22119],{"type":34,"value":21683},{"type":29,"tag":88,"props":22121,"children":22122},{"style":122},[22123],{"type":34,"value":306},{"type":29,"tag":88,"props":22125,"children":22126},{"style":122},[22127],{"type":34,"value":125},{"type":29,"tag":88,"props":22129,"children":22130},{"class":90,"line":1115},[22131,22135,22139,22143,22147,22151],{"type":29,"tag":88,"props":22132,"children":22133},{"style":873},[22134],{"type":34,"value":876},{"type":29,"tag":88,"props":22136,"children":22137},{"style":122},[22138],{"type":34,"value":338},{"type":29,"tag":88,"props":22140,"children":22141},{"style":157},[22142],{"type":34,"value":21838},{"type":29,"tag":88,"props":22144,"children":22145},{"style":163},[22146],{"type":34,"value":166},{"type":29,"tag":88,"props":22148,"children":22149},{"style":157},[22150],{"type":34,"value":21683},{"type":29,"tag":88,"props":22152,"children":22153},{"style":122},[22154],{"type":34,"value":424},{"type":29,"tag":88,"props":22156,"children":22157},{"class":90,"line":11},[22158,22162,22166,22170,22174,22178,22182],{"type":29,"tag":88,"props":22159,"children":22160},{"style":873},[22161],{"type":34,"value":876},{"type":29,"tag":88,"props":22163,"children":22164},{"style":122},[22165],{"type":34,"value":338},{"type":29,"tag":88,"props":22167,"children":22168},{"style":157},[22169],{"type":34,"value":21746},{"type":29,"tag":88,"props":22171,"children":22172},{"style":163},[22173],{"type":34,"value":166},{"type":29,"tag":88,"props":22175,"children":22176},{"style":157},[22177],{"type":34,"value":21683},{"type":29,"tag":88,"props":22179,"children":22180},{"style":122},[22181],{"type":34,"value":5988},{"type":29,"tag":88,"props":22183,"children":22184},{"style":95},[22185],{"type":34,"value":22067},{"type":29,"tag":88,"props":22187,"children":22188},{"class":90,"line":1180},[22189],{"type":29,"tag":88,"props":22190,"children":22191},{"style":122},[22192],{"type":34,"value":433},{"type":29,"tag":88,"props":22194,"children":22195},{"class":90,"line":1240},[22196],{"type":29,"tag":88,"props":22197,"children":22198},{"style":122},[22199],{"type":34,"value":442},{"type":29,"tag":30,"props":22201,"children":22202},{},[22203,22205,22210,22212,22217,22219,22225,22226,22232],{"type":34,"value":22204},"À première vue, cela semble correct. Cependant, cette implémentation brise le principe de substitution de Liskov. Si l'on remplace un ",{"type":29,"tag":84,"props":22206,"children":22208},{"className":22207},[],[22209],{"type":34,"value":21585},{"type":34,"value":22211}," par un ",{"type":29,"tag":84,"props":22213,"children":22215},{"className":22214},[],[22216],{"type":34,"value":21593},{"type":34,"value":22218},", le comportement de la méthode ",{"type":29,"tag":84,"props":22220,"children":22222},{"className":22221},[],[22223],{"type":34,"value":22224},"setWidth()",{"type":34,"value":5730},{"type":29,"tag":84,"props":22227,"children":22229},{"className":22228},[],[22230],{"type":34,"value":22231},"setHeight()",{"type":34,"value":22233}," 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":29,"tag":10576,"props":22235,"children":22237},{"id":22236},"exemple-avec-lsp-appliqué",[22238],{"type":34,"value":22239},"Exemple avec LSP appliqué :",{"type":29,"tag":30,"props":22241,"children":22242},{},[22243],{"type":34,"value":22244},"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":29,"tag":77,"props":22246,"children":22248},{"className":81,"code":22247,"language":80,"meta":8,"style":8},"\u002F\u002F 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\u002F\u002F 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",[22249],{"type":29,"tag":84,"props":22250,"children":22251},{"__ignoreMap":8},[22252,22260,22279,22298,22317,22324,22359,22386,22393,22400,22435,22462,22469,22476,22499,22522,22529,22536,22543,22551,22570,22590,22597,22633,22661,22668,22675,22698,22722,22729],{"type":29,"tag":88,"props":22253,"children":22254},{"class":90,"line":91},[22255],{"type":29,"tag":88,"props":22256,"children":22257},{"style":95},[22258],{"type":34,"value":22259},"\u002F\u002F Classe Rectangle\n",{"type":29,"tag":88,"props":22261,"children":22262},{"class":90,"line":101},[22263,22267,22271,22275],{"type":29,"tag":88,"props":22264,"children":22265},{"style":105},[22266],{"type":34,"value":108},{"type":29,"tag":88,"props":22268,"children":22269},{"style":105},[22270],{"type":34,"value":113},{"type":29,"tag":88,"props":22272,"children":22273},{"style":116},[22274],{"type":34,"value":21642},{"type":29,"tag":88,"props":22276,"children":22277},{"style":122},[22278],{"type":34,"value":125},{"type":29,"tag":88,"props":22280,"children":22281},{"class":90,"line":128},[22282,22286,22290,22294],{"type":29,"tag":88,"props":22283,"children":22284},{"style":105},[22285],{"type":34,"value":143},{"type":29,"tag":88,"props":22287,"children":22288},{"style":105},[22289],{"type":34,"value":8608},{"type":29,"tag":88,"props":22291,"children":22292},{"style":157},[22293],{"type":34,"value":21663},{"type":29,"tag":88,"props":22295,"children":22296},{"style":122},[22297],{"type":34,"value":424},{"type":29,"tag":88,"props":22299,"children":22300},{"class":90,"line":137},[22301,22305,22309,22313],{"type":29,"tag":88,"props":22302,"children":22303},{"style":105},[22304],{"type":34,"value":143},{"type":29,"tag":88,"props":22306,"children":22307},{"style":105},[22308],{"type":34,"value":8608},{"type":29,"tag":88,"props":22310,"children":22311},{"style":157},[22312],{"type":34,"value":21683},{"type":29,"tag":88,"props":22314,"children":22315},{"style":122},[22316],{"type":34,"value":424},{"type":29,"tag":88,"props":22318,"children":22319},{"class":90,"line":211},[22320],{"type":29,"tag":88,"props":22321,"children":22322},{"emptyLinePlaceholder":13},[22323],{"type":34,"value":134},{"type":29,"tag":88,"props":22325,"children":22326},{"class":90,"line":262},[22327,22331,22335,22339,22343,22347,22351,22355],{"type":29,"tag":88,"props":22328,"children":22329},{"style":105},[22330],{"type":34,"value":276},{"type":29,"tag":88,"props":22332,"children":22333},{"style":105},[22334],{"type":34,"value":1303},{"type":29,"tag":88,"props":22336,"children":22337},{"style":174},[22338],{"type":34,"value":21710},{"type":29,"tag":88,"props":22340,"children":22341},{"style":122},[22342],{"type":34,"value":181},{"type":29,"tag":88,"props":22344,"children":22345},{"style":105},[22346],{"type":34,"value":8622},{"type":29,"tag":88,"props":22348,"children":22349},{"style":298},[22350],{"type":34,"value":21663},{"type":29,"tag":88,"props":22352,"children":22353},{"style":122},[22354],{"type":34,"value":306},{"type":29,"tag":88,"props":22356,"children":22357},{"style":122},[22358],{"type":34,"value":125},{"type":29,"tag":88,"props":22360,"children":22361},{"class":90,"line":270},[22362,22366,22370,22374,22378,22382],{"type":29,"tag":88,"props":22363,"children":22364},{"style":873},[22365],{"type":34,"value":876},{"type":29,"tag":88,"props":22367,"children":22368},{"style":122},[22369],{"type":34,"value":338},{"type":29,"tag":88,"props":22371,"children":22372},{"style":157},[22373],{"type":34,"value":21746},{"type":29,"tag":88,"props":22375,"children":22376},{"style":163},[22377],{"type":34,"value":166},{"type":29,"tag":88,"props":22379,"children":22380},{"style":157},[22381],{"type":34,"value":21663},{"type":29,"tag":88,"props":22383,"children":22384},{"style":122},[22385],{"type":34,"value":424},{"type":29,"tag":88,"props":22387,"children":22388},{"class":90,"line":313},[22389],{"type":29,"tag":88,"props":22390,"children":22391},{"style":122},[22392],{"type":34,"value":433},{"type":29,"tag":88,"props":22394,"children":22395},{"class":90,"line":360},[22396],{"type":29,"tag":88,"props":22397,"children":22398},{"emptyLinePlaceholder":13},[22399],{"type":34,"value":134},{"type":29,"tag":88,"props":22401,"children":22402},{"class":90,"line":409},[22403,22407,22411,22415,22419,22423,22427,22431],{"type":29,"tag":88,"props":22404,"children":22405},{"style":105},[22406],{"type":34,"value":276},{"type":29,"tag":88,"props":22408,"children":22409},{"style":105},[22410],{"type":34,"value":1303},{"type":29,"tag":88,"props":22412,"children":22413},{"style":174},[22414],{"type":34,"value":21802},{"type":29,"tag":88,"props":22416,"children":22417},{"style":122},[22418],{"type":34,"value":181},{"type":29,"tag":88,"props":22420,"children":22421},{"style":105},[22422],{"type":34,"value":8622},{"type":29,"tag":88,"props":22424,"children":22425},{"style":298},[22426],{"type":34,"value":21683},{"type":29,"tag":88,"props":22428,"children":22429},{"style":122},[22430],{"type":34,"value":306},{"type":29,"tag":88,"props":22432,"children":22433},{"style":122},[22434],{"type":34,"value":125},{"type":29,"tag":88,"props":22436,"children":22437},{"class":90,"line":427},[22438,22442,22446,22450,22454,22458],{"type":29,"tag":88,"props":22439,"children":22440},{"style":873},[22441],{"type":34,"value":876},{"type":29,"tag":88,"props":22443,"children":22444},{"style":122},[22445],{"type":34,"value":338},{"type":29,"tag":88,"props":22447,"children":22448},{"style":157},[22449],{"type":34,"value":21838},{"type":29,"tag":88,"props":22451,"children":22452},{"style":163},[22453],{"type":34,"value":166},{"type":29,"tag":88,"props":22455,"children":22456},{"style":157},[22457],{"type":34,"value":21683},{"type":29,"tag":88,"props":22459,"children":22460},{"style":122},[22461],{"type":34,"value":424},{"type":29,"tag":88,"props":22463,"children":22464},{"class":90,"line":436},[22465],{"type":29,"tag":88,"props":22466,"children":22467},{"style":122},[22468],{"type":34,"value":433},{"type":29,"tag":88,"props":22470,"children":22471},{"class":90,"line":767},[22472],{"type":29,"tag":88,"props":22473,"children":22474},{"emptyLinePlaceholder":13},[22475],{"type":34,"value":134},{"type":29,"tag":88,"props":22477,"children":22478},{"class":90,"line":792},[22479,22483,22487,22491,22495],{"type":29,"tag":88,"props":22480,"children":22481},{"style":105},[22482],{"type":34,"value":276},{"type":29,"tag":88,"props":22484,"children":22485},{"style":105},[22486],{"type":34,"value":8608},{"type":29,"tag":88,"props":22488,"children":22489},{"style":174},[22490],{"type":34,"value":21880},{"type":29,"tag":88,"props":22492,"children":22493},{"style":122},[22494],{"type":34,"value":1470},{"type":29,"tag":88,"props":22496,"children":22497},{"style":122},[22498],{"type":34,"value":125},{"type":29,"tag":88,"props":22500,"children":22501},{"class":90,"line":817},[22502,22506,22510,22514,22518],{"type":29,"tag":88,"props":22503,"children":22504},{"style":105},[22505],{"type":34,"value":415},{"type":29,"tag":88,"props":22507,"children":22508},{"style":157},[22509],{"type":34,"value":21900},{"type":29,"tag":88,"props":22511,"children":22512},{"style":163},[22513],{"type":34,"value":8709},{"type":29,"tag":88,"props":22515,"children":22516},{"style":157},[22517],{"type":34,"value":21683},{"type":29,"tag":88,"props":22519,"children":22520},{"style":122},[22521],{"type":34,"value":424},{"type":29,"tag":88,"props":22523,"children":22524},{"class":90,"line":825},[22525],{"type":29,"tag":88,"props":22526,"children":22527},{"style":122},[22528],{"type":34,"value":433},{"type":29,"tag":88,"props":22530,"children":22531},{"class":90,"line":869},[22532],{"type":29,"tag":88,"props":22533,"children":22534},{"style":122},[22535],{"type":34,"value":442},{"type":29,"tag":88,"props":22537,"children":22538},{"class":90,"line":900},[22539],{"type":29,"tag":88,"props":22540,"children":22541},{"emptyLinePlaceholder":13},[22542],{"type":34,"value":134},{"type":29,"tag":88,"props":22544,"children":22545},{"class":90,"line":929},[22546],{"type":29,"tag":88,"props":22547,"children":22548},{"style":95},[22549],{"type":34,"value":22550},"\u002F\u002F Classe Square avec son propre comportement\n",{"type":29,"tag":88,"props":22552,"children":22553},{"class":90,"line":937},[22554,22558,22562,22566],{"type":29,"tag":88,"props":22555,"children":22556},{"style":105},[22557],{"type":34,"value":108},{"type":29,"tag":88,"props":22559,"children":22560},{"style":105},[22561],{"type":34,"value":113},{"type":29,"tag":88,"props":22563,"children":22564},{"style":116},[22565],{"type":34,"value":21949},{"type":29,"tag":88,"props":22567,"children":22568},{"style":122},[22569],{"type":34,"value":125},{"type":29,"tag":88,"props":22571,"children":22572},{"class":90,"line":945},[22573,22577,22581,22586],{"type":29,"tag":88,"props":22574,"children":22575},{"style":105},[22576],{"type":34,"value":143},{"type":29,"tag":88,"props":22578,"children":22579},{"style":105},[22580],{"type":34,"value":8608},{"type":29,"tag":88,"props":22582,"children":22583},{"style":157},[22584],{"type":34,"value":22585}," side",{"type":29,"tag":88,"props":22587,"children":22588},{"style":122},[22589],{"type":34,"value":424},{"type":29,"tag":88,"props":22591,"children":22592},{"class":90,"line":981},[22593],{"type":29,"tag":88,"props":22594,"children":22595},{"emptyLinePlaceholder":13},[22596],{"type":34,"value":134},{"type":29,"tag":88,"props":22598,"children":22599},{"class":90,"line":1021},[22600,22604,22608,22613,22617,22621,22625,22629],{"type":29,"tag":88,"props":22601,"children":22602},{"style":105},[22603],{"type":34,"value":276},{"type":29,"tag":88,"props":22605,"children":22606},{"style":105},[22607],{"type":34,"value":1303},{"type":29,"tag":88,"props":22609,"children":22610},{"style":174},[22611],{"type":34,"value":22612}," setSide",{"type":29,"tag":88,"props":22614,"children":22615},{"style":122},[22616],{"type":34,"value":181},{"type":29,"tag":88,"props":22618,"children":22619},{"style":105},[22620],{"type":34,"value":8622},{"type":29,"tag":88,"props":22622,"children":22623},{"style":298},[22624],{"type":34,"value":22585},{"type":29,"tag":88,"props":22626,"children":22627},{"style":122},[22628],{"type":34,"value":306},{"type":29,"tag":88,"props":22630,"children":22631},{"style":122},[22632],{"type":34,"value":125},{"type":29,"tag":88,"props":22634,"children":22635},{"class":90,"line":1066},[22636,22640,22644,22649,22653,22657],{"type":29,"tag":88,"props":22637,"children":22638},{"style":873},[22639],{"type":34,"value":876},{"type":29,"tag":88,"props":22641,"children":22642},{"style":122},[22643],{"type":34,"value":338},{"type":29,"tag":88,"props":22645,"children":22646},{"style":157},[22647],{"type":34,"value":22648},"side ",{"type":29,"tag":88,"props":22650,"children":22651},{"style":163},[22652],{"type":34,"value":166},{"type":29,"tag":88,"props":22654,"children":22655},{"style":157},[22656],{"type":34,"value":22585},{"type":29,"tag":88,"props":22658,"children":22659},{"style":122},[22660],{"type":34,"value":424},{"type":29,"tag":88,"props":22662,"children":22663},{"class":90,"line":1082},[22664],{"type":29,"tag":88,"props":22665,"children":22666},{"style":122},[22667],{"type":34,"value":433},{"type":29,"tag":88,"props":22669,"children":22670},{"class":90,"line":1090},[22671],{"type":29,"tag":88,"props":22672,"children":22673},{"emptyLinePlaceholder":13},[22674],{"type":34,"value":134},{"type":29,"tag":88,"props":22676,"children":22677},{"class":90,"line":1098},[22678,22682,22686,22690,22694],{"type":29,"tag":88,"props":22679,"children":22680},{"style":105},[22681],{"type":34,"value":276},{"type":29,"tag":88,"props":22683,"children":22684},{"style":105},[22685],{"type":34,"value":8608},{"type":29,"tag":88,"props":22687,"children":22688},{"style":174},[22689],{"type":34,"value":21880},{"type":29,"tag":88,"props":22691,"children":22692},{"style":122},[22693],{"type":34,"value":1470},{"type":29,"tag":88,"props":22695,"children":22696},{"style":122},[22697],{"type":34,"value":125},{"type":29,"tag":88,"props":22699,"children":22700},{"class":90,"line":1106},[22701,22705,22710,22714,22718],{"type":29,"tag":88,"props":22702,"children":22703},{"style":105},[22704],{"type":34,"value":415},{"type":29,"tag":88,"props":22706,"children":22707},{"style":157},[22708],{"type":34,"value":22709}," side ",{"type":29,"tag":88,"props":22711,"children":22712},{"style":163},[22713],{"type":34,"value":8709},{"type":29,"tag":88,"props":22715,"children":22716},{"style":157},[22717],{"type":34,"value":22585},{"type":29,"tag":88,"props":22719,"children":22720},{"style":122},[22721],{"type":34,"value":424},{"type":29,"tag":88,"props":22723,"children":22724},{"class":90,"line":1115},[22725],{"type":29,"tag":88,"props":22726,"children":22727},{"style":122},[22728],{"type":34,"value":433},{"type":29,"tag":88,"props":22730,"children":22731},{"class":90,"line":11},[22732],{"type":29,"tag":88,"props":22733,"children":22734},{"style":122},[22735],{"type":34,"value":442},{"type":29,"tag":47,"props":22737,"children":22738},{},[],{"type":29,"tag":8526,"props":22740,"children":22741},{"type":8528},[22742],{"type":29,"tag":30,"props":22743,"children":22744},{},[22745,22750],{"type":29,"tag":447,"props":22746,"children":22747},{},[22748],{"type":34,"value":22749},"Évitez l'héritage si les comportements diffèrent",{"type":34,"value":22751}," 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":29,"tag":51,"props":22753,"children":22755},{"id":22754},"_4-principe-de-ségrégation-des-interfaces-interface-segregation-principle-isp",[22756],{"type":34,"value":22757},"4. Principe de Ségrégation des Interfaces (Interface Segregation Principle - ISP)",{"type":29,"tag":30,"props":22759,"children":22760},{},[22761],{"type":34,"value":22762},"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":29,"tag":8542,"props":22764,"children":22766},{"id":22765},"pourquoi-cest-important-3",[22767],{"type":34,"value":19524},{"type":29,"tag":30,"props":22769,"children":22770},{},[22771],{"type":34,"value":22772},"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":29,"tag":8542,"props":22774,"children":22776},{"id":22775},"exemple-concret-en-java-3",[22777],{"type":34,"value":19535},{"type":29,"tag":30,"props":22779,"children":22780},{},[22781,22783,22789],{"type":34,"value":22782},"Imaginons que nous ayons un système qui gère différentes sortes d'oiseaux. Nous avons une interface ",{"type":29,"tag":84,"props":22784,"children":22786},{"className":22785},[],[22787],{"type":34,"value":22788},"Bird",{"type":34,"value":22790}," qui contient des méthodes communes pour les oiseaux.",{"type":29,"tag":10576,"props":22792,"children":22794},{"id":22793},"exemple-sans-isp",[22795],{"type":34,"value":22796},"Exemple sans ISP :",{"type":29,"tag":30,"props":22798,"children":22799},{},[22800],{"type":34,"value":22801},"Voici une interface qui regroupe trop de responsabilités :",{"type":29,"tag":77,"props":22803,"children":22805},{"className":81,"code":22804,"language":80,"meta":8,"style":8},"public interface Bird {\n    void fly();\n    void swim();\n    void makeSound();\n}\n",[22806],{"type":29,"tag":84,"props":22807,"children":22808},{"__ignoreMap":8},[22809,22829,22845,22861,22877],{"type":29,"tag":88,"props":22810,"children":22811},{"class":90,"line":91},[22812,22816,22820,22825],{"type":29,"tag":88,"props":22813,"children":22814},{"style":105},[22815],{"type":34,"value":108},{"type":29,"tag":88,"props":22817,"children":22818},{"style":105},[22819],{"type":34,"value":601},{"type":29,"tag":88,"props":22821,"children":22822},{"style":116},[22823],{"type":34,"value":22824}," Bird",{"type":29,"tag":88,"props":22826,"children":22827},{"style":122},[22828],{"type":34,"value":125},{"type":29,"tag":88,"props":22830,"children":22831},{"class":90,"line":101},[22832,22836,22841],{"type":29,"tag":88,"props":22833,"children":22834},{"style":105},[22835],{"type":34,"value":681},{"type":29,"tag":88,"props":22837,"children":22838},{"style":174},[22839],{"type":34,"value":22840}," fly",{"type":29,"tag":88,"props":22842,"children":22843},{"style":122},[22844],{"type":34,"value":1810},{"type":29,"tag":88,"props":22846,"children":22847},{"class":90,"line":128},[22848,22852,22857],{"type":29,"tag":88,"props":22849,"children":22850},{"style":105},[22851],{"type":34,"value":681},{"type":29,"tag":88,"props":22853,"children":22854},{"style":174},[22855],{"type":34,"value":22856}," swim",{"type":29,"tag":88,"props":22858,"children":22859},{"style":122},[22860],{"type":34,"value":1810},{"type":29,"tag":88,"props":22862,"children":22863},{"class":90,"line":137},[22864,22868,22873],{"type":29,"tag":88,"props":22865,"children":22866},{"style":105},[22867],{"type":34,"value":681},{"type":29,"tag":88,"props":22869,"children":22870},{"style":174},[22871],{"type":34,"value":22872}," makeSound",{"type":29,"tag":88,"props":22874,"children":22875},{"style":122},[22876],{"type":34,"value":1810},{"type":29,"tag":88,"props":22878,"children":22879},{"class":90,"line":211},[22880],{"type":29,"tag":88,"props":22881,"children":22882},{"style":122},[22883],{"type":34,"value":442},{"type":29,"tag":30,"props":22885,"children":22886},{},[22887,22889,22895,22896,22902,22904,22910],{"type":34,"value":22888},"Toutes les classes qui implémentent cette interface devront fournir des implémentations pour ",{"type":29,"tag":84,"props":22890,"children":22892},{"className":22891},[],[22893],{"type":34,"value":22894},"fly()",{"type":34,"value":544},{"type":29,"tag":84,"props":22897,"children":22899},{"className":22898},[],[22900],{"type":34,"value":22901},"swim()",{"type":34,"value":22903},", et ",{"type":29,"tag":84,"props":22905,"children":22907},{"className":22906},[],[22908],{"type":34,"value":22909},"makeSound()",{"type":34,"value":22911},". 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":29,"tag":30,"props":22913,"children":22914},{},[22915],{"type":34,"value":22916},"Voici une implémentation pour un pingouin, qui enfreint clairement l'ISP :",{"type":29,"tag":77,"props":22918,"children":22920},{"className":81,"code":22919,"language":80,"meta":8,"style":8},"public class Penguin implements Bird {\n    @Override\n    public void fly() {\n        \u002F\u002F 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",[22921],{"type":29,"tag":84,"props":22922,"children":22923},{"__ignoreMap":8},[22924,22952,22963,22986,22994,23001,23008,23019,23042,23078,23085,23092,23103,23126,23162,23169],{"type":29,"tag":88,"props":22925,"children":22926},{"class":90,"line":91},[22927,22931,22935,22940,22944,22948],{"type":29,"tag":88,"props":22928,"children":22929},{"style":105},[22930],{"type":34,"value":108},{"type":29,"tag":88,"props":22932,"children":22933},{"style":105},[22934],{"type":34,"value":113},{"type":29,"tag":88,"props":22936,"children":22937},{"style":116},[22938],{"type":34,"value":22939}," Penguin",{"type":29,"tag":88,"props":22941,"children":22942},{"style":105},[22943],{"type":34,"value":1134},{"type":29,"tag":88,"props":22945,"children":22946},{"style":116},[22947],{"type":34,"value":22824},{"type":29,"tag":88,"props":22949,"children":22950},{"style":122},[22951],{"type":34,"value":125},{"type":29,"tag":88,"props":22953,"children":22954},{"class":90,"line":101},[22955,22959],{"type":29,"tag":88,"props":22956,"children":22957},{"style":1974},[22958],{"type":34,"value":3302},{"type":29,"tag":88,"props":22960,"children":22961},{"style":1980},[22962],{"type":34,"value":3307},{"type":29,"tag":88,"props":22964,"children":22965},{"class":90,"line":128},[22966,22970,22974,22978,22982],{"type":29,"tag":88,"props":22967,"children":22968},{"style":105},[22969],{"type":34,"value":276},{"type":29,"tag":88,"props":22971,"children":22972},{"style":105},[22973],{"type":34,"value":1303},{"type":29,"tag":88,"props":22975,"children":22976},{"style":174},[22977],{"type":34,"value":22840},{"type":29,"tag":88,"props":22979,"children":22980},{"style":122},[22981],{"type":34,"value":1470},{"type":29,"tag":88,"props":22983,"children":22984},{"style":122},[22985],{"type":34,"value":125},{"type":29,"tag":88,"props":22987,"children":22988},{"class":90,"line":137},[22989],{"type":29,"tag":88,"props":22990,"children":22991},{"style":95},[22992],{"type":34,"value":22993},"        \u002F\u002F Pingouin ne peut pas voler, on laisse la méthode vide\n",{"type":29,"tag":88,"props":22995,"children":22996},{"class":90,"line":211},[22997],{"type":29,"tag":88,"props":22998,"children":22999},{"style":122},[23000],{"type":34,"value":433},{"type":29,"tag":88,"props":23002,"children":23003},{"class":90,"line":262},[23004],{"type":29,"tag":88,"props":23005,"children":23006},{"emptyLinePlaceholder":13},[23007],{"type":34,"value":134},{"type":29,"tag":88,"props":23009,"children":23010},{"class":90,"line":270},[23011,23015],{"type":29,"tag":88,"props":23012,"children":23013},{"style":1974},[23014],{"type":34,"value":3302},{"type":29,"tag":88,"props":23016,"children":23017},{"style":1980},[23018],{"type":34,"value":3307},{"type":29,"tag":88,"props":23020,"children":23021},{"class":90,"line":313},[23022,23026,23030,23034,23038],{"type":29,"tag":88,"props":23023,"children":23024},{"style":105},[23025],{"type":34,"value":276},{"type":29,"tag":88,"props":23027,"children":23028},{"style":105},[23029],{"type":34,"value":1303},{"type":29,"tag":88,"props":23031,"children":23032},{"style":174},[23033],{"type":34,"value":22856},{"type":29,"tag":88,"props":23035,"children":23036},{"style":122},[23037],{"type":34,"value":1470},{"type":29,"tag":88,"props":23039,"children":23040},{"style":122},[23041],{"type":34,"value":125},{"type":29,"tag":88,"props":23043,"children":23044},{"class":90,"line":360},[23045,23049,23053,23057,23061,23065,23069,23074],{"type":29,"tag":88,"props":23046,"children":23047},{"style":157},[23048],{"type":34,"value":19726},{"type":29,"tag":88,"props":23050,"children":23051},{"style":122},[23052],{"type":34,"value":338},{"type":29,"tag":88,"props":23054,"children":23055},{"style":157},[23056],{"type":34,"value":18091},{"type":29,"tag":88,"props":23058,"children":23059},{"style":122},[23060],{"type":34,"value":338},{"type":29,"tag":88,"props":23062,"children":23063},{"style":174},[23064],{"type":34,"value":18100},{"type":29,"tag":88,"props":23066,"children":23067},{"style":122},[23068],{"type":34,"value":181},{"type":29,"tag":88,"props":23070,"children":23071},{"style":184},[23072],{"type":34,"value":23073},"\"Le pingouin nage.\"",{"type":29,"tag":88,"props":23075,"children":23076},{"style":122},[23077],{"type":34,"value":357},{"type":29,"tag":88,"props":23079,"children":23080},{"class":90,"line":409},[23081],{"type":29,"tag":88,"props":23082,"children":23083},{"style":122},[23084],{"type":34,"value":433},{"type":29,"tag":88,"props":23086,"children":23087},{"class":90,"line":427},[23088],{"type":29,"tag":88,"props":23089,"children":23090},{"emptyLinePlaceholder":13},[23091],{"type":34,"value":134},{"type":29,"tag":88,"props":23093,"children":23094},{"class":90,"line":436},[23095,23099],{"type":29,"tag":88,"props":23096,"children":23097},{"style":1974},[23098],{"type":34,"value":3302},{"type":29,"tag":88,"props":23100,"children":23101},{"style":1980},[23102],{"type":34,"value":3307},{"type":29,"tag":88,"props":23104,"children":23105},{"class":90,"line":767},[23106,23110,23114,23118,23122],{"type":29,"tag":88,"props":23107,"children":23108},{"style":105},[23109],{"type":34,"value":276},{"type":29,"tag":88,"props":23111,"children":23112},{"style":105},[23113],{"type":34,"value":1303},{"type":29,"tag":88,"props":23115,"children":23116},{"style":174},[23117],{"type":34,"value":22872},{"type":29,"tag":88,"props":23119,"children":23120},{"style":122},[23121],{"type":34,"value":1470},{"type":29,"tag":88,"props":23123,"children":23124},{"style":122},[23125],{"type":34,"value":125},{"type":29,"tag":88,"props":23127,"children":23128},{"class":90,"line":792},[23129,23133,23137,23141,23145,23149,23153,23158],{"type":29,"tag":88,"props":23130,"children":23131},{"style":157},[23132],{"type":34,"value":19726},{"type":29,"tag":88,"props":23134,"children":23135},{"style":122},[23136],{"type":34,"value":338},{"type":29,"tag":88,"props":23138,"children":23139},{"style":157},[23140],{"type":34,"value":18091},{"type":29,"tag":88,"props":23142,"children":23143},{"style":122},[23144],{"type":34,"value":338},{"type":29,"tag":88,"props":23146,"children":23147},{"style":174},[23148],{"type":34,"value":18100},{"type":29,"tag":88,"props":23150,"children":23151},{"style":122},[23152],{"type":34,"value":181},{"type":29,"tag":88,"props":23154,"children":23155},{"style":184},[23156],{"type":34,"value":23157},"\"Le pingouin émet un son.\"",{"type":29,"tag":88,"props":23159,"children":23160},{"style":122},[23161],{"type":34,"value":357},{"type":29,"tag":88,"props":23163,"children":23164},{"class":90,"line":817},[23165],{"type":29,"tag":88,"props":23166,"children":23167},{"style":122},[23168],{"type":34,"value":433},{"type":29,"tag":88,"props":23170,"children":23171},{"class":90,"line":825},[23172],{"type":29,"tag":88,"props":23173,"children":23174},{"style":122},[23175],{"type":34,"value":442},{"type":29,"tag":30,"props":23177,"children":23178},{},[23179,23181,23186,23188,23193],{"type":34,"value":23180},"La méthode ",{"type":29,"tag":84,"props":23182,"children":23184},{"className":23183},[],[23185],{"type":34,"value":22894},{"type":34,"value":23187}," est ici inutile, mais nous devons quand même la définir parce que l'interface ",{"type":29,"tag":84,"props":23189,"children":23191},{"className":23190},[],[23192],{"type":34,"value":22788},{"type":34,"value":23194}," l'impose. Cela entraîne du code mort et une mauvaise conception.",{"type":29,"tag":10576,"props":23196,"children":23198},{"id":23197},"exemple-avec-isp-appliqué",[23199],{"type":34,"value":23200},"Exemple avec ISP appliqué :",{"type":29,"tag":30,"props":23202,"children":23203},{},[23204,23206,23211],{"type":34,"value":23205},"Pour corriger cela, nous allons séparer l'interface ",{"type":29,"tag":84,"props":23207,"children":23209},{"className":23208},[],[23210],{"type":34,"value":22788},{"type":34,"value":23212}," en plusieurs petites interfaces spécifiques à des capacités d’oiseaux.",{"type":29,"tag":77,"props":23214,"children":23216},{"className":81,"code":23215,"language":80,"meta":8,"style":8},"\u002F\u002F Interface pour les oiseaux qui volent\npublic interface FlyingBird {\n    void fly();\n}\n\n\u002F\u002F Interface pour les oiseaux qui nagent\npublic interface SwimmingBird {\n    void swim();\n}\n\n\u002F\u002F Interface pour les oiseaux qui émettent des sons\npublic interface SoundingBird {\n    void makeSound();\n}\n",[23217],{"type":29,"tag":84,"props":23218,"children":23219},{"__ignoreMap":8},[23220,23228,23248,23263,23270,23277,23285,23305,23320,23327,23334,23342,23362,23377],{"type":29,"tag":88,"props":23221,"children":23222},{"class":90,"line":91},[23223],{"type":29,"tag":88,"props":23224,"children":23225},{"style":95},[23226],{"type":34,"value":23227},"\u002F\u002F Interface pour les oiseaux qui volent\n",{"type":29,"tag":88,"props":23229,"children":23230},{"class":90,"line":101},[23231,23235,23239,23244],{"type":29,"tag":88,"props":23232,"children":23233},{"style":105},[23234],{"type":34,"value":108},{"type":29,"tag":88,"props":23236,"children":23237},{"style":105},[23238],{"type":34,"value":601},{"type":29,"tag":88,"props":23240,"children":23241},{"style":116},[23242],{"type":34,"value":23243}," FlyingBird",{"type":29,"tag":88,"props":23245,"children":23246},{"style":122},[23247],{"type":34,"value":125},{"type":29,"tag":88,"props":23249,"children":23250},{"class":90,"line":128},[23251,23255,23259],{"type":29,"tag":88,"props":23252,"children":23253},{"style":105},[23254],{"type":34,"value":681},{"type":29,"tag":88,"props":23256,"children":23257},{"style":174},[23258],{"type":34,"value":22840},{"type":29,"tag":88,"props":23260,"children":23261},{"style":122},[23262],{"type":34,"value":1810},{"type":29,"tag":88,"props":23264,"children":23265},{"class":90,"line":137},[23266],{"type":29,"tag":88,"props":23267,"children":23268},{"style":122},[23269],{"type":34,"value":442},{"type":29,"tag":88,"props":23271,"children":23272},{"class":90,"line":211},[23273],{"type":29,"tag":88,"props":23274,"children":23275},{"emptyLinePlaceholder":13},[23276],{"type":34,"value":134},{"type":29,"tag":88,"props":23278,"children":23279},{"class":90,"line":262},[23280],{"type":29,"tag":88,"props":23281,"children":23282},{"style":95},[23283],{"type":34,"value":23284},"\u002F\u002F Interface pour les oiseaux qui nagent\n",{"type":29,"tag":88,"props":23286,"children":23287},{"class":90,"line":270},[23288,23292,23296,23301],{"type":29,"tag":88,"props":23289,"children":23290},{"style":105},[23291],{"type":34,"value":108},{"type":29,"tag":88,"props":23293,"children":23294},{"style":105},[23295],{"type":34,"value":601},{"type":29,"tag":88,"props":23297,"children":23298},{"style":116},[23299],{"type":34,"value":23300}," SwimmingBird",{"type":29,"tag":88,"props":23302,"children":23303},{"style":122},[23304],{"type":34,"value":125},{"type":29,"tag":88,"props":23306,"children":23307},{"class":90,"line":313},[23308,23312,23316],{"type":29,"tag":88,"props":23309,"children":23310},{"style":105},[23311],{"type":34,"value":681},{"type":29,"tag":88,"props":23313,"children":23314},{"style":174},[23315],{"type":34,"value":22856},{"type":29,"tag":88,"props":23317,"children":23318},{"style":122},[23319],{"type":34,"value":1810},{"type":29,"tag":88,"props":23321,"children":23322},{"class":90,"line":360},[23323],{"type":29,"tag":88,"props":23324,"children":23325},{"style":122},[23326],{"type":34,"value":442},{"type":29,"tag":88,"props":23328,"children":23329},{"class":90,"line":409},[23330],{"type":29,"tag":88,"props":23331,"children":23332},{"emptyLinePlaceholder":13},[23333],{"type":34,"value":134},{"type":29,"tag":88,"props":23335,"children":23336},{"class":90,"line":427},[23337],{"type":29,"tag":88,"props":23338,"children":23339},{"style":95},[23340],{"type":34,"value":23341},"\u002F\u002F Interface pour les oiseaux qui émettent des sons\n",{"type":29,"tag":88,"props":23343,"children":23344},{"class":90,"line":436},[23345,23349,23353,23358],{"type":29,"tag":88,"props":23346,"children":23347},{"style":105},[23348],{"type":34,"value":108},{"type":29,"tag":88,"props":23350,"children":23351},{"style":105},[23352],{"type":34,"value":601},{"type":29,"tag":88,"props":23354,"children":23355},{"style":116},[23356],{"type":34,"value":23357}," SoundingBird",{"type":29,"tag":88,"props":23359,"children":23360},{"style":122},[23361],{"type":34,"value":125},{"type":29,"tag":88,"props":23363,"children":23364},{"class":90,"line":767},[23365,23369,23373],{"type":29,"tag":88,"props":23366,"children":23367},{"style":105},[23368],{"type":34,"value":681},{"type":29,"tag":88,"props":23370,"children":23371},{"style":174},[23372],{"type":34,"value":22872},{"type":29,"tag":88,"props":23374,"children":23375},{"style":122},[23376],{"type":34,"value":1810},{"type":29,"tag":88,"props":23378,"children":23379},{"class":90,"line":792},[23380],{"type":29,"tag":88,"props":23381,"children":23382},{"style":122},[23383],{"type":34,"value":442},{"type":29,"tag":30,"props":23385,"children":23386},{},[23387],{"type":34,"value":23388},"Maintenant, nous pouvons créer des classes qui implémentent uniquement les interfaces dont elles ont besoin :",{"type":29,"tag":77,"props":23390,"children":23392},{"className":81,"code":23391,"language":80,"meta":8,"style":8},"\u002F\u002F 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\u002F\u002F 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",[23393],{"type":29,"tag":84,"props":23394,"children":23395},{"__ignoreMap":8},[23396,23404,23439,23450,23473,23508,23515,23522,23533,23556,23591,23598,23605,23612,23620,23656,23667,23690,23726,23733,23740,23751,23774,23810,23817],{"type":29,"tag":88,"props":23397,"children":23398},{"class":90,"line":91},[23399],{"type":29,"tag":88,"props":23400,"children":23401},{"style":95},[23402],{"type":34,"value":23403},"\u002F\u002F Le pingouin nage et émet des sons, mais ne vole pas\n",{"type":29,"tag":88,"props":23405,"children":23406},{"class":90,"line":101},[23407,23411,23415,23419,23423,23427,23431,23435],{"type":29,"tag":88,"props":23408,"children":23409},{"style":105},[23410],{"type":34,"value":108},{"type":29,"tag":88,"props":23412,"children":23413},{"style":105},[23414],{"type":34,"value":113},{"type":29,"tag":88,"props":23416,"children":23417},{"style":116},[23418],{"type":34,"value":22939},{"type":29,"tag":88,"props":23420,"children":23421},{"style":105},[23422],{"type":34,"value":1134},{"type":29,"tag":88,"props":23424,"children":23425},{"style":116},[23426],{"type":34,"value":23300},{"type":29,"tag":88,"props":23428,"children":23429},{"style":122},[23430],{"type":34,"value":192},{"type":29,"tag":88,"props":23432,"children":23433},{"style":116},[23434],{"type":34,"value":23357},{"type":29,"tag":88,"props":23436,"children":23437},{"style":122},[23438],{"type":34,"value":125},{"type":29,"tag":88,"props":23440,"children":23441},{"class":90,"line":128},[23442,23446],{"type":29,"tag":88,"props":23443,"children":23444},{"style":1974},[23445],{"type":34,"value":3302},{"type":29,"tag":88,"props":23447,"children":23448},{"style":1980},[23449],{"type":34,"value":3307},{"type":29,"tag":88,"props":23451,"children":23452},{"class":90,"line":137},[23453,23457,23461,23465,23469],{"type":29,"tag":88,"props":23454,"children":23455},{"style":105},[23456],{"type":34,"value":276},{"type":29,"tag":88,"props":23458,"children":23459},{"style":105},[23460],{"type":34,"value":1303},{"type":29,"tag":88,"props":23462,"children":23463},{"style":174},[23464],{"type":34,"value":22856},{"type":29,"tag":88,"props":23466,"children":23467},{"style":122},[23468],{"type":34,"value":1470},{"type":29,"tag":88,"props":23470,"children":23471},{"style":122},[23472],{"type":34,"value":125},{"type":29,"tag":88,"props":23474,"children":23475},{"class":90,"line":211},[23476,23480,23484,23488,23492,23496,23500,23504],{"type":29,"tag":88,"props":23477,"children":23478},{"style":157},[23479],{"type":34,"value":19726},{"type":29,"tag":88,"props":23481,"children":23482},{"style":122},[23483],{"type":34,"value":338},{"type":29,"tag":88,"props":23485,"children":23486},{"style":157},[23487],{"type":34,"value":18091},{"type":29,"tag":88,"props":23489,"children":23490},{"style":122},[23491],{"type":34,"value":338},{"type":29,"tag":88,"props":23493,"children":23494},{"style":174},[23495],{"type":34,"value":18100},{"type":29,"tag":88,"props":23497,"children":23498},{"style":122},[23499],{"type":34,"value":181},{"type":29,"tag":88,"props":23501,"children":23502},{"style":184},[23503],{"type":34,"value":23073},{"type":29,"tag":88,"props":23505,"children":23506},{"style":122},[23507],{"type":34,"value":357},{"type":29,"tag":88,"props":23509,"children":23510},{"class":90,"line":262},[23511],{"type":29,"tag":88,"props":23512,"children":23513},{"style":122},[23514],{"type":34,"value":433},{"type":29,"tag":88,"props":23516,"children":23517},{"class":90,"line":270},[23518],{"type":29,"tag":88,"props":23519,"children":23520},{"emptyLinePlaceholder":13},[23521],{"type":34,"value":134},{"type":29,"tag":88,"props":23523,"children":23524},{"class":90,"line":313},[23525,23529],{"type":29,"tag":88,"props":23526,"children":23527},{"style":1974},[23528],{"type":34,"value":3302},{"type":29,"tag":88,"props":23530,"children":23531},{"style":1980},[23532],{"type":34,"value":3307},{"type":29,"tag":88,"props":23534,"children":23535},{"class":90,"line":360},[23536,23540,23544,23548,23552],{"type":29,"tag":88,"props":23537,"children":23538},{"style":105},[23539],{"type":34,"value":276},{"type":29,"tag":88,"props":23541,"children":23542},{"style":105},[23543],{"type":34,"value":1303},{"type":29,"tag":88,"props":23545,"children":23546},{"style":174},[23547],{"type":34,"value":22872},{"type":29,"tag":88,"props":23549,"children":23550},{"style":122},[23551],{"type":34,"value":1470},{"type":29,"tag":88,"props":23553,"children":23554},{"style":122},[23555],{"type":34,"value":125},{"type":29,"tag":88,"props":23557,"children":23558},{"class":90,"line":409},[23559,23563,23567,23571,23575,23579,23583,23587],{"type":29,"tag":88,"props":23560,"children":23561},{"style":157},[23562],{"type":34,"value":19726},{"type":29,"tag":88,"props":23564,"children":23565},{"style":122},[23566],{"type":34,"value":338},{"type":29,"tag":88,"props":23568,"children":23569},{"style":157},[23570],{"type":34,"value":18091},{"type":29,"tag":88,"props":23572,"children":23573},{"style":122},[23574],{"type":34,"value":338},{"type":29,"tag":88,"props":23576,"children":23577},{"style":174},[23578],{"type":34,"value":18100},{"type":29,"tag":88,"props":23580,"children":23581},{"style":122},[23582],{"type":34,"value":181},{"type":29,"tag":88,"props":23584,"children":23585},{"style":184},[23586],{"type":34,"value":23157},{"type":29,"tag":88,"props":23588,"children":23589},{"style":122},[23590],{"type":34,"value":357},{"type":29,"tag":88,"props":23592,"children":23593},{"class":90,"line":427},[23594],{"type":29,"tag":88,"props":23595,"children":23596},{"style":122},[23597],{"type":34,"value":433},{"type":29,"tag":88,"props":23599,"children":23600},{"class":90,"line":436},[23601],{"type":29,"tag":88,"props":23602,"children":23603},{"style":122},[23604],{"type":34,"value":442},{"type":29,"tag":88,"props":23606,"children":23607},{"class":90,"line":767},[23608],{"type":29,"tag":88,"props":23609,"children":23610},{"emptyLinePlaceholder":13},[23611],{"type":34,"value":134},{"type":29,"tag":88,"props":23613,"children":23614},{"class":90,"line":792},[23615],{"type":29,"tag":88,"props":23616,"children":23617},{"style":95},[23618],{"type":34,"value":23619},"\u002F\u002F L'aigle vole et émet des sons\n",{"type":29,"tag":88,"props":23621,"children":23622},{"class":90,"line":817},[23623,23627,23631,23636,23640,23644,23648,23652],{"type":29,"tag":88,"props":23624,"children":23625},{"style":105},[23626],{"type":34,"value":108},{"type":29,"tag":88,"props":23628,"children":23629},{"style":105},[23630],{"type":34,"value":113},{"type":29,"tag":88,"props":23632,"children":23633},{"style":116},[23634],{"type":34,"value":23635}," Eagle",{"type":29,"tag":88,"props":23637,"children":23638},{"style":105},[23639],{"type":34,"value":1134},{"type":29,"tag":88,"props":23641,"children":23642},{"style":116},[23643],{"type":34,"value":23243},{"type":29,"tag":88,"props":23645,"children":23646},{"style":122},[23647],{"type":34,"value":192},{"type":29,"tag":88,"props":23649,"children":23650},{"style":116},[23651],{"type":34,"value":23357},{"type":29,"tag":88,"props":23653,"children":23654},{"style":122},[23655],{"type":34,"value":125},{"type":29,"tag":88,"props":23657,"children":23658},{"class":90,"line":825},[23659,23663],{"type":29,"tag":88,"props":23660,"children":23661},{"style":1974},[23662],{"type":34,"value":3302},{"type":29,"tag":88,"props":23664,"children":23665},{"style":1980},[23666],{"type":34,"value":3307},{"type":29,"tag":88,"props":23668,"children":23669},{"class":90,"line":869},[23670,23674,23678,23682,23686],{"type":29,"tag":88,"props":23671,"children":23672},{"style":105},[23673],{"type":34,"value":276},{"type":29,"tag":88,"props":23675,"children":23676},{"style":105},[23677],{"type":34,"value":1303},{"type":29,"tag":88,"props":23679,"children":23680},{"style":174},[23681],{"type":34,"value":22840},{"type":29,"tag":88,"props":23683,"children":23684},{"style":122},[23685],{"type":34,"value":1470},{"type":29,"tag":88,"props":23687,"children":23688},{"style":122},[23689],{"type":34,"value":125},{"type":29,"tag":88,"props":23691,"children":23692},{"class":90,"line":900},[23693,23697,23701,23705,23709,23713,23717,23722],{"type":29,"tag":88,"props":23694,"children":23695},{"style":157},[23696],{"type":34,"value":19726},{"type":29,"tag":88,"props":23698,"children":23699},{"style":122},[23700],{"type":34,"value":338},{"type":29,"tag":88,"props":23702,"children":23703},{"style":157},[23704],{"type":34,"value":18091},{"type":29,"tag":88,"props":23706,"children":23707},{"style":122},[23708],{"type":34,"value":338},{"type":29,"tag":88,"props":23710,"children":23711},{"style":174},[23712],{"type":34,"value":18100},{"type":29,"tag":88,"props":23714,"children":23715},{"style":122},[23716],{"type":34,"value":181},{"type":29,"tag":88,"props":23718,"children":23719},{"style":184},[23720],{"type":34,"value":23721},"\"L'aigle vole.\"",{"type":29,"tag":88,"props":23723,"children":23724},{"style":122},[23725],{"type":34,"value":357},{"type":29,"tag":88,"props":23727,"children":23728},{"class":90,"line":929},[23729],{"type":29,"tag":88,"props":23730,"children":23731},{"style":122},[23732],{"type":34,"value":433},{"type":29,"tag":88,"props":23734,"children":23735},{"class":90,"line":937},[23736],{"type":29,"tag":88,"props":23737,"children":23738},{"emptyLinePlaceholder":13},[23739],{"type":34,"value":134},{"type":29,"tag":88,"props":23741,"children":23742},{"class":90,"line":945},[23743,23747],{"type":29,"tag":88,"props":23744,"children":23745},{"style":1974},[23746],{"type":34,"value":3302},{"type":29,"tag":88,"props":23748,"children":23749},{"style":1980},[23750],{"type":34,"value":3307},{"type":29,"tag":88,"props":23752,"children":23753},{"class":90,"line":981},[23754,23758,23762,23766,23770],{"type":29,"tag":88,"props":23755,"children":23756},{"style":105},[23757],{"type":34,"value":276},{"type":29,"tag":88,"props":23759,"children":23760},{"style":105},[23761],{"type":34,"value":1303},{"type":29,"tag":88,"props":23763,"children":23764},{"style":174},[23765],{"type":34,"value":22872},{"type":29,"tag":88,"props":23767,"children":23768},{"style":122},[23769],{"type":34,"value":1470},{"type":29,"tag":88,"props":23771,"children":23772},{"style":122},[23773],{"type":34,"value":125},{"type":29,"tag":88,"props":23775,"children":23776},{"class":90,"line":1021},[23777,23781,23785,23789,23793,23797,23801,23806],{"type":29,"tag":88,"props":23778,"children":23779},{"style":157},[23780],{"type":34,"value":19726},{"type":29,"tag":88,"props":23782,"children":23783},{"style":122},[23784],{"type":34,"value":338},{"type":29,"tag":88,"props":23786,"children":23787},{"style":157},[23788],{"type":34,"value":18091},{"type":29,"tag":88,"props":23790,"children":23791},{"style":122},[23792],{"type":34,"value":338},{"type":29,"tag":88,"props":23794,"children":23795},{"style":174},[23796],{"type":34,"value":18100},{"type":29,"tag":88,"props":23798,"children":23799},{"style":122},[23800],{"type":34,"value":181},{"type":29,"tag":88,"props":23802,"children":23803},{"style":184},[23804],{"type":34,"value":23805},"\"L'aigle émet un son.\"",{"type":29,"tag":88,"props":23807,"children":23808},{"style":122},[23809],{"type":34,"value":357},{"type":29,"tag":88,"props":23811,"children":23812},{"class":90,"line":1066},[23813],{"type":29,"tag":88,"props":23814,"children":23815},{"style":122},[23816],{"type":34,"value":433},{"type":29,"tag":88,"props":23818,"children":23819},{"class":90,"line":1082},[23820],{"type":29,"tag":88,"props":23821,"children":23822},{"style":122},[23823],{"type":34,"value":442},{"type":29,"tag":47,"props":23825,"children":23826},{},[],{"type":29,"tag":8526,"props":23828,"children":23829},{"type":8528},[23830],{"type":29,"tag":30,"props":23831,"children":23832},{},[23833,23838],{"type":29,"tag":447,"props":23834,"children":23835},{},[23836],{"type":34,"value":23837},"Divisez vos interfaces selon les besoins réels",{"type":34,"value":23839},". 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":29,"tag":51,"props":23841,"children":23843},{"id":23842},"_5-principe-dinversion-des-dépendances-dependency-inversion-principle-dip",[23844],{"type":34,"value":23845},"5. Principe d'Inversion des Dépendances (Dependency Inversion Principle - DIP)",{"type":29,"tag":30,"props":23847,"children":23848},{},[23849],{"type":34,"value":23850},"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":29,"tag":8542,"props":23852,"children":23854},{"id":23853},"pourquoi-cest-important-4",[23855],{"type":34,"value":19524},{"type":29,"tag":30,"props":23857,"children":23858},{},[23859],{"type":34,"value":23860},"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":29,"tag":8542,"props":23862,"children":23864},{"id":23863},"exemple-concret-en-java-4",[23865],{"type":34,"value":19535},{"type":29,"tag":30,"props":23867,"children":23868},{},[23869,23870,23876],{"type":34,"value":21579},{"type":29,"tag":84,"props":23871,"children":23873},{"className":23872},[],[23874],{"type":34,"value":23875},"NotificationService",{"type":34,"value":23877}," 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":29,"tag":10576,"props":23879,"children":23881},{"id":23880},"exemple-sans-dip",[23882],{"type":34,"value":23883},"Exemple sans DIP :",{"type":29,"tag":30,"props":23885,"children":23886},{},[23887,23889,23895],{"type":34,"value":23888},"Voici une implémentation où le service de notification dépend directement de la classe ",{"type":29,"tag":84,"props":23890,"children":23892},{"className":23891},[],[23893],{"type":34,"value":23894},"EmailService",{"type":34,"value":21063},{"type":29,"tag":77,"props":23897,"children":23899},{"className":81,"code":23898,"language":80,"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",[23900],{"type":29,"tag":84,"props":23901,"children":23902},{"__ignoreMap":8},[23903,23922,23959,24003,24010,24017,24024,24043,24062,24069,24088,24119,24126,24133,24169,24198,24205],{"type":29,"tag":88,"props":23904,"children":23905},{"class":90,"line":91},[23906,23910,23914,23918],{"type":29,"tag":88,"props":23907,"children":23908},{"style":105},[23909],{"type":34,"value":108},{"type":29,"tag":88,"props":23911,"children":23912},{"style":105},[23913],{"type":34,"value":113},{"type":29,"tag":88,"props":23915,"children":23916},{"style":116},[23917],{"type":34,"value":7300},{"type":29,"tag":88,"props":23919,"children":23920},{"style":122},[23921],{"type":34,"value":125},{"type":29,"tag":88,"props":23923,"children":23924},{"class":90,"line":101},[23925,23929,23933,23938,23942,23946,23951,23955],{"type":29,"tag":88,"props":23926,"children":23927},{"style":105},[23928],{"type":34,"value":276},{"type":29,"tag":88,"props":23930,"children":23931},{"style":105},[23932],{"type":34,"value":1303},{"type":29,"tag":88,"props":23934,"children":23935},{"style":174},[23936],{"type":34,"value":23937}," sendEmail",{"type":29,"tag":88,"props":23939,"children":23940},{"style":122},[23941],{"type":34,"value":181},{"type":29,"tag":88,"props":23943,"children":23944},{"style":151},[23945],{"type":34,"value":695},{"type":29,"tag":88,"props":23947,"children":23948},{"style":298},[23949],{"type":34,"value":23950}," message",{"type":29,"tag":88,"props":23952,"children":23953},{"style":122},[23954],{"type":34,"value":306},{"type":29,"tag":88,"props":23956,"children":23957},{"style":122},[23958],{"type":34,"value":125},{"type":29,"tag":88,"props":23960,"children":23961},{"class":90,"line":128},[23962,23966,23970,23974,23978,23982,23986,23991,23995,23999],{"type":29,"tag":88,"props":23963,"children":23964},{"style":157},[23965],{"type":34,"value":19726},{"type":29,"tag":88,"props":23967,"children":23968},{"style":122},[23969],{"type":34,"value":338},{"type":29,"tag":88,"props":23971,"children":23972},{"style":157},[23973],{"type":34,"value":18091},{"type":29,"tag":88,"props":23975,"children":23976},{"style":122},[23977],{"type":34,"value":338},{"type":29,"tag":88,"props":23979,"children":23980},{"style":174},[23981],{"type":34,"value":18100},{"type":29,"tag":88,"props":23983,"children":23984},{"style":122},[23985],{"type":34,"value":181},{"type":29,"tag":88,"props":23987,"children":23988},{"style":184},[23989],{"type":34,"value":23990},"\"Envoi de l'email : \"",{"type":29,"tag":88,"props":23992,"children":23993},{"style":163},[23994],{"type":34,"value":5485},{"type":29,"tag":88,"props":23996,"children":23997},{"style":157},[23998],{"type":34,"value":23950},{"type":29,"tag":88,"props":24000,"children":24001},{"style":122},[24002],{"type":34,"value":357},{"type":29,"tag":88,"props":24004,"children":24005},{"class":90,"line":137},[24006],{"type":29,"tag":88,"props":24007,"children":24008},{"style":122},[24009],{"type":34,"value":433},{"type":29,"tag":88,"props":24011,"children":24012},{"class":90,"line":211},[24013],{"type":29,"tag":88,"props":24014,"children":24015},{"style":122},[24016],{"type":34,"value":442},{"type":29,"tag":88,"props":24018,"children":24019},{"class":90,"line":262},[24020],{"type":29,"tag":88,"props":24021,"children":24022},{"emptyLinePlaceholder":13},[24023],{"type":34,"value":134},{"type":29,"tag":88,"props":24025,"children":24026},{"class":90,"line":270},[24027,24031,24035,24039],{"type":29,"tag":88,"props":24028,"children":24029},{"style":105},[24030],{"type":34,"value":108},{"type":29,"tag":88,"props":24032,"children":24033},{"style":105},[24034],{"type":34,"value":113},{"type":29,"tag":88,"props":24036,"children":24037},{"style":116},[24038],{"type":34,"value":4662},{"type":29,"tag":88,"props":24040,"children":24041},{"style":122},[24042],{"type":34,"value":125},{"type":29,"tag":88,"props":24044,"children":24045},{"class":90,"line":313},[24046,24050,24054,24058],{"type":29,"tag":88,"props":24047,"children":24048},{"style":105},[24049],{"type":34,"value":143},{"type":29,"tag":88,"props":24051,"children":24052},{"style":151},[24053],{"type":34,"value":7300},{"type":29,"tag":88,"props":24055,"children":24056},{"style":157},[24057],{"type":34,"value":7305},{"type":29,"tag":88,"props":24059,"children":24060},{"style":122},[24061],{"type":34,"value":424},{"type":29,"tag":88,"props":24063,"children":24064},{"class":90,"line":360},[24065],{"type":29,"tag":88,"props":24066,"children":24067},{"emptyLinePlaceholder":13},[24068],{"type":34,"value":134},{"type":29,"tag":88,"props":24070,"children":24071},{"class":90,"line":409},[24072,24076,24080,24084],{"type":29,"tag":88,"props":24073,"children":24074},{"style":105},[24075],{"type":34,"value":276},{"type":29,"tag":88,"props":24077,"children":24078},{"style":174},[24079],{"type":34,"value":4662},{"type":29,"tag":88,"props":24081,"children":24082},{"style":122},[24083],{"type":34,"value":1470},{"type":29,"tag":88,"props":24085,"children":24086},{"style":122},[24087],{"type":34,"value":125},{"type":29,"tag":88,"props":24089,"children":24090},{"class":90,"line":427},[24091,24095,24099,24103,24107,24111,24115],{"type":29,"tag":88,"props":24092,"children":24093},{"style":873},[24094],{"type":34,"value":876},{"type":29,"tag":88,"props":24096,"children":24097},{"style":122},[24098],{"type":34,"value":338},{"type":29,"tag":88,"props":24100,"children":24101},{"style":157},[24102],{"type":34,"value":7404},{"type":29,"tag":88,"props":24104,"children":24105},{"style":163},[24106],{"type":34,"value":166},{"type":29,"tag":88,"props":24108,"children":24109},{"style":105},[24110],{"type":34,"value":171},{"type":29,"tag":88,"props":24112,"children":24113},{"style":174},[24114],{"type":34,"value":7300},{"type":29,"tag":88,"props":24116,"children":24117},{"style":122},[24118],{"type":34,"value":1810},{"type":29,"tag":88,"props":24120,"children":24121},{"class":90,"line":436},[24122],{"type":29,"tag":88,"props":24123,"children":24124},{"style":122},[24125],{"type":34,"value":433},{"type":29,"tag":88,"props":24127,"children":24128},{"class":90,"line":767},[24129],{"type":29,"tag":88,"props":24130,"children":24131},{"emptyLinePlaceholder":13},[24132],{"type":34,"value":134},{"type":29,"tag":88,"props":24134,"children":24135},{"class":90,"line":792},[24136,24140,24144,24149,24153,24157,24161,24165],{"type":29,"tag":88,"props":24137,"children":24138},{"style":105},[24139],{"type":34,"value":276},{"type":29,"tag":88,"props":24141,"children":24142},{"style":105},[24143],{"type":34,"value":1303},{"type":29,"tag":88,"props":24145,"children":24146},{"style":174},[24147],{"type":34,"value":24148}," sendNotification",{"type":29,"tag":88,"props":24150,"children":24151},{"style":122},[24152],{"type":34,"value":181},{"type":29,"tag":88,"props":24154,"children":24155},{"style":151},[24156],{"type":34,"value":695},{"type":29,"tag":88,"props":24158,"children":24159},{"style":298},[24160],{"type":34,"value":23950},{"type":29,"tag":88,"props":24162,"children":24163},{"style":122},[24164],{"type":34,"value":306},{"type":29,"tag":88,"props":24166,"children":24167},{"style":122},[24168],{"type":34,"value":125},{"type":29,"tag":88,"props":24170,"children":24171},{"class":90,"line":817},[24172,24176,24180,24185,24189,24194],{"type":29,"tag":88,"props":24173,"children":24174},{"style":157},[24175],{"type":34,"value":7670},{"type":29,"tag":88,"props":24177,"children":24178},{"style":122},[24179],{"type":34,"value":338},{"type":29,"tag":88,"props":24181,"children":24182},{"style":174},[24183],{"type":34,"value":24184},"sendEmail",{"type":29,"tag":88,"props":24186,"children":24187},{"style":122},[24188],{"type":34,"value":181},{"type":29,"tag":88,"props":24190,"children":24191},{"style":157},[24192],{"type":34,"value":24193},"message",{"type":29,"tag":88,"props":24195,"children":24196},{"style":122},[24197],{"type":34,"value":357},{"type":29,"tag":88,"props":24199,"children":24200},{"class":90,"line":825},[24201],{"type":29,"tag":88,"props":24202,"children":24203},{"style":122},[24204],{"type":34,"value":433},{"type":29,"tag":88,"props":24206,"children":24207},{"class":90,"line":869},[24208],{"type":29,"tag":88,"props":24209,"children":24210},{"style":122},[24211],{"type":34,"value":442},{"type":29,"tag":30,"props":24213,"children":24214},{},[24215,24217,24222,24224,24229,24231,24236],{"type":34,"value":24216},"Dans cet exemple, ",{"type":29,"tag":84,"props":24218,"children":24220},{"className":24219},[],[24221],{"type":34,"value":23875},{"type":34,"value":24223}," est étroitement couplé à ",{"type":29,"tag":84,"props":24225,"children":24227},{"className":24226},[],[24228],{"type":34,"value":23894},{"type":34,"value":24230},". Si nous voulions envoyer une notification par SMS au lieu d’un email, nous devrions modifier la classe ",{"type":29,"tag":84,"props":24232,"children":24234},{"className":24233},[],[24235],{"type":34,"value":23875},{"type":34,"value":24237},", ce qui va à l'encontre du principe DIP.",{"type":29,"tag":10576,"props":24239,"children":24241},{"id":24240},"exemple-avec-dip-appliqué",[24242],{"type":34,"value":24243},"Exemple avec DIP appliqué :",{"type":29,"tag":30,"props":24245,"children":24246},{},[24247,24249,24255],{"type":34,"value":24248},"Pour respecter le principe d'inversion des dépendances, nous allons introduire une abstraction sous forme d'une interface ",{"type":29,"tag":84,"props":24250,"children":24252},{"className":24251},[],[24253],{"type":34,"value":24254},"NotificationSender",{"type":34,"value":24256}," que toutes les implémentations concrètes (Email, SMS, etc.) respecteront.",{"type":29,"tag":77,"props":24258,"children":24260},{"className":81,"code":24259,"language":80,"meta":8,"style":8},"\u002F\u002F Interface pour les services d'envoi de notifications\npublic interface NotificationSender {\n    void send(String message);\n}\n\n\u002F\u002F 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\u002F\u002F 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\u002F\u002F Service de notification utilisant l'interface NotificationSender\npublic class NotificationService {\n    private NotificationSender sender;\n\n    \u002F\u002F 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",[24261],{"type":29,"tag":84,"props":24262,"children":24263},{"__ignoreMap":8},[24264,24272,24292,24320,24327,24334,24342,24370,24381,24416,24459,24466,24473,24480,24488,24516,24527,24562,24606,24613,24620,24627,24635,24654,24674,24681,24689,24720,24748,24755,24762,24797,24825,24832],{"type":29,"tag":88,"props":24265,"children":24266},{"class":90,"line":91},[24267],{"type":29,"tag":88,"props":24268,"children":24269},{"style":95},[24270],{"type":34,"value":24271},"\u002F\u002F Interface pour les services d'envoi de notifications\n",{"type":29,"tag":88,"props":24273,"children":24274},{"class":90,"line":101},[24275,24279,24283,24288],{"type":29,"tag":88,"props":24276,"children":24277},{"style":105},[24278],{"type":34,"value":108},{"type":29,"tag":88,"props":24280,"children":24281},{"style":105},[24282],{"type":34,"value":601},{"type":29,"tag":88,"props":24284,"children":24285},{"style":116},[24286],{"type":34,"value":24287}," NotificationSender",{"type":29,"tag":88,"props":24289,"children":24290},{"style":122},[24291],{"type":34,"value":125},{"type":29,"tag":88,"props":24293,"children":24294},{"class":90,"line":128},[24295,24299,24304,24308,24312,24316],{"type":29,"tag":88,"props":24296,"children":24297},{"style":105},[24298],{"type":34,"value":681},{"type":29,"tag":88,"props":24300,"children":24301},{"style":174},[24302],{"type":34,"value":24303}," send",{"type":29,"tag":88,"props":24305,"children":24306},{"style":122},[24307],{"type":34,"value":181},{"type":29,"tag":88,"props":24309,"children":24310},{"style":151},[24311],{"type":34,"value":695},{"type":29,"tag":88,"props":24313,"children":24314},{"style":298},[24315],{"type":34,"value":23950},{"type":29,"tag":88,"props":24317,"children":24318},{"style":122},[24319],{"type":34,"value":357},{"type":29,"tag":88,"props":24321,"children":24322},{"class":90,"line":137},[24323],{"type":29,"tag":88,"props":24324,"children":24325},{"style":122},[24326],{"type":34,"value":442},{"type":29,"tag":88,"props":24328,"children":24329},{"class":90,"line":211},[24330],{"type":29,"tag":88,"props":24331,"children":24332},{"emptyLinePlaceholder":13},[24333],{"type":34,"value":134},{"type":29,"tag":88,"props":24335,"children":24336},{"class":90,"line":262},[24337],{"type":29,"tag":88,"props":24338,"children":24339},{"style":95},[24340],{"type":34,"value":24341},"\u002F\u002F Implémentation pour l'email\n",{"type":29,"tag":88,"props":24343,"children":24344},{"class":90,"line":270},[24345,24349,24353,24358,24362,24366],{"type":29,"tag":88,"props":24346,"children":24347},{"style":105},[24348],{"type":34,"value":108},{"type":29,"tag":88,"props":24350,"children":24351},{"style":105},[24352],{"type":34,"value":113},{"type":29,"tag":88,"props":24354,"children":24355},{"style":116},[24356],{"type":34,"value":24357}," EmailSender",{"type":29,"tag":88,"props":24359,"children":24360},{"style":105},[24361],{"type":34,"value":1134},{"type":29,"tag":88,"props":24363,"children":24364},{"style":116},[24365],{"type":34,"value":24287},{"type":29,"tag":88,"props":24367,"children":24368},{"style":122},[24369],{"type":34,"value":125},{"type":29,"tag":88,"props":24371,"children":24372},{"class":90,"line":313},[24373,24377],{"type":29,"tag":88,"props":24374,"children":24375},{"style":1974},[24376],{"type":34,"value":3302},{"type":29,"tag":88,"props":24378,"children":24379},{"style":1980},[24380],{"type":34,"value":3307},{"type":29,"tag":88,"props":24382,"children":24383},{"class":90,"line":360},[24384,24388,24392,24396,24400,24404,24408,24412],{"type":29,"tag":88,"props":24385,"children":24386},{"style":105},[24387],{"type":34,"value":276},{"type":29,"tag":88,"props":24389,"children":24390},{"style":105},[24391],{"type":34,"value":1303},{"type":29,"tag":88,"props":24393,"children":24394},{"style":174},[24395],{"type":34,"value":24303},{"type":29,"tag":88,"props":24397,"children":24398},{"style":122},[24399],{"type":34,"value":181},{"type":29,"tag":88,"props":24401,"children":24402},{"style":151},[24403],{"type":34,"value":695},{"type":29,"tag":88,"props":24405,"children":24406},{"style":298},[24407],{"type":34,"value":23950},{"type":29,"tag":88,"props":24409,"children":24410},{"style":122},[24411],{"type":34,"value":306},{"type":29,"tag":88,"props":24413,"children":24414},{"style":122},[24415],{"type":34,"value":125},{"type":29,"tag":88,"props":24417,"children":24418},{"class":90,"line":409},[24419,24423,24427,24431,24435,24439,24443,24447,24451,24455],{"type":29,"tag":88,"props":24420,"children":24421},{"style":157},[24422],{"type":34,"value":19726},{"type":29,"tag":88,"props":24424,"children":24425},{"style":122},[24426],{"type":34,"value":338},{"type":29,"tag":88,"props":24428,"children":24429},{"style":157},[24430],{"type":34,"value":18091},{"type":29,"tag":88,"props":24432,"children":24433},{"style":122},[24434],{"type":34,"value":338},{"type":29,"tag":88,"props":24436,"children":24437},{"style":174},[24438],{"type":34,"value":18100},{"type":29,"tag":88,"props":24440,"children":24441},{"style":122},[24442],{"type":34,"value":181},{"type":29,"tag":88,"props":24444,"children":24445},{"style":184},[24446],{"type":34,"value":23990},{"type":29,"tag":88,"props":24448,"children":24449},{"style":163},[24450],{"type":34,"value":5485},{"type":29,"tag":88,"props":24452,"children":24453},{"style":157},[24454],{"type":34,"value":23950},{"type":29,"tag":88,"props":24456,"children":24457},{"style":122},[24458],{"type":34,"value":357},{"type":29,"tag":88,"props":24460,"children":24461},{"class":90,"line":427},[24462],{"type":29,"tag":88,"props":24463,"children":24464},{"style":122},[24465],{"type":34,"value":433},{"type":29,"tag":88,"props":24467,"children":24468},{"class":90,"line":436},[24469],{"type":29,"tag":88,"props":24470,"children":24471},{"style":122},[24472],{"type":34,"value":442},{"type":29,"tag":88,"props":24474,"children":24475},{"class":90,"line":767},[24476],{"type":29,"tag":88,"props":24477,"children":24478},{"emptyLinePlaceholder":13},[24479],{"type":34,"value":134},{"type":29,"tag":88,"props":24481,"children":24482},{"class":90,"line":792},[24483],{"type":29,"tag":88,"props":24484,"children":24485},{"style":95},[24486],{"type":34,"value":24487},"\u002F\u002F Implémentation pour SMS\n",{"type":29,"tag":88,"props":24489,"children":24490},{"class":90,"line":817},[24491,24495,24499,24504,24508,24512],{"type":29,"tag":88,"props":24492,"children":24493},{"style":105},[24494],{"type":34,"value":108},{"type":29,"tag":88,"props":24496,"children":24497},{"style":105},[24498],{"type":34,"value":113},{"type":29,"tag":88,"props":24500,"children":24501},{"style":116},[24502],{"type":34,"value":24503}," SMSSender",{"type":29,"tag":88,"props":24505,"children":24506},{"style":105},[24507],{"type":34,"value":1134},{"type":29,"tag":88,"props":24509,"children":24510},{"style":116},[24511],{"type":34,"value":24287},{"type":29,"tag":88,"props":24513,"children":24514},{"style":122},[24515],{"type":34,"value":125},{"type":29,"tag":88,"props":24517,"children":24518},{"class":90,"line":825},[24519,24523],{"type":29,"tag":88,"props":24520,"children":24521},{"style":1974},[24522],{"type":34,"value":3302},{"type":29,"tag":88,"props":24524,"children":24525},{"style":1980},[24526],{"type":34,"value":3307},{"type":29,"tag":88,"props":24528,"children":24529},{"class":90,"line":869},[24530,24534,24538,24542,24546,24550,24554,24558],{"type":29,"tag":88,"props":24531,"children":24532},{"style":105},[24533],{"type":34,"value":276},{"type":29,"tag":88,"props":24535,"children":24536},{"style":105},[24537],{"type":34,"value":1303},{"type":29,"tag":88,"props":24539,"children":24540},{"style":174},[24541],{"type":34,"value":24303},{"type":29,"tag":88,"props":24543,"children":24544},{"style":122},[24545],{"type":34,"value":181},{"type":29,"tag":88,"props":24547,"children":24548},{"style":151},[24549],{"type":34,"value":695},{"type":29,"tag":88,"props":24551,"children":24552},{"style":298},[24553],{"type":34,"value":23950},{"type":29,"tag":88,"props":24555,"children":24556},{"style":122},[24557],{"type":34,"value":306},{"type":29,"tag":88,"props":24559,"children":24560},{"style":122},[24561],{"type":34,"value":125},{"type":29,"tag":88,"props":24563,"children":24564},{"class":90,"line":900},[24565,24569,24573,24577,24581,24585,24589,24594,24598,24602],{"type":29,"tag":88,"props":24566,"children":24567},{"style":157},[24568],{"type":34,"value":19726},{"type":29,"tag":88,"props":24570,"children":24571},{"style":122},[24572],{"type":34,"value":338},{"type":29,"tag":88,"props":24574,"children":24575},{"style":157},[24576],{"type":34,"value":18091},{"type":29,"tag":88,"props":24578,"children":24579},{"style":122},[24580],{"type":34,"value":338},{"type":29,"tag":88,"props":24582,"children":24583},{"style":174},[24584],{"type":34,"value":18100},{"type":29,"tag":88,"props":24586,"children":24587},{"style":122},[24588],{"type":34,"value":181},{"type":29,"tag":88,"props":24590,"children":24591},{"style":184},[24592],{"type":34,"value":24593},"\"Envoi du SMS : \"",{"type":29,"tag":88,"props":24595,"children":24596},{"style":163},[24597],{"type":34,"value":5485},{"type":29,"tag":88,"props":24599,"children":24600},{"style":157},[24601],{"type":34,"value":23950},{"type":29,"tag":88,"props":24603,"children":24604},{"style":122},[24605],{"type":34,"value":357},{"type":29,"tag":88,"props":24607,"children":24608},{"class":90,"line":929},[24609],{"type":29,"tag":88,"props":24610,"children":24611},{"style":122},[24612],{"type":34,"value":433},{"type":29,"tag":88,"props":24614,"children":24615},{"class":90,"line":937},[24616],{"type":29,"tag":88,"props":24617,"children":24618},{"style":122},[24619],{"type":34,"value":442},{"type":29,"tag":88,"props":24621,"children":24622},{"class":90,"line":945},[24623],{"type":29,"tag":88,"props":24624,"children":24625},{"emptyLinePlaceholder":13},[24626],{"type":34,"value":134},{"type":29,"tag":88,"props":24628,"children":24629},{"class":90,"line":981},[24630],{"type":29,"tag":88,"props":24631,"children":24632},{"style":95},[24633],{"type":34,"value":24634},"\u002F\u002F Service de notification utilisant l'interface NotificationSender\n",{"type":29,"tag":88,"props":24636,"children":24637},{"class":90,"line":1021},[24638,24642,24646,24650],{"type":29,"tag":88,"props":24639,"children":24640},{"style":105},[24641],{"type":34,"value":108},{"type":29,"tag":88,"props":24643,"children":24644},{"style":105},[24645],{"type":34,"value":113},{"type":29,"tag":88,"props":24647,"children":24648},{"style":116},[24649],{"type":34,"value":4662},{"type":29,"tag":88,"props":24651,"children":24652},{"style":122},[24653],{"type":34,"value":125},{"type":29,"tag":88,"props":24655,"children":24656},{"class":90,"line":1066},[24657,24661,24665,24670],{"type":29,"tag":88,"props":24658,"children":24659},{"style":105},[24660],{"type":34,"value":143},{"type":29,"tag":88,"props":24662,"children":24663},{"style":151},[24664],{"type":34,"value":24287},{"type":29,"tag":88,"props":24666,"children":24667},{"style":157},[24668],{"type":34,"value":24669}," sender",{"type":29,"tag":88,"props":24671,"children":24672},{"style":122},[24673],{"type":34,"value":424},{"type":29,"tag":88,"props":24675,"children":24676},{"class":90,"line":1082},[24677],{"type":29,"tag":88,"props":24678,"children":24679},{"emptyLinePlaceholder":13},[24680],{"type":34,"value":134},{"type":29,"tag":88,"props":24682,"children":24683},{"class":90,"line":1090},[24684],{"type":29,"tag":88,"props":24685,"children":24686},{"style":95},[24687],{"type":34,"value":24688},"    \u002F\u002F Injection de dépendance via le constructeur\n",{"type":29,"tag":88,"props":24690,"children":24691},{"class":90,"line":1098},[24692,24696,24700,24704,24708,24712,24716],{"type":29,"tag":88,"props":24693,"children":24694},{"style":105},[24695],{"type":34,"value":276},{"type":29,"tag":88,"props":24697,"children":24698},{"style":174},[24699],{"type":34,"value":4662},{"type":29,"tag":88,"props":24701,"children":24702},{"style":122},[24703],{"type":34,"value":181},{"type":29,"tag":88,"props":24705,"children":24706},{"style":151},[24707],{"type":34,"value":24254},{"type":29,"tag":88,"props":24709,"children":24710},{"style":298},[24711],{"type":34,"value":24669},{"type":29,"tag":88,"props":24713,"children":24714},{"style":122},[24715],{"type":34,"value":306},{"type":29,"tag":88,"props":24717,"children":24718},{"style":122},[24719],{"type":34,"value":125},{"type":29,"tag":88,"props":24721,"children":24722},{"class":90,"line":1106},[24723,24727,24731,24736,24740,24744],{"type":29,"tag":88,"props":24724,"children":24725},{"style":873},[24726],{"type":34,"value":876},{"type":29,"tag":88,"props":24728,"children":24729},{"style":122},[24730],{"type":34,"value":338},{"type":29,"tag":88,"props":24732,"children":24733},{"style":157},[24734],{"type":34,"value":24735},"sender ",{"type":29,"tag":88,"props":24737,"children":24738},{"style":163},[24739],{"type":34,"value":166},{"type":29,"tag":88,"props":24741,"children":24742},{"style":157},[24743],{"type":34,"value":24669},{"type":29,"tag":88,"props":24745,"children":24746},{"style":122},[24747],{"type":34,"value":424},{"type":29,"tag":88,"props":24749,"children":24750},{"class":90,"line":1115},[24751],{"type":29,"tag":88,"props":24752,"children":24753},{"style":122},[24754],{"type":34,"value":433},{"type":29,"tag":88,"props":24756,"children":24757},{"class":90,"line":11},[24758],{"type":29,"tag":88,"props":24759,"children":24760},{"emptyLinePlaceholder":13},[24761],{"type":34,"value":134},{"type":29,"tag":88,"props":24763,"children":24764},{"class":90,"line":1180},[24765,24769,24773,24777,24781,24785,24789,24793],{"type":29,"tag":88,"props":24766,"children":24767},{"style":105},[24768],{"type":34,"value":276},{"type":29,"tag":88,"props":24770,"children":24771},{"style":105},[24772],{"type":34,"value":1303},{"type":29,"tag":88,"props":24774,"children":24775},{"style":174},[24776],{"type":34,"value":24148},{"type":29,"tag":88,"props":24778,"children":24779},{"style":122},[24780],{"type":34,"value":181},{"type":29,"tag":88,"props":24782,"children":24783},{"style":151},[24784],{"type":34,"value":695},{"type":29,"tag":88,"props":24786,"children":24787},{"style":298},[24788],{"type":34,"value":23950},{"type":29,"tag":88,"props":24790,"children":24791},{"style":122},[24792],{"type":34,"value":306},{"type":29,"tag":88,"props":24794,"children":24795},{"style":122},[24796],{"type":34,"value":125},{"type":29,"tag":88,"props":24798,"children":24799},{"class":90,"line":1240},[24800,24805,24809,24813,24817,24821],{"type":29,"tag":88,"props":24801,"children":24802},{"style":157},[24803],{"type":34,"value":24804},"        sender",{"type":29,"tag":88,"props":24806,"children":24807},{"style":122},[24808],{"type":34,"value":338},{"type":29,"tag":88,"props":24810,"children":24811},{"style":174},[24812],{"type":34,"value":1357},{"type":29,"tag":88,"props":24814,"children":24815},{"style":122},[24816],{"type":34,"value":181},{"type":29,"tag":88,"props":24818,"children":24819},{"style":157},[24820],{"type":34,"value":24193},{"type":29,"tag":88,"props":24822,"children":24823},{"style":122},[24824],{"type":34,"value":357},{"type":29,"tag":88,"props":24826,"children":24827},{"class":90,"line":1248},[24828],{"type":29,"tag":88,"props":24829,"children":24830},{"style":122},[24831],{"type":34,"value":433},{"type":29,"tag":88,"props":24833,"children":24834},{"class":90,"line":1256},[24835],{"type":29,"tag":88,"props":24836,"children":24837},{"style":122},[24838],{"type":34,"value":442},{"type":29,"tag":30,"props":24840,"children":24841},{},[24842,24843,24848,24850,24856,24858,24863,24865,24871,24873,24878],{"type":34,"value":14696},{"type":29,"tag":84,"props":24844,"children":24846},{"className":24845},[],[24847],{"type":34,"value":23875},{"type":34,"value":24849}," ne dépend plus d'une implémentation concrète comme ",{"type":29,"tag":84,"props":24851,"children":24853},{"className":24852},[],[24854],{"type":34,"value":24855},"EmailSender",{"type":34,"value":24857},", mais d'une abstraction (",{"type":29,"tag":84,"props":24859,"children":24861},{"className":24860},[],[24862],{"type":34,"value":24254},{"type":34,"value":24864},"). Changer d'implémentation devient trivial : pour envoyer des SMS à la place des emails, il suffit de passer un ",{"type":29,"tag":84,"props":24866,"children":24868},{"className":24867},[],[24869],{"type":34,"value":24870},"SMSSender",{"type":34,"value":24872}," au lieu d'un ",{"type":29,"tag":84,"props":24874,"children":24876},{"className":24875},[],[24877],{"type":34,"value":24855},{"type":34,"value":21063},{"type":29,"tag":77,"props":24880,"children":24882},{"className":81,"code":24881,"language":80,"meta":8,"style":8},"public class Main {\n    public static void main(String[] args) {\n        \u002F\u002F Envoi de notification par email\n        NotificationSender emailSender = new EmailSender();\n        NotificationService notificationService = new NotificationService(emailSender);\n        notificationService.sendNotification(\"Message par email\");\n\n        \u002F\u002F 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",[24883],{"type":29,"tag":84,"props":24884,"children":24885},{"__ignoreMap":8},[24886,24905,24948,24956,24985,25023,25052,25059,25067,25095,25107,25114,25142,25171,25178],{"type":29,"tag":88,"props":24887,"children":24888},{"class":90,"line":91},[24889,24893,24897,24901],{"type":29,"tag":88,"props":24890,"children":24891},{"style":105},[24892],{"type":34,"value":108},{"type":29,"tag":88,"props":24894,"children":24895},{"style":105},[24896],{"type":34,"value":113},{"type":29,"tag":88,"props":24898,"children":24899},{"style":116},[24900],{"type":34,"value":21224},{"type":29,"tag":88,"props":24902,"children":24903},{"style":122},[24904],{"type":34,"value":125},{"type":29,"tag":88,"props":24906,"children":24907},{"class":90,"line":101},[24908,24912,24916,24920,24924,24928,24932,24936,24940,24944],{"type":29,"tag":88,"props":24909,"children":24910},{"style":105},[24911],{"type":34,"value":276},{"type":29,"tag":88,"props":24913,"children":24914},{"style":105},[24915],{"type":34,"value":12248},{"type":29,"tag":88,"props":24917,"children":24918},{"style":105},[24919],{"type":34,"value":1303},{"type":29,"tag":88,"props":24921,"children":24922},{"style":174},[24923],{"type":34,"value":21248},{"type":29,"tag":88,"props":24925,"children":24926},{"style":122},[24927],{"type":34,"value":181},{"type":29,"tag":88,"props":24929,"children":24930},{"style":105},[24931],{"type":34,"value":695},{"type":29,"tag":88,"props":24933,"children":24934},{"style":122},[24935],{"type":34,"value":21261},{"type":29,"tag":88,"props":24937,"children":24938},{"style":298},[24939],{"type":34,"value":21266},{"type":29,"tag":88,"props":24941,"children":24942},{"style":122},[24943],{"type":34,"value":306},{"type":29,"tag":88,"props":24945,"children":24946},{"style":122},[24947],{"type":34,"value":125},{"type":29,"tag":88,"props":24949,"children":24950},{"class":90,"line":128},[24951],{"type":29,"tag":88,"props":24952,"children":24953},{"style":95},[24954],{"type":34,"value":24955},"        \u002F\u002F Envoi de notification par email\n",{"type":29,"tag":88,"props":24957,"children":24958},{"class":90,"line":137},[24959,24964,24969,24973,24977,24981],{"type":29,"tag":88,"props":24960,"children":24961},{"style":151},[24962],{"type":34,"value":24963},"        NotificationSender",{"type":29,"tag":88,"props":24965,"children":24966},{"style":157},[24967],{"type":34,"value":24968}," emailSender ",{"type":29,"tag":88,"props":24970,"children":24971},{"style":163},[24972],{"type":34,"value":166},{"type":29,"tag":88,"props":24974,"children":24975},{"style":105},[24976],{"type":34,"value":171},{"type":29,"tag":88,"props":24978,"children":24979},{"style":174},[24980],{"type":34,"value":24357},{"type":29,"tag":88,"props":24982,"children":24983},{"style":122},[24984],{"type":34,"value":1810},{"type":29,"tag":88,"props":24986,"children":24987},{"class":90,"line":211},[24988,24993,24998,25002,25006,25010,25014,25019],{"type":29,"tag":88,"props":24989,"children":24990},{"style":151},[24991],{"type":34,"value":24992},"        NotificationService",{"type":29,"tag":88,"props":24994,"children":24995},{"style":157},[24996],{"type":34,"value":24997}," notificationService ",{"type":29,"tag":88,"props":24999,"children":25000},{"style":163},[25001],{"type":34,"value":166},{"type":29,"tag":88,"props":25003,"children":25004},{"style":105},[25005],{"type":34,"value":171},{"type":29,"tag":88,"props":25007,"children":25008},{"style":174},[25009],{"type":34,"value":4662},{"type":29,"tag":88,"props":25011,"children":25012},{"style":122},[25013],{"type":34,"value":181},{"type":29,"tag":88,"props":25015,"children":25016},{"style":157},[25017],{"type":34,"value":25018},"emailSender",{"type":29,"tag":88,"props":25020,"children":25021},{"style":122},[25022],{"type":34,"value":357},{"type":29,"tag":88,"props":25024,"children":25025},{"class":90,"line":262},[25026,25030,25034,25039,25043,25048],{"type":29,"tag":88,"props":25027,"children":25028},{"style":157},[25029],{"type":34,"value":5201},{"type":29,"tag":88,"props":25031,"children":25032},{"style":122},[25033],{"type":34,"value":338},{"type":29,"tag":88,"props":25035,"children":25036},{"style":174},[25037],{"type":34,"value":25038},"sendNotification",{"type":29,"tag":88,"props":25040,"children":25041},{"style":122},[25042],{"type":34,"value":181},{"type":29,"tag":88,"props":25044,"children":25045},{"style":184},[25046],{"type":34,"value":25047},"\"Message par email\"",{"type":29,"tag":88,"props":25049,"children":25050},{"style":122},[25051],{"type":34,"value":357},{"type":29,"tag":88,"props":25053,"children":25054},{"class":90,"line":270},[25055],{"type":29,"tag":88,"props":25056,"children":25057},{"emptyLinePlaceholder":13},[25058],{"type":34,"value":134},{"type":29,"tag":88,"props":25060,"children":25061},{"class":90,"line":313},[25062],{"type":29,"tag":88,"props":25063,"children":25064},{"style":95},[25065],{"type":34,"value":25066},"        \u002F\u002F Envoi de notification par SMS\n",{"type":29,"tag":88,"props":25068,"children":25069},{"class":90,"line":360},[25070,25074,25079,25083,25087,25091],{"type":29,"tag":88,"props":25071,"children":25072},{"style":151},[25073],{"type":34,"value":24963},{"type":29,"tag":88,"props":25075,"children":25076},{"style":157},[25077],{"type":34,"value":25078}," smsSender ",{"type":29,"tag":88,"props":25080,"children":25081},{"style":163},[25082],{"type":34,"value":166},{"type":29,"tag":88,"props":25084,"children":25085},{"style":105},[25086],{"type":34,"value":171},{"type":29,"tag":88,"props":25088,"children":25089},{"style":174},[25090],{"type":34,"value":24503},{"type":29,"tag":88,"props":25092,"children":25093},{"style":122},[25094],{"type":34,"value":1810},{"type":29,"tag":88,"props":25096,"children":25097},{"class":90,"line":409},[25098,25102],{"type":29,"tag":88,"props":25099,"children":25100},{"style":151},[25101],{"type":34,"value":24992},{"type":29,"tag":88,"props":25103,"children":25104},{"style":157},[25105],{"type":34,"value":25106}," smsNotificationService\n",{"type":29,"tag":88,"props":25108,"children":25109},{"class":90,"line":427},[25110],{"type":29,"tag":88,"props":25111,"children":25112},{"emptyLinePlaceholder":13},[25113],{"type":34,"value":134},{"type":29,"tag":88,"props":25115,"children":25116},{"class":90,"line":436},[25117,25121,25125,25129,25133,25138],{"type":29,"tag":88,"props":25118,"children":25119},{"style":163},[25120],{"type":34,"value":6498},{"type":29,"tag":88,"props":25122,"children":25123},{"style":105},[25124],{"type":34,"value":171},{"type":29,"tag":88,"props":25126,"children":25127},{"style":174},[25128],{"type":34,"value":4662},{"type":29,"tag":88,"props":25130,"children":25131},{"style":122},[25132],{"type":34,"value":181},{"type":29,"tag":88,"props":25134,"children":25135},{"style":157},[25136],{"type":34,"value":25137},"smsSender",{"type":29,"tag":88,"props":25139,"children":25140},{"style":122},[25141],{"type":34,"value":357},{"type":29,"tag":88,"props":25143,"children":25144},{"class":90,"line":767},[25145,25150,25154,25158,25162,25167],{"type":29,"tag":88,"props":25146,"children":25147},{"style":157},[25148],{"type":34,"value":25149},"        smsNotificationService",{"type":29,"tag":88,"props":25151,"children":25152},{"style":122},[25153],{"type":34,"value":338},{"type":29,"tag":88,"props":25155,"children":25156},{"style":174},[25157],{"type":34,"value":25038},{"type":29,"tag":88,"props":25159,"children":25160},{"style":122},[25161],{"type":34,"value":181},{"type":29,"tag":88,"props":25163,"children":25164},{"style":184},[25165],{"type":34,"value":25166},"\"Message par SMS\"",{"type":29,"tag":88,"props":25168,"children":25169},{"style":122},[25170],{"type":34,"value":357},{"type":29,"tag":88,"props":25172,"children":25173},{"class":90,"line":792},[25174],{"type":29,"tag":88,"props":25175,"children":25176},{"style":122},[25177],{"type":34,"value":433},{"type":29,"tag":88,"props":25179,"children":25180},{"class":90,"line":817},[25181],{"type":29,"tag":88,"props":25182,"children":25183},{"style":122},[25184],{"type":34,"value":442},{"type":29,"tag":47,"props":25186,"children":25187},{},[],{"type":29,"tag":8526,"props":25189,"children":25190},{"type":8528},[25191],{"type":29,"tag":30,"props":25192,"children":25193},{},[25194,25199],{"type":29,"tag":447,"props":25195,"children":25196},{},[25197],{"type":34,"value":25198},"Injectez vos dépendances",{"type":34,"value":25200}," 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":29,"tag":51,"props":25202,"children":25204},{"id":25203},"_6-exemples-concrets-de-chaque-principe-en-java",[25205],{"type":34,"value":25206},"6. Exemples concrets de chaque principe en Java",{"type":29,"tag":17095,"props":25208,"children":25209},{},[25210,25234,25251,25282,25321],{"type":29,"tag":457,"props":25211,"children":25212},{},[25213,25218,25219],{"type":29,"tag":447,"props":25214,"children":25215},{},[25216],{"type":34,"value":25217},"Single Responsibility Principle (SRP)",{"type":34,"value":21063},{"type":29,"tag":453,"props":25220,"children":25221},{},[25222],{"type":29,"tag":457,"props":25223,"children":25224},{},[25225,25227,25232],{"type":34,"value":25226},"Exemple : Une classe ",{"type":29,"tag":84,"props":25228,"children":25230},{"className":25229},[],[25231],{"type":34,"value":19546},{"type":34,"value":25233}," 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":29,"tag":457,"props":25235,"children":25236},{},[25237,25242,25243],{"type":29,"tag":447,"props":25238,"children":25239},{},[25240],{"type":34,"value":25241},"Open\u002FClosed Principle (OCP)",{"type":34,"value":21063},{"type":29,"tag":453,"props":25244,"children":25245},{},[25246],{"type":29,"tag":457,"props":25247,"children":25248},{},[25249],{"type":34,"value":25250},"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":29,"tag":457,"props":25252,"children":25253},{},[25254,25259,25260],{"type":29,"tag":447,"props":25255,"children":25256},{},[25257],{"type":34,"value":25258},"Liskov Substitution Principle (LSP)",{"type":34,"value":21063},{"type":29,"tag":453,"props":25261,"children":25262},{},[25263],{"type":29,"tag":457,"props":25264,"children":25265},{},[25266,25268,25273,25275,25280],{"type":34,"value":25267},"Exemple : Évitez d'utiliser l'héritage entre une classe ",{"type":29,"tag":84,"props":25269,"children":25271},{"className":25270},[],[25272],{"type":34,"value":21585},{"type":34,"value":25274}," et une classe ",{"type":29,"tag":84,"props":25276,"children":25278},{"className":25277},[],[25279],{"type":34,"value":21593},{"type":34,"value":25281}," si leurs comportements sont fondamentalement différents (comme les changements indépendants de largeur et de hauteur).",{"type":29,"tag":457,"props":25283,"children":25284},{},[25285,25290,25291],{"type":29,"tag":447,"props":25286,"children":25287},{},[25288],{"type":34,"value":25289},"Interface Segregation Principle (ISP)",{"type":34,"value":21063},{"type":29,"tag":453,"props":25292,"children":25293},{},[25294],{"type":29,"tag":457,"props":25295,"children":25296},{},[25297,25299,25305,25306,25312,25314,25319],{"type":34,"value":25298},"Exemple : Créez des interfaces spécifiques (",{"type":29,"tag":84,"props":25300,"children":25302},{"className":25301},[],[25303],{"type":34,"value":25304},"FlyingBird",{"type":34,"value":544},{"type":29,"tag":84,"props":25307,"children":25309},{"className":25308},[],[25310],{"type":34,"value":25311},"SwimmingBird",{"type":34,"value":25313},", etc.) au lieu d'une seule interface générale ",{"type":29,"tag":84,"props":25315,"children":25317},{"className":25316},[],[25318],{"type":34,"value":22788},{"type":34,"value":25320}," qui oblige toutes les classes à implémenter des méthodes non pertinentes.",{"type":29,"tag":457,"props":25322,"children":25323},{},[25324,25329,25330],{"type":29,"tag":447,"props":25325,"children":25326},{},[25327],{"type":34,"value":25328},"Dependency Inversion Principle (DIP)",{"type":34,"value":21063},{"type":29,"tag":453,"props":25331,"children":25332},{},[25333],{"type":29,"tag":457,"props":25334,"children":25335},{},[25336,25338,25343,25345,25350],{"type":34,"value":25337},"Exemple : Au lieu de dépendre directement d'une classe ",{"type":29,"tag":84,"props":25339,"children":25341},{"className":25340},[],[25342],{"type":34,"value":23894},{"type":34,"value":25344},", utilisez une interface ",{"type":29,"tag":84,"props":25346,"children":25348},{"className":25347},[],[25349],{"type":34,"value":24254},{"type":34,"value":25351}," pour injecter des services d'envoi de notifications par email, SMS, etc.",{"type":29,"tag":2288,"props":25353,"children":25355},{"cta":5629,"href":5630,"title":25354,"type":5632},"SOLID, ce sont 5 leviers : il en existe 100 pour coder propre",[25356],{"type":29,"tag":30,"props":25357,"children":25358},{},[25359],{"type":34,"value":25360},"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":29,"tag":47,"props":25362,"children":25363},{},[],{"type":29,"tag":51,"props":25365,"children":25367},{"id":25366},"_7-faq-sur-les-principes-solid-en-java",[25368],{"type":34,"value":25369},"7. FAQ sur les principes SOLID en Java",{"type":29,"tag":5649,"props":25371,"children":25372},{},[25373,25378],{"type":29,"tag":5653,"props":25374,"children":25375},{},[25376],{"type":34,"value":25377},"Pourquoi appliquer les principes SOLID en Java ?",{"type":29,"tag":30,"props":25379,"children":25380},{},[25381],{"type":34,"value":25382},"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":29,"tag":5649,"props":25384,"children":25385},{},[25386,25391],{"type":29,"tag":5653,"props":25387,"children":25388},{},[25389],{"type":34,"value":25390},"Est-ce que les principes SOLID sont applicables à tous les projets Java ?",{"type":29,"tag":30,"props":25392,"children":25393},{},[25394],{"type":34,"value":25395},"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":29,"tag":5649,"props":25397,"children":25398},{},[25399,25404],{"type":29,"tag":5653,"props":25400,"children":25401},{},[25402],{"type":34,"value":25403},"Quel est le principe SOLID le plus important ?",{"type":29,"tag":30,"props":25405,"children":25406},{},[25407],{"type":34,"value":25408},"Tous les principes sont importants, mais si vous débutez, le SRP (principe de responsabilité unique) et le OCP (principe ouvert\u002Ffermé) sont souvent les plus critiques pour améliorer la maintenabilité de votre code.",{"type":29,"tag":5649,"props":25410,"children":25411},{},[25412,25417],{"type":29,"tag":5653,"props":25413,"children":25414},{},[25415],{"type":34,"value":25416},"Comment appliquer SOLID dans un projet existant ?",{"type":29,"tag":30,"props":25418,"children":25419},{},[25420],{"type":34,"value":25421},"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":29,"tag":47,"props":25423,"children":25424},{},[],{"type":29,"tag":2288,"props":25426,"children":25427},{"cta":19356,"href":10075,"title":19357,"type":5755},[25428],{"type":29,"tag":30,"props":25429,"children":25430},{},[25431],{"type":34,"value":25432},"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":29,"tag":5763,"props":25434,"children":25435},{},[25436],{"type":34,"value":5767},{"title":8,"searchDepth":101,"depth":101,"links":25438},[25439,25440,25441,25445,25449,25453,25457,25461,25462],{"id":19398,"depth":101,"text":19401},{"id":19489,"depth":101,"text":19492},{"id":19503,"depth":101,"text":19506,"children":25442},[25443,25444],{"id":19521,"depth":128,"text":19524},{"id":19532,"depth":128,"text":19535},{"id":20282,"depth":101,"text":20285,"children":25446},[25447,25448],{"id":20307,"depth":128,"text":19524},{"id":20317,"depth":128,"text":19535},{"id":21551,"depth":101,"text":21554,"children":25450},[25451,25452],{"id":21562,"depth":128,"text":19524},{"id":21572,"depth":128,"text":19535},{"id":22754,"depth":101,"text":22757,"children":25454},[25455,25456],{"id":22765,"depth":128,"text":19524},{"id":22775,"depth":128,"text":19535},{"id":23842,"depth":101,"text":23845,"children":25458},[25459,25460],{"id":23853,"depth":128,"text":19524},{"id":23863,"depth":128,"text":19535},{"id":25203,"depth":101,"text":25206},{"id":25366,"depth":101,"text":25369},"content:fr:architecture-craft:principes-solid-java-exemples.md","fr\u002Farchitecture-craft\u002Fprincipes-solid-java-exemples.md","fr\u002Farchitecture-craft\u002Fprincipes-solid-java-exemples",{"_path":19481,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":25467,"description":25468,"id":1573,"date":25469,"listed":13,"nocomments":7,"hidden":7,"categories":25470,"tags":25471,"cover":25472,"readingTime":25473,"body":25478,"_type":5777,"_id":28811,"_source":5779,"_file":28812,"_stem":28813,"_extension":5782},"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 à...","2024-04-01",[6],[16,8453],"covers\u002Farticles\u002Fprincipe-dip.jpg",{"text":25474,"minutes":25475,"time":25476,"words":25477},"13 min read",12.14,728400,2428,{"type":26,"children":25479,"toc":28792},[25480,25486,25491,25510,25521,25524,25530,25546,25558,25569,25612,25621,25624,25633,25639,25655,25661,25666,25678,25684,25689,25711,25714,25757,25760,25766,25777,25783,25788,26097,26128,26134,26159,26741,26774,27062,27068,27079,27090,27105,27120,27123,27129,27153,27159,27177,27199,27202,27208,27213,27225,27582,27620,27854,27866,27871,28126,28133,28226,28232,28269,28494,28507,28515,28518,28527,28530,28536,28554,28586,28612,28638,28651,28688,28732,28735,28739,28756,28761,28781,28788],{"type":29,"tag":51,"props":25481,"children":25483},{"id":25482},"introduction-au-dip-dependency-inversion-principle",[25484],{"type":34,"value":25485},"Introduction au DIP (Dependency Inversion Principle)",{"type":29,"tag":30,"props":25487,"children":25488},{},[25489],{"type":34,"value":25490},"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":29,"tag":30,"props":25492,"children":25493},{},[25494,25496,25501,25503,25508],{"type":34,"value":25495},"Le principe de l'inversion des dépendances (",{"type":29,"tag":447,"props":25497,"children":25498},{},[25499],{"type":34,"value":25500},"DIP",{"type":34,"value":25502},", Dependency Inversion Principle) attaque exactement cette ",{"type":29,"tag":447,"props":25504,"children":25505},{},[25506],{"type":34,"value":25507},"rigidité",{"type":34,"value":25509}," qui rend chaque modification coûteuse. Mieux modulariser, mieux tester, casser le couplage : c'est ce que le DIP apporte concrètement.",{"type":29,"tag":30,"props":25511,"children":25512},{},[25513,25515,25519],{"type":34,"value":25514},"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":29,"tag":8474,"props":25516,"children":25517},{},[25518],{"type":34,"value":19416},{"type":34,"value":25520},"), et comment l'appliquer dans vos projets Java.",{"type":29,"tag":47,"props":25522,"children":25523},{},[],{"type":29,"tag":51,"props":25525,"children":25527},{"id":25526},"pourquoi-le-dip-est-essentiel-dans-le-software-craftsmanship",[25528],{"type":34,"value":25529},"Pourquoi le DIP est essentiel dans le Software Craftsmanship",{"type":29,"tag":30,"props":25531,"children":25532},{},[25533,25534,25538,25540,25544],{"type":34,"value":10213},{"type":29,"tag":447,"props":25535,"children":25536},{},[25537],{"type":34,"value":16975},{"type":34,"value":25539}," 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":29,"tag":447,"props":25541,"children":25542},{},[25543],{"type":34,"value":25500},{"type":34,"value":25545}," joue un rôle crucial.",{"type":29,"tag":30,"props":25547,"children":25548},{},[25549,25551,25556],{"type":34,"value":25550},"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":29,"tag":447,"props":25552,"children":25553},{},[25554],{"type":34,"value":25555},"séparation des préoccupations",{"type":34,"value":25557}," et aide à découpler les différentes parties du système.",{"type":29,"tag":30,"props":25559,"children":25560},{},[25561,25563,25567],{"type":34,"value":25562},"Voici pourquoi le DIP est essentiel dans une démarche de ",{"type":29,"tag":447,"props":25564,"children":25565},{},[25566],{"type":34,"value":16975},{"type":34,"value":25568}," :",{"type":29,"tag":453,"props":25570,"children":25571},{},[25572,25582,25592,25602],{"type":29,"tag":457,"props":25573,"children":25574},{},[25575,25580],{"type":29,"tag":447,"props":25576,"children":25577},{},[25578],{"type":34,"value":25579},"Réduction des couplages forts",{"type":34,"value":25581}," : 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":29,"tag":457,"props":25583,"children":25584},{},[25585,25590],{"type":29,"tag":447,"props":25586,"children":25587},{},[25588],{"type":34,"value":25589},"Facilite les tests",{"type":34,"value":25591}," : 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":29,"tag":457,"props":25593,"children":25594},{},[25595,25600],{"type":29,"tag":447,"props":25596,"children":25597},{},[25598],{"type":34,"value":25599},"Encourage la réutilisabilité",{"type":34,"value":25601}," : 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":29,"tag":457,"props":25603,"children":25604},{},[25605,25610],{"type":29,"tag":447,"props":25606,"children":25607},{},[25608],{"type":34,"value":25609},"Simplification des évolutions",{"type":34,"value":25611}," : 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":29,"tag":8526,"props":25613,"children":25615},{"type":25614},"warning",[25616],{"type":29,"tag":30,"props":25617,"children":25618},{},[25619],{"type":34,"value":25620},"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":29,"tag":47,"props":25622,"children":25623},{},[],{"type":29,"tag":2288,"props":25625,"children":25627},{"cta":2290,"href":2291,"title":25626,"type":2293},"Vous voulez savoir placer une abstraction là où elle découple vraiment, et pas partout par réflexe ?",[25628],{"type":29,"tag":30,"props":25629,"children":25630},{},[25631],{"type":34,"value":25632},"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":29,"tag":51,"props":25634,"children":25636},{"id":25635},"les-deux-règles-principales-du-dip",[25637],{"type":34,"value":25638},"Les deux règles principales du DIP",{"type":29,"tag":30,"props":25640,"children":25641},{},[25642,25643,25647,25649,25653],{"type":34,"value":10213},{"type":29,"tag":447,"props":25644,"children":25645},{},[25646],{"type":34,"value":25500},{"type":34,"value":25648}," (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":29,"tag":63,"props":25650,"children":25651},{"href":65},[25652],{"type":34,"value":68},{"type":34,"value":25654}," : 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":29,"tag":8542,"props":25656,"children":25658},{"id":25657},"_1-les-modules-de-haut-niveau-ne-doivent-pas-dépendre-des-modules-de-bas-niveau-tous-deux-doivent-dépendre-dabstractions",[25659],{"type":34,"value":25660},"1. Les modules de haut niveau ne doivent pas dépendre des modules de bas niveau. Tous deux doivent dépendre d'abstractions.",{"type":29,"tag":30,"props":25662,"children":25663},{},[25664],{"type":34,"value":25665},"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":29,"tag":30,"props":25667,"children":25668},{},[25669,25671,25676],{"type":34,"value":25670},"En appliquant le DIP, vous devez introduire des ",{"type":29,"tag":447,"props":25672,"children":25673},{},[25674],{"type":34,"value":25675},"interfaces ou des abstractions",{"type":34,"value":25677}," 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":29,"tag":8542,"props":25679,"children":25681},{"id":25680},"_2-les-abstractions-ne-doivent-pas-dépendre-des-détails-ce-sont-les-détails-qui-doivent-dépendre-des-abstractions",[25682],{"type":34,"value":25683},"2. Les abstractions ne doivent pas dépendre des détails. Ce sont les détails qui doivent dépendre des abstractions.",{"type":29,"tag":30,"props":25685,"children":25686},{},[25687],{"type":34,"value":25688},"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":29,"tag":8526,"props":25690,"children":25691},{"type":8528},[25692],{"type":29,"tag":30,"props":25693,"children":25694},{},[25695,25697,25702,25704,25709],{"type":34,"value":25696},"Pour respecter ces deux règles, je vous recommande de toujours concevoir des ",{"type":29,"tag":447,"props":25698,"children":25699},{},[25700],{"type":34,"value":25701},"interfaces",{"type":34,"value":25703}," ou des ",{"type":29,"tag":447,"props":25705,"children":25706},{},[25707],{"type":34,"value":25708},"abstractions",{"type":34,"value":25710}," 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":29,"tag":47,"props":25712,"children":25713},{},[],{"type":29,"tag":30,"props":25715,"children":25716},{},[25717,25719,25725,25727,25733,25734,25740,25742,25748,25749,25755],{"type":34,"value":25718},"Prenons un exemple concret : avec une interface ",{"type":29,"tag":84,"props":25720,"children":25722},{"className":25721},[],[25723],{"type":34,"value":25724},"IDatabase",{"type":34,"value":25726}," qui définit ",{"type":29,"tag":84,"props":25728,"children":25730},{"className":25729},[],[25731],{"type":34,"value":25732},"save()",{"type":34,"value":8982},{"type":29,"tag":84,"props":25735,"children":25737},{"className":25736},[],[25738],{"type":34,"value":25739},"find()",{"type":34,"value":25741},", ce sont les implémentations (",{"type":29,"tag":84,"props":25743,"children":25745},{"className":25744},[],[25746],{"type":34,"value":25747},"MySQLDatabase",{"type":34,"value":544},{"type":29,"tag":84,"props":25750,"children":25752},{"className":25751},[],[25753],{"type":34,"value":25754},"MongoDatabase",{"type":34,"value":25756},") 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":29,"tag":47,"props":25758,"children":25759},{},[],{"type":29,"tag":51,"props":25761,"children":25763},{"id":25762},"exemples-concrets-de-violation-et-application-du-dip-en-java",[25764],{"type":34,"value":25765},"Exemples concrets de violation et application du DIP en Java",{"type":29,"tag":30,"props":25767,"children":25768},{},[25769,25771,25775],{"type":34,"value":25770},"Pour bien comprendre le ",{"type":29,"tag":447,"props":25772,"children":25773},{},[25774],{"type":34,"value":25500},{"type":34,"value":25776},", 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":29,"tag":8542,"props":25778,"children":25780},{"id":25779},"exemple-de-violation-du-dip",[25781],{"type":34,"value":25782},"Exemple de violation du DIP",{"type":29,"tag":30,"props":25784,"children":25785},{},[25786],{"type":34,"value":25787},"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":29,"tag":77,"props":25789,"children":25791},{"className":81,"code":25790,"language":80,"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",[25792],{"type":29,"tag":84,"props":25793,"children":25794},{"__ignoreMap":8},[25795,25814,25834,25841,25860,25892,25899,25906,25941,25969,25976,25983,25990,26005,26040,26083,26090],{"type":29,"tag":88,"props":25796,"children":25797},{"class":90,"line":91},[25798,25802,25806,25810],{"type":29,"tag":88,"props":25799,"children":25800},{"style":105},[25801],{"type":34,"value":108},{"type":29,"tag":88,"props":25803,"children":25804},{"style":105},[25805],{"type":34,"value":113},{"type":29,"tag":88,"props":25807,"children":25808},{"style":116},[25809],{"type":34,"value":4662},{"type":29,"tag":88,"props":25811,"children":25812},{"style":122},[25813],{"type":34,"value":125},{"type":29,"tag":88,"props":25815,"children":25816},{"class":90,"line":101},[25817,25821,25825,25830],{"type":29,"tag":88,"props":25818,"children":25819},{"style":105},[25820],{"type":34,"value":143},{"type":29,"tag":88,"props":25822,"children":25823},{"style":151},[25824],{"type":34,"value":24357},{"type":29,"tag":88,"props":25826,"children":25827},{"style":157},[25828],{"type":34,"value":25829}," emailSender",{"type":29,"tag":88,"props":25831,"children":25832},{"style":122},[25833],{"type":34,"value":424},{"type":29,"tag":88,"props":25835,"children":25836},{"class":90,"line":128},[25837],{"type":29,"tag":88,"props":25838,"children":25839},{"emptyLinePlaceholder":13},[25840],{"type":34,"value":134},{"type":29,"tag":88,"props":25842,"children":25843},{"class":90,"line":137},[25844,25848,25852,25856],{"type":29,"tag":88,"props":25845,"children":25846},{"style":105},[25847],{"type":34,"value":276},{"type":29,"tag":88,"props":25849,"children":25850},{"style":174},[25851],{"type":34,"value":4662},{"type":29,"tag":88,"props":25853,"children":25854},{"style":122},[25855],{"type":34,"value":1470},{"type":29,"tag":88,"props":25857,"children":25858},{"style":122},[25859],{"type":34,"value":125},{"type":29,"tag":88,"props":25861,"children":25862},{"class":90,"line":211},[25863,25867,25871,25876,25880,25884,25888],{"type":29,"tag":88,"props":25864,"children":25865},{"style":873},[25866],{"type":34,"value":876},{"type":29,"tag":88,"props":25868,"children":25869},{"style":122},[25870],{"type":34,"value":338},{"type":29,"tag":88,"props":25872,"children":25873},{"style":157},[25874],{"type":34,"value":25875},"emailSender ",{"type":29,"tag":88,"props":25877,"children":25878},{"style":163},[25879],{"type":34,"value":166},{"type":29,"tag":88,"props":25881,"children":25882},{"style":105},[25883],{"type":34,"value":171},{"type":29,"tag":88,"props":25885,"children":25886},{"style":174},[25887],{"type":34,"value":24357},{"type":29,"tag":88,"props":25889,"children":25890},{"style":122},[25891],{"type":34,"value":1810},{"type":29,"tag":88,"props":25893,"children":25894},{"class":90,"line":262},[25895],{"type":29,"tag":88,"props":25896,"children":25897},{"style":122},[25898],{"type":34,"value":433},{"type":29,"tag":88,"props":25900,"children":25901},{"class":90,"line":270},[25902],{"type":29,"tag":88,"props":25903,"children":25904},{"emptyLinePlaceholder":13},[25905],{"type":34,"value":134},{"type":29,"tag":88,"props":25907,"children":25908},{"class":90,"line":313},[25909,25913,25917,25921,25925,25929,25933,25937],{"type":29,"tag":88,"props":25910,"children":25911},{"style":105},[25912],{"type":34,"value":276},{"type":29,"tag":88,"props":25914,"children":25915},{"style":105},[25916],{"type":34,"value":1303},{"type":29,"tag":88,"props":25918,"children":25919},{"style":174},[25920],{"type":34,"value":24148},{"type":29,"tag":88,"props":25922,"children":25923},{"style":122},[25924],{"type":34,"value":181},{"type":29,"tag":88,"props":25926,"children":25927},{"style":151},[25928],{"type":34,"value":695},{"type":29,"tag":88,"props":25930,"children":25931},{"style":298},[25932],{"type":34,"value":23950},{"type":29,"tag":88,"props":25934,"children":25935},{"style":122},[25936],{"type":34,"value":306},{"type":29,"tag":88,"props":25938,"children":25939},{"style":122},[25940],{"type":34,"value":125},{"type":29,"tag":88,"props":25942,"children":25943},{"class":90,"line":360},[25944,25949,25953,25957,25961,25965],{"type":29,"tag":88,"props":25945,"children":25946},{"style":157},[25947],{"type":34,"value":25948},"        emailSender",{"type":29,"tag":88,"props":25950,"children":25951},{"style":122},[25952],{"type":34,"value":338},{"type":29,"tag":88,"props":25954,"children":25955},{"style":174},[25956],{"type":34,"value":24184},{"type":29,"tag":88,"props":25958,"children":25959},{"style":122},[25960],{"type":34,"value":181},{"type":29,"tag":88,"props":25962,"children":25963},{"style":157},[25964],{"type":34,"value":24193},{"type":29,"tag":88,"props":25966,"children":25967},{"style":122},[25968],{"type":34,"value":357},{"type":29,"tag":88,"props":25970,"children":25971},{"class":90,"line":409},[25972],{"type":29,"tag":88,"props":25973,"children":25974},{"style":122},[25975],{"type":34,"value":433},{"type":29,"tag":88,"props":25977,"children":25978},{"class":90,"line":427},[25979],{"type":29,"tag":88,"props":25980,"children":25981},{"style":122},[25982],{"type":34,"value":442},{"type":29,"tag":88,"props":25984,"children":25985},{"class":90,"line":436},[25986],{"type":29,"tag":88,"props":25987,"children":25988},{"emptyLinePlaceholder":13},[25989],{"type":34,"value":134},{"type":29,"tag":88,"props":25991,"children":25992},{"class":90,"line":767},[25993,25997,26001],{"type":29,"tag":88,"props":25994,"children":25995},{"style":105},[25996],{"type":34,"value":1225},{"type":29,"tag":88,"props":25998,"children":25999},{"style":116},[26000],{"type":34,"value":24357},{"type":29,"tag":88,"props":26002,"children":26003},{"style":122},[26004],{"type":34,"value":125},{"type":29,"tag":88,"props":26006,"children":26007},{"class":90,"line":792},[26008,26012,26016,26020,26024,26028,26032,26036],{"type":29,"tag":88,"props":26009,"children":26010},{"style":105},[26011],{"type":34,"value":276},{"type":29,"tag":88,"props":26013,"children":26014},{"style":105},[26015],{"type":34,"value":1303},{"type":29,"tag":88,"props":26017,"children":26018},{"style":174},[26019],{"type":34,"value":23937},{"type":29,"tag":88,"props":26021,"children":26022},{"style":122},[26023],{"type":34,"value":181},{"type":29,"tag":88,"props":26025,"children":26026},{"style":151},[26027],{"type":34,"value":695},{"type":29,"tag":88,"props":26029,"children":26030},{"style":298},[26031],{"type":34,"value":23950},{"type":29,"tag":88,"props":26033,"children":26034},{"style":122},[26035],{"type":34,"value":306},{"type":29,"tag":88,"props":26037,"children":26038},{"style":122},[26039],{"type":34,"value":125},{"type":29,"tag":88,"props":26041,"children":26042},{"class":90,"line":817},[26043,26047,26051,26055,26059,26063,26067,26071,26075,26079],{"type":29,"tag":88,"props":26044,"children":26045},{"style":157},[26046],{"type":34,"value":19726},{"type":29,"tag":88,"props":26048,"children":26049},{"style":122},[26050],{"type":34,"value":338},{"type":29,"tag":88,"props":26052,"children":26053},{"style":157},[26054],{"type":34,"value":18091},{"type":29,"tag":88,"props":26056,"children":26057},{"style":122},[26058],{"type":34,"value":338},{"type":29,"tag":88,"props":26060,"children":26061},{"style":174},[26062],{"type":34,"value":18100},{"type":29,"tag":88,"props":26064,"children":26065},{"style":122},[26066],{"type":34,"value":181},{"type":29,"tag":88,"props":26068,"children":26069},{"style":184},[26070],{"type":34,"value":23990},{"type":29,"tag":88,"props":26072,"children":26073},{"style":163},[26074],{"type":34,"value":5485},{"type":29,"tag":88,"props":26076,"children":26077},{"style":157},[26078],{"type":34,"value":23950},{"type":29,"tag":88,"props":26080,"children":26081},{"style":122},[26082],{"type":34,"value":357},{"type":29,"tag":88,"props":26084,"children":26085},{"class":90,"line":825},[26086],{"type":29,"tag":88,"props":26087,"children":26088},{"style":122},[26089],{"type":34,"value":433},{"type":29,"tag":88,"props":26091,"children":26092},{"class":90,"line":869},[26093],{"type":29,"tag":88,"props":26094,"children":26095},{"style":122},[26096],{"type":34,"value":442},{"type":29,"tag":30,"props":26098,"children":26099},{},[26100,26101,26106,26108,26113,26115,26119,26121,26126],{"type":34,"value":11007},{"type":29,"tag":84,"props":26102,"children":26104},{"className":26103},[],[26105],{"type":34,"value":23875},{"type":34,"value":26107}," dépend directement de ",{"type":29,"tag":84,"props":26109,"children":26111},{"className":26110},[],[26112],{"type":34,"value":24855},{"type":34,"value":26114},", ce qui viole le ",{"type":29,"tag":447,"props":26116,"children":26117},{},[26118],{"type":34,"value":25500},{"type":34,"value":26120},". 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":29,"tag":84,"props":26122,"children":26124},{"className":26123},[],[26125],{"type":34,"value":23875},{"type":34,"value":26127},", ce qui n’est pas optimal.",{"type":29,"tag":8542,"props":26129,"children":26131},{"id":26130},"correction-avec-le-dip",[26132],{"type":34,"value":26133},"Correction avec le DIP",{"type":29,"tag":30,"props":26135,"children":26136},{},[26137,26139,26143,26145,26150,26152,26157],{"type":34,"value":26138},"Pour appliquer le ",{"type":29,"tag":447,"props":26140,"children":26141},{},[26142],{"type":34,"value":25500},{"type":34,"value":26144},", nous allons introduire une ",{"type":29,"tag":447,"props":26146,"children":26147},{},[26148],{"type":34,"value":26149},"interface",{"type":34,"value":26151}," pour définir le comportement attendu d'un système d'envoi de notifications, et faire en sorte que ",{"type":29,"tag":84,"props":26153,"children":26155},{"className":26154},[],[26156],{"type":34,"value":23875},{"type":34,"value":26158}," dépende de cette abstraction :",{"type":29,"tag":77,"props":26160,"children":26162},{"className":81,"code":26161,"language":80,"meta":8,"style":8},"\u002F\u002F Interface qui respecte le DIP\npublic interface MessageSender {\n    void sendMessage(String message);\n}\n\n\u002F\u002F 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\u002F\u002F 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\u002F\u002F Service de notification respectant le DIP\npublic class NotificationService {\n    private MessageSender messageSender;\n\n    \u002F\u002F 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",[26163],{"type":29,"tag":84,"props":26164,"children":26165},{"__ignoreMap":8},[26166,26174,26194,26222,26229,26236,26244,26271,26282,26317,26360,26367,26374,26381,26389,26417,26428,26463,26506,26513,26520,26527,26535,26554,26574,26581,26589,26621,26649,26656,26663,26698,26727,26734],{"type":29,"tag":88,"props":26167,"children":26168},{"class":90,"line":91},[26169],{"type":29,"tag":88,"props":26170,"children":26171},{"style":95},[26172],{"type":34,"value":26173},"\u002F\u002F Interface qui respecte le DIP\n",{"type":29,"tag":88,"props":26175,"children":26176},{"class":90,"line":101},[26177,26181,26185,26190],{"type":29,"tag":88,"props":26178,"children":26179},{"style":105},[26180],{"type":34,"value":108},{"type":29,"tag":88,"props":26182,"children":26183},{"style":105},[26184],{"type":34,"value":601},{"type":29,"tag":88,"props":26186,"children":26187},{"style":116},[26188],{"type":34,"value":26189}," MessageSender",{"type":29,"tag":88,"props":26191,"children":26192},{"style":122},[26193],{"type":34,"value":125},{"type":29,"tag":88,"props":26195,"children":26196},{"class":90,"line":128},[26197,26201,26206,26210,26214,26218],{"type":29,"tag":88,"props":26198,"children":26199},{"style":105},[26200],{"type":34,"value":681},{"type":29,"tag":88,"props":26202,"children":26203},{"style":174},[26204],{"type":34,"value":26205}," sendMessage",{"type":29,"tag":88,"props":26207,"children":26208},{"style":122},[26209],{"type":34,"value":181},{"type":29,"tag":88,"props":26211,"children":26212},{"style":151},[26213],{"type":34,"value":695},{"type":29,"tag":88,"props":26215,"children":26216},{"style":298},[26217],{"type":34,"value":23950},{"type":29,"tag":88,"props":26219,"children":26220},{"style":122},[26221],{"type":34,"value":357},{"type":29,"tag":88,"props":26223,"children":26224},{"class":90,"line":137},[26225],{"type":29,"tag":88,"props":26226,"children":26227},{"style":122},[26228],{"type":34,"value":442},{"type":29,"tag":88,"props":26230,"children":26231},{"class":90,"line":211},[26232],{"type":29,"tag":88,"props":26233,"children":26234},{"emptyLinePlaceholder":13},[26235],{"type":34,"value":134},{"type":29,"tag":88,"props":26237,"children":26238},{"class":90,"line":262},[26239],{"type":29,"tag":88,"props":26240,"children":26241},{"style":95},[26242],{"type":34,"value":26243},"\u002F\u002F Implémentation pour l'envoi d'emails\n",{"type":29,"tag":88,"props":26245,"children":26246},{"class":90,"line":270},[26247,26251,26255,26259,26263,26267],{"type":29,"tag":88,"props":26248,"children":26249},{"style":105},[26250],{"type":34,"value":108},{"type":29,"tag":88,"props":26252,"children":26253},{"style":105},[26254],{"type":34,"value":113},{"type":29,"tag":88,"props":26256,"children":26257},{"style":116},[26258],{"type":34,"value":24357},{"type":29,"tag":88,"props":26260,"children":26261},{"style":105},[26262],{"type":34,"value":1134},{"type":29,"tag":88,"props":26264,"children":26265},{"style":116},[26266],{"type":34,"value":26189},{"type":29,"tag":88,"props":26268,"children":26269},{"style":122},[26270],{"type":34,"value":125},{"type":29,"tag":88,"props":26272,"children":26273},{"class":90,"line":313},[26274,26278],{"type":29,"tag":88,"props":26275,"children":26276},{"style":1974},[26277],{"type":34,"value":3302},{"type":29,"tag":88,"props":26279,"children":26280},{"style":1980},[26281],{"type":34,"value":3307},{"type":29,"tag":88,"props":26283,"children":26284},{"class":90,"line":360},[26285,26289,26293,26297,26301,26305,26309,26313],{"type":29,"tag":88,"props":26286,"children":26287},{"style":105},[26288],{"type":34,"value":276},{"type":29,"tag":88,"props":26290,"children":26291},{"style":105},[26292],{"type":34,"value":1303},{"type":29,"tag":88,"props":26294,"children":26295},{"style":174},[26296],{"type":34,"value":26205},{"type":29,"tag":88,"props":26298,"children":26299},{"style":122},[26300],{"type":34,"value":181},{"type":29,"tag":88,"props":26302,"children":26303},{"style":151},[26304],{"type":34,"value":695},{"type":29,"tag":88,"props":26306,"children":26307},{"style":298},[26308],{"type":34,"value":23950},{"type":29,"tag":88,"props":26310,"children":26311},{"style":122},[26312],{"type":34,"value":306},{"type":29,"tag":88,"props":26314,"children":26315},{"style":122},[26316],{"type":34,"value":125},{"type":29,"tag":88,"props":26318,"children":26319},{"class":90,"line":409},[26320,26324,26328,26332,26336,26340,26344,26348,26352,26356],{"type":29,"tag":88,"props":26321,"children":26322},{"style":157},[26323],{"type":34,"value":19726},{"type":29,"tag":88,"props":26325,"children":26326},{"style":122},[26327],{"type":34,"value":338},{"type":29,"tag":88,"props":26329,"children":26330},{"style":157},[26331],{"type":34,"value":18091},{"type":29,"tag":88,"props":26333,"children":26334},{"style":122},[26335],{"type":34,"value":338},{"type":29,"tag":88,"props":26337,"children":26338},{"style":174},[26339],{"type":34,"value":18100},{"type":29,"tag":88,"props":26341,"children":26342},{"style":122},[26343],{"type":34,"value":181},{"type":29,"tag":88,"props":26345,"children":26346},{"style":184},[26347],{"type":34,"value":23990},{"type":29,"tag":88,"props":26349,"children":26350},{"style":163},[26351],{"type":34,"value":5485},{"type":29,"tag":88,"props":26353,"children":26354},{"style":157},[26355],{"type":34,"value":23950},{"type":29,"tag":88,"props":26357,"children":26358},{"style":122},[26359],{"type":34,"value":357},{"type":29,"tag":88,"props":26361,"children":26362},{"class":90,"line":427},[26363],{"type":29,"tag":88,"props":26364,"children":26365},{"style":122},[26366],{"type":34,"value":433},{"type":29,"tag":88,"props":26368,"children":26369},{"class":90,"line":436},[26370],{"type":29,"tag":88,"props":26371,"children":26372},{"style":122},[26373],{"type":34,"value":442},{"type":29,"tag":88,"props":26375,"children":26376},{"class":90,"line":767},[26377],{"type":29,"tag":88,"props":26378,"children":26379},{"emptyLinePlaceholder":13},[26380],{"type":34,"value":134},{"type":29,"tag":88,"props":26382,"children":26383},{"class":90,"line":792},[26384],{"type":29,"tag":88,"props":26385,"children":26386},{"style":95},[26387],{"type":34,"value":26388},"\u002F\u002F Implémentation pour l'envoi de SMS\n",{"type":29,"tag":88,"props":26390,"children":26391},{"class":90,"line":817},[26392,26396,26400,26405,26409,26413],{"type":29,"tag":88,"props":26393,"children":26394},{"style":105},[26395],{"type":34,"value":108},{"type":29,"tag":88,"props":26397,"children":26398},{"style":105},[26399],{"type":34,"value":113},{"type":29,"tag":88,"props":26401,"children":26402},{"style":116},[26403],{"type":34,"value":26404}," SmsSender",{"type":29,"tag":88,"props":26406,"children":26407},{"style":105},[26408],{"type":34,"value":1134},{"type":29,"tag":88,"props":26410,"children":26411},{"style":116},[26412],{"type":34,"value":26189},{"type":29,"tag":88,"props":26414,"children":26415},{"style":122},[26416],{"type":34,"value":125},{"type":29,"tag":88,"props":26418,"children":26419},{"class":90,"line":825},[26420,26424],{"type":29,"tag":88,"props":26421,"children":26422},{"style":1974},[26423],{"type":34,"value":3302},{"type":29,"tag":88,"props":26425,"children":26426},{"style":1980},[26427],{"type":34,"value":3307},{"type":29,"tag":88,"props":26429,"children":26430},{"class":90,"line":869},[26431,26435,26439,26443,26447,26451,26455,26459],{"type":29,"tag":88,"props":26432,"children":26433},{"style":105},[26434],{"type":34,"value":276},{"type":29,"tag":88,"props":26436,"children":26437},{"style":105},[26438],{"type":34,"value":1303},{"type":29,"tag":88,"props":26440,"children":26441},{"style":174},[26442],{"type":34,"value":26205},{"type":29,"tag":88,"props":26444,"children":26445},{"style":122},[26446],{"type":34,"value":181},{"type":29,"tag":88,"props":26448,"children":26449},{"style":151},[26450],{"type":34,"value":695},{"type":29,"tag":88,"props":26452,"children":26453},{"style":298},[26454],{"type":34,"value":23950},{"type":29,"tag":88,"props":26456,"children":26457},{"style":122},[26458],{"type":34,"value":306},{"type":29,"tag":88,"props":26460,"children":26461},{"style":122},[26462],{"type":34,"value":125},{"type":29,"tag":88,"props":26464,"children":26465},{"class":90,"line":900},[26466,26470,26474,26478,26482,26486,26490,26494,26498,26502],{"type":29,"tag":88,"props":26467,"children":26468},{"style":157},[26469],{"type":34,"value":19726},{"type":29,"tag":88,"props":26471,"children":26472},{"style":122},[26473],{"type":34,"value":338},{"type":29,"tag":88,"props":26475,"children":26476},{"style":157},[26477],{"type":34,"value":18091},{"type":29,"tag":88,"props":26479,"children":26480},{"style":122},[26481],{"type":34,"value":338},{"type":29,"tag":88,"props":26483,"children":26484},{"style":174},[26485],{"type":34,"value":18100},{"type":29,"tag":88,"props":26487,"children":26488},{"style":122},[26489],{"type":34,"value":181},{"type":29,"tag":88,"props":26491,"children":26492},{"style":184},[26493],{"type":34,"value":24593},{"type":29,"tag":88,"props":26495,"children":26496},{"style":163},[26497],{"type":34,"value":5485},{"type":29,"tag":88,"props":26499,"children":26500},{"style":157},[26501],{"type":34,"value":23950},{"type":29,"tag":88,"props":26503,"children":26504},{"style":122},[26505],{"type":34,"value":357},{"type":29,"tag":88,"props":26507,"children":26508},{"class":90,"line":929},[26509],{"type":29,"tag":88,"props":26510,"children":26511},{"style":122},[26512],{"type":34,"value":433},{"type":29,"tag":88,"props":26514,"children":26515},{"class":90,"line":937},[26516],{"type":29,"tag":88,"props":26517,"children":26518},{"style":122},[26519],{"type":34,"value":442},{"type":29,"tag":88,"props":26521,"children":26522},{"class":90,"line":945},[26523],{"type":29,"tag":88,"props":26524,"children":26525},{"emptyLinePlaceholder":13},[26526],{"type":34,"value":134},{"type":29,"tag":88,"props":26528,"children":26529},{"class":90,"line":981},[26530],{"type":29,"tag":88,"props":26531,"children":26532},{"style":95},[26533],{"type":34,"value":26534},"\u002F\u002F Service de notification respectant le DIP\n",{"type":29,"tag":88,"props":26536,"children":26537},{"class":90,"line":1021},[26538,26542,26546,26550],{"type":29,"tag":88,"props":26539,"children":26540},{"style":105},[26541],{"type":34,"value":108},{"type":29,"tag":88,"props":26543,"children":26544},{"style":105},[26545],{"type":34,"value":113},{"type":29,"tag":88,"props":26547,"children":26548},{"style":116},[26549],{"type":34,"value":4662},{"type":29,"tag":88,"props":26551,"children":26552},{"style":122},[26553],{"type":34,"value":125},{"type":29,"tag":88,"props":26555,"children":26556},{"class":90,"line":1066},[26557,26561,26565,26570],{"type":29,"tag":88,"props":26558,"children":26559},{"style":105},[26560],{"type":34,"value":143},{"type":29,"tag":88,"props":26562,"children":26563},{"style":151},[26564],{"type":34,"value":26189},{"type":29,"tag":88,"props":26566,"children":26567},{"style":157},[26568],{"type":34,"value":26569}," messageSender",{"type":29,"tag":88,"props":26571,"children":26572},{"style":122},[26573],{"type":34,"value":424},{"type":29,"tag":88,"props":26575,"children":26576},{"class":90,"line":1082},[26577],{"type":29,"tag":88,"props":26578,"children":26579},{"emptyLinePlaceholder":13},[26580],{"type":34,"value":134},{"type":29,"tag":88,"props":26582,"children":26583},{"class":90,"line":1090},[26584],{"type":29,"tag":88,"props":26585,"children":26586},{"style":95},[26587],{"type":34,"value":26588},"    \u002F\u002F Injection de la dépendance via le constructeur\n",{"type":29,"tag":88,"props":26590,"children":26591},{"class":90,"line":1098},[26592,26596,26600,26604,26609,26613,26617],{"type":29,"tag":88,"props":26593,"children":26594},{"style":105},[26595],{"type":34,"value":276},{"type":29,"tag":88,"props":26597,"children":26598},{"style":174},[26599],{"type":34,"value":4662},{"type":29,"tag":88,"props":26601,"children":26602},{"style":122},[26603],{"type":34,"value":181},{"type":29,"tag":88,"props":26605,"children":26606},{"style":151},[26607],{"type":34,"value":26608},"MessageSender",{"type":29,"tag":88,"props":26610,"children":26611},{"style":298},[26612],{"type":34,"value":26569},{"type":29,"tag":88,"props":26614,"children":26615},{"style":122},[26616],{"type":34,"value":306},{"type":29,"tag":88,"props":26618,"children":26619},{"style":122},[26620],{"type":34,"value":125},{"type":29,"tag":88,"props":26622,"children":26623},{"class":90,"line":1106},[26624,26628,26632,26637,26641,26645],{"type":29,"tag":88,"props":26625,"children":26626},{"style":873},[26627],{"type":34,"value":876},{"type":29,"tag":88,"props":26629,"children":26630},{"style":122},[26631],{"type":34,"value":338},{"type":29,"tag":88,"props":26633,"children":26634},{"style":157},[26635],{"type":34,"value":26636},"messageSender ",{"type":29,"tag":88,"props":26638,"children":26639},{"style":163},[26640],{"type":34,"value":166},{"type":29,"tag":88,"props":26642,"children":26643},{"style":157},[26644],{"type":34,"value":26569},{"type":29,"tag":88,"props":26646,"children":26647},{"style":122},[26648],{"type":34,"value":424},{"type":29,"tag":88,"props":26650,"children":26651},{"class":90,"line":1115},[26652],{"type":29,"tag":88,"props":26653,"children":26654},{"style":122},[26655],{"type":34,"value":433},{"type":29,"tag":88,"props":26657,"children":26658},{"class":90,"line":11},[26659],{"type":29,"tag":88,"props":26660,"children":26661},{"emptyLinePlaceholder":13},[26662],{"type":34,"value":134},{"type":29,"tag":88,"props":26664,"children":26665},{"class":90,"line":1180},[26666,26670,26674,26678,26682,26686,26690,26694],{"type":29,"tag":88,"props":26667,"children":26668},{"style":105},[26669],{"type":34,"value":276},{"type":29,"tag":88,"props":26671,"children":26672},{"style":105},[26673],{"type":34,"value":1303},{"type":29,"tag":88,"props":26675,"children":26676},{"style":174},[26677],{"type":34,"value":24148},{"type":29,"tag":88,"props":26679,"children":26680},{"style":122},[26681],{"type":34,"value":181},{"type":29,"tag":88,"props":26683,"children":26684},{"style":151},[26685],{"type":34,"value":695},{"type":29,"tag":88,"props":26687,"children":26688},{"style":298},[26689],{"type":34,"value":23950},{"type":29,"tag":88,"props":26691,"children":26692},{"style":122},[26693],{"type":34,"value":306},{"type":29,"tag":88,"props":26695,"children":26696},{"style":122},[26697],{"type":34,"value":125},{"type":29,"tag":88,"props":26699,"children":26700},{"class":90,"line":1240},[26701,26706,26710,26715,26719,26723],{"type":29,"tag":88,"props":26702,"children":26703},{"style":157},[26704],{"type":34,"value":26705},"        messageSender",{"type":29,"tag":88,"props":26707,"children":26708},{"style":122},[26709],{"type":34,"value":338},{"type":29,"tag":88,"props":26711,"children":26712},{"style":174},[26713],{"type":34,"value":26714},"sendMessage",{"type":29,"tag":88,"props":26716,"children":26717},{"style":122},[26718],{"type":34,"value":181},{"type":29,"tag":88,"props":26720,"children":26721},{"style":157},[26722],{"type":34,"value":24193},{"type":29,"tag":88,"props":26724,"children":26725},{"style":122},[26726],{"type":34,"value":357},{"type":29,"tag":88,"props":26728,"children":26729},{"class":90,"line":1248},[26730],{"type":29,"tag":88,"props":26731,"children":26732},{"style":122},[26733],{"type":34,"value":433},{"type":29,"tag":88,"props":26735,"children":26736},{"class":90,"line":1256},[26737],{"type":29,"tag":88,"props":26738,"children":26739},{"style":122},[26740],{"type":34,"value":442},{"type":29,"tag":30,"props":26742,"children":26743},{},[26744,26746,26751,26753,26758,26760,26765,26767,26772],{"type":34,"value":26745},"Dans ce nouvel exemple, ",{"type":29,"tag":84,"props":26747,"children":26749},{"className":26748},[],[26750],{"type":34,"value":23875},{"type":34,"value":26752}," dépend d'une abstraction (",{"type":29,"tag":84,"props":26754,"children":26756},{"className":26755},[],[26757],{"type":34,"value":26608},{"type":34,"value":26759},"), plus d'une implémentation concrète comme ",{"type":29,"tag":84,"props":26761,"children":26763},{"className":26762},[],[26764],{"type":34,"value":24855},{"type":34,"value":26766},". Changer le mode d'envoi devient trivial, sans modifier ",{"type":29,"tag":84,"props":26768,"children":26770},{"className":26769},[],[26771],{"type":34,"value":23875},{"type":34,"value":26773},". Pour passer aux SMS au lieu des emails :",{"type":29,"tag":77,"props":26775,"children":26777},{"className":81,"code":26776,"language":80,"meta":8,"style":8},"public class Main {\n    public static void main(String[] args) {\n        \u002F\u002F 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        \u002F\u002F 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",[26778],{"type":29,"tag":84,"props":26779,"children":26780},{"__ignoreMap":8},[26781,26800,26843,26851,26879,26914,26942,26949,26957,26984,27020,27048,27055],{"type":29,"tag":88,"props":26782,"children":26783},{"class":90,"line":91},[26784,26788,26792,26796],{"type":29,"tag":88,"props":26785,"children":26786},{"style":105},[26787],{"type":34,"value":108},{"type":29,"tag":88,"props":26789,"children":26790},{"style":105},[26791],{"type":34,"value":113},{"type":29,"tag":88,"props":26793,"children":26794},{"style":116},[26795],{"type":34,"value":21224},{"type":29,"tag":88,"props":26797,"children":26798},{"style":122},[26799],{"type":34,"value":125},{"type":29,"tag":88,"props":26801,"children":26802},{"class":90,"line":101},[26803,26807,26811,26815,26819,26823,26827,26831,26835,26839],{"type":29,"tag":88,"props":26804,"children":26805},{"style":105},[26806],{"type":34,"value":276},{"type":29,"tag":88,"props":26808,"children":26809},{"style":105},[26810],{"type":34,"value":12248},{"type":29,"tag":88,"props":26812,"children":26813},{"style":105},[26814],{"type":34,"value":1303},{"type":29,"tag":88,"props":26816,"children":26817},{"style":174},[26818],{"type":34,"value":21248},{"type":29,"tag":88,"props":26820,"children":26821},{"style":122},[26822],{"type":34,"value":181},{"type":29,"tag":88,"props":26824,"children":26825},{"style":105},[26826],{"type":34,"value":695},{"type":29,"tag":88,"props":26828,"children":26829},{"style":122},[26830],{"type":34,"value":21261},{"type":29,"tag":88,"props":26832,"children":26833},{"style":298},[26834],{"type":34,"value":21266},{"type":29,"tag":88,"props":26836,"children":26837},{"style":122},[26838],{"type":34,"value":306},{"type":29,"tag":88,"props":26840,"children":26841},{"style":122},[26842],{"type":34,"value":125},{"type":29,"tag":88,"props":26844,"children":26845},{"class":90,"line":128},[26846],{"type":29,"tag":88,"props":26847,"children":26848},{"style":95},[26849],{"type":34,"value":26850},"        \u002F\u002F Injection d'une implémentation concrète\n",{"type":29,"tag":88,"props":26852,"children":26853},{"class":90,"line":137},[26854,26859,26863,26867,26871,26875],{"type":29,"tag":88,"props":26855,"children":26856},{"style":151},[26857],{"type":34,"value":26858},"        MessageSender",{"type":29,"tag":88,"props":26860,"children":26861},{"style":157},[26862],{"type":34,"value":24968},{"type":29,"tag":88,"props":26864,"children":26865},{"style":163},[26866],{"type":34,"value":166},{"type":29,"tag":88,"props":26868,"children":26869},{"style":105},[26870],{"type":34,"value":171},{"type":29,"tag":88,"props":26872,"children":26873},{"style":174},[26874],{"type":34,"value":24357},{"type":29,"tag":88,"props":26876,"children":26877},{"style":122},[26878],{"type":34,"value":1810},{"type":29,"tag":88,"props":26880,"children":26881},{"class":90,"line":211},[26882,26886,26890,26894,26898,26902,26906,26910],{"type":29,"tag":88,"props":26883,"children":26884},{"style":151},[26885],{"type":34,"value":24992},{"type":29,"tag":88,"props":26887,"children":26888},{"style":157},[26889],{"type":34,"value":24997},{"type":29,"tag":88,"props":26891,"children":26892},{"style":163},[26893],{"type":34,"value":166},{"type":29,"tag":88,"props":26895,"children":26896},{"style":105},[26897],{"type":34,"value":171},{"type":29,"tag":88,"props":26899,"children":26900},{"style":174},[26901],{"type":34,"value":4662},{"type":29,"tag":88,"props":26903,"children":26904},{"style":122},[26905],{"type":34,"value":181},{"type":29,"tag":88,"props":26907,"children":26908},{"style":157},[26909],{"type":34,"value":25018},{"type":29,"tag":88,"props":26911,"children":26912},{"style":122},[26913],{"type":34,"value":357},{"type":29,"tag":88,"props":26915,"children":26916},{"class":90,"line":262},[26917,26921,26925,26929,26933,26938],{"type":29,"tag":88,"props":26918,"children":26919},{"style":157},[26920],{"type":34,"value":5201},{"type":29,"tag":88,"props":26922,"children":26923},{"style":122},[26924],{"type":34,"value":338},{"type":29,"tag":88,"props":26926,"children":26927},{"style":174},[26928],{"type":34,"value":25038},{"type":29,"tag":88,"props":26930,"children":26931},{"style":122},[26932],{"type":34,"value":181},{"type":29,"tag":88,"props":26934,"children":26935},{"style":184},[26936],{"type":34,"value":26937},"\"Hello par Email!\"",{"type":29,"tag":88,"props":26939,"children":26940},{"style":122},[26941],{"type":34,"value":357},{"type":29,"tag":88,"props":26943,"children":26944},{"class":90,"line":270},[26945],{"type":29,"tag":88,"props":26946,"children":26947},{"emptyLinePlaceholder":13},[26948],{"type":34,"value":134},{"type":29,"tag":88,"props":26950,"children":26951},{"class":90,"line":313},[26952],{"type":29,"tag":88,"props":26953,"children":26954},{"style":95},[26955],{"type":34,"value":26956},"        \u002F\u002F Changement facile d'implémentation sans modifier NotificationService\n",{"type":29,"tag":88,"props":26958,"children":26959},{"class":90,"line":360},[26960,26964,26968,26972,26976,26980],{"type":29,"tag":88,"props":26961,"children":26962},{"style":151},[26963],{"type":34,"value":26858},{"type":29,"tag":88,"props":26965,"children":26966},{"style":157},[26967],{"type":34,"value":25078},{"type":29,"tag":88,"props":26969,"children":26970},{"style":163},[26971],{"type":34,"value":166},{"type":29,"tag":88,"props":26973,"children":26974},{"style":105},[26975],{"type":34,"value":171},{"type":29,"tag":88,"props":26977,"children":26978},{"style":174},[26979],{"type":34,"value":26404},{"type":29,"tag":88,"props":26981,"children":26982},{"style":122},[26983],{"type":34,"value":1810},{"type":29,"tag":88,"props":26985,"children":26986},{"class":90,"line":409},[26987,26991,26996,27000,27004,27008,27012,27016],{"type":29,"tag":88,"props":26988,"children":26989},{"style":151},[26990],{"type":34,"value":24992},{"type":29,"tag":88,"props":26992,"children":26993},{"style":157},[26994],{"type":34,"value":26995}," smsNotificationService ",{"type":29,"tag":88,"props":26997,"children":26998},{"style":163},[26999],{"type":34,"value":166},{"type":29,"tag":88,"props":27001,"children":27002},{"style":105},[27003],{"type":34,"value":171},{"type":29,"tag":88,"props":27005,"children":27006},{"style":174},[27007],{"type":34,"value":4662},{"type":29,"tag":88,"props":27009,"children":27010},{"style":122},[27011],{"type":34,"value":181},{"type":29,"tag":88,"props":27013,"children":27014},{"style":157},[27015],{"type":34,"value":25137},{"type":29,"tag":88,"props":27017,"children":27018},{"style":122},[27019],{"type":34,"value":357},{"type":29,"tag":88,"props":27021,"children":27022},{"class":90,"line":427},[27023,27027,27031,27035,27039,27044],{"type":29,"tag":88,"props":27024,"children":27025},{"style":157},[27026],{"type":34,"value":25149},{"type":29,"tag":88,"props":27028,"children":27029},{"style":122},[27030],{"type":34,"value":338},{"type":29,"tag":88,"props":27032,"children":27033},{"style":174},[27034],{"type":34,"value":25038},{"type":29,"tag":88,"props":27036,"children":27037},{"style":122},[27038],{"type":34,"value":181},{"type":29,"tag":88,"props":27040,"children":27041},{"style":184},[27042],{"type":34,"value":27043},"\"Hello par SMS!\"",{"type":29,"tag":88,"props":27045,"children":27046},{"style":122},[27047],{"type":34,"value":357},{"type":29,"tag":88,"props":27049,"children":27050},{"class":90,"line":436},[27051],{"type":29,"tag":88,"props":27052,"children":27053},{"style":122},[27054],{"type":34,"value":433},{"type":29,"tag":88,"props":27056,"children":27057},{"class":90,"line":767},[27058],{"type":29,"tag":88,"props":27059,"children":27060},{"style":122},[27061],{"type":34,"value":442},{"type":29,"tag":8542,"props":27063,"children":27065},{"id":27064},"ce-que-nous-avons-corrigé",[27066],{"type":34,"value":27067},"Ce que nous avons corrigé :",{"type":29,"tag":453,"props":27069,"children":27070},{},[27071],{"type":29,"tag":457,"props":27072,"children":27073},{},[27074,27075],{"type":34,"value":10145},{"type":29,"tag":447,"props":27076,"children":27077},{},[27078],{"type":34,"value":23875},{"type":29,"tag":30,"props":27080,"children":27081},{},[27082,27084,27089],{"type":34,"value":27083},"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":29,"tag":84,"props":27085,"children":27087},{"className":27086},[],[27088],{"type":34,"value":26608},{"type":34,"value":8127},{"type":29,"tag":453,"props":27091,"children":27092},{},[27093],{"type":29,"tag":457,"props":27094,"children":27095},{},[27096,27098,27103],{"type":34,"value":27097},"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":29,"tag":84,"props":27099,"children":27101},{"className":27100},[],[27102],{"type":34,"value":26608},{"type":34,"value":27104}," sans toucher au code existant.",{"type":29,"tag":8526,"props":27106,"children":27108},{"type":27107},"tip",[27109],{"type":29,"tag":30,"props":27110,"children":27111},{},[27112,27114,27118],{"type":34,"value":27113},"Je vous recommande de toujours préférer l'injection de dépendances via des ",{"type":29,"tag":447,"props":27115,"children":27116},{},[27117],{"type":34,"value":25701},{"type":34,"value":27119},". Cela vous permettra de changer facilement les implémentations sans avoir à modifier plusieurs classes.",{"type":29,"tag":47,"props":27121,"children":27122},{},[],{"type":29,"tag":51,"props":27124,"children":27126},{"id":27125},"comment-appliquer-le-dip-dans-un-projet-java",[27127],{"type":34,"value":27128},"Comment appliquer le DIP dans un projet Java",{"type":29,"tag":30,"props":27130,"children":27131},{},[27132,27134,27139,27141,27145,27147,27152],{"type":34,"value":27133},"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":29,"tag":447,"props":27135,"children":27136},{},[27137],{"type":34,"value":27138},"Spring",{"type":34,"value":27140}," nous facilitent grandement l'implémentation du ",{"type":29,"tag":447,"props":27142,"children":27143},{},[27144],{"type":34,"value":25500},{"type":34,"value":27146}," grâce à des concepts comme l'",{"type":29,"tag":447,"props":27148,"children":27149},{},[27150],{"type":34,"value":27151},"injection de dépendances",{"type":34,"value":338},{"type":29,"tag":8542,"props":27154,"children":27156},{"id":27155},"utiliser-spring-pour-appliquer-le-dip",[27157],{"type":34,"value":27158},"Utiliser Spring pour appliquer le DIP",{"type":29,"tag":30,"props":27160,"children":27161},{},[27162,27164,27169,27171,27175],{"type":34,"value":27163},"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":29,"tag":447,"props":27165,"children":27166},{},[27167],{"type":34,"value":27168},"framework Spring",{"type":34,"value":27170}," entre en jeu. Spring facilite l’application du ",{"type":29,"tag":447,"props":27172,"children":27173},{},[27174],{"type":34,"value":25500},{"type":34,"value":27176}," en fournissant un conteneur d’injection de dépendances qui gère la création et l’injection des objets à votre place.",{"type":29,"tag":8526,"props":27178,"children":27179},{"type":27107},[27180],{"type":29,"tag":30,"props":27181,"children":27182},{},[27183,27185,27191,27192,27197],{"type":34,"value":27184},"Utilisez les annotations ",{"type":29,"tag":84,"props":27186,"children":27188},{"className":27187},[],[27189],{"type":34,"value":27190},"@Autowired",{"type":34,"value":8982},{"type":29,"tag":84,"props":27193,"children":27195},{"className":27194},[],[27196],{"type":34,"value":4620},{"type":34,"value":27198}," 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":29,"tag":47,"props":27200,"children":27201},{},[],{"type":29,"tag":8542,"props":27203,"children":27205},{"id":27204},"exemple-avec-spring",[27206],{"type":34,"value":27207},"Exemple avec Spring",{"type":29,"tag":30,"props":27209,"children":27210},{},[27211],{"type":34,"value":27212},"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":29,"tag":17095,"props":27214,"children":27215},{},[27216],{"type":29,"tag":457,"props":27217,"children":27218},{},[27219,27224],{"type":29,"tag":447,"props":27220,"children":27221},{},[27222],{"type":34,"value":27223},"Définir les interfaces et implémentations comme avant",{"type":34,"value":21063},{"type":29,"tag":77,"props":27226,"children":27228},{"className":81,"code":27227,"language":80,"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",[27229],{"type":29,"tag":84,"props":27230,"children":27231},{"__ignoreMap":8},[27232,27251,27278,27285,27292,27304,27331,27342,27377,27420,27427,27434,27441,27452,27479,27490,27525,27568,27575],{"type":29,"tag":88,"props":27233,"children":27234},{"class":90,"line":91},[27235,27239,27243,27247],{"type":29,"tag":88,"props":27236,"children":27237},{"style":105},[27238],{"type":34,"value":108},{"type":29,"tag":88,"props":27240,"children":27241},{"style":105},[27242],{"type":34,"value":601},{"type":29,"tag":88,"props":27244,"children":27245},{"style":116},[27246],{"type":34,"value":26189},{"type":29,"tag":88,"props":27248,"children":27249},{"style":122},[27250],{"type":34,"value":125},{"type":29,"tag":88,"props":27252,"children":27253},{"class":90,"line":101},[27254,27258,27262,27266,27270,27274],{"type":29,"tag":88,"props":27255,"children":27256},{"style":105},[27257],{"type":34,"value":681},{"type":29,"tag":88,"props":27259,"children":27260},{"style":174},[27261],{"type":34,"value":26205},{"type":29,"tag":88,"props":27263,"children":27264},{"style":122},[27265],{"type":34,"value":181},{"type":29,"tag":88,"props":27267,"children":27268},{"style":151},[27269],{"type":34,"value":695},{"type":29,"tag":88,"props":27271,"children":27272},{"style":298},[27273],{"type":34,"value":23950},{"type":29,"tag":88,"props":27275,"children":27276},{"style":122},[27277],{"type":34,"value":357},{"type":29,"tag":88,"props":27279,"children":27280},{"class":90,"line":128},[27281],{"type":29,"tag":88,"props":27282,"children":27283},{"style":122},[27284],{"type":34,"value":442},{"type":29,"tag":88,"props":27286,"children":27287},{"class":90,"line":137},[27288],{"type":29,"tag":88,"props":27289,"children":27290},{"emptyLinePlaceholder":13},[27291],{"type":34,"value":134},{"type":29,"tag":88,"props":27293,"children":27294},{"class":90,"line":211},[27295,27299],{"type":29,"tag":88,"props":27296,"children":27297},{"style":1974},[27298],{"type":34,"value":1977},{"type":29,"tag":88,"props":27300,"children":27301},{"style":1980},[27302],{"type":34,"value":27303},"Component\n",{"type":29,"tag":88,"props":27305,"children":27306},{"class":90,"line":262},[27307,27311,27315,27319,27323,27327],{"type":29,"tag":88,"props":27308,"children":27309},{"style":105},[27310],{"type":34,"value":108},{"type":29,"tag":88,"props":27312,"children":27313},{"style":105},[27314],{"type":34,"value":113},{"type":29,"tag":88,"props":27316,"children":27317},{"style":116},[27318],{"type":34,"value":24357},{"type":29,"tag":88,"props":27320,"children":27321},{"style":105},[27322],{"type":34,"value":1134},{"type":29,"tag":88,"props":27324,"children":27325},{"style":116},[27326],{"type":34,"value":26189},{"type":29,"tag":88,"props":27328,"children":27329},{"style":122},[27330],{"type":34,"value":125},{"type":29,"tag":88,"props":27332,"children":27333},{"class":90,"line":270},[27334,27338],{"type":29,"tag":88,"props":27335,"children":27336},{"style":1974},[27337],{"type":34,"value":3302},{"type":29,"tag":88,"props":27339,"children":27340},{"style":1980},[27341],{"type":34,"value":3307},{"type":29,"tag":88,"props":27343,"children":27344},{"class":90,"line":313},[27345,27349,27353,27357,27361,27365,27369,27373],{"type":29,"tag":88,"props":27346,"children":27347},{"style":105},[27348],{"type":34,"value":276},{"type":29,"tag":88,"props":27350,"children":27351},{"style":105},[27352],{"type":34,"value":1303},{"type":29,"tag":88,"props":27354,"children":27355},{"style":174},[27356],{"type":34,"value":26205},{"type":29,"tag":88,"props":27358,"children":27359},{"style":122},[27360],{"type":34,"value":181},{"type":29,"tag":88,"props":27362,"children":27363},{"style":151},[27364],{"type":34,"value":695},{"type":29,"tag":88,"props":27366,"children":27367},{"style":298},[27368],{"type":34,"value":23950},{"type":29,"tag":88,"props":27370,"children":27371},{"style":122},[27372],{"type":34,"value":306},{"type":29,"tag":88,"props":27374,"children":27375},{"style":122},[27376],{"type":34,"value":125},{"type":29,"tag":88,"props":27378,"children":27379},{"class":90,"line":360},[27380,27384,27388,27392,27396,27400,27404,27408,27412,27416],{"type":29,"tag":88,"props":27381,"children":27382},{"style":157},[27383],{"type":34,"value":19726},{"type":29,"tag":88,"props":27385,"children":27386},{"style":122},[27387],{"type":34,"value":338},{"type":29,"tag":88,"props":27389,"children":27390},{"style":157},[27391],{"type":34,"value":18091},{"type":29,"tag":88,"props":27393,"children":27394},{"style":122},[27395],{"type":34,"value":338},{"type":29,"tag":88,"props":27397,"children":27398},{"style":174},[27399],{"type":34,"value":18100},{"type":29,"tag":88,"props":27401,"children":27402},{"style":122},[27403],{"type":34,"value":181},{"type":29,"tag":88,"props":27405,"children":27406},{"style":184},[27407],{"type":34,"value":23990},{"type":29,"tag":88,"props":27409,"children":27410},{"style":163},[27411],{"type":34,"value":5485},{"type":29,"tag":88,"props":27413,"children":27414},{"style":157},[27415],{"type":34,"value":23950},{"type":29,"tag":88,"props":27417,"children":27418},{"style":122},[27419],{"type":34,"value":357},{"type":29,"tag":88,"props":27421,"children":27422},{"class":90,"line":409},[27423],{"type":29,"tag":88,"props":27424,"children":27425},{"style":122},[27426],{"type":34,"value":433},{"type":29,"tag":88,"props":27428,"children":27429},{"class":90,"line":427},[27430],{"type":29,"tag":88,"props":27431,"children":27432},{"style":122},[27433],{"type":34,"value":442},{"type":29,"tag":88,"props":27435,"children":27436},{"class":90,"line":436},[27437],{"type":29,"tag":88,"props":27438,"children":27439},{"emptyLinePlaceholder":13},[27440],{"type":34,"value":134},{"type":29,"tag":88,"props":27442,"children":27443},{"class":90,"line":767},[27444,27448],{"type":29,"tag":88,"props":27445,"children":27446},{"style":1974},[27447],{"type":34,"value":1977},{"type":29,"tag":88,"props":27449,"children":27450},{"style":1980},[27451],{"type":34,"value":27303},{"type":29,"tag":88,"props":27453,"children":27454},{"class":90,"line":792},[27455,27459,27463,27467,27471,27475],{"type":29,"tag":88,"props":27456,"children":27457},{"style":105},[27458],{"type":34,"value":108},{"type":29,"tag":88,"props":27460,"children":27461},{"style":105},[27462],{"type":34,"value":113},{"type":29,"tag":88,"props":27464,"children":27465},{"style":116},[27466],{"type":34,"value":26404},{"type":29,"tag":88,"props":27468,"children":27469},{"style":105},[27470],{"type":34,"value":1134},{"type":29,"tag":88,"props":27472,"children":27473},{"style":116},[27474],{"type":34,"value":26189},{"type":29,"tag":88,"props":27476,"children":27477},{"style":122},[27478],{"type":34,"value":125},{"type":29,"tag":88,"props":27480,"children":27481},{"class":90,"line":817},[27482,27486],{"type":29,"tag":88,"props":27483,"children":27484},{"style":1974},[27485],{"type":34,"value":3302},{"type":29,"tag":88,"props":27487,"children":27488},{"style":1980},[27489],{"type":34,"value":3307},{"type":29,"tag":88,"props":27491,"children":27492},{"class":90,"line":825},[27493,27497,27501,27505,27509,27513,27517,27521],{"type":29,"tag":88,"props":27494,"children":27495},{"style":105},[27496],{"type":34,"value":276},{"type":29,"tag":88,"props":27498,"children":27499},{"style":105},[27500],{"type":34,"value":1303},{"type":29,"tag":88,"props":27502,"children":27503},{"style":174},[27504],{"type":34,"value":26205},{"type":29,"tag":88,"props":27506,"children":27507},{"style":122},[27508],{"type":34,"value":181},{"type":29,"tag":88,"props":27510,"children":27511},{"style":151},[27512],{"type":34,"value":695},{"type":29,"tag":88,"props":27514,"children":27515},{"style":298},[27516],{"type":34,"value":23950},{"type":29,"tag":88,"props":27518,"children":27519},{"style":122},[27520],{"type":34,"value":306},{"type":29,"tag":88,"props":27522,"children":27523},{"style":122},[27524],{"type":34,"value":125},{"type":29,"tag":88,"props":27526,"children":27527},{"class":90,"line":869},[27528,27532,27536,27540,27544,27548,27552,27556,27560,27564],{"type":29,"tag":88,"props":27529,"children":27530},{"style":157},[27531],{"type":34,"value":19726},{"type":29,"tag":88,"props":27533,"children":27534},{"style":122},[27535],{"type":34,"value":338},{"type":29,"tag":88,"props":27537,"children":27538},{"style":157},[27539],{"type":34,"value":18091},{"type":29,"tag":88,"props":27541,"children":27542},{"style":122},[27543],{"type":34,"value":338},{"type":29,"tag":88,"props":27545,"children":27546},{"style":174},[27547],{"type":34,"value":18100},{"type":29,"tag":88,"props":27549,"children":27550},{"style":122},[27551],{"type":34,"value":181},{"type":29,"tag":88,"props":27553,"children":27554},{"style":184},[27555],{"type":34,"value":24593},{"type":29,"tag":88,"props":27557,"children":27558},{"style":163},[27559],{"type":34,"value":5485},{"type":29,"tag":88,"props":27561,"children":27562},{"style":157},[27563],{"type":34,"value":23950},{"type":29,"tag":88,"props":27565,"children":27566},{"style":122},[27567],{"type":34,"value":357},{"type":29,"tag":88,"props":27569,"children":27570},{"class":90,"line":900},[27571],{"type":29,"tag":88,"props":27572,"children":27573},{"style":122},[27574],{"type":34,"value":433},{"type":29,"tag":88,"props":27576,"children":27577},{"class":90,"line":929},[27578],{"type":29,"tag":88,"props":27579,"children":27580},{"style":122},[27581],{"type":34,"value":442},{"type":29,"tag":17095,"props":27583,"children":27584},{"start":101},[27585],{"type":29,"tag":457,"props":27586,"children":27587},{},[27588,27593,27594,27597,27599,27604,27606,27611,27613,27618],{"type":29,"tag":447,"props":27589,"children":27590},{},[27591],{"type":34,"value":27592},"Injection de dépendances avec Spring",{"type":34,"value":21063},{"type":29,"tag":11452,"props":27595,"children":27596},{},[],{"type":34,"value":27598},"Nous allons maintenant utiliser l'annotation ",{"type":29,"tag":84,"props":27600,"children":27602},{"className":27601},[],[27603],{"type":34,"value":27190},{"type":34,"value":27605}," de Spring pour injecter l'implémentation concrète de ",{"type":29,"tag":84,"props":27607,"children":27609},{"className":27608},[],[27610],{"type":34,"value":26608},{"type":34,"value":27612}," dans ",{"type":29,"tag":84,"props":27614,"children":27616},{"className":27615},[],[27617],{"type":34,"value":23875},{"type":34,"value":27619},", sans avoir à gérer manuellement l'instanciation.",{"type":29,"tag":77,"props":27621,"children":27623},{"className":81,"code":27622,"language":80,"meta":8,"style":8},"@Component\npublic class NotificationService {\n    private final MessageSender messageSender;\n\n    \u002F\u002F 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",[27624],{"type":29,"tag":84,"props":27625,"children":27626},{"__ignoreMap":8},[27627,27638,27657,27680,27687,27695,27706,27737,27764,27771,27778,27813,27840,27847],{"type":29,"tag":88,"props":27628,"children":27629},{"class":90,"line":91},[27630,27634],{"type":29,"tag":88,"props":27631,"children":27632},{"style":1974},[27633],{"type":34,"value":1977},{"type":29,"tag":88,"props":27635,"children":27636},{"style":1980},[27637],{"type":34,"value":27303},{"type":29,"tag":88,"props":27639,"children":27640},{"class":90,"line":101},[27641,27645,27649,27653],{"type":29,"tag":88,"props":27642,"children":27643},{"style":105},[27644],{"type":34,"value":108},{"type":29,"tag":88,"props":27646,"children":27647},{"style":105},[27648],{"type":34,"value":113},{"type":29,"tag":88,"props":27650,"children":27651},{"style":116},[27652],{"type":34,"value":4662},{"type":29,"tag":88,"props":27654,"children":27655},{"style":122},[27656],{"type":34,"value":125},{"type":29,"tag":88,"props":27658,"children":27659},{"class":90,"line":128},[27660,27664,27668,27672,27676],{"type":29,"tag":88,"props":27661,"children":27662},{"style":105},[27663],{"type":34,"value":143},{"type":29,"tag":88,"props":27665,"children":27666},{"style":105},[27667],{"type":34,"value":148},{"type":29,"tag":88,"props":27669,"children":27670},{"style":151},[27671],{"type":34,"value":26189},{"type":29,"tag":88,"props":27673,"children":27674},{"style":157},[27675],{"type":34,"value":26569},{"type":29,"tag":88,"props":27677,"children":27678},{"style":122},[27679],{"type":34,"value":424},{"type":29,"tag":88,"props":27681,"children":27682},{"class":90,"line":137},[27683],{"type":29,"tag":88,"props":27684,"children":27685},{"emptyLinePlaceholder":13},[27686],{"type":34,"value":134},{"type":29,"tag":88,"props":27688,"children":27689},{"class":90,"line":211},[27690],{"type":29,"tag":88,"props":27691,"children":27692},{"style":95},[27693],{"type":34,"value":27694},"    \u002F\u002F Injection de la dépendance par constructeur\n",{"type":29,"tag":88,"props":27696,"children":27697},{"class":90,"line":262},[27698,27702],{"type":29,"tag":88,"props":27699,"children":27700},{"style":1974},[27701],{"type":34,"value":3302},{"type":29,"tag":88,"props":27703,"children":27704},{"style":1980},[27705],{"type":34,"value":5968},{"type":29,"tag":88,"props":27707,"children":27708},{"class":90,"line":270},[27709,27713,27717,27721,27725,27729,27733],{"type":29,"tag":88,"props":27710,"children":27711},{"style":105},[27712],{"type":34,"value":276},{"type":29,"tag":88,"props":27714,"children":27715},{"style":174},[27716],{"type":34,"value":4662},{"type":29,"tag":88,"props":27718,"children":27719},{"style":122},[27720],{"type":34,"value":181},{"type":29,"tag":88,"props":27722,"children":27723},{"style":151},[27724],{"type":34,"value":26608},{"type":29,"tag":88,"props":27726,"children":27727},{"style":298},[27728],{"type":34,"value":26569},{"type":29,"tag":88,"props":27730,"children":27731},{"style":122},[27732],{"type":34,"value":306},{"type":29,"tag":88,"props":27734,"children":27735},{"style":122},[27736],{"type":34,"value":125},{"type":29,"tag":88,"props":27738,"children":27739},{"class":90,"line":313},[27740,27744,27748,27752,27756,27760],{"type":29,"tag":88,"props":27741,"children":27742},{"style":873},[27743],{"type":34,"value":876},{"type":29,"tag":88,"props":27745,"children":27746},{"style":122},[27747],{"type":34,"value":338},{"type":29,"tag":88,"props":27749,"children":27750},{"style":157},[27751],{"type":34,"value":26636},{"type":29,"tag":88,"props":27753,"children":27754},{"style":163},[27755],{"type":34,"value":166},{"type":29,"tag":88,"props":27757,"children":27758},{"style":157},[27759],{"type":34,"value":26569},{"type":29,"tag":88,"props":27761,"children":27762},{"style":122},[27763],{"type":34,"value":424},{"type":29,"tag":88,"props":27765,"children":27766},{"class":90,"line":360},[27767],{"type":29,"tag":88,"props":27768,"children":27769},{"style":122},[27770],{"type":34,"value":433},{"type":29,"tag":88,"props":27772,"children":27773},{"class":90,"line":409},[27774],{"type":29,"tag":88,"props":27775,"children":27776},{"emptyLinePlaceholder":13},[27777],{"type":34,"value":134},{"type":29,"tag":88,"props":27779,"children":27780},{"class":90,"line":427},[27781,27785,27789,27793,27797,27801,27805,27809],{"type":29,"tag":88,"props":27782,"children":27783},{"style":105},[27784],{"type":34,"value":276},{"type":29,"tag":88,"props":27786,"children":27787},{"style":105},[27788],{"type":34,"value":1303},{"type":29,"tag":88,"props":27790,"children":27791},{"style":174},[27792],{"type":34,"value":24148},{"type":29,"tag":88,"props":27794,"children":27795},{"style":122},[27796],{"type":34,"value":181},{"type":29,"tag":88,"props":27798,"children":27799},{"style":151},[27800],{"type":34,"value":695},{"type":29,"tag":88,"props":27802,"children":27803},{"style":298},[27804],{"type":34,"value":23950},{"type":29,"tag":88,"props":27806,"children":27807},{"style":122},[27808],{"type":34,"value":306},{"type":29,"tag":88,"props":27810,"children":27811},{"style":122},[27812],{"type":34,"value":125},{"type":29,"tag":88,"props":27814,"children":27815},{"class":90,"line":436},[27816,27820,27824,27828,27832,27836],{"type":29,"tag":88,"props":27817,"children":27818},{"style":157},[27819],{"type":34,"value":26705},{"type":29,"tag":88,"props":27821,"children":27822},{"style":122},[27823],{"type":34,"value":338},{"type":29,"tag":88,"props":27825,"children":27826},{"style":174},[27827],{"type":34,"value":26714},{"type":29,"tag":88,"props":27829,"children":27830},{"style":122},[27831],{"type":34,"value":181},{"type":29,"tag":88,"props":27833,"children":27834},{"style":157},[27835],{"type":34,"value":24193},{"type":29,"tag":88,"props":27837,"children":27838},{"style":122},[27839],{"type":34,"value":357},{"type":29,"tag":88,"props":27841,"children":27842},{"class":90,"line":767},[27843],{"type":29,"tag":88,"props":27844,"children":27845},{"style":122},[27846],{"type":34,"value":433},{"type":29,"tag":88,"props":27848,"children":27849},{"class":90,"line":792},[27850],{"type":29,"tag":88,"props":27851,"children":27852},{"style":122},[27853],{"type":34,"value":442},{"type":29,"tag":17095,"props":27855,"children":27856},{"start":128},[27857],{"type":29,"tag":457,"props":27858,"children":27859},{},[27860,27865],{"type":29,"tag":447,"props":27861,"children":27862},{},[27863],{"type":34,"value":27864},"Configurer et exécuter l’application",{"type":34,"value":21063},{"type":29,"tag":30,"props":27867,"children":27868},{},[27869],{"type":34,"value":27870},"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":29,"tag":77,"props":27872,"children":27874},{"className":81,"code":27873,"language":80,"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        \u002F\u002F Obtenir NotificationService du contexte Spring\n        NotificationService notificationService = context.getBean(NotificationService.class);\n        notificationService.sendNotification(\"Hello via Spring!\");\n    }\n}\n",[27875],{"type":29,"tag":84,"props":27876,"children":27877},{"__ignoreMap":8},[27878,27890,27910,27917,27960,28020,28027,28035,28084,28112,28119],{"type":29,"tag":88,"props":27879,"children":27880},{"class":90,"line":91},[27881,27885],{"type":29,"tag":88,"props":27882,"children":27883},{"style":1974},[27884],{"type":34,"value":1977},{"type":29,"tag":88,"props":27886,"children":27887},{"style":1980},[27888],{"type":34,"value":27889},"SpringBootApplication\n",{"type":29,"tag":88,"props":27891,"children":27892},{"class":90,"line":101},[27893,27897,27901,27906],{"type":29,"tag":88,"props":27894,"children":27895},{"style":105},[27896],{"type":34,"value":108},{"type":29,"tag":88,"props":27898,"children":27899},{"style":105},[27900],{"type":34,"value":113},{"type":29,"tag":88,"props":27902,"children":27903},{"style":116},[27904],{"type":34,"value":27905}," DipExampleApplication",{"type":29,"tag":88,"props":27907,"children":27908},{"style":122},[27909],{"type":34,"value":125},{"type":29,"tag":88,"props":27911,"children":27912},{"class":90,"line":128},[27913],{"type":29,"tag":88,"props":27914,"children":27915},{"emptyLinePlaceholder":13},[27916],{"type":34,"value":134},{"type":29,"tag":88,"props":27918,"children":27919},{"class":90,"line":137},[27920,27924,27928,27932,27936,27940,27944,27948,27952,27956],{"type":29,"tag":88,"props":27921,"children":27922},{"style":105},[27923],{"type":34,"value":276},{"type":29,"tag":88,"props":27925,"children":27926},{"style":105},[27927],{"type":34,"value":12248},{"type":29,"tag":88,"props":27929,"children":27930},{"style":105},[27931],{"type":34,"value":1303},{"type":29,"tag":88,"props":27933,"children":27934},{"style":174},[27935],{"type":34,"value":21248},{"type":29,"tag":88,"props":27937,"children":27938},{"style":122},[27939],{"type":34,"value":181},{"type":29,"tag":88,"props":27941,"children":27942},{"style":105},[27943],{"type":34,"value":695},{"type":29,"tag":88,"props":27945,"children":27946},{"style":122},[27947],{"type":34,"value":21261},{"type":29,"tag":88,"props":27949,"children":27950},{"style":298},[27951],{"type":34,"value":21266},{"type":29,"tag":88,"props":27953,"children":27954},{"style":122},[27955],{"type":34,"value":306},{"type":29,"tag":88,"props":27957,"children":27958},{"style":122},[27959],{"type":34,"value":125},{"type":29,"tag":88,"props":27961,"children":27962},{"class":90,"line":211},[27963,27968,27973,27977,27982,27986,27991,27995,28000,28004,28008,28012,28016],{"type":29,"tag":88,"props":27964,"children":27965},{"style":151},[27966],{"type":34,"value":27967},"        ApplicationContext",{"type":29,"tag":88,"props":27969,"children":27970},{"style":157},[27971],{"type":34,"value":27972}," context ",{"type":29,"tag":88,"props":27974,"children":27975},{"style":163},[27976],{"type":34,"value":166},{"type":29,"tag":88,"props":27978,"children":27979},{"style":157},[27980],{"type":34,"value":27981}," SpringApplication",{"type":29,"tag":88,"props":27983,"children":27984},{"style":122},[27985],{"type":34,"value":338},{"type":29,"tag":88,"props":27987,"children":27988},{"style":174},[27989],{"type":34,"value":27990},"run",{"type":29,"tag":88,"props":27992,"children":27993},{"style":122},[27994],{"type":34,"value":181},{"type":29,"tag":88,"props":27996,"children":27997},{"style":157},[27998],{"type":34,"value":27999},"DipExampleApplication",{"type":29,"tag":88,"props":28001,"children":28002},{"style":122},[28003],{"type":34,"value":338},{"type":29,"tag":88,"props":28005,"children":28006},{"style":157},[28007],{"type":34,"value":1225},{"type":29,"tag":88,"props":28009,"children":28010},{"style":122},[28011],{"type":34,"value":192},{"type":29,"tag":88,"props":28013,"children":28014},{"style":157},[28015],{"type":34,"value":21266},{"type":29,"tag":88,"props":28017,"children":28018},{"style":122},[28019],{"type":34,"value":357},{"type":29,"tag":88,"props":28021,"children":28022},{"class":90,"line":262},[28023],{"type":29,"tag":88,"props":28024,"children":28025},{"emptyLinePlaceholder":13},[28026],{"type":34,"value":134},{"type":29,"tag":88,"props":28028,"children":28029},{"class":90,"line":270},[28030],{"type":29,"tag":88,"props":28031,"children":28032},{"style":95},[28033],{"type":34,"value":28034},"        \u002F\u002F Obtenir NotificationService du contexte Spring\n",{"type":29,"tag":88,"props":28036,"children":28037},{"class":90,"line":313},[28038,28042,28046,28050,28055,28059,28064,28068,28072,28076,28080],{"type":29,"tag":88,"props":28039,"children":28040},{"style":151},[28041],{"type":34,"value":24992},{"type":29,"tag":88,"props":28043,"children":28044},{"style":157},[28045],{"type":34,"value":24997},{"type":29,"tag":88,"props":28047,"children":28048},{"style":163},[28049],{"type":34,"value":166},{"type":29,"tag":88,"props":28051,"children":28052},{"style":157},[28053],{"type":34,"value":28054}," context",{"type":29,"tag":88,"props":28056,"children":28057},{"style":122},[28058],{"type":34,"value":338},{"type":29,"tag":88,"props":28060,"children":28061},{"style":174},[28062],{"type":34,"value":28063},"getBean",{"type":29,"tag":88,"props":28065,"children":28066},{"style":122},[28067],{"type":34,"value":181},{"type":29,"tag":88,"props":28069,"children":28070},{"style":157},[28071],{"type":34,"value":23875},{"type":29,"tag":88,"props":28073,"children":28074},{"style":122},[28075],{"type":34,"value":338},{"type":29,"tag":88,"props":28077,"children":28078},{"style":157},[28079],{"type":34,"value":1225},{"type":29,"tag":88,"props":28081,"children":28082},{"style":122},[28083],{"type":34,"value":357},{"type":29,"tag":88,"props":28085,"children":28086},{"class":90,"line":360},[28087,28091,28095,28099,28103,28108],{"type":29,"tag":88,"props":28088,"children":28089},{"style":157},[28090],{"type":34,"value":5201},{"type":29,"tag":88,"props":28092,"children":28093},{"style":122},[28094],{"type":34,"value":338},{"type":29,"tag":88,"props":28096,"children":28097},{"style":174},[28098],{"type":34,"value":25038},{"type":29,"tag":88,"props":28100,"children":28101},{"style":122},[28102],{"type":34,"value":181},{"type":29,"tag":88,"props":28104,"children":28105},{"style":184},[28106],{"type":34,"value":28107},"\"Hello via Spring!\"",{"type":29,"tag":88,"props":28109,"children":28110},{"style":122},[28111],{"type":34,"value":357},{"type":29,"tag":88,"props":28113,"children":28114},{"class":90,"line":409},[28115],{"type":29,"tag":88,"props":28116,"children":28117},{"style":122},[28118],{"type":34,"value":433},{"type":29,"tag":88,"props":28120,"children":28121},{"class":90,"line":427},[28122],{"type":29,"tag":88,"props":28123,"children":28124},{"style":122},[28125],{"type":34,"value":442},{"type":29,"tag":28127,"props":28128,"children":28130},"h5",{"id":28129},"ce-que-spring-fait-pour-vous",[28131],{"type":34,"value":28132},"Ce que Spring fait pour vous :",{"type":29,"tag":453,"props":28134,"children":28135},{},[28136,28173,28203],{"type":29,"tag":457,"props":28137,"children":28138},{},[28139,28144,28146,28151,28153,28158,28159,28165,28167,28172],{"type":29,"tag":447,"props":28140,"children":28141},{},[28142],{"type":34,"value":28143},"Gestion automatique des dépendances",{"type":34,"value":28145}," : Grâce à Spring, vous n’avez pas besoin de créer manuellement les objets de type ",{"type":29,"tag":84,"props":28147,"children":28149},{"className":28148},[],[28150],{"type":34,"value":26608},{"type":34,"value":28152},". Spring instancie automatiquement la classe ",{"type":29,"tag":84,"props":28154,"children":28156},{"className":28155},[],[28157],{"type":34,"value":24855},{"type":34,"value":5730},{"type":29,"tag":84,"props":28160,"children":28162},{"className":28161},[],[28163],{"type":34,"value":28164},"SmsSender",{"type":34,"value":28166}," (selon la configuration) et l’injecte dans ",{"type":29,"tag":84,"props":28168,"children":28170},{"className":28169},[],[28171],{"type":34,"value":23875},{"type":34,"value":338},{"type":29,"tag":457,"props":28174,"children":28175},{},[28176,28181,28183,28188,28190,28195,28197,28202],{"type":29,"tag":447,"props":28177,"children":28178},{},[28179],{"type":34,"value":28180},"Découplage",{"type":34,"value":28182}," : Comme ",{"type":29,"tag":84,"props":28184,"children":28186},{"className":28185},[],[28187],{"type":34,"value":23875},{"type":34,"value":28189}," dépend de l’interface ",{"type":29,"tag":84,"props":28191,"children":28193},{"className":28192},[],[28194],{"type":34,"value":26608},{"type":34,"value":28196},", vous pouvez facilement changer l’implémentation injectée sans modifier le code de ",{"type":29,"tag":84,"props":28198,"children":28200},{"className":28199},[],[28201],{"type":34,"value":23875},{"type":34,"value":338},{"type":29,"tag":457,"props":28204,"children":28205},{},[28206,28211,28213,28218,28219,28224],{"type":29,"tag":447,"props":28207,"children":28208},{},[28209],{"type":34,"value":28210},"Facilité de configuration",{"type":34,"value":28212}," : Avec des annotations comme ",{"type":29,"tag":84,"props":28214,"children":28216},{"className":28215},[],[28217],{"type":34,"value":4620},{"type":34,"value":8982},{"type":29,"tag":84,"props":28220,"children":28222},{"className":28221},[],[28223],{"type":34,"value":27190},{"type":34,"value":28225},", 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":29,"tag":10576,"props":28227,"children":28229},{"id":28228},"avantages-dappliquer-le-dip-dans-un-projet-spring",[28230],{"type":34,"value":28231},"Avantages d’appliquer le DIP dans un projet Spring",{"type":29,"tag":17095,"props":28233,"children":28234},{},[28235,28245],{"type":29,"tag":457,"props":28236,"children":28237},{},[28238,28243],{"type":29,"tag":447,"props":28239,"children":28240},{},[28241],{"type":34,"value":28242},"Flexibilité accrue",{"type":34,"value":28244}," : 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":29,"tag":457,"props":28246,"children":28247},{},[28248,28253,28255,28260,28262,28267],{"type":29,"tag":447,"props":28249,"children":28250},{},[28251],{"type":34,"value":28252},"Tests unitaires simplifiés",{"type":34,"value":28254}," : grâce aux abstractions, mocker ou stubber les dépendances dans les tests unitaires devient direct. Tester ",{"type":29,"tag":84,"props":28256,"children":28258},{"className":28257},[],[28259],{"type":34,"value":23875},{"type":34,"value":28261}," sans implémenter un vrai ",{"type":29,"tag":84,"props":28263,"children":28265},{"className":28264},[],[28266],{"type":34,"value":26608},{"type":34,"value":28268}," se résume à :",{"type":29,"tag":77,"props":28270,"children":28272},{"className":81,"code":28271,"language":80,"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",[28273],{"type":29,"tag":84,"props":28274,"children":28275},{"__ignoreMap":8},[28276,28287,28311,28362,28399,28406,28435,28442,28487],{"type":29,"tag":88,"props":28277,"children":28278},{"class":90,"line":91},[28279,28283],{"type":29,"tag":88,"props":28280,"children":28281},{"style":1974},[28282],{"type":34,"value":1977},{"type":29,"tag":88,"props":28284,"children":28285},{"style":1980},[28286],{"type":34,"value":1983},{"type":29,"tag":88,"props":28288,"children":28289},{"class":90,"line":101},[28290,28294,28298,28303,28307],{"type":29,"tag":88,"props":28291,"children":28292},{"style":105},[28293],{"type":34,"value":108},{"type":29,"tag":88,"props":28295,"children":28296},{"style":105},[28297],{"type":34,"value":1303},{"type":29,"tag":88,"props":28299,"children":28300},{"style":174},[28301],{"type":34,"value":28302}," testSendNotification",{"type":29,"tag":88,"props":28304,"children":28305},{"style":122},[28306],{"type":34,"value":1470},{"type":29,"tag":88,"props":28308,"children":28309},{"style":122},[28310],{"type":34,"value":125},{"type":29,"tag":88,"props":28312,"children":28313},{"class":90,"line":128},[28314,28319,28324,28328,28333,28337,28342,28346,28350,28354,28358],{"type":29,"tag":88,"props":28315,"children":28316},{"style":151},[28317],{"type":34,"value":28318},"    MessageSender",{"type":29,"tag":88,"props":28320,"children":28321},{"style":157},[28322],{"type":34,"value":28323}," mockSender ",{"type":29,"tag":88,"props":28325,"children":28326},{"style":163},[28327],{"type":34,"value":166},{"type":29,"tag":88,"props":28329,"children":28330},{"style":157},[28331],{"type":34,"value":28332}," Mockito",{"type":29,"tag":88,"props":28334,"children":28335},{"style":122},[28336],{"type":34,"value":338},{"type":29,"tag":88,"props":28338,"children":28339},{"style":174},[28340],{"type":34,"value":28341},"mock",{"type":29,"tag":88,"props":28343,"children":28344},{"style":122},[28345],{"type":34,"value":181},{"type":29,"tag":88,"props":28347,"children":28348},{"style":157},[28349],{"type":34,"value":26608},{"type":29,"tag":88,"props":28351,"children":28352},{"style":122},[28353],{"type":34,"value":338},{"type":29,"tag":88,"props":28355,"children":28356},{"style":157},[28357],{"type":34,"value":1225},{"type":29,"tag":88,"props":28359,"children":28360},{"style":122},[28361],{"type":34,"value":357},{"type":29,"tag":88,"props":28363,"children":28364},{"class":90,"line":137},[28365,28370,28374,28378,28382,28386,28390,28395],{"type":29,"tag":88,"props":28366,"children":28367},{"style":151},[28368],{"type":34,"value":28369},"    NotificationService",{"type":29,"tag":88,"props":28371,"children":28372},{"style":157},[28373],{"type":34,"value":2074},{"type":29,"tag":88,"props":28375,"children":28376},{"style":163},[28377],{"type":34,"value":166},{"type":29,"tag":88,"props":28379,"children":28380},{"style":105},[28381],{"type":34,"value":171},{"type":29,"tag":88,"props":28383,"children":28384},{"style":174},[28385],{"type":34,"value":4662},{"type":29,"tag":88,"props":28387,"children":28388},{"style":122},[28389],{"type":34,"value":181},{"type":29,"tag":88,"props":28391,"children":28392},{"style":157},[28393],{"type":34,"value":28394},"mockSender",{"type":29,"tag":88,"props":28396,"children":28397},{"style":122},[28398],{"type":34,"value":357},{"type":29,"tag":88,"props":28400,"children":28401},{"class":90,"line":211},[28402],{"type":29,"tag":88,"props":28403,"children":28404},{"emptyLinePlaceholder":13},[28405],{"type":34,"value":134},{"type":29,"tag":88,"props":28407,"children":28408},{"class":90,"line":262},[28409,28414,28418,28422,28426,28431],{"type":29,"tag":88,"props":28410,"children":28411},{"style":157},[28412],{"type":34,"value":28413},"    service",{"type":29,"tag":88,"props":28415,"children":28416},{"style":122},[28417],{"type":34,"value":338},{"type":29,"tag":88,"props":28419,"children":28420},{"style":174},[28421],{"type":34,"value":25038},{"type":29,"tag":88,"props":28423,"children":28424},{"style":122},[28425],{"type":34,"value":181},{"type":29,"tag":88,"props":28427,"children":28428},{"style":184},[28429],{"type":34,"value":28430},"\"Test message\"",{"type":29,"tag":88,"props":28432,"children":28433},{"style":122},[28434],{"type":34,"value":357},{"type":29,"tag":88,"props":28436,"children":28437},{"class":90,"line":270},[28438],{"type":29,"tag":88,"props":28439,"children":28440},{"emptyLinePlaceholder":13},[28441],{"type":34,"value":134},{"type":29,"tag":88,"props":28443,"children":28444},{"class":90,"line":313},[28445,28450,28454,28459,28463,28467,28471,28475,28479,28483],{"type":29,"tag":88,"props":28446,"children":28447},{"style":157},[28448],{"type":34,"value":28449},"    Mockito",{"type":29,"tag":88,"props":28451,"children":28452},{"style":122},[28453],{"type":34,"value":338},{"type":29,"tag":88,"props":28455,"children":28456},{"style":174},[28457],{"type":34,"value":28458},"verify",{"type":29,"tag":88,"props":28460,"children":28461},{"style":122},[28462],{"type":34,"value":181},{"type":29,"tag":88,"props":28464,"children":28465},{"style":157},[28466],{"type":34,"value":28394},{"type":29,"tag":88,"props":28468,"children":28469},{"style":122},[28470],{"type":34,"value":8127},{"type":29,"tag":88,"props":28472,"children":28473},{"style":174},[28474],{"type":34,"value":26714},{"type":29,"tag":88,"props":28476,"children":28477},{"style":122},[28478],{"type":34,"value":181},{"type":29,"tag":88,"props":28480,"children":28481},{"style":184},[28482],{"type":34,"value":28430},{"type":29,"tag":88,"props":28484,"children":28485},{"style":122},[28486],{"type":34,"value":357},{"type":29,"tag":88,"props":28488,"children":28489},{"class":90,"line":360},[28490],{"type":29,"tag":88,"props":28491,"children":28492},{"style":122},[28493],{"type":34,"value":442},{"type":29,"tag":17095,"props":28495,"children":28496},{"start":128},[28497],{"type":29,"tag":457,"props":28498,"children":28499},{},[28500,28505],{"type":29,"tag":447,"props":28501,"children":28502},{},[28503],{"type":34,"value":28504},"Scalabilité",{"type":34,"value":28506}," : 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":29,"tag":8526,"props":28508,"children":28509},{"type":25614},[28510],{"type":29,"tag":30,"props":28511,"children":28512},{},[28513],{"type":34,"value":28514},"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":29,"tag":47,"props":28516,"children":28517},{},[],{"type":29,"tag":2288,"props":28519,"children":28521},{"cta":5629,"href":5630,"title":28520,"type":5632},"Le DIP n'est qu'une pratique parmi les 100 que j'applique pour garder un code propre",[28522],{"type":29,"tag":30,"props":28523,"children":28524},{},[28525],{"type":34,"value":28526},"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":29,"tag":47,"props":28528,"children":28529},{},[],{"type":29,"tag":51,"props":28531,"children":28533},{"id":28532},"faq-réponses-aux-questions-fréquentes-sur-le-dip",[28534],{"type":34,"value":28535},"FAQ : Réponses aux questions fréquentes sur le DIP",{"type":29,"tag":5649,"props":28537,"children":28538},{},[28539,28544],{"type":29,"tag":5653,"props":28540,"children":28541},{},[28542],{"type":34,"value":28543},"1. Qu’est-ce que le DIP en termes simples ?",{"type":29,"tag":30,"props":28545,"children":28546},{},[28547,28548,28552],{"type":34,"value":10213},{"type":29,"tag":447,"props":28549,"children":28550},{},[28551],{"type":34,"value":25500},{"type":34,"value":28553}," (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":29,"tag":5649,"props":28555,"children":28556},{},[28557,28562],{"type":29,"tag":5653,"props":28558,"children":28559},{},[28560],{"type":34,"value":28561},"2. Pourquoi est-il si important d’appliquer le DIP ?",{"type":29,"tag":30,"props":28563,"children":28564},{},[28565,28567,28572,28573,28578,28579,28584],{"type":34,"value":28566},"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":29,"tag":447,"props":28568,"children":28569},{},[28570],{"type":34,"value":28571},"flexible",{"type":34,"value":544},{"type":29,"tag":447,"props":28574,"children":28575},{},[28576],{"type":34,"value":28577},"évolutif",{"type":34,"value":8982},{"type":29,"tag":447,"props":28580,"children":28581},{},[28582],{"type":34,"value":28583},"testable",{"type":34,"value":28585},". Décisif dans des projets à long terme ou de grande envergure.",{"type":29,"tag":5649,"props":28587,"children":28588},{},[28589,28594],{"type":29,"tag":5653,"props":28590,"children":28591},{},[28592],{"type":34,"value":28593},"3. Est-ce que le DIP rend le code plus complexe ?",{"type":29,"tag":30,"props":28595,"children":28596},{},[28597,28599,28603,28605,28610],{"type":34,"value":28598},"Cela peut paraître plus complexe au début, car vous ajoutez des ",{"type":29,"tag":447,"props":28600,"children":28601},{},[28602],{"type":34,"value":25701},{"type":34,"value":28604}," 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":29,"tag":447,"props":28606,"children":28607},{},[28608],{"type":34,"value":28609},"investissement",{"type":34,"value":28611}," en qualité.",{"type":29,"tag":5649,"props":28613,"children":28614},{},[28615,28620,28625],{"type":29,"tag":5653,"props":28616,"children":28617},{},[28618],{"type":34,"value":28619},"4. Dois-je appliquer le DIP dans tous mes projets, même les petits ?",{"type":29,"tag":30,"props":28621,"children":28622},{},[28623],{"type":34,"value":28624},"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":29,"tag":8787,"props":28626,"children":28627},{},[28628],{"type":29,"tag":30,"props":28629,"children":28630},{},[28631,28636],{"type":29,"tag":447,"props":28632,"children":28633},{},[28634],{"type":34,"value":28635},"TIP :",{"type":34,"value":28637}," 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":29,"tag":5649,"props":28639,"children":28640},{},[28641,28646],{"type":29,"tag":5653,"props":28642,"children":28643},{},[28644],{"type":34,"value":28645},"5. Comment puis-je savoir si mon code viole le DIP ?",{"type":29,"tag":30,"props":28647,"children":28648},{},[28649],{"type":34,"value":28650},"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":29,"tag":5649,"props":28652,"children":28653},{},[28654,28659],{"type":29,"tag":5653,"props":28655,"children":28656},{},[28657],{"type":34,"value":28658},"6. Comment le DIP fonctionne-t-il avec d’autres principes SOLID ?",{"type":29,"tag":30,"props":28660,"children":28661},{},[28662,28664,28669,28671,28675,28676,28680,28682,28686],{"type":34,"value":28663},"Le DIP est étroitement lié à d’autres principes du ",{"type":29,"tag":447,"props":28665,"children":28666},{},[28667],{"type":34,"value":28668},"SOLID",{"type":34,"value":28670},". Par exemple, il complète le ",{"type":29,"tag":447,"props":28672,"children":28673},{},[28674],{"type":34,"value":25258},{"type":34,"value":10174},{"type":29,"tag":447,"props":28677,"children":28678},{},[28679],{"type":34,"value":25241},{"type":34,"value":28681},", 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":29,"tag":447,"props":28683,"children":28684},{},[28685],{"type":34,"value":25217},{"type":34,"value":28687},", car chaque module devient responsable d’une tâche unique.",{"type":29,"tag":5649,"props":28689,"children":28690},{},[28691,28696],{"type":29,"tag":5653,"props":28692,"children":28693},{},[28694],{"type":34,"value":28695},"7. Quels outils et frameworks peuvent m’aider à appliquer le DIP en Java ?",{"type":29,"tag":30,"props":28697,"children":28698},{},[28699,28700,28704,28706,28710,28712,28717,28719,28724,28725,28730],{"type":34,"value":10213},{"type":29,"tag":447,"props":28701,"children":28702},{},[28703],{"type":34,"value":27168},{"type":34,"value":28705}," est l’un des outils les plus populaires pour appliquer le DIP en Java. Avec des concepts comme l’",{"type":29,"tag":447,"props":28707,"children":28708},{},[28709],{"type":34,"value":27151},{"type":34,"value":28711}," (DI) et l’utilisation d’annotations comme ",{"type":29,"tag":84,"props":28713,"children":28715},{"className":28714},[],[28716],{"type":34,"value":27190},{"type":34,"value":28718},", vous pouvez facilement structurer vos applications en respectant le DIP. D’autres frameworks comme ",{"type":29,"tag":447,"props":28720,"children":28721},{},[28722],{"type":34,"value":28723},"Guice",{"type":34,"value":5730},{"type":29,"tag":447,"props":28726,"children":28727},{},[28728],{"type":34,"value":28729},"Jakarta EE CDI",{"type":34,"value":28731}," offrent également des solutions pour gérer les dépendances.",{"type":29,"tag":47,"props":28733,"children":28734},{},[],{"type":29,"tag":51,"props":28736,"children":28737},{"id":15632},[28738],{"type":34,"value":15635},{"type":29,"tag":30,"props":28740,"children":28741},{},[28742,28744,28748,28750,28754],{"type":34,"value":28743},"Cinquième des ",{"type":29,"tag":63,"props":28745,"children":28746},{"href":9965},[28747],{"type":34,"value":9968},{"type":34,"value":28749},", le ",{"type":29,"tag":447,"props":28751,"children":28752},{},[28753],{"type":34,"value":25500},{"type":34,"value":28755}," 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":29,"tag":30,"props":28757,"children":28758},{},[28759],{"type":34,"value":28760},"Pour un code plus maintenable, commencez à adopter le DIP dès maintenant. Avec ou sans Spring, le principe reste bénéfique.",{"type":29,"tag":8787,"props":28762,"children":28763},{},[28764],{"type":29,"tag":30,"props":28765,"children":28766},{},[28767,28772,28774,28779],{"type":29,"tag":447,"props":28768,"children":28769},{},[28770],{"type":34,"value":28771},"Attention :",{"type":34,"value":28773}," L’objectif du DIP est de rendre votre code ",{"type":29,"tag":447,"props":28775,"children":28776},{},[28777],{"type":34,"value":28778},"modulable et adaptable",{"type":34,"value":28780},". 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":29,"tag":2288,"props":28782,"children":28783},{"cta":10074,"href":10075,"title":10076,"type":5755},[28784],{"type":29,"tag":30,"props":28785,"children":28786},{},[28787],{"type":34,"value":10082},{"type":29,"tag":5763,"props":28789,"children":28790},{},[28791],{"type":34,"value":5767},{"title":8,"searchDepth":101,"depth":101,"links":28793},[28794,28795,28796,28800,28805,28809,28810],{"id":25482,"depth":101,"text":25485},{"id":25526,"depth":101,"text":25529},{"id":25635,"depth":101,"text":25638,"children":28797},[28798,28799],{"id":25657,"depth":128,"text":25660},{"id":25680,"depth":128,"text":25683},{"id":25762,"depth":101,"text":25765,"children":28801},[28802,28803,28804],{"id":25779,"depth":128,"text":25782},{"id":26130,"depth":128,"text":26133},{"id":27064,"depth":128,"text":27067},{"id":27125,"depth":101,"text":27128,"children":28806},[28807,28808],{"id":27155,"depth":128,"text":27158},{"id":27204,"depth":128,"text":27207},{"id":28532,"depth":101,"text":28535},{"id":15632,"depth":101,"text":15635},"content:fr:architecture-craft:principe-inversion-dependances-dip-java-guide-complet.md","fr\u002Farchitecture-craft\u002Fprincipe-inversion-dependances-dip-java-guide-complet.md","fr\u002Farchitecture-craft\u002Fprincipe-inversion-dependances-dip-java-guide-complet",{"_path":19470,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":28815,"description":28816,"id":1477,"date":28817,"listed":13,"nocomments":7,"hidden":7,"categories":28818,"tags":28819,"cover":28820,"readingTime":28821,"body":28826,"_type":5777,"_id":31641,"_source":5779,"_file":31642,"_stem":31643,"_extension":5782},"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...","2024-03-27",[6],[16,8453],"covers\u002Farticles\u002Fprincipe-isp.jpg",{"text":28822,"minutes":28823,"time":28824,"words":28825},"12 min read",11.17,670200,2234,{"type":26,"children":28827,"toc":31621},[28828,28841,28846,28857,28860,28866,28877,28882,28888,28916,28921,28934,28940,28967,28973,28978,28984,28989,29002,29005,29011,29016,29022,29034,29116,29129,29359,29371,29391,29397,29409,29556,29575,29692,29719,29930,29935,29947,29953,29966,30048,30069,30182,30194,30397,30424,30719,30724,30727,30736,30742,30747,30753,30758,30766,30915,30920,30932,30938,30943,30950,31048,31061,31067,31079,31087,31403,31415,31421,31426,31438,31441,31450,31453,31459,31472,31485,31505,31518,31537,31550,31563,31576,31589,31592,31604,31607,31617],{"type":29,"tag":30,"props":28829,"children":28830},{},[28831,28833,28839],{"type":34,"value":28832},"Sur une mission récente dans la banque, j'ai retrouvé une interface ",{"type":29,"tag":84,"props":28834,"children":28836},{"className":28835},[],[28837],{"type":34,"value":28838},"Service",{"type":34,"value":28840}," 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":29,"tag":30,"props":28842,"children":28843},{},[28844],{"type":34,"value":28845},"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":29,"tag":30,"props":28847,"children":28848},{},[28849,28851,28855],{"type":34,"value":28850},"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":29,"tag":8474,"props":28852,"children":28853},{},[28854],{"type":34,"value":19416},{"type":34,"value":28856},", 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":29,"tag":47,"props":28858,"children":28859},{},[],{"type":29,"tag":51,"props":28861,"children":28863},{"id":28862},"pourquoi-respecter-le-principe-isp",[28864],{"type":34,"value":28865},"Pourquoi respecter le principe ISP ?",{"type":29,"tag":30,"props":28867,"children":28868},{},[28869,28871,28875],{"type":34,"value":28870},"Le principe de séparation d’interface (ISP) fait partie des cinq ",{"type":29,"tag":63,"props":28872,"children":28873},{"href":9965},[28874],{"type":34,"value":9968},{"type":34,"value":28876},", 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":29,"tag":30,"props":28878,"children":28879},{},[28880],{"type":34,"value":28881},"Mais pourquoi est-ce si important ?",{"type":29,"tag":8542,"props":28883,"children":28885},{"id":28884},"_1-faciliter-la-maintenance-et-lévolution-du-code",[28886],{"type":34,"value":28887},"1. Faciliter la maintenance et l’évolution du code",{"type":29,"tag":30,"props":28889,"children":28890},{},[28891,28893,28899,28901,28907,28908,28914],{"type":34,"value":28892},"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":29,"tag":84,"props":28894,"children":28896},{"className":28895},[],[28897],{"type":34,"value":28898},"Employe",{"type":34,"value":28900}," avec ",{"type":29,"tag":84,"props":28902,"children":28904},{"className":28903},[],[28905],{"type":34,"value":28906},"calculerSalaire()",{"type":34,"value":8982},{"type":29,"tag":84,"props":28909,"children":28911},{"className":28910},[],[28912],{"type":34,"value":28913},"gererProjets()",{"type":34,"value":28915}," : 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":29,"tag":30,"props":28917,"children":28918},{},[28919],{"type":34,"value":28920},"Résultat : chaque changement dans cette interface déclenche des bugs inattendus et alourdit l'évolution du code.",{"type":29,"tag":8787,"props":28922,"children":28923},{},[28924],{"type":29,"tag":30,"props":28925,"children":28926},{},[28927,28932],{"type":29,"tag":447,"props":28928,"children":28929},{},[28930],{"type":34,"value":28931},"Tip",{"type":34,"value":28933}," : 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":29,"tag":8542,"props":28935,"children":28937},{"id":28936},"_2-favoriser-la-réutilisabilité",[28938],{"type":34,"value":28939},"2. Favoriser la réutilisabilité",{"type":29,"tag":30,"props":28941,"children":28942},{},[28943,28945,28950,28952,28958,28959,28965],{"type":34,"value":28944},"Une interface spécifique, centrée sur une seule tâche, ouvre la voie à la réutilisabilité. Si vous divisez ",{"type":29,"tag":84,"props":28946,"children":28948},{"className":28947},[],[28949],{"type":34,"value":28898},{"type":34,"value":28951}," en deux interfaces ciblées (",{"type":29,"tag":84,"props":28953,"children":28955},{"className":28954},[],[28956],{"type":34,"value":28957},"Salarie",{"type":34,"value":8982},{"type":29,"tag":84,"props":28960,"children":28962},{"className":28961},[],[28963],{"type":34,"value":28964},"Manager",{"type":34,"value":28966},"), 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":29,"tag":8542,"props":28968,"children":28970},{"id":28969},"_3-réduire-le-couplage",[28971],{"type":34,"value":28972},"3. Réduire le couplage",{"type":29,"tag":30,"props":28974,"children":28975},{},[28976],{"type":34,"value":28977},"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":29,"tag":8542,"props":28979,"children":28981},{"id":28980},"_4-améliorer-les-tests-unitaires",[28982],{"type":34,"value":28983},"4. Améliorer les tests unitaires",{"type":29,"tag":30,"props":28985,"children":28986},{},[28987],{"type":34,"value":28988},"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":29,"tag":8787,"props":28990,"children":28991},{},[28992],{"type":29,"tag":30,"props":28993,"children":28994},{},[28995,29000],{"type":29,"tag":447,"props":28996,"children":28997},{},[28998],{"type":34,"value":28999},"Alerte",{"type":34,"value":29001}," : Des interfaces larges et mal segmentées augmentent le couplage, ce qui rend vos tests plus difficiles à écrire et à maintenir.",{"type":29,"tag":47,"props":29003,"children":29004},{},[],{"type":29,"tag":51,"props":29006,"children":29008},{"id":29007},"comment-appliquer-isp-en-java",[29009],{"type":34,"value":29010},"Comment appliquer ISP en Java ?",{"type":29,"tag":30,"props":29012,"children":29013},{},[29014],{"type":34,"value":29015},"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":29,"tag":8542,"props":29017,"children":29019},{"id":29018},"exemple-1-une-interface-trop-large",[29020],{"type":34,"value":29021},"Exemple 1 : Une interface trop large",{"type":29,"tag":30,"props":29023,"children":29024},{},[29025,29027,29032],{"type":34,"value":29026},"Prenons une interface ",{"type":29,"tag":84,"props":29028,"children":29030},{"className":29029},[],[29031],{"type":34,"value":28898},{"type":34,"value":29033}," 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":29,"tag":77,"props":29035,"children":29037},{"className":81,"code":29036,"language":80,"meta":8,"style":8},"public interface Employe {\n    void travailler();\n    void gererProjets();\n    void calculerSalaire();\n}\n",[29038],{"type":29,"tag":84,"props":29039,"children":29040},{"__ignoreMap":8},[29041,29061,29077,29093,29109],{"type":29,"tag":88,"props":29042,"children":29043},{"class":90,"line":91},[29044,29048,29052,29057],{"type":29,"tag":88,"props":29045,"children":29046},{"style":105},[29047],{"type":34,"value":108},{"type":29,"tag":88,"props":29049,"children":29050},{"style":105},[29051],{"type":34,"value":601},{"type":29,"tag":88,"props":29053,"children":29054},{"style":116},[29055],{"type":34,"value":29056}," Employe",{"type":29,"tag":88,"props":29058,"children":29059},{"style":122},[29060],{"type":34,"value":125},{"type":29,"tag":88,"props":29062,"children":29063},{"class":90,"line":101},[29064,29068,29073],{"type":29,"tag":88,"props":29065,"children":29066},{"style":105},[29067],{"type":34,"value":681},{"type":29,"tag":88,"props":29069,"children":29070},{"style":174},[29071],{"type":34,"value":29072}," travailler",{"type":29,"tag":88,"props":29074,"children":29075},{"style":122},[29076],{"type":34,"value":1810},{"type":29,"tag":88,"props":29078,"children":29079},{"class":90,"line":128},[29080,29084,29089],{"type":29,"tag":88,"props":29081,"children":29082},{"style":105},[29083],{"type":34,"value":681},{"type":29,"tag":88,"props":29085,"children":29086},{"style":174},[29087],{"type":34,"value":29088}," gererProjets",{"type":29,"tag":88,"props":29090,"children":29091},{"style":122},[29092],{"type":34,"value":1810},{"type":29,"tag":88,"props":29094,"children":29095},{"class":90,"line":137},[29096,29100,29105],{"type":29,"tag":88,"props":29097,"children":29098},{"style":105},[29099],{"type":34,"value":681},{"type":29,"tag":88,"props":29101,"children":29102},{"style":174},[29103],{"type":34,"value":29104}," calculerSalaire",{"type":29,"tag":88,"props":29106,"children":29107},{"style":122},[29108],{"type":34,"value":1810},{"type":29,"tag":88,"props":29110,"children":29111},{"class":90,"line":211},[29112],{"type":29,"tag":88,"props":29113,"children":29114},{"style":122},[29115],{"type":34,"value":442},{"type":29,"tag":30,"props":29117,"children":29118},{},[29119,29121,29127],{"type":34,"value":29120},"Dans ce cas, une classe ",{"type":29,"tag":84,"props":29122,"children":29124},{"className":29123},[],[29125],{"type":34,"value":29126},"Developpeur",{"type":34,"value":29128}," 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":29,"tag":77,"props":29130,"children":29132},{"className":81,"code":29131,"language":80,"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        \u002F\u002F Non pertinent pour un développeur.\n    }\n\n    @Override\n    public void calculerSalaire() {\n        \u002F\u002F Non pertinent pour un développeur.\n    }\n}\n",[29133],{"type":29,"tag":84,"props":29134,"children":29135},{"__ignoreMap":8},[29136,29164,29175,29198,29234,29241,29248,29259,29282,29290,29297,29304,29315,29338,29345,29352],{"type":29,"tag":88,"props":29137,"children":29138},{"class":90,"line":91},[29139,29143,29147,29152,29156,29160],{"type":29,"tag":88,"props":29140,"children":29141},{"style":105},[29142],{"type":34,"value":108},{"type":29,"tag":88,"props":29144,"children":29145},{"style":105},[29146],{"type":34,"value":113},{"type":29,"tag":88,"props":29148,"children":29149},{"style":116},[29150],{"type":34,"value":29151}," Developpeur",{"type":29,"tag":88,"props":29153,"children":29154},{"style":105},[29155],{"type":34,"value":1134},{"type":29,"tag":88,"props":29157,"children":29158},{"style":116},[29159],{"type":34,"value":29056},{"type":29,"tag":88,"props":29161,"children":29162},{"style":122},[29163],{"type":34,"value":125},{"type":29,"tag":88,"props":29165,"children":29166},{"class":90,"line":101},[29167,29171],{"type":29,"tag":88,"props":29168,"children":29169},{"style":1974},[29170],{"type":34,"value":3302},{"type":29,"tag":88,"props":29172,"children":29173},{"style":1980},[29174],{"type":34,"value":3307},{"type":29,"tag":88,"props":29176,"children":29177},{"class":90,"line":128},[29178,29182,29186,29190,29194],{"type":29,"tag":88,"props":29179,"children":29180},{"style":105},[29181],{"type":34,"value":276},{"type":29,"tag":88,"props":29183,"children":29184},{"style":105},[29185],{"type":34,"value":1303},{"type":29,"tag":88,"props":29187,"children":29188},{"style":174},[29189],{"type":34,"value":29072},{"type":29,"tag":88,"props":29191,"children":29192},{"style":122},[29193],{"type":34,"value":1470},{"type":29,"tag":88,"props":29195,"children":29196},{"style":122},[29197],{"type":34,"value":125},{"type":29,"tag":88,"props":29199,"children":29200},{"class":90,"line":137},[29201,29205,29209,29213,29217,29221,29225,29230],{"type":29,"tag":88,"props":29202,"children":29203},{"style":157},[29204],{"type":34,"value":19726},{"type":29,"tag":88,"props":29206,"children":29207},{"style":122},[29208],{"type":34,"value":338},{"type":29,"tag":88,"props":29210,"children":29211},{"style":157},[29212],{"type":34,"value":18091},{"type":29,"tag":88,"props":29214,"children":29215},{"style":122},[29216],{"type":34,"value":338},{"type":29,"tag":88,"props":29218,"children":29219},{"style":174},[29220],{"type":34,"value":18100},{"type":29,"tag":88,"props":29222,"children":29223},{"style":122},[29224],{"type":34,"value":181},{"type":29,"tag":88,"props":29226,"children":29227},{"style":184},[29228],{"type":34,"value":29229},"\"Le développeur écrit du code.\"",{"type":29,"tag":88,"props":29231,"children":29232},{"style":122},[29233],{"type":34,"value":357},{"type":29,"tag":88,"props":29235,"children":29236},{"class":90,"line":211},[29237],{"type":29,"tag":88,"props":29238,"children":29239},{"style":122},[29240],{"type":34,"value":433},{"type":29,"tag":88,"props":29242,"children":29243},{"class":90,"line":262},[29244],{"type":29,"tag":88,"props":29245,"children":29246},{"emptyLinePlaceholder":13},[29247],{"type":34,"value":134},{"type":29,"tag":88,"props":29249,"children":29250},{"class":90,"line":270},[29251,29255],{"type":29,"tag":88,"props":29252,"children":29253},{"style":1974},[29254],{"type":34,"value":3302},{"type":29,"tag":88,"props":29256,"children":29257},{"style":1980},[29258],{"type":34,"value":3307},{"type":29,"tag":88,"props":29260,"children":29261},{"class":90,"line":313},[29262,29266,29270,29274,29278],{"type":29,"tag":88,"props":29263,"children":29264},{"style":105},[29265],{"type":34,"value":276},{"type":29,"tag":88,"props":29267,"children":29268},{"style":105},[29269],{"type":34,"value":1303},{"type":29,"tag":88,"props":29271,"children":29272},{"style":174},[29273],{"type":34,"value":29088},{"type":29,"tag":88,"props":29275,"children":29276},{"style":122},[29277],{"type":34,"value":1470},{"type":29,"tag":88,"props":29279,"children":29280},{"style":122},[29281],{"type":34,"value":125},{"type":29,"tag":88,"props":29283,"children":29284},{"class":90,"line":360},[29285],{"type":29,"tag":88,"props":29286,"children":29287},{"style":95},[29288],{"type":34,"value":29289},"        \u002F\u002F Non pertinent pour un développeur.\n",{"type":29,"tag":88,"props":29291,"children":29292},{"class":90,"line":409},[29293],{"type":29,"tag":88,"props":29294,"children":29295},{"style":122},[29296],{"type":34,"value":433},{"type":29,"tag":88,"props":29298,"children":29299},{"class":90,"line":427},[29300],{"type":29,"tag":88,"props":29301,"children":29302},{"emptyLinePlaceholder":13},[29303],{"type":34,"value":134},{"type":29,"tag":88,"props":29305,"children":29306},{"class":90,"line":436},[29307,29311],{"type":29,"tag":88,"props":29308,"children":29309},{"style":1974},[29310],{"type":34,"value":3302},{"type":29,"tag":88,"props":29312,"children":29313},{"style":1980},[29314],{"type":34,"value":3307},{"type":29,"tag":88,"props":29316,"children":29317},{"class":90,"line":767},[29318,29322,29326,29330,29334],{"type":29,"tag":88,"props":29319,"children":29320},{"style":105},[29321],{"type":34,"value":276},{"type":29,"tag":88,"props":29323,"children":29324},{"style":105},[29325],{"type":34,"value":1303},{"type":29,"tag":88,"props":29327,"children":29328},{"style":174},[29329],{"type":34,"value":29104},{"type":29,"tag":88,"props":29331,"children":29332},{"style":122},[29333],{"type":34,"value":1470},{"type":29,"tag":88,"props":29335,"children":29336},{"style":122},[29337],{"type":34,"value":125},{"type":29,"tag":88,"props":29339,"children":29340},{"class":90,"line":792},[29341],{"type":29,"tag":88,"props":29342,"children":29343},{"style":95},[29344],{"type":34,"value":29289},{"type":29,"tag":88,"props":29346,"children":29347},{"class":90,"line":817},[29348],{"type":29,"tag":88,"props":29349,"children":29350},{"style":122},[29351],{"type":34,"value":433},{"type":29,"tag":88,"props":29353,"children":29354},{"class":90,"line":825},[29355],{"type":29,"tag":88,"props":29356,"children":29357},{"style":122},[29358],{"type":34,"value":442},{"type":29,"tag":30,"props":29360,"children":29361},{},[29362,29364,29369],{"type":34,"value":29363},"Ici, ",{"type":29,"tag":84,"props":29365,"children":29367},{"className":29366},[],[29368],{"type":34,"value":29126},{"type":34,"value":29370}," se retrouve à implémenter des méthodes inutiles, ce qui est une violation directe du principe ISP.",{"type":29,"tag":8787,"props":29372,"children":29373},{},[29374],{"type":29,"tag":30,"props":29375,"children":29376},{},[29377,29381,29383,29389],{"type":29,"tag":447,"props":29378,"children":29379},{},[29380],{"type":34,"value":28999},{"type":34,"value":29382}," : Si vous vous retrouvez à laisser des méthodes vides ou à lever des exceptions ",{"type":29,"tag":84,"props":29384,"children":29386},{"className":29385},[],[29387],{"type":34,"value":29388},"UnsupportedOperationException",{"type":34,"value":29390},", c'est un signal clair qu'une interface est trop large.",{"type":29,"tag":8542,"props":29392,"children":29394},{"id":29393},"exemple-2-appliquer-le-principe-isp-avec-des-interfaces-spécifiques",[29395],{"type":34,"value":29396},"Exemple 2 : Appliquer le principe ISP avec des interfaces spécifiques",{"type":29,"tag":30,"props":29398,"children":29399},{},[29400,29402,29407],{"type":34,"value":29401},"Pour corriger cette conception, nous devons diviser l'interface ",{"type":29,"tag":84,"props":29403,"children":29405},{"className":29404},[],[29406],{"type":34,"value":28898},{"type":34,"value":29408}," en plusieurs interfaces plus spécifiques. Chaque interface doit refléter un comportement précis, que seules les classes pertinentes implémenteront.",{"type":29,"tag":77,"props":29410,"children":29412},{"className":81,"code":29411,"language":80,"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",[29413],{"type":29,"tag":84,"props":29414,"children":29415},{"__ignoreMap":8},[29416,29436,29451,29458,29465,29485,29500,29507,29514,29534,29549],{"type":29,"tag":88,"props":29417,"children":29418},{"class":90,"line":91},[29419,29423,29427,29432],{"type":29,"tag":88,"props":29420,"children":29421},{"style":105},[29422],{"type":34,"value":108},{"type":29,"tag":88,"props":29424,"children":29425},{"style":105},[29426],{"type":34,"value":601},{"type":29,"tag":88,"props":29428,"children":29429},{"style":116},[29430],{"type":34,"value":29431}," Travailleur",{"type":29,"tag":88,"props":29433,"children":29434},{"style":122},[29435],{"type":34,"value":125},{"type":29,"tag":88,"props":29437,"children":29438},{"class":90,"line":101},[29439,29443,29447],{"type":29,"tag":88,"props":29440,"children":29441},{"style":105},[29442],{"type":34,"value":681},{"type":29,"tag":88,"props":29444,"children":29445},{"style":174},[29446],{"type":34,"value":29072},{"type":29,"tag":88,"props":29448,"children":29449},{"style":122},[29450],{"type":34,"value":1810},{"type":29,"tag":88,"props":29452,"children":29453},{"class":90,"line":128},[29454],{"type":29,"tag":88,"props":29455,"children":29456},{"style":122},[29457],{"type":34,"value":442},{"type":29,"tag":88,"props":29459,"children":29460},{"class":90,"line":137},[29461],{"type":29,"tag":88,"props":29462,"children":29463},{"emptyLinePlaceholder":13},[29464],{"type":34,"value":134},{"type":29,"tag":88,"props":29466,"children":29467},{"class":90,"line":211},[29468,29472,29476,29481],{"type":29,"tag":88,"props":29469,"children":29470},{"style":105},[29471],{"type":34,"value":108},{"type":29,"tag":88,"props":29473,"children":29474},{"style":105},[29475],{"type":34,"value":601},{"type":29,"tag":88,"props":29477,"children":29478},{"style":116},[29479],{"type":34,"value":29480}," Manager",{"type":29,"tag":88,"props":29482,"children":29483},{"style":122},[29484],{"type":34,"value":125},{"type":29,"tag":88,"props":29486,"children":29487},{"class":90,"line":262},[29488,29492,29496],{"type":29,"tag":88,"props":29489,"children":29490},{"style":105},[29491],{"type":34,"value":681},{"type":29,"tag":88,"props":29493,"children":29494},{"style":174},[29495],{"type":34,"value":29088},{"type":29,"tag":88,"props":29497,"children":29498},{"style":122},[29499],{"type":34,"value":1810},{"type":29,"tag":88,"props":29501,"children":29502},{"class":90,"line":270},[29503],{"type":29,"tag":88,"props":29504,"children":29505},{"style":122},[29506],{"type":34,"value":442},{"type":29,"tag":88,"props":29508,"children":29509},{"class":90,"line":313},[29510],{"type":29,"tag":88,"props":29511,"children":29512},{"emptyLinePlaceholder":13},[29513],{"type":34,"value":134},{"type":29,"tag":88,"props":29515,"children":29516},{"class":90,"line":360},[29517,29521,29525,29530],{"type":29,"tag":88,"props":29518,"children":29519},{"style":105},[29520],{"type":34,"value":108},{"type":29,"tag":88,"props":29522,"children":29523},{"style":105},[29524],{"type":34,"value":601},{"type":29,"tag":88,"props":29526,"children":29527},{"style":116},[29528],{"type":34,"value":29529}," Salarie",{"type":29,"tag":88,"props":29531,"children":29532},{"style":122},[29533],{"type":34,"value":125},{"type":29,"tag":88,"props":29535,"children":29536},{"class":90,"line":409},[29537,29541,29545],{"type":29,"tag":88,"props":29538,"children":29539},{"style":105},[29540],{"type":34,"value":681},{"type":29,"tag":88,"props":29542,"children":29543},{"style":174},[29544],{"type":34,"value":29104},{"type":29,"tag":88,"props":29546,"children":29547},{"style":122},[29548],{"type":34,"value":1810},{"type":29,"tag":88,"props":29550,"children":29551},{"class":90,"line":427},[29552],{"type":29,"tag":88,"props":29553,"children":29554},{"style":122},[29555],{"type":34,"value":442},{"type":29,"tag":30,"props":29557,"children":29558},{},[29559,29561,29566,29568,29574],{"type":34,"value":29560},"Maintenant, la classe ",{"type":29,"tag":84,"props":29562,"children":29564},{"className":29563},[],[29565],{"type":34,"value":29126},{"type":34,"value":29567}," 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":29,"tag":84,"props":29569,"children":29571},{"className":29570},[],[29572],{"type":34,"value":29573},"Travailleur",{"type":34,"value":21063},{"type":29,"tag":77,"props":29576,"children":29578},{"className":81,"code":29577,"language":80,"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",[29579],{"type":29,"tag":84,"props":29580,"children":29581},{"__ignoreMap":8},[29582,29609,29620,29643,29678,29685],{"type":29,"tag":88,"props":29583,"children":29584},{"class":90,"line":91},[29585,29589,29593,29597,29601,29605],{"type":29,"tag":88,"props":29586,"children":29587},{"style":105},[29588],{"type":34,"value":108},{"type":29,"tag":88,"props":29590,"children":29591},{"style":105},[29592],{"type":34,"value":113},{"type":29,"tag":88,"props":29594,"children":29595},{"style":116},[29596],{"type":34,"value":29151},{"type":29,"tag":88,"props":29598,"children":29599},{"style":105},[29600],{"type":34,"value":1134},{"type":29,"tag":88,"props":29602,"children":29603},{"style":116},[29604],{"type":34,"value":29431},{"type":29,"tag":88,"props":29606,"children":29607},{"style":122},[29608],{"type":34,"value":125},{"type":29,"tag":88,"props":29610,"children":29611},{"class":90,"line":101},[29612,29616],{"type":29,"tag":88,"props":29613,"children":29614},{"style":1974},[29615],{"type":34,"value":3302},{"type":29,"tag":88,"props":29617,"children":29618},{"style":1980},[29619],{"type":34,"value":3307},{"type":29,"tag":88,"props":29621,"children":29622},{"class":90,"line":128},[29623,29627,29631,29635,29639],{"type":29,"tag":88,"props":29624,"children":29625},{"style":105},[29626],{"type":34,"value":276},{"type":29,"tag":88,"props":29628,"children":29629},{"style":105},[29630],{"type":34,"value":1303},{"type":29,"tag":88,"props":29632,"children":29633},{"style":174},[29634],{"type":34,"value":29072},{"type":29,"tag":88,"props":29636,"children":29637},{"style":122},[29638],{"type":34,"value":1470},{"type":29,"tag":88,"props":29640,"children":29641},{"style":122},[29642],{"type":34,"value":125},{"type":29,"tag":88,"props":29644,"children":29645},{"class":90,"line":137},[29646,29650,29654,29658,29662,29666,29670,29674],{"type":29,"tag":88,"props":29647,"children":29648},{"style":157},[29649],{"type":34,"value":19726},{"type":29,"tag":88,"props":29651,"children":29652},{"style":122},[29653],{"type":34,"value":338},{"type":29,"tag":88,"props":29655,"children":29656},{"style":157},[29657],{"type":34,"value":18091},{"type":29,"tag":88,"props":29659,"children":29660},{"style":122},[29661],{"type":34,"value":338},{"type":29,"tag":88,"props":29663,"children":29664},{"style":174},[29665],{"type":34,"value":18100},{"type":29,"tag":88,"props":29667,"children":29668},{"style":122},[29669],{"type":34,"value":181},{"type":29,"tag":88,"props":29671,"children":29672},{"style":184},[29673],{"type":34,"value":29229},{"type":29,"tag":88,"props":29675,"children":29676},{"style":122},[29677],{"type":34,"value":357},{"type":29,"tag":88,"props":29679,"children":29680},{"class":90,"line":211},[29681],{"type":29,"tag":88,"props":29682,"children":29683},{"style":122},[29684],{"type":34,"value":433},{"type":29,"tag":88,"props":29686,"children":29687},{"class":90,"line":262},[29688],{"type":29,"tag":88,"props":29689,"children":29690},{"style":122},[29691],{"type":34,"value":442},{"type":29,"tag":30,"props":29693,"children":29694},{},[29695,29697,29703,29705,29710,29712,29717],{"type":34,"value":29696},"De même, un ",{"type":29,"tag":84,"props":29698,"children":29700},{"className":29699},[],[29701],{"type":34,"value":29702},"ResponsableProjet",{"type":34,"value":29704}," pourrait implémenter l’interface ",{"type":29,"tag":84,"props":29706,"children":29708},{"className":29707},[],[29709],{"type":34,"value":28964},{"type":34,"value":29711}," et l’interface ",{"type":29,"tag":84,"props":29713,"children":29715},{"className":29714},[],[29716],{"type":34,"value":29573},{"type":34,"value":29718}," s'il gère des projets tout en travaillant :",{"type":29,"tag":77,"props":29720,"children":29722},{"className":81,"code":29721,"language":80,"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",[29723],{"type":29,"tag":84,"props":29724,"children":29725},{"__ignoreMap":8},[29726,29762,29773,29796,29832,29839,29846,29857,29880,29916,29923],{"type":29,"tag":88,"props":29727,"children":29728},{"class":90,"line":91},[29729,29733,29737,29742,29746,29750,29754,29758],{"type":29,"tag":88,"props":29730,"children":29731},{"style":105},[29732],{"type":34,"value":108},{"type":29,"tag":88,"props":29734,"children":29735},{"style":105},[29736],{"type":34,"value":113},{"type":29,"tag":88,"props":29738,"children":29739},{"style":116},[29740],{"type":34,"value":29741}," ResponsableProjet",{"type":29,"tag":88,"props":29743,"children":29744},{"style":105},[29745],{"type":34,"value":1134},{"type":29,"tag":88,"props":29747,"children":29748},{"style":116},[29749],{"type":34,"value":29480},{"type":29,"tag":88,"props":29751,"children":29752},{"style":122},[29753],{"type":34,"value":192},{"type":29,"tag":88,"props":29755,"children":29756},{"style":116},[29757],{"type":34,"value":29431},{"type":29,"tag":88,"props":29759,"children":29760},{"style":122},[29761],{"type":34,"value":125},{"type":29,"tag":88,"props":29763,"children":29764},{"class":90,"line":101},[29765,29769],{"type":29,"tag":88,"props":29766,"children":29767},{"style":1974},[29768],{"type":34,"value":3302},{"type":29,"tag":88,"props":29770,"children":29771},{"style":1980},[29772],{"type":34,"value":3307},{"type":29,"tag":88,"props":29774,"children":29775},{"class":90,"line":128},[29776,29780,29784,29788,29792],{"type":29,"tag":88,"props":29777,"children":29778},{"style":105},[29779],{"type":34,"value":276},{"type":29,"tag":88,"props":29781,"children":29782},{"style":105},[29783],{"type":34,"value":1303},{"type":29,"tag":88,"props":29785,"children":29786},{"style":174},[29787],{"type":34,"value":29072},{"type":29,"tag":88,"props":29789,"children":29790},{"style":122},[29791],{"type":34,"value":1470},{"type":29,"tag":88,"props":29793,"children":29794},{"style":122},[29795],{"type":34,"value":125},{"type":29,"tag":88,"props":29797,"children":29798},{"class":90,"line":137},[29799,29803,29807,29811,29815,29819,29823,29828],{"type":29,"tag":88,"props":29800,"children":29801},{"style":157},[29802],{"type":34,"value":19726},{"type":29,"tag":88,"props":29804,"children":29805},{"style":122},[29806],{"type":34,"value":338},{"type":29,"tag":88,"props":29808,"children":29809},{"style":157},[29810],{"type":34,"value":18091},{"type":29,"tag":88,"props":29812,"children":29813},{"style":122},[29814],{"type":34,"value":338},{"type":29,"tag":88,"props":29816,"children":29817},{"style":174},[29818],{"type":34,"value":18100},{"type":29,"tag":88,"props":29820,"children":29821},{"style":122},[29822],{"type":34,"value":181},{"type":29,"tag":88,"props":29824,"children":29825},{"style":184},[29826],{"type":34,"value":29827},"\"Le responsable de projet supervise les tâches.\"",{"type":29,"tag":88,"props":29829,"children":29830},{"style":122},[29831],{"type":34,"value":357},{"type":29,"tag":88,"props":29833,"children":29834},{"class":90,"line":211},[29835],{"type":29,"tag":88,"props":29836,"children":29837},{"style":122},[29838],{"type":34,"value":433},{"type":29,"tag":88,"props":29840,"children":29841},{"class":90,"line":262},[29842],{"type":29,"tag":88,"props":29843,"children":29844},{"emptyLinePlaceholder":13},[29845],{"type":34,"value":134},{"type":29,"tag":88,"props":29847,"children":29848},{"class":90,"line":270},[29849,29853],{"type":29,"tag":88,"props":29850,"children":29851},{"style":1974},[29852],{"type":34,"value":3302},{"type":29,"tag":88,"props":29854,"children":29855},{"style":1980},[29856],{"type":34,"value":3307},{"type":29,"tag":88,"props":29858,"children":29859},{"class":90,"line":313},[29860,29864,29868,29872,29876],{"type":29,"tag":88,"props":29861,"children":29862},{"style":105},[29863],{"type":34,"value":276},{"type":29,"tag":88,"props":29865,"children":29866},{"style":105},[29867],{"type":34,"value":1303},{"type":29,"tag":88,"props":29869,"children":29870},{"style":174},[29871],{"type":34,"value":29088},{"type":29,"tag":88,"props":29873,"children":29874},{"style":122},[29875],{"type":34,"value":1470},{"type":29,"tag":88,"props":29877,"children":29878},{"style":122},[29879],{"type":34,"value":125},{"type":29,"tag":88,"props":29881,"children":29882},{"class":90,"line":360},[29883,29887,29891,29895,29899,29903,29907,29912],{"type":29,"tag":88,"props":29884,"children":29885},{"style":157},[29886],{"type":34,"value":19726},{"type":29,"tag":88,"props":29888,"children":29889},{"style":122},[29890],{"type":34,"value":338},{"type":29,"tag":88,"props":29892,"children":29893},{"style":157},[29894],{"type":34,"value":18091},{"type":29,"tag":88,"props":29896,"children":29897},{"style":122},[29898],{"type":34,"value":338},{"type":29,"tag":88,"props":29900,"children":29901},{"style":174},[29902],{"type":34,"value":18100},{"type":29,"tag":88,"props":29904,"children":29905},{"style":122},[29906],{"type":34,"value":181},{"type":29,"tag":88,"props":29908,"children":29909},{"style":184},[29910],{"type":34,"value":29911},"\"Le responsable de projet gère les équipes.\"",{"type":29,"tag":88,"props":29913,"children":29914},{"style":122},[29915],{"type":34,"value":357},{"type":29,"tag":88,"props":29917,"children":29918},{"class":90,"line":409},[29919],{"type":29,"tag":88,"props":29920,"children":29921},{"style":122},[29922],{"type":34,"value":433},{"type":29,"tag":88,"props":29924,"children":29925},{"class":90,"line":427},[29926],{"type":29,"tag":88,"props":29927,"children":29928},{"style":122},[29929],{"type":34,"value":442},{"type":29,"tag":30,"props":29931,"children":29932},{},[29933],{"type":34,"value":29934},"Cette approche respecte parfaitement le principe ISP, car chaque classe n'implémente que les méthodes dont elle a réellement besoin.",{"type":29,"tag":8787,"props":29936,"children":29937},{},[29938],{"type":29,"tag":30,"props":29939,"children":29940},{},[29941,29945],{"type":29,"tag":447,"props":29942,"children":29943},{},[29944],{"type":34,"value":28931},{"type":34,"value":29946}," : 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":29,"tag":8542,"props":29948,"children":29950},{"id":29949},"exemple-3-refactoring-dune-interface-lourde",[29951],{"type":34,"value":29952},"Exemple 3 : Refactoring d'une interface lourde",{"type":29,"tag":30,"props":29954,"children":29955},{},[29956,29958,29964],{"type":34,"value":29957},"Imaginons que vous travaillez avec une interface existante qui est trop large, et vous voulez la refactorer pour respecter ISP. Prenons une interface ",{"type":29,"tag":84,"props":29959,"children":29961},{"className":29960},[],[29962],{"type":34,"value":29963},"Machine",{"type":34,"value":29965}," qui force toutes les machines à avoir des comportements différents :",{"type":29,"tag":77,"props":29967,"children":29969},{"className":81,"code":29968,"language":80,"meta":8,"style":8},"public interface Machine {\n    void demarrer();\n    void arreter();\n    void nettoyer();\n}\n",[29970],{"type":29,"tag":84,"props":29971,"children":29972},{"__ignoreMap":8},[29973,29993,30009,30025,30041],{"type":29,"tag":88,"props":29974,"children":29975},{"class":90,"line":91},[29976,29980,29984,29989],{"type":29,"tag":88,"props":29977,"children":29978},{"style":105},[29979],{"type":34,"value":108},{"type":29,"tag":88,"props":29981,"children":29982},{"style":105},[29983],{"type":34,"value":601},{"type":29,"tag":88,"props":29985,"children":29986},{"style":116},[29987],{"type":34,"value":29988}," Machine",{"type":29,"tag":88,"props":29990,"children":29991},{"style":122},[29992],{"type":34,"value":125},{"type":29,"tag":88,"props":29994,"children":29995},{"class":90,"line":101},[29996,30000,30005],{"type":29,"tag":88,"props":29997,"children":29998},{"style":105},[29999],{"type":34,"value":681},{"type":29,"tag":88,"props":30001,"children":30002},{"style":174},[30003],{"type":34,"value":30004}," demarrer",{"type":29,"tag":88,"props":30006,"children":30007},{"style":122},[30008],{"type":34,"value":1810},{"type":29,"tag":88,"props":30010,"children":30011},{"class":90,"line":128},[30012,30016,30021],{"type":29,"tag":88,"props":30013,"children":30014},{"style":105},[30015],{"type":34,"value":681},{"type":29,"tag":88,"props":30017,"children":30018},{"style":174},[30019],{"type":34,"value":30020}," arreter",{"type":29,"tag":88,"props":30022,"children":30023},{"style":122},[30024],{"type":34,"value":1810},{"type":29,"tag":88,"props":30026,"children":30027},{"class":90,"line":137},[30028,30032,30037],{"type":29,"tag":88,"props":30029,"children":30030},{"style":105},[30031],{"type":34,"value":681},{"type":29,"tag":88,"props":30033,"children":30034},{"style":174},[30035],{"type":34,"value":30036}," nettoyer",{"type":29,"tag":88,"props":30038,"children":30039},{"style":122},[30040],{"type":34,"value":1810},{"type":29,"tag":88,"props":30042,"children":30043},{"class":90,"line":211},[30044],{"type":29,"tag":88,"props":30045,"children":30046},{"style":122},[30047],{"type":34,"value":442},{"type":29,"tag":30,"props":30049,"children":30050},{},[30051,30053,30059,30061,30067],{"type":34,"value":30052},"Si vous implémentez une classe ",{"type":29,"tag":84,"props":30054,"children":30056},{"className":30055},[],[30057],{"type":34,"value":30058},"RobotCuisine",{"type":34,"value":30060},", vous n'avez pas forcément besoin de la méthode ",{"type":29,"tag":84,"props":30062,"children":30064},{"className":30063},[],[30065],{"type":34,"value":30066},"nettoyer",{"type":34,"value":30068},", 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":29,"tag":77,"props":30070,"children":30072},{"className":81,"code":30071,"language":80,"meta":8,"style":8},"public interface Demarrage {\n    void demarrer();\n    void arreter();\n}\n\npublic interface Nettoyage {\n    void nettoyer();\n}\n",[30073],{"type":29,"tag":84,"props":30074,"children":30075},{"__ignoreMap":8},[30076,30096,30111,30126,30133,30140,30160,30175],{"type":29,"tag":88,"props":30077,"children":30078},{"class":90,"line":91},[30079,30083,30087,30092],{"type":29,"tag":88,"props":30080,"children":30081},{"style":105},[30082],{"type":34,"value":108},{"type":29,"tag":88,"props":30084,"children":30085},{"style":105},[30086],{"type":34,"value":601},{"type":29,"tag":88,"props":30088,"children":30089},{"style":116},[30090],{"type":34,"value":30091}," Demarrage",{"type":29,"tag":88,"props":30093,"children":30094},{"style":122},[30095],{"type":34,"value":125},{"type":29,"tag":88,"props":30097,"children":30098},{"class":90,"line":101},[30099,30103,30107],{"type":29,"tag":88,"props":30100,"children":30101},{"style":105},[30102],{"type":34,"value":681},{"type":29,"tag":88,"props":30104,"children":30105},{"style":174},[30106],{"type":34,"value":30004},{"type":29,"tag":88,"props":30108,"children":30109},{"style":122},[30110],{"type":34,"value":1810},{"type":29,"tag":88,"props":30112,"children":30113},{"class":90,"line":128},[30114,30118,30122],{"type":29,"tag":88,"props":30115,"children":30116},{"style":105},[30117],{"type":34,"value":681},{"type":29,"tag":88,"props":30119,"children":30120},{"style":174},[30121],{"type":34,"value":30020},{"type":29,"tag":88,"props":30123,"children":30124},{"style":122},[30125],{"type":34,"value":1810},{"type":29,"tag":88,"props":30127,"children":30128},{"class":90,"line":137},[30129],{"type":29,"tag":88,"props":30130,"children":30131},{"style":122},[30132],{"type":34,"value":442},{"type":29,"tag":88,"props":30134,"children":30135},{"class":90,"line":211},[30136],{"type":29,"tag":88,"props":30137,"children":30138},{"emptyLinePlaceholder":13},[30139],{"type":34,"value":134},{"type":29,"tag":88,"props":30141,"children":30142},{"class":90,"line":262},[30143,30147,30151,30156],{"type":29,"tag":88,"props":30144,"children":30145},{"style":105},[30146],{"type":34,"value":108},{"type":29,"tag":88,"props":30148,"children":30149},{"style":105},[30150],{"type":34,"value":601},{"type":29,"tag":88,"props":30152,"children":30153},{"style":116},[30154],{"type":34,"value":30155}," Nettoyage",{"type":29,"tag":88,"props":30157,"children":30158},{"style":122},[30159],{"type":34,"value":125},{"type":29,"tag":88,"props":30161,"children":30162},{"class":90,"line":270},[30163,30167,30171],{"type":29,"tag":88,"props":30164,"children":30165},{"style":105},[30166],{"type":34,"value":681},{"type":29,"tag":88,"props":30168,"children":30169},{"style":174},[30170],{"type":34,"value":30036},{"type":29,"tag":88,"props":30172,"children":30173},{"style":122},[30174],{"type":34,"value":1810},{"type":29,"tag":88,"props":30176,"children":30177},{"class":90,"line":313},[30178],{"type":29,"tag":88,"props":30179,"children":30180},{"style":122},[30181],{"type":34,"value":442},{"type":29,"tag":30,"props":30183,"children":30184},{},[30185,30187,30192],{"type":34,"value":30186},"Ensuite, ",{"type":29,"tag":84,"props":30188,"children":30190},{"className":30189},[],[30191],{"type":34,"value":30058},{"type":34,"value":30193}," n’implémentera que les méthodes nécessaires :",{"type":29,"tag":77,"props":30195,"children":30197},{"className":81,"code":30196,"language":80,"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",[30198],{"type":29,"tag":84,"props":30199,"children":30200},{"__ignoreMap":8},[30201,30229,30240,30263,30299,30306,30313,30324,30347,30383,30390],{"type":29,"tag":88,"props":30202,"children":30203},{"class":90,"line":91},[30204,30208,30212,30217,30221,30225],{"type":29,"tag":88,"props":30205,"children":30206},{"style":105},[30207],{"type":34,"value":108},{"type":29,"tag":88,"props":30209,"children":30210},{"style":105},[30211],{"type":34,"value":113},{"type":29,"tag":88,"props":30213,"children":30214},{"style":116},[30215],{"type":34,"value":30216}," RobotCuisine",{"type":29,"tag":88,"props":30218,"children":30219},{"style":105},[30220],{"type":34,"value":1134},{"type":29,"tag":88,"props":30222,"children":30223},{"style":116},[30224],{"type":34,"value":30091},{"type":29,"tag":88,"props":30226,"children":30227},{"style":122},[30228],{"type":34,"value":125},{"type":29,"tag":88,"props":30230,"children":30231},{"class":90,"line":101},[30232,30236],{"type":29,"tag":88,"props":30233,"children":30234},{"style":1974},[30235],{"type":34,"value":3302},{"type":29,"tag":88,"props":30237,"children":30238},{"style":1980},[30239],{"type":34,"value":3307},{"type":29,"tag":88,"props":30241,"children":30242},{"class":90,"line":128},[30243,30247,30251,30255,30259],{"type":29,"tag":88,"props":30244,"children":30245},{"style":105},[30246],{"type":34,"value":276},{"type":29,"tag":88,"props":30248,"children":30249},{"style":105},[30250],{"type":34,"value":1303},{"type":29,"tag":88,"props":30252,"children":30253},{"style":174},[30254],{"type":34,"value":30004},{"type":29,"tag":88,"props":30256,"children":30257},{"style":122},[30258],{"type":34,"value":1470},{"type":29,"tag":88,"props":30260,"children":30261},{"style":122},[30262],{"type":34,"value":125},{"type":29,"tag":88,"props":30264,"children":30265},{"class":90,"line":137},[30266,30270,30274,30278,30282,30286,30290,30295],{"type":29,"tag":88,"props":30267,"children":30268},{"style":157},[30269],{"type":34,"value":19726},{"type":29,"tag":88,"props":30271,"children":30272},{"style":122},[30273],{"type":34,"value":338},{"type":29,"tag":88,"props":30275,"children":30276},{"style":157},[30277],{"type":34,"value":18091},{"type":29,"tag":88,"props":30279,"children":30280},{"style":122},[30281],{"type":34,"value":338},{"type":29,"tag":88,"props":30283,"children":30284},{"style":174},[30285],{"type":34,"value":18100},{"type":29,"tag":88,"props":30287,"children":30288},{"style":122},[30289],{"type":34,"value":181},{"type":29,"tag":88,"props":30291,"children":30292},{"style":184},[30293],{"type":34,"value":30294},"\"Le robot démarre.\"",{"type":29,"tag":88,"props":30296,"children":30297},{"style":122},[30298],{"type":34,"value":357},{"type":29,"tag":88,"props":30300,"children":30301},{"class":90,"line":211},[30302],{"type":29,"tag":88,"props":30303,"children":30304},{"style":122},[30305],{"type":34,"value":433},{"type":29,"tag":88,"props":30307,"children":30308},{"class":90,"line":262},[30309],{"type":29,"tag":88,"props":30310,"children":30311},{"emptyLinePlaceholder":13},[30312],{"type":34,"value":134},{"type":29,"tag":88,"props":30314,"children":30315},{"class":90,"line":270},[30316,30320],{"type":29,"tag":88,"props":30317,"children":30318},{"style":1974},[30319],{"type":34,"value":3302},{"type":29,"tag":88,"props":30321,"children":30322},{"style":1980},[30323],{"type":34,"value":3307},{"type":29,"tag":88,"props":30325,"children":30326},{"class":90,"line":313},[30327,30331,30335,30339,30343],{"type":29,"tag":88,"props":30328,"children":30329},{"style":105},[30330],{"type":34,"value":276},{"type":29,"tag":88,"props":30332,"children":30333},{"style":105},[30334],{"type":34,"value":1303},{"type":29,"tag":88,"props":30336,"children":30337},{"style":174},[30338],{"type":34,"value":30020},{"type":29,"tag":88,"props":30340,"children":30341},{"style":122},[30342],{"type":34,"value":1470},{"type":29,"tag":88,"props":30344,"children":30345},{"style":122},[30346],{"type":34,"value":125},{"type":29,"tag":88,"props":30348,"children":30349},{"class":90,"line":360},[30350,30354,30358,30362,30366,30370,30374,30379],{"type":29,"tag":88,"props":30351,"children":30352},{"style":157},[30353],{"type":34,"value":19726},{"type":29,"tag":88,"props":30355,"children":30356},{"style":122},[30357],{"type":34,"value":338},{"type":29,"tag":88,"props":30359,"children":30360},{"style":157},[30361],{"type":34,"value":18091},{"type":29,"tag":88,"props":30363,"children":30364},{"style":122},[30365],{"type":34,"value":338},{"type":29,"tag":88,"props":30367,"children":30368},{"style":174},[30369],{"type":34,"value":18100},{"type":29,"tag":88,"props":30371,"children":30372},{"style":122},[30373],{"type":34,"value":181},{"type":29,"tag":88,"props":30375,"children":30376},{"style":184},[30377],{"type":34,"value":30378},"\"Le robot s'arrête.\"",{"type":29,"tag":88,"props":30380,"children":30381},{"style":122},[30382],{"type":34,"value":357},{"type":29,"tag":88,"props":30384,"children":30385},{"class":90,"line":409},[30386],{"type":29,"tag":88,"props":30387,"children":30388},{"style":122},[30389],{"type":34,"value":433},{"type":29,"tag":88,"props":30391,"children":30392},{"class":90,"line":427},[30393],{"type":29,"tag":88,"props":30394,"children":30395},{"style":122},[30396],{"type":34,"value":442},{"type":29,"tag":30,"props":30398,"children":30399},{},[30400,30402,30407,30409,30415,30417,30423],{"type":34,"value":30401},"Si vous avez une autre classe qui a besoin de la méthode ",{"type":29,"tag":84,"props":30403,"children":30405},{"className":30404},[],[30406],{"type":34,"value":30066},{"type":34,"value":30408},", comme une classe ",{"type":29,"tag":84,"props":30410,"children":30412},{"className":30411},[],[30413],{"type":34,"value":30414},"LaveVaisselle",{"type":34,"value":30416},", elle peut implémenter l'interface ",{"type":29,"tag":84,"props":30418,"children":30420},{"className":30419},[],[30421],{"type":34,"value":30422},"Nettoyage",{"type":34,"value":21063},{"type":29,"tag":77,"props":30425,"children":30427},{"className":81,"code":30426,"language":80,"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",[30428],{"type":29,"tag":84,"props":30429,"children":30430},{"__ignoreMap":8},[30431,30467,30478,30501,30537,30544,30551,30562,30585,30621,30628,30635,30646,30669,30705,30712],{"type":29,"tag":88,"props":30432,"children":30433},{"class":90,"line":91},[30434,30438,30442,30447,30451,30455,30459,30463],{"type":29,"tag":88,"props":30435,"children":30436},{"style":105},[30437],{"type":34,"value":108},{"type":29,"tag":88,"props":30439,"children":30440},{"style":105},[30441],{"type":34,"value":113},{"type":29,"tag":88,"props":30443,"children":30444},{"style":116},[30445],{"type":34,"value":30446}," LaveVaisselle",{"type":29,"tag":88,"props":30448,"children":30449},{"style":105},[30450],{"type":34,"value":1134},{"type":29,"tag":88,"props":30452,"children":30453},{"style":116},[30454],{"type":34,"value":30091},{"type":29,"tag":88,"props":30456,"children":30457},{"style":122},[30458],{"type":34,"value":192},{"type":29,"tag":88,"props":30460,"children":30461},{"style":116},[30462],{"type":34,"value":30155},{"type":29,"tag":88,"props":30464,"children":30465},{"style":122},[30466],{"type":34,"value":125},{"type":29,"tag":88,"props":30468,"children":30469},{"class":90,"line":101},[30470,30474],{"type":29,"tag":88,"props":30471,"children":30472},{"style":1974},[30473],{"type":34,"value":3302},{"type":29,"tag":88,"props":30475,"children":30476},{"style":1980},[30477],{"type":34,"value":3307},{"type":29,"tag":88,"props":30479,"children":30480},{"class":90,"line":128},[30481,30485,30489,30493,30497],{"type":29,"tag":88,"props":30482,"children":30483},{"style":105},[30484],{"type":34,"value":276},{"type":29,"tag":88,"props":30486,"children":30487},{"style":105},[30488],{"type":34,"value":1303},{"type":29,"tag":88,"props":30490,"children":30491},{"style":174},[30492],{"type":34,"value":30004},{"type":29,"tag":88,"props":30494,"children":30495},{"style":122},[30496],{"type":34,"value":1470},{"type":29,"tag":88,"props":30498,"children":30499},{"style":122},[30500],{"type":34,"value":125},{"type":29,"tag":88,"props":30502,"children":30503},{"class":90,"line":137},[30504,30508,30512,30516,30520,30524,30528,30533],{"type":29,"tag":88,"props":30505,"children":30506},{"style":157},[30507],{"type":34,"value":19726},{"type":29,"tag":88,"props":30509,"children":30510},{"style":122},[30511],{"type":34,"value":338},{"type":29,"tag":88,"props":30513,"children":30514},{"style":157},[30515],{"type":34,"value":18091},{"type":29,"tag":88,"props":30517,"children":30518},{"style":122},[30519],{"type":34,"value":338},{"type":29,"tag":88,"props":30521,"children":30522},{"style":174},[30523],{"type":34,"value":18100},{"type":29,"tag":88,"props":30525,"children":30526},{"style":122},[30527],{"type":34,"value":181},{"type":29,"tag":88,"props":30529,"children":30530},{"style":184},[30531],{"type":34,"value":30532},"\"Le lave-vaisselle démarre.\"",{"type":29,"tag":88,"props":30534,"children":30535},{"style":122},[30536],{"type":34,"value":357},{"type":29,"tag":88,"props":30538,"children":30539},{"class":90,"line":211},[30540],{"type":29,"tag":88,"props":30541,"children":30542},{"style":122},[30543],{"type":34,"value":433},{"type":29,"tag":88,"props":30545,"children":30546},{"class":90,"line":262},[30547],{"type":29,"tag":88,"props":30548,"children":30549},{"emptyLinePlaceholder":13},[30550],{"type":34,"value":134},{"type":29,"tag":88,"props":30552,"children":30553},{"class":90,"line":270},[30554,30558],{"type":29,"tag":88,"props":30555,"children":30556},{"style":1974},[30557],{"type":34,"value":3302},{"type":29,"tag":88,"props":30559,"children":30560},{"style":1980},[30561],{"type":34,"value":3307},{"type":29,"tag":88,"props":30563,"children":30564},{"class":90,"line":313},[30565,30569,30573,30577,30581],{"type":29,"tag":88,"props":30566,"children":30567},{"style":105},[30568],{"type":34,"value":276},{"type":29,"tag":88,"props":30570,"children":30571},{"style":105},[30572],{"type":34,"value":1303},{"type":29,"tag":88,"props":30574,"children":30575},{"style":174},[30576],{"type":34,"value":30020},{"type":29,"tag":88,"props":30578,"children":30579},{"style":122},[30580],{"type":34,"value":1470},{"type":29,"tag":88,"props":30582,"children":30583},{"style":122},[30584],{"type":34,"value":125},{"type":29,"tag":88,"props":30586,"children":30587},{"class":90,"line":360},[30588,30592,30596,30600,30604,30608,30612,30617],{"type":29,"tag":88,"props":30589,"children":30590},{"style":157},[30591],{"type":34,"value":19726},{"type":29,"tag":88,"props":30593,"children":30594},{"style":122},[30595],{"type":34,"value":338},{"type":29,"tag":88,"props":30597,"children":30598},{"style":157},[30599],{"type":34,"value":18091},{"type":29,"tag":88,"props":30601,"children":30602},{"style":122},[30603],{"type":34,"value":338},{"type":29,"tag":88,"props":30605,"children":30606},{"style":174},[30607],{"type":34,"value":18100},{"type":29,"tag":88,"props":30609,"children":30610},{"style":122},[30611],{"type":34,"value":181},{"type":29,"tag":88,"props":30613,"children":30614},{"style":184},[30615],{"type":34,"value":30616},"\"Le lave-vaisselle s'arrête.\"",{"type":29,"tag":88,"props":30618,"children":30619},{"style":122},[30620],{"type":34,"value":357},{"type":29,"tag":88,"props":30622,"children":30623},{"class":90,"line":409},[30624],{"type":29,"tag":88,"props":30625,"children":30626},{"style":122},[30627],{"type":34,"value":433},{"type":29,"tag":88,"props":30629,"children":30630},{"class":90,"line":427},[30631],{"type":29,"tag":88,"props":30632,"children":30633},{"emptyLinePlaceholder":13},[30634],{"type":34,"value":134},{"type":29,"tag":88,"props":30636,"children":30637},{"class":90,"line":436},[30638,30642],{"type":29,"tag":88,"props":30639,"children":30640},{"style":1974},[30641],{"type":34,"value":3302},{"type":29,"tag":88,"props":30643,"children":30644},{"style":1980},[30645],{"type":34,"value":3307},{"type":29,"tag":88,"props":30647,"children":30648},{"class":90,"line":767},[30649,30653,30657,30661,30665],{"type":29,"tag":88,"props":30650,"children":30651},{"style":105},[30652],{"type":34,"value":276},{"type":29,"tag":88,"props":30654,"children":30655},{"style":105},[30656],{"type":34,"value":1303},{"type":29,"tag":88,"props":30658,"children":30659},{"style":174},[30660],{"type":34,"value":30036},{"type":29,"tag":88,"props":30662,"children":30663},{"style":122},[30664],{"type":34,"value":1470},{"type":29,"tag":88,"props":30666,"children":30667},{"style":122},[30668],{"type":34,"value":125},{"type":29,"tag":88,"props":30670,"children":30671},{"class":90,"line":792},[30672,30676,30680,30684,30688,30692,30696,30701],{"type":29,"tag":88,"props":30673,"children":30674},{"style":157},[30675],{"type":34,"value":19726},{"type":29,"tag":88,"props":30677,"children":30678},{"style":122},[30679],{"type":34,"value":338},{"type":29,"tag":88,"props":30681,"children":30682},{"style":157},[30683],{"type":34,"value":18091},{"type":29,"tag":88,"props":30685,"children":30686},{"style":122},[30687],{"type":34,"value":338},{"type":29,"tag":88,"props":30689,"children":30690},{"style":174},[30691],{"type":34,"value":18100},{"type":29,"tag":88,"props":30693,"children":30694},{"style":122},[30695],{"type":34,"value":181},{"type":29,"tag":88,"props":30697,"children":30698},{"style":184},[30699],{"type":34,"value":30700},"\"Le lave-vaisselle nettoie.\"",{"type":29,"tag":88,"props":30702,"children":30703},{"style":122},[30704],{"type":34,"value":357},{"type":29,"tag":88,"props":30706,"children":30707},{"class":90,"line":817},[30708],{"type":29,"tag":88,"props":30709,"children":30710},{"style":122},[30711],{"type":34,"value":433},{"type":29,"tag":88,"props":30713,"children":30714},{"class":90,"line":825},[30715],{"type":29,"tag":88,"props":30716,"children":30717},{"style":122},[30718],{"type":34,"value":442},{"type":29,"tag":30,"props":30720,"children":30721},{},[30722],{"type":34,"value":30723},"Cette séparation rend le code plus flexible, plus modulaire et plus simple à tester.",{"type":29,"tag":47,"props":30725,"children":30726},{},[],{"type":29,"tag":2288,"props":30728,"children":30730},{"cta":2290,"href":2291,"title":30729,"type":2293},"Vous voulez acquérir le réflexe de découper une interface au bon endroit, sans y penser ?",[30731],{"type":29,"tag":30,"props":30732,"children":30733},{},[30734],{"type":34,"value":30735},"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":29,"tag":51,"props":30737,"children":30739},{"id":30738},"les-erreurs-courantes-à-éviter",[30740],{"type":34,"value":30741},"Les erreurs courantes à éviter",{"type":29,"tag":30,"props":30743,"children":30744},{},[30745],{"type":34,"value":30746},"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":29,"tag":8542,"props":30748,"children":30750},{"id":30749},"_1-créer-trop-dinterfaces-inutiles",[30751],{"type":34,"value":30752},"1. Créer trop d'interfaces inutiles",{"type":29,"tag":30,"props":30754,"children":30755},{},[30756],{"type":34,"value":30757},"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":29,"tag":30,"props":30759,"children":30760},{},[30761],{"type":29,"tag":447,"props":30762,"children":30763},{},[30764],{"type":34,"value":30765},"Exemple à éviter :",{"type":29,"tag":77,"props":30767,"children":30769},{"className":81,"code":30768,"language":80,"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",[30770],{"type":29,"tag":84,"props":30771,"children":30772},{"__ignoreMap":8},[30773,30793,30809,30816,30823,30843,30859,30866,30873,30893,30908],{"type":29,"tag":88,"props":30774,"children":30775},{"class":90,"line":91},[30776,30780,30784,30789],{"type":29,"tag":88,"props":30777,"children":30778},{"style":105},[30779],{"type":34,"value":108},{"type":29,"tag":88,"props":30781,"children":30782},{"style":105},[30783],{"type":34,"value":601},{"type":29,"tag":88,"props":30785,"children":30786},{"style":116},[30787],{"type":34,"value":30788}," Travailler",{"type":29,"tag":88,"props":30790,"children":30791},{"style":122},[30792],{"type":34,"value":125},{"type":29,"tag":88,"props":30794,"children":30795},{"class":90,"line":101},[30796,30800,30805],{"type":29,"tag":88,"props":30797,"children":30798},{"style":105},[30799],{"type":34,"value":681},{"type":29,"tag":88,"props":30801,"children":30802},{"style":174},[30803],{"type":34,"value":30804}," ecrireCode",{"type":29,"tag":88,"props":30806,"children":30807},{"style":122},[30808],{"type":34,"value":1810},{"type":29,"tag":88,"props":30810,"children":30811},{"class":90,"line":128},[30812],{"type":29,"tag":88,"props":30813,"children":30814},{"style":122},[30815],{"type":34,"value":442},{"type":29,"tag":88,"props":30817,"children":30818},{"class":90,"line":137},[30819],{"type":29,"tag":88,"props":30820,"children":30821},{"emptyLinePlaceholder":13},[30822],{"type":34,"value":134},{"type":29,"tag":88,"props":30824,"children":30825},{"class":90,"line":211},[30826,30830,30834,30839],{"type":29,"tag":88,"props":30827,"children":30828},{"style":105},[30829],{"type":34,"value":108},{"type":29,"tag":88,"props":30831,"children":30832},{"style":105},[30833],{"type":34,"value":601},{"type":29,"tag":88,"props":30835,"children":30836},{"style":116},[30837],{"type":34,"value":30838}," ManagerProjet",{"type":29,"tag":88,"props":30840,"children":30841},{"style":122},[30842],{"type":34,"value":125},{"type":29,"tag":88,"props":30844,"children":30845},{"class":90,"line":262},[30846,30850,30855],{"type":29,"tag":88,"props":30847,"children":30848},{"style":105},[30849],{"type":34,"value":681},{"type":29,"tag":88,"props":30851,"children":30852},{"style":174},[30853],{"type":34,"value":30854}," organiserReunion",{"type":29,"tag":88,"props":30856,"children":30857},{"style":122},[30858],{"type":34,"value":1810},{"type":29,"tag":88,"props":30860,"children":30861},{"class":90,"line":270},[30862],{"type":29,"tag":88,"props":30863,"children":30864},{"style":122},[30865],{"type":34,"value":442},{"type":29,"tag":88,"props":30867,"children":30868},{"class":90,"line":313},[30869],{"type":29,"tag":88,"props":30870,"children":30871},{"emptyLinePlaceholder":13},[30872],{"type":34,"value":134},{"type":29,"tag":88,"props":30874,"children":30875},{"class":90,"line":360},[30876,30880,30884,30889],{"type":29,"tag":88,"props":30877,"children":30878},{"style":105},[30879],{"type":34,"value":108},{"type":29,"tag":88,"props":30881,"children":30882},{"style":105},[30883],{"type":34,"value":601},{"type":29,"tag":88,"props":30885,"children":30886},{"style":116},[30887],{"type":34,"value":30888}," SalarieEntreprise",{"type":29,"tag":88,"props":30890,"children":30891},{"style":122},[30892],{"type":34,"value":125},{"type":29,"tag":88,"props":30894,"children":30895},{"class":90,"line":409},[30896,30900,30904],{"type":29,"tag":88,"props":30897,"children":30898},{"style":105},[30899],{"type":34,"value":681},{"type":29,"tag":88,"props":30901,"children":30902},{"style":174},[30903],{"type":34,"value":29104},{"type":29,"tag":88,"props":30905,"children":30906},{"style":122},[30907],{"type":34,"value":1810},{"type":29,"tag":88,"props":30909,"children":30910},{"class":90,"line":427},[30911],{"type":29,"tag":88,"props":30912,"children":30913},{"style":122},[30914],{"type":34,"value":442},{"type":29,"tag":30,"props":30916,"children":30917},{},[30918],{"type":34,"value":30919},"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":29,"tag":8787,"props":30921,"children":30922},{},[30923],{"type":29,"tag":30,"props":30924,"children":30925},{},[30926,30930],{"type":29,"tag":447,"props":30927,"children":30928},{},[30929],{"type":34,"value":28931},{"type":34,"value":30931}," : 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":29,"tag":8542,"props":30933,"children":30935},{"id":30934},"_2-concevoir-des-interfaces-trop-larges",[30936],{"type":34,"value":30937},"2. Concevoir des interfaces trop larges",{"type":29,"tag":30,"props":30939,"children":30940},{},[30941],{"type":34,"value":30942},"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":29,"tag":30,"props":30944,"children":30945},{},[30946],{"type":29,"tag":447,"props":30947,"children":30948},{},[30949],{"type":34,"value":30765},{"type":29,"tag":77,"props":30951,"children":30953},{"className":81,"code":30952,"language":80,"meta":8,"style":8},"public interface ServiceClient {\n    void traiterCommande();\n    void envoyerFacture();\n    void gererReclamations();\n    void realiserAudit();\n}\n",[30954],{"type":29,"tag":84,"props":30955,"children":30956},{"__ignoreMap":8},[30957,30977,30993,31009,31025,31041],{"type":29,"tag":88,"props":30958,"children":30959},{"class":90,"line":91},[30960,30964,30968,30973],{"type":29,"tag":88,"props":30961,"children":30962},{"style":105},[30963],{"type":34,"value":108},{"type":29,"tag":88,"props":30965,"children":30966},{"style":105},[30967],{"type":34,"value":601},{"type":29,"tag":88,"props":30969,"children":30970},{"style":116},[30971],{"type":34,"value":30972}," ServiceClient",{"type":29,"tag":88,"props":30974,"children":30975},{"style":122},[30976],{"type":34,"value":125},{"type":29,"tag":88,"props":30978,"children":30979},{"class":90,"line":101},[30980,30984,30989],{"type":29,"tag":88,"props":30981,"children":30982},{"style":105},[30983],{"type":34,"value":681},{"type":29,"tag":88,"props":30985,"children":30986},{"style":174},[30987],{"type":34,"value":30988}," traiterCommande",{"type":29,"tag":88,"props":30990,"children":30991},{"style":122},[30992],{"type":34,"value":1810},{"type":29,"tag":88,"props":30994,"children":30995},{"class":90,"line":128},[30996,31000,31005],{"type":29,"tag":88,"props":30997,"children":30998},{"style":105},[30999],{"type":34,"value":681},{"type":29,"tag":88,"props":31001,"children":31002},{"style":174},[31003],{"type":34,"value":31004}," envoyerFacture",{"type":29,"tag":88,"props":31006,"children":31007},{"style":122},[31008],{"type":34,"value":1810},{"type":29,"tag":88,"props":31010,"children":31011},{"class":90,"line":137},[31012,31016,31021],{"type":29,"tag":88,"props":31013,"children":31014},{"style":105},[31015],{"type":34,"value":681},{"type":29,"tag":88,"props":31017,"children":31018},{"style":174},[31019],{"type":34,"value":31020}," gererReclamations",{"type":29,"tag":88,"props":31022,"children":31023},{"style":122},[31024],{"type":34,"value":1810},{"type":29,"tag":88,"props":31026,"children":31027},{"class":90,"line":211},[31028,31032,31037],{"type":29,"tag":88,"props":31029,"children":31030},{"style":105},[31031],{"type":34,"value":681},{"type":29,"tag":88,"props":31033,"children":31034},{"style":174},[31035],{"type":34,"value":31036}," realiserAudit",{"type":29,"tag":88,"props":31038,"children":31039},{"style":122},[31040],{"type":34,"value":1810},{"type":29,"tag":88,"props":31042,"children":31043},{"class":90,"line":262},[31044],{"type":29,"tag":88,"props":31045,"children":31046},{"style":122},[31047],{"type":34,"value":442},{"type":29,"tag":30,"props":31049,"children":31050},{},[31051,31053,31059],{"type":34,"value":31052},"Ici, une interface ",{"type":29,"tag":84,"props":31054,"children":31056},{"className":31055},[],[31057],{"type":34,"value":31058},"ServiceClient",{"type":34,"value":31060}," 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":29,"tag":8542,"props":31062,"children":31064},{"id":31063},"_3-ne-pas-reconnaître-les-symptômes-dune-interface-trop-lourde",[31065],{"type":34,"value":31066},"3. Ne pas reconnaître les symptômes d’une interface trop lourde",{"type":29,"tag":30,"props":31068,"children":31069},{},[31070,31072,31077],{"type":34,"value":31071},"Si vous vous rendez compte que vous devez fréquemment passer des paramètres ",{"type":29,"tag":84,"props":31073,"children":31075},{"className":31074},[],[31076],{"type":34,"value":18641},{"type":34,"value":31078}," 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":29,"tag":30,"props":31080,"children":31081},{},[31082],{"type":29,"tag":447,"props":31083,"children":31084},{},[31085],{"type":34,"value":31086},"Exemple :",{"type":29,"tag":77,"props":31088,"children":31090},{"className":81,"code":31089,"language":80,"meta":8,"style":8},"public class ServiceLivraison implements ServiceClient {\n    @Override\n    public void traiterCommande() {\n        \u002F\u002F Code de traitement de commande\n    }\n\n    @Override\n    public void envoyerFacture() {\n        \u002F\u002F 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        \u002F\u002F Code de gestion des réclamations\n    }\n\n    @Override\n    public void realiserAudit() {\n        \u002F\u002F Non pertinent pour ServiceLivraison.\n        throw new UnsupportedOperationException(\"Méthode non supportée.\");\n    }\n}\n",[31091],{"type":29,"tag":84,"props":31092,"children":31093},{"__ignoreMap":8},[31094,31122,31133,31156,31164,31171,31178,31189,31212,31220,31250,31257,31264,31275,31298,31306,31313,31320,31331,31354,31362,31389,31396],{"type":29,"tag":88,"props":31095,"children":31096},{"class":90,"line":91},[31097,31101,31105,31110,31114,31118],{"type":29,"tag":88,"props":31098,"children":31099},{"style":105},[31100],{"type":34,"value":108},{"type":29,"tag":88,"props":31102,"children":31103},{"style":105},[31104],{"type":34,"value":113},{"type":29,"tag":88,"props":31106,"children":31107},{"style":116},[31108],{"type":34,"value":31109}," ServiceLivraison",{"type":29,"tag":88,"props":31111,"children":31112},{"style":105},[31113],{"type":34,"value":1134},{"type":29,"tag":88,"props":31115,"children":31116},{"style":116},[31117],{"type":34,"value":30972},{"type":29,"tag":88,"props":31119,"children":31120},{"style":122},[31121],{"type":34,"value":125},{"type":29,"tag":88,"props":31123,"children":31124},{"class":90,"line":101},[31125,31129],{"type":29,"tag":88,"props":31126,"children":31127},{"style":1974},[31128],{"type":34,"value":3302},{"type":29,"tag":88,"props":31130,"children":31131},{"style":1980},[31132],{"type":34,"value":3307},{"type":29,"tag":88,"props":31134,"children":31135},{"class":90,"line":128},[31136,31140,31144,31148,31152],{"type":29,"tag":88,"props":31137,"children":31138},{"style":105},[31139],{"type":34,"value":276},{"type":29,"tag":88,"props":31141,"children":31142},{"style":105},[31143],{"type":34,"value":1303},{"type":29,"tag":88,"props":31145,"children":31146},{"style":174},[31147],{"type":34,"value":30988},{"type":29,"tag":88,"props":31149,"children":31150},{"style":122},[31151],{"type":34,"value":1470},{"type":29,"tag":88,"props":31153,"children":31154},{"style":122},[31155],{"type":34,"value":125},{"type":29,"tag":88,"props":31157,"children":31158},{"class":90,"line":137},[31159],{"type":29,"tag":88,"props":31160,"children":31161},{"style":95},[31162],{"type":34,"value":31163},"        \u002F\u002F Code de traitement de commande\n",{"type":29,"tag":88,"props":31165,"children":31166},{"class":90,"line":211},[31167],{"type":29,"tag":88,"props":31168,"children":31169},{"style":122},[31170],{"type":34,"value":433},{"type":29,"tag":88,"props":31172,"children":31173},{"class":90,"line":262},[31174],{"type":29,"tag":88,"props":31175,"children":31176},{"emptyLinePlaceholder":13},[31177],{"type":34,"value":134},{"type":29,"tag":88,"props":31179,"children":31180},{"class":90,"line":270},[31181,31185],{"type":29,"tag":88,"props":31182,"children":31183},{"style":1974},[31184],{"type":34,"value":3302},{"type":29,"tag":88,"props":31186,"children":31187},{"style":1980},[31188],{"type":34,"value":3307},{"type":29,"tag":88,"props":31190,"children":31191},{"class":90,"line":313},[31192,31196,31200,31204,31208],{"type":29,"tag":88,"props":31193,"children":31194},{"style":105},[31195],{"type":34,"value":276},{"type":29,"tag":88,"props":31197,"children":31198},{"style":105},[31199],{"type":34,"value":1303},{"type":29,"tag":88,"props":31201,"children":31202},{"style":174},[31203],{"type":34,"value":31004},{"type":29,"tag":88,"props":31205,"children":31206},{"style":122},[31207],{"type":34,"value":1470},{"type":29,"tag":88,"props":31209,"children":31210},{"style":122},[31211],{"type":34,"value":125},{"type":29,"tag":88,"props":31213,"children":31214},{"class":90,"line":360},[31215],{"type":29,"tag":88,"props":31216,"children":31217},{"style":95},[31218],{"type":34,"value":31219},"        \u002F\u002F Cette méthode n'est pas pertinente pour ServiceLivraison.\n",{"type":29,"tag":88,"props":31221,"children":31222},{"class":90,"line":409},[31223,31228,31232,31237,31241,31246],{"type":29,"tag":88,"props":31224,"children":31225},{"style":105},[31226],{"type":34,"value":31227},"        throw",{"type":29,"tag":88,"props":31229,"children":31230},{"style":105},[31231],{"type":34,"value":171},{"type":29,"tag":88,"props":31233,"children":31234},{"style":174},[31235],{"type":34,"value":31236}," UnsupportedOperationException",{"type":29,"tag":88,"props":31238,"children":31239},{"style":122},[31240],{"type":34,"value":181},{"type":29,"tag":88,"props":31242,"children":31243},{"style":184},[31244],{"type":34,"value":31245},"\"Méthode non supportée.\"",{"type":29,"tag":88,"props":31247,"children":31248},{"style":122},[31249],{"type":34,"value":357},{"type":29,"tag":88,"props":31251,"children":31252},{"class":90,"line":427},[31253],{"type":29,"tag":88,"props":31254,"children":31255},{"style":122},[31256],{"type":34,"value":433},{"type":29,"tag":88,"props":31258,"children":31259},{"class":90,"line":436},[31260],{"type":29,"tag":88,"props":31261,"children":31262},{"emptyLinePlaceholder":13},[31263],{"type":34,"value":134},{"type":29,"tag":88,"props":31265,"children":31266},{"class":90,"line":767},[31267,31271],{"type":29,"tag":88,"props":31268,"children":31269},{"style":1974},[31270],{"type":34,"value":3302},{"type":29,"tag":88,"props":31272,"children":31273},{"style":1980},[31274],{"type":34,"value":3307},{"type":29,"tag":88,"props":31276,"children":31277},{"class":90,"line":792},[31278,31282,31286,31290,31294],{"type":29,"tag":88,"props":31279,"children":31280},{"style":105},[31281],{"type":34,"value":276},{"type":29,"tag":88,"props":31283,"children":31284},{"style":105},[31285],{"type":34,"value":1303},{"type":29,"tag":88,"props":31287,"children":31288},{"style":174},[31289],{"type":34,"value":31020},{"type":29,"tag":88,"props":31291,"children":31292},{"style":122},[31293],{"type":34,"value":1470},{"type":29,"tag":88,"props":31295,"children":31296},{"style":122},[31297],{"type":34,"value":125},{"type":29,"tag":88,"props":31299,"children":31300},{"class":90,"line":817},[31301],{"type":29,"tag":88,"props":31302,"children":31303},{"style":95},[31304],{"type":34,"value":31305},"        \u002F\u002F Code de gestion des réclamations\n",{"type":29,"tag":88,"props":31307,"children":31308},{"class":90,"line":825},[31309],{"type":29,"tag":88,"props":31310,"children":31311},{"style":122},[31312],{"type":34,"value":433},{"type":29,"tag":88,"props":31314,"children":31315},{"class":90,"line":869},[31316],{"type":29,"tag":88,"props":31317,"children":31318},{"emptyLinePlaceholder":13},[31319],{"type":34,"value":134},{"type":29,"tag":88,"props":31321,"children":31322},{"class":90,"line":900},[31323,31327],{"type":29,"tag":88,"props":31324,"children":31325},{"style":1974},[31326],{"type":34,"value":3302},{"type":29,"tag":88,"props":31328,"children":31329},{"style":1980},[31330],{"type":34,"value":3307},{"type":29,"tag":88,"props":31332,"children":31333},{"class":90,"line":929},[31334,31338,31342,31346,31350],{"type":29,"tag":88,"props":31335,"children":31336},{"style":105},[31337],{"type":34,"value":276},{"type":29,"tag":88,"props":31339,"children":31340},{"style":105},[31341],{"type":34,"value":1303},{"type":29,"tag":88,"props":31343,"children":31344},{"style":174},[31345],{"type":34,"value":31036},{"type":29,"tag":88,"props":31347,"children":31348},{"style":122},[31349],{"type":34,"value":1470},{"type":29,"tag":88,"props":31351,"children":31352},{"style":122},[31353],{"type":34,"value":125},{"type":29,"tag":88,"props":31355,"children":31356},{"class":90,"line":937},[31357],{"type":29,"tag":88,"props":31358,"children":31359},{"style":95},[31360],{"type":34,"value":31361},"        \u002F\u002F Non pertinent pour ServiceLivraison.\n",{"type":29,"tag":88,"props":31363,"children":31364},{"class":90,"line":945},[31365,31369,31373,31377,31381,31385],{"type":29,"tag":88,"props":31366,"children":31367},{"style":105},[31368],{"type":34,"value":31227},{"type":29,"tag":88,"props":31370,"children":31371},{"style":105},[31372],{"type":34,"value":171},{"type":29,"tag":88,"props":31374,"children":31375},{"style":174},[31376],{"type":34,"value":31236},{"type":29,"tag":88,"props":31378,"children":31379},{"style":122},[31380],{"type":34,"value":181},{"type":29,"tag":88,"props":31382,"children":31383},{"style":184},[31384],{"type":34,"value":31245},{"type":29,"tag":88,"props":31386,"children":31387},{"style":122},[31388],{"type":34,"value":357},{"type":29,"tag":88,"props":31390,"children":31391},{"class":90,"line":981},[31392],{"type":29,"tag":88,"props":31393,"children":31394},{"style":122},[31395],{"type":34,"value":433},{"type":29,"tag":88,"props":31397,"children":31398},{"class":90,"line":1021},[31399],{"type":29,"tag":88,"props":31400,"children":31401},{"style":122},[31402],{"type":34,"value":442},{"type":29,"tag":30,"props":31404,"children":31405},{},[31406,31407,31413],{"type":34,"value":11007},{"type":29,"tag":84,"props":31408,"children":31410},{"className":31409},[],[31411],{"type":34,"value":31412},"ServiceLivraison",{"type":34,"value":31414}," 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":29,"tag":8542,"props":31416,"children":31418},{"id":31417},"_4-ne-pas-penser-aux-changements-futurs",[31419],{"type":34,"value":31420},"4. Ne pas penser aux changements futurs",{"type":29,"tag":30,"props":31422,"children":31423},{},[31424],{"type":34,"value":31425},"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":29,"tag":8787,"props":31427,"children":31428},{},[31429],{"type":29,"tag":30,"props":31430,"children":31431},{},[31432,31436],{"type":29,"tag":447,"props":31433,"children":31434},{},[31435],{"type":34,"value":28931},{"type":34,"value":31437}," : 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":29,"tag":47,"props":31439,"children":31440},{},[],{"type":29,"tag":2288,"props":31442,"children":31444},{"cta":5629,"href":5630,"title":31443,"type":5632},"Bien découper une interface n'est qu'une pratique sur 100",[31445],{"type":29,"tag":30,"props":31446,"children":31447},{},[31448],{"type":34,"value":31449},"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":29,"tag":47,"props":31451,"children":31452},{},[],{"type":29,"tag":51,"props":31454,"children":31456},{"id":31455},"faq-sur-le-principe-isp-interface-segregation-principle",[31457],{"type":34,"value":31458},"FAQ sur le principe ISP (Interface Segregation Principle)",{"type":29,"tag":5649,"props":31460,"children":31461},{},[31462,31467],{"type":29,"tag":5653,"props":31463,"children":31464},{},[31465],{"type":34,"value":31466},"1. Qu’est-ce que le principe de séparation d’interface (ISP) en quelques mots ?",{"type":29,"tag":30,"props":31468,"children":31469},{},[31470],{"type":34,"value":31471},"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":29,"tag":5649,"props":31473,"children":31474},{},[31475,31480],{"type":29,"tag":5653,"props":31476,"children":31477},{},[31478],{"type":34,"value":31479},"2. Pourquoi est-ce important de respecter ISP ?",{"type":29,"tag":30,"props":31481,"children":31482},{},[31483],{"type":34,"value":31484},"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":29,"tag":5649,"props":31486,"children":31487},{},[31488,31493],{"type":29,"tag":5653,"props":31489,"children":31490},{},[31491],{"type":34,"value":31492},"3. Comment puis-je savoir qu’une interface est trop large ?",{"type":29,"tag":30,"props":31494,"children":31495},{},[31496,31498,31503],{"type":34,"value":31497},"Si vous vous retrouvez à implémenter des méthodes dont votre classe n’a pas besoin ou à lever des exceptions du type ",{"type":29,"tag":84,"props":31499,"children":31501},{"className":31500},[],[31502],{"type":34,"value":29388},{"type":34,"value":31504},", 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":29,"tag":5649,"props":31506,"children":31507},{},[31508,31513],{"type":29,"tag":5653,"props":31509,"children":31510},{},[31511],{"type":34,"value":31512},"4. Combien d’interfaces devrais-je créer ?",{"type":29,"tag":30,"props":31514,"children":31515},{},[31516],{"type":34,"value":31517},"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":29,"tag":5649,"props":31519,"children":31520},{},[31521,31526],{"type":29,"tag":5653,"props":31522,"children":31523},{},[31524],{"type":34,"value":31525},"5. Quelles sont les différences entre ISP et le principe de responsabilité unique (SRP) ?",{"type":29,"tag":30,"props":31527,"children":31528},{},[31529,31531,31535],{"type":34,"value":31530},"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":29,"tag":63,"props":31532,"children":31533},{"href":5},[31534],{"type":34,"value":5883},{"type":34,"value":31536},", car les modules de haut niveau peuvent dépendre d’abstractions précises plutôt que de contrats fourre-tout.",{"type":29,"tag":5649,"props":31538,"children":31539},{},[31540,31545],{"type":29,"tag":5653,"props":31541,"children":31542},{},[31543],{"type":34,"value":31544},"6. Quel est le lien entre ISP et les autres principes SOLID ?",{"type":29,"tag":30,"props":31546,"children":31547},{},[31548],{"type":34,"value":31549},"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":29,"tag":5649,"props":31551,"children":31552},{},[31553,31558],{"type":29,"tag":5653,"props":31554,"children":31555},{},[31556],{"type":34,"value":31557},"7. Quels sont les avantages d’ISP pour les tests unitaires ?",{"type":29,"tag":30,"props":31559,"children":31560},{},[31561],{"type":34,"value":31562},"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":29,"tag":5649,"props":31564,"children":31565},{},[31566,31571],{"type":29,"tag":5653,"props":31567,"children":31568},{},[31569],{"type":34,"value":31570},"8. Comment appliquer ISP dans des projets existants sans tout refactorer ?",{"type":29,"tag":30,"props":31572,"children":31573},{},[31574],{"type":34,"value":31575},"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":29,"tag":5649,"props":31577,"children":31578},{},[31579,31584],{"type":29,"tag":5653,"props":31580,"children":31581},{},[31582],{"type":34,"value":31583},"9. Peut-on respecter ISP dans des langages autres que Java ?",{"type":29,"tag":30,"props":31585,"children":31586},{},[31587],{"type":34,"value":31588},"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":29,"tag":47,"props":31590,"children":31591},{},[],{"type":29,"tag":30,"props":31593,"children":31594},{},[31595,31597,31602],{"type":34,"value":31596},"En suivant ces conseils et en évitant les erreurs courantes, vous pourrez tirer le meilleur parti du ",{"type":29,"tag":447,"props":31598,"children":31599},{},[31600],{"type":34,"value":31601},"principe de séparation d'interface (ISP)",{"type":34,"value":31603}," et écrire un code modulaire, maintenable et facile à tester.",{"type":29,"tag":47,"props":31605,"children":31606},{},[],{"type":29,"tag":2288,"props":31608,"children":31611},{"cta":31609,"href":10075,"title":31610,"type":5755},"Télécharger le diagnostic gratuit →","Ressource gratuite : 10 signaux que votre équipe tech est en danger",[31612],{"type":29,"tag":30,"props":31613,"children":31614},{},[31615],{"type":34,"value":31616},"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":29,"tag":5763,"props":31618,"children":31619},{},[31620],{"type":34,"value":5767},{"title":8,"searchDepth":101,"depth":101,"links":31622},[31623,31629,31634,31640],{"id":28862,"depth":101,"text":28865,"children":31624},[31625,31626,31627,31628],{"id":28884,"depth":128,"text":28887},{"id":28936,"depth":128,"text":28939},{"id":28969,"depth":128,"text":28972},{"id":28980,"depth":128,"text":28983},{"id":29007,"depth":101,"text":29010,"children":31630},[31631,31632,31633],{"id":29018,"depth":128,"text":29021},{"id":29393,"depth":128,"text":29396},{"id":29949,"depth":128,"text":29952},{"id":30738,"depth":101,"text":30741,"children":31635},[31636,31637,31638,31639],{"id":30749,"depth":128,"text":30752},{"id":30934,"depth":128,"text":30937},{"id":31063,"depth":128,"text":31066},{"id":31417,"depth":128,"text":31420},{"id":31455,"depth":101,"text":31458},"content:fr:architecture-craft:principe-isp-software-craftsmanship-exemples-java.md","fr\u002Farchitecture-craft\u002Fprincipe-isp-software-craftsmanship-exemples-java.md","fr\u002Farchitecture-craft\u002Fprincipe-isp-software-craftsmanship-exemples-java",{"_path":19459,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":31645,"description":31646,"id":1418,"date":31647,"listed":13,"nocomments":7,"hidden":7,"categories":31648,"tags":31649,"cover":31650,"readingTime":31651,"body":31656,"_type":5777,"_id":35763,"_source":5779,"_file":35764,"_stem":35765,"_extension":5782},"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.","2024-02-06",[6],[16,8453],"covers\u002Farticles\u002Fprincipe-lsp.jpg",{"text":31652,"minutes":31653,"time":31654,"words":31655},"10 min read",9.835,590100,1967,{"type":26,"children":31657,"toc":35747},[31658,31664,31674,31685,31690,31693,31699,31704,31710,31715,31721,31769,31775,31786,31789,31798,31804,31823,31835,32253,32265,32278,32601,32635,32641,32652,33079,33085,33119,33145,33148,33154,33172,33178,33197,33214,33219,33230,33639,33651,33663,33941,33987,33993,34012,34595,34600,34625,34631,34662,34668,34680,34686,35201,35207,35541,35544,35550,35555,35561,35579,35585,35603,35606,35615,35618,35624,35637,35650,35681,35694,35707,35720,35733,35736,35743],{"type":29,"tag":51,"props":31659,"children":31661},{"id":31660},"principe-de-liskov-substitution-lsp-pour-les-développeurs-de-logiciels",[31662],{"type":34,"value":31663},"Principe de Liskov Substitution (LSP) pour les développeurs de logiciels",{"type":29,"tag":30,"props":31665,"children":31666},{},[31667,31669],{"type":34,"value":31668},"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":29,"tag":8474,"props":31670,"children":31671},{},[31672],{"type":34,"value":31673},"l'héritage a-t-il vraiment été le bon outil ?",{"type":29,"tag":30,"props":31675,"children":31676},{},[31677,31679,31683],{"type":34,"value":31678},"Le principe de substitution de Liskov (LSP), formulé par Barbara Liskov en 1987, attaque exactement ce scénario. Quatrième des cinq ",{"type":29,"tag":63,"props":31680,"children":31681},{"href":9965},[31682],{"type":34,"value":9968},{"type":34,"value":31684},", 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":29,"tag":30,"props":31686,"children":31687},{},[31688],{"type":34,"value":31689},"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":29,"tag":47,"props":31691,"children":31692},{},[],{"type":29,"tag":51,"props":31694,"children":31696},{"id":31695},"quest-ce-que-le-principe-de-substitution-de-liskov-lsp",[31697],{"type":34,"value":31698},"Qu’est-ce que le principe de substitution de Liskov (LSP) ?",{"type":29,"tag":30,"props":31700,"children":31701},{},[31702],{"type":34,"value":31703},"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":29,"tag":10576,"props":31705,"children":31707},{"id":31706},"en-termes-simples-voici-ce-que-cela-signifie",[31708],{"type":34,"value":31709},"En termes simples, voici ce que cela signifie :",{"type":29,"tag":30,"props":31711,"children":31712},{},[31713],{"type":34,"value":31714},"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":29,"tag":28127,"props":31716,"children":31718},{"id":31717},"exemple-classique-pour-mieux-comprendre",[31719],{"type":34,"value":31720},"Exemple classique pour mieux comprendre :",{"type":29,"tag":30,"props":31722,"children":31723},{},[31724,31726,31732,31734,31739,31740,31746,31748,31753,31755,31760,31762,31767],{"type":34,"value":31725},"Imaginez que vous développez une application qui manipule des formes géométriques. Vous avez une classe de base ",{"type":29,"tag":84,"props":31727,"children":31729},{"className":31728},[],[31730],{"type":34,"value":31731},"Forme",{"type":34,"value":31733},", et deux sous-classes : ",{"type":29,"tag":84,"props":31735,"children":31737},{"className":31736},[],[31738],{"type":34,"value":21585},{"type":34,"value":8982},{"type":29,"tag":84,"props":31741,"children":31743},{"className":31742},[],[31744],{"type":34,"value":31745},"Carré",{"type":34,"value":31747},". 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":29,"tag":84,"props":31749,"children":31751},{"className":31750},[],[31752],{"type":34,"value":31745},{"type":34,"value":31754}," qui redéfinit le comportement de ",{"type":29,"tag":84,"props":31756,"children":31758},{"className":31757},[],[31759],{"type":34,"value":21585},{"type":34,"value":31761},", vous risquez de casser la logique qui fonctionne parfaitement pour la classe ",{"type":29,"tag":84,"props":31763,"children":31765},{"className":31764},[],[31766],{"type":34,"value":21585},{"type":34,"value":31768},". Cela brise le LSP.",{"type":29,"tag":8542,"props":31770,"children":31772},{"id":31771},"pourquoi-ce-principe-est-il-important",[31773],{"type":34,"value":31774},"Pourquoi ce principe est-il important ?",{"type":29,"tag":30,"props":31776,"children":31777},{},[31778,31780,31784],{"type":34,"value":31779},"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":29,"tag":63,"props":31781,"children":31782},{"href":5},[31783],{"type":34,"value":5883},{"type":34,"value":31785}," 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":29,"tag":47,"props":31787,"children":31788},{},[],{"type":29,"tag":2288,"props":31790,"children":31792},{"cta":2290,"href":2291,"title":31791,"type":2293},"Vous voulez sentir quand un héritage va casser un contrat avant de l'écrire ?",[31793],{"type":29,"tag":30,"props":31794,"children":31795},{},[31796],{"type":34,"value":31797},"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":29,"tag":51,"props":31799,"children":31801},{"id":31800},"exemple-pratique-briser-le-lsp-ce-quil-ne-faut-pas-faire",[31802],{"type":34,"value":31803},"Exemple pratique - Briser le LSP : Ce qu’il ne faut pas faire",{"type":29,"tag":30,"props":31805,"children":31806},{},[31807,31809,31814,31816,31821],{"type":34,"value":31808},"Prenons l'exemple classique du ",{"type":29,"tag":84,"props":31810,"children":31812},{"className":31811},[],[31813],{"type":34,"value":21585},{"type":34,"value":31815}," et du ",{"type":29,"tag":84,"props":31817,"children":31819},{"className":31818},[],[31820],{"type":34,"value":31745},{"type":34,"value":31822}," en Java pour illustrer une violation du principe de substitution de Liskov (LSP).",{"type":29,"tag":10576,"props":31824,"children":31826},{"id":31825},"classe-rectangle",[31827,31829,31834],{"type":34,"value":31828},"Classe ",{"type":29,"tag":84,"props":31830,"children":31832},{"className":31831},[],[31833],{"type":34,"value":21585},{"type":34,"value":21063},{"type":29,"tag":77,"props":31836,"children":31838},{"className":81,"code":31837,"language":80,"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",[31839],{"type":29,"tag":84,"props":31840,"children":31841},{"__ignoreMap":8},[31842,31861,31881,31900,31907,31950,31978,32006,32013,32020,32056,32083,32090,32097,32133,32160,32167,32174,32198,32239,32246],{"type":29,"tag":88,"props":31843,"children":31844},{"class":90,"line":91},[31845,31849,31853,31857],{"type":29,"tag":88,"props":31846,"children":31847},{"style":105},[31848],{"type":34,"value":108},{"type":29,"tag":88,"props":31850,"children":31851},{"style":105},[31852],{"type":34,"value":113},{"type":29,"tag":88,"props":31854,"children":31855},{"style":116},[31856],{"type":34,"value":21642},{"type":29,"tag":88,"props":31858,"children":31859},{"style":122},[31860],{"type":34,"value":125},{"type":29,"tag":88,"props":31862,"children":31863},{"class":90,"line":101},[31864,31868,31872,31877],{"type":29,"tag":88,"props":31865,"children":31866},{"style":105},[31867],{"type":34,"value":21654},{"type":29,"tag":88,"props":31869,"children":31870},{"style":105},[31871],{"type":34,"value":8608},{"type":29,"tag":88,"props":31873,"children":31874},{"style":157},[31875],{"type":34,"value":31876}," largeur",{"type":29,"tag":88,"props":31878,"children":31879},{"style":122},[31880],{"type":34,"value":424},{"type":29,"tag":88,"props":31882,"children":31883},{"class":90,"line":128},[31884,31888,31892,31896],{"type":29,"tag":88,"props":31885,"children":31886},{"style":105},[31887],{"type":34,"value":21654},{"type":29,"tag":88,"props":31889,"children":31890},{"style":105},[31891],{"type":34,"value":8608},{"type":29,"tag":88,"props":31893,"children":31894},{"style":157},[31895],{"type":34,"value":15955},{"type":29,"tag":88,"props":31897,"children":31898},{"style":122},[31899],{"type":34,"value":424},{"type":29,"tag":88,"props":31901,"children":31902},{"class":90,"line":137},[31903],{"type":29,"tag":88,"props":31904,"children":31905},{"emptyLinePlaceholder":13},[31906],{"type":34,"value":134},{"type":29,"tag":88,"props":31908,"children":31909},{"class":90,"line":211},[31910,31914,31918,31922,31926,31930,31934,31938,31942,31946],{"type":29,"tag":88,"props":31911,"children":31912},{"style":105},[31913],{"type":34,"value":276},{"type":29,"tag":88,"props":31915,"children":31916},{"style":174},[31917],{"type":34,"value":21642},{"type":29,"tag":88,"props":31919,"children":31920},{"style":122},[31921],{"type":34,"value":181},{"type":29,"tag":88,"props":31923,"children":31924},{"style":105},[31925],{"type":34,"value":8622},{"type":29,"tag":88,"props":31927,"children":31928},{"style":298},[31929],{"type":34,"value":31876},{"type":29,"tag":88,"props":31931,"children":31932},{"style":122},[31933],{"type":34,"value":192},{"type":29,"tag":88,"props":31935,"children":31936},{"style":105},[31937],{"type":34,"value":8608},{"type":29,"tag":88,"props":31939,"children":31940},{"style":298},[31941],{"type":34,"value":15955},{"type":29,"tag":88,"props":31943,"children":31944},{"style":122},[31945],{"type":34,"value":306},{"type":29,"tag":88,"props":31947,"children":31948},{"style":122},[31949],{"type":34,"value":125},{"type":29,"tag":88,"props":31951,"children":31952},{"class":90,"line":262},[31953,31957,31961,31966,31970,31974],{"type":29,"tag":88,"props":31954,"children":31955},{"style":873},[31956],{"type":34,"value":876},{"type":29,"tag":88,"props":31958,"children":31959},{"style":122},[31960],{"type":34,"value":338},{"type":29,"tag":88,"props":31962,"children":31963},{"style":157},[31964],{"type":34,"value":31965},"largeur ",{"type":29,"tag":88,"props":31967,"children":31968},{"style":163},[31969],{"type":34,"value":166},{"type":29,"tag":88,"props":31971,"children":31972},{"style":157},[31973],{"type":34,"value":31876},{"type":29,"tag":88,"props":31975,"children":31976},{"style":122},[31977],{"type":34,"value":424},{"type":29,"tag":88,"props":31979,"children":31980},{"class":90,"line":270},[31981,31985,31989,31994,31998,32002],{"type":29,"tag":88,"props":31982,"children":31983},{"style":873},[31984],{"type":34,"value":876},{"type":29,"tag":88,"props":31986,"children":31987},{"style":122},[31988],{"type":34,"value":338},{"type":29,"tag":88,"props":31990,"children":31991},{"style":157},[31992],{"type":34,"value":31993},"hauteur ",{"type":29,"tag":88,"props":31995,"children":31996},{"style":163},[31997],{"type":34,"value":166},{"type":29,"tag":88,"props":31999,"children":32000},{"style":157},[32001],{"type":34,"value":15955},{"type":29,"tag":88,"props":32003,"children":32004},{"style":122},[32005],{"type":34,"value":424},{"type":29,"tag":88,"props":32007,"children":32008},{"class":90,"line":313},[32009],{"type":29,"tag":88,"props":32010,"children":32011},{"style":122},[32012],{"type":34,"value":433},{"type":29,"tag":88,"props":32014,"children":32015},{"class":90,"line":360},[32016],{"type":29,"tag":88,"props":32017,"children":32018},{"emptyLinePlaceholder":13},[32019],{"type":34,"value":134},{"type":29,"tag":88,"props":32021,"children":32022},{"class":90,"line":409},[32023,32027,32031,32036,32040,32044,32048,32052],{"type":29,"tag":88,"props":32024,"children":32025},{"style":105},[32026],{"type":34,"value":276},{"type":29,"tag":88,"props":32028,"children":32029},{"style":105},[32030],{"type":34,"value":1303},{"type":29,"tag":88,"props":32032,"children":32033},{"style":174},[32034],{"type":34,"value":32035}," setLargeur",{"type":29,"tag":88,"props":32037,"children":32038},{"style":122},[32039],{"type":34,"value":181},{"type":29,"tag":88,"props":32041,"children":32042},{"style":105},[32043],{"type":34,"value":8622},{"type":29,"tag":88,"props":32045,"children":32046},{"style":298},[32047],{"type":34,"value":31876},{"type":29,"tag":88,"props":32049,"children":32050},{"style":122},[32051],{"type":34,"value":306},{"type":29,"tag":88,"props":32053,"children":32054},{"style":122},[32055],{"type":34,"value":125},{"type":29,"tag":88,"props":32057,"children":32058},{"class":90,"line":427},[32059,32063,32067,32071,32075,32079],{"type":29,"tag":88,"props":32060,"children":32061},{"style":873},[32062],{"type":34,"value":876},{"type":29,"tag":88,"props":32064,"children":32065},{"style":122},[32066],{"type":34,"value":338},{"type":29,"tag":88,"props":32068,"children":32069},{"style":157},[32070],{"type":34,"value":31965},{"type":29,"tag":88,"props":32072,"children":32073},{"style":163},[32074],{"type":34,"value":166},{"type":29,"tag":88,"props":32076,"children":32077},{"style":157},[32078],{"type":34,"value":31876},{"type":29,"tag":88,"props":32080,"children":32081},{"style":122},[32082],{"type":34,"value":424},{"type":29,"tag":88,"props":32084,"children":32085},{"class":90,"line":436},[32086],{"type":29,"tag":88,"props":32087,"children":32088},{"style":122},[32089],{"type":34,"value":433},{"type":29,"tag":88,"props":32091,"children":32092},{"class":90,"line":767},[32093],{"type":29,"tag":88,"props":32094,"children":32095},{"emptyLinePlaceholder":13},[32096],{"type":34,"value":134},{"type":29,"tag":88,"props":32098,"children":32099},{"class":90,"line":792},[32100,32104,32108,32113,32117,32121,32125,32129],{"type":29,"tag":88,"props":32101,"children":32102},{"style":105},[32103],{"type":34,"value":276},{"type":29,"tag":88,"props":32105,"children":32106},{"style":105},[32107],{"type":34,"value":1303},{"type":29,"tag":88,"props":32109,"children":32110},{"style":174},[32111],{"type":34,"value":32112}," setHauteur",{"type":29,"tag":88,"props":32114,"children":32115},{"style":122},[32116],{"type":34,"value":181},{"type":29,"tag":88,"props":32118,"children":32119},{"style":105},[32120],{"type":34,"value":8622},{"type":29,"tag":88,"props":32122,"children":32123},{"style":298},[32124],{"type":34,"value":15955},{"type":29,"tag":88,"props":32126,"children":32127},{"style":122},[32128],{"type":34,"value":306},{"type":29,"tag":88,"props":32130,"children":32131},{"style":122},[32132],{"type":34,"value":125},{"type":29,"tag":88,"props":32134,"children":32135},{"class":90,"line":817},[32136,32140,32144,32148,32152,32156],{"type":29,"tag":88,"props":32137,"children":32138},{"style":873},[32139],{"type":34,"value":876},{"type":29,"tag":88,"props":32141,"children":32142},{"style":122},[32143],{"type":34,"value":338},{"type":29,"tag":88,"props":32145,"children":32146},{"style":157},[32147],{"type":34,"value":31993},{"type":29,"tag":88,"props":32149,"children":32150},{"style":163},[32151],{"type":34,"value":166},{"type":29,"tag":88,"props":32153,"children":32154},{"style":157},[32155],{"type":34,"value":15955},{"type":29,"tag":88,"props":32157,"children":32158},{"style":122},[32159],{"type":34,"value":424},{"type":29,"tag":88,"props":32161,"children":32162},{"class":90,"line":825},[32163],{"type":29,"tag":88,"props":32164,"children":32165},{"style":122},[32166],{"type":34,"value":433},{"type":29,"tag":88,"props":32168,"children":32169},{"class":90,"line":869},[32170],{"type":29,"tag":88,"props":32171,"children":32172},{"emptyLinePlaceholder":13},[32173],{"type":34,"value":134},{"type":29,"tag":88,"props":32175,"children":32176},{"class":90,"line":900},[32177,32181,32185,32190,32194],{"type":29,"tag":88,"props":32178,"children":32179},{"style":105},[32180],{"type":34,"value":276},{"type":29,"tag":88,"props":32182,"children":32183},{"style":105},[32184],{"type":34,"value":8608},{"type":29,"tag":88,"props":32186,"children":32187},{"style":174},[32188],{"type":34,"value":32189}," calculerAire",{"type":29,"tag":88,"props":32191,"children":32192},{"style":122},[32193],{"type":34,"value":1470},{"type":29,"tag":88,"props":32195,"children":32196},{"style":122},[32197],{"type":34,"value":125},{"type":29,"tag":88,"props":32199,"children":32200},{"class":90,"line":929},[32201,32205,32210,32214,32218,32222,32226,32230,32235],{"type":29,"tag":88,"props":32202,"children":32203},{"style":105},[32204],{"type":34,"value":415},{"type":29,"tag":88,"props":32206,"children":32207},{"style":873},[32208],{"type":34,"value":32209}," this",{"type":29,"tag":88,"props":32211,"children":32212},{"style":122},[32213],{"type":34,"value":338},{"type":29,"tag":88,"props":32215,"children":32216},{"style":157},[32217],{"type":34,"value":31965},{"type":29,"tag":88,"props":32219,"children":32220},{"style":163},[32221],{"type":34,"value":8709},{"type":29,"tag":88,"props":32223,"children":32224},{"style":873},[32225],{"type":34,"value":32209},{"type":29,"tag":88,"props":32227,"children":32228},{"style":122},[32229],{"type":34,"value":338},{"type":29,"tag":88,"props":32231,"children":32232},{"style":157},[32233],{"type":34,"value":32234},"hauteur",{"type":29,"tag":88,"props":32236,"children":32237},{"style":122},[32238],{"type":34,"value":424},{"type":29,"tag":88,"props":32240,"children":32241},{"class":90,"line":937},[32242],{"type":29,"tag":88,"props":32243,"children":32244},{"style":122},[32245],{"type":34,"value":433},{"type":29,"tag":88,"props":32247,"children":32248},{"class":90,"line":945},[32249],{"type":29,"tag":88,"props":32250,"children":32251},{"style":122},[32252],{"type":34,"value":442},{"type":29,"tag":30,"props":32254,"children":32255},{},[32256,32258,32263],{"type":34,"value":32257},"Ici, la classe ",{"type":29,"tag":84,"props":32259,"children":32261},{"className":32260},[],[32262],{"type":34,"value":21585},{"type":34,"value":32264}," fonctionne normalement. Elle a des méthodes pour définir la largeur et la hauteur, et pour calculer l'aire.",{"type":29,"tag":10576,"props":32266,"children":32268},{"id":32267},"sous-classe-carre",[32269,32271,32277],{"type":34,"value":32270},"Sous-classe ",{"type":29,"tag":84,"props":32272,"children":32274},{"className":32273},[],[32275],{"type":34,"value":32276},"Carre",{"type":34,"value":21063},{"type":29,"tag":77,"props":32279,"children":32281},{"className":81,"code":32280,"language":80,"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",[32282],{"type":29,"tag":84,"props":32283,"children":32284},{"__ignoreMap":8},[32285,32313,32320,32352,32381,32388,32395,32406,32441,32484,32491,32498,32509,32544,32587,32594],{"type":29,"tag":88,"props":32286,"children":32287},{"class":90,"line":91},[32288,32292,32296,32301,32305,32309],{"type":29,"tag":88,"props":32289,"children":32290},{"style":105},[32291],{"type":34,"value":108},{"type":29,"tag":88,"props":32293,"children":32294},{"style":105},[32295],{"type":34,"value":113},{"type":29,"tag":88,"props":32297,"children":32298},{"style":116},[32299],{"type":34,"value":32300}," Carre",{"type":29,"tag":88,"props":32302,"children":32303},{"style":105},[32304],{"type":34,"value":21954},{"type":29,"tag":88,"props":32306,"children":32307},{"style":116},[32308],{"type":34,"value":21642},{"type":29,"tag":88,"props":32310,"children":32311},{"style":122},[32312],{"type":34,"value":125},{"type":29,"tag":88,"props":32314,"children":32315},{"class":90,"line":101},[32316],{"type":29,"tag":88,"props":32317,"children":32318},{"emptyLinePlaceholder":13},[32319],{"type":34,"value":134},{"type":29,"tag":88,"props":32321,"children":32322},{"class":90,"line":128},[32323,32327,32331,32335,32339,32344,32348],{"type":29,"tag":88,"props":32324,"children":32325},{"style":105},[32326],{"type":34,"value":276},{"type":29,"tag":88,"props":32328,"children":32329},{"style":174},[32330],{"type":34,"value":32300},{"type":29,"tag":88,"props":32332,"children":32333},{"style":122},[32334],{"type":34,"value":181},{"type":29,"tag":88,"props":32336,"children":32337},{"style":105},[32338],{"type":34,"value":8622},{"type":29,"tag":88,"props":32340,"children":32341},{"style":298},[32342],{"type":34,"value":32343}," taille",{"type":29,"tag":88,"props":32345,"children":32346},{"style":122},[32347],{"type":34,"value":306},{"type":29,"tag":88,"props":32349,"children":32350},{"style":122},[32351],{"type":34,"value":125},{"type":29,"tag":88,"props":32353,"children":32354},{"class":90,"line":137},[32355,32360,32364,32369,32373,32377],{"type":29,"tag":88,"props":32356,"children":32357},{"style":6490},[32358],{"type":34,"value":32359},"        super",{"type":29,"tag":88,"props":32361,"children":32362},{"style":122},[32363],{"type":34,"value":181},{"type":29,"tag":88,"props":32365,"children":32366},{"style":157},[32367],{"type":34,"value":32368},"taille",{"type":29,"tag":88,"props":32370,"children":32371},{"style":122},[32372],{"type":34,"value":192},{"type":29,"tag":88,"props":32374,"children":32375},{"style":157},[32376],{"type":34,"value":32343},{"type":29,"tag":88,"props":32378,"children":32379},{"style":122},[32380],{"type":34,"value":357},{"type":29,"tag":88,"props":32382,"children":32383},{"class":90,"line":211},[32384],{"type":29,"tag":88,"props":32385,"children":32386},{"style":122},[32387],{"type":34,"value":433},{"type":29,"tag":88,"props":32389,"children":32390},{"class":90,"line":262},[32391],{"type":29,"tag":88,"props":32392,"children":32393},{"emptyLinePlaceholder":13},[32394],{"type":34,"value":134},{"type":29,"tag":88,"props":32396,"children":32397},{"class":90,"line":270},[32398,32402],{"type":29,"tag":88,"props":32399,"children":32400},{"style":1974},[32401],{"type":34,"value":3302},{"type":29,"tag":88,"props":32403,"children":32404},{"style":1980},[32405],{"type":34,"value":3307},{"type":29,"tag":88,"props":32407,"children":32408},{"class":90,"line":313},[32409,32413,32417,32421,32425,32429,32433,32437],{"type":29,"tag":88,"props":32410,"children":32411},{"style":105},[32412],{"type":34,"value":276},{"type":29,"tag":88,"props":32414,"children":32415},{"style":105},[32416],{"type":34,"value":1303},{"type":29,"tag":88,"props":32418,"children":32419},{"style":174},[32420],{"type":34,"value":32035},{"type":29,"tag":88,"props":32422,"children":32423},{"style":122},[32424],{"type":34,"value":181},{"type":29,"tag":88,"props":32426,"children":32427},{"style":105},[32428],{"type":34,"value":8622},{"type":29,"tag":88,"props":32430,"children":32431},{"style":298},[32432],{"type":34,"value":32343},{"type":29,"tag":88,"props":32434,"children":32435},{"style":122},[32436],{"type":34,"value":306},{"type":29,"tag":88,"props":32438,"children":32439},{"style":122},[32440],{"type":34,"value":125},{"type":29,"tag":88,"props":32442,"children":32443},{"class":90,"line":360},[32444,32448,32452,32456,32460,32464,32468,32472,32476,32480],{"type":29,"tag":88,"props":32445,"children":32446},{"style":873},[32447],{"type":34,"value":876},{"type":29,"tag":88,"props":32449,"children":32450},{"style":122},[32451],{"type":34,"value":338},{"type":29,"tag":88,"props":32453,"children":32454},{"style":157},[32455],{"type":34,"value":31965},{"type":29,"tag":88,"props":32457,"children":32458},{"style":163},[32459],{"type":34,"value":166},{"type":29,"tag":88,"props":32461,"children":32462},{"style":873},[32463],{"type":34,"value":32209},{"type":29,"tag":88,"props":32465,"children":32466},{"style":122},[32467],{"type":34,"value":338},{"type":29,"tag":88,"props":32469,"children":32470},{"style":157},[32471],{"type":34,"value":31993},{"type":29,"tag":88,"props":32473,"children":32474},{"style":163},[32475],{"type":34,"value":166},{"type":29,"tag":88,"props":32477,"children":32478},{"style":157},[32479],{"type":34,"value":32343},{"type":29,"tag":88,"props":32481,"children":32482},{"style":122},[32483],{"type":34,"value":424},{"type":29,"tag":88,"props":32485,"children":32486},{"class":90,"line":409},[32487],{"type":29,"tag":88,"props":32488,"children":32489},{"style":122},[32490],{"type":34,"value":433},{"type":29,"tag":88,"props":32492,"children":32493},{"class":90,"line":427},[32494],{"type":29,"tag":88,"props":32495,"children":32496},{"emptyLinePlaceholder":13},[32497],{"type":34,"value":134},{"type":29,"tag":88,"props":32499,"children":32500},{"class":90,"line":436},[32501,32505],{"type":29,"tag":88,"props":32502,"children":32503},{"style":1974},[32504],{"type":34,"value":3302},{"type":29,"tag":88,"props":32506,"children":32507},{"style":1980},[32508],{"type":34,"value":3307},{"type":29,"tag":88,"props":32510,"children":32511},{"class":90,"line":767},[32512,32516,32520,32524,32528,32532,32536,32540],{"type":29,"tag":88,"props":32513,"children":32514},{"style":105},[32515],{"type":34,"value":276},{"type":29,"tag":88,"props":32517,"children":32518},{"style":105},[32519],{"type":34,"value":1303},{"type":29,"tag":88,"props":32521,"children":32522},{"style":174},[32523],{"type":34,"value":32112},{"type":29,"tag":88,"props":32525,"children":32526},{"style":122},[32527],{"type":34,"value":181},{"type":29,"tag":88,"props":32529,"children":32530},{"style":105},[32531],{"type":34,"value":8622},{"type":29,"tag":88,"props":32533,"children":32534},{"style":298},[32535],{"type":34,"value":32343},{"type":29,"tag":88,"props":32537,"children":32538},{"style":122},[32539],{"type":34,"value":306},{"type":29,"tag":88,"props":32541,"children":32542},{"style":122},[32543],{"type":34,"value":125},{"type":29,"tag":88,"props":32545,"children":32546},{"class":90,"line":792},[32547,32551,32555,32559,32563,32567,32571,32575,32579,32583],{"type":29,"tag":88,"props":32548,"children":32549},{"style":873},[32550],{"type":34,"value":876},{"type":29,"tag":88,"props":32552,"children":32553},{"style":122},[32554],{"type":34,"value":338},{"type":29,"tag":88,"props":32556,"children":32557},{"style":157},[32558],{"type":34,"value":31965},{"type":29,"tag":88,"props":32560,"children":32561},{"style":163},[32562],{"type":34,"value":166},{"type":29,"tag":88,"props":32564,"children":32565},{"style":873},[32566],{"type":34,"value":32209},{"type":29,"tag":88,"props":32568,"children":32569},{"style":122},[32570],{"type":34,"value":338},{"type":29,"tag":88,"props":32572,"children":32573},{"style":157},[32574],{"type":34,"value":31993},{"type":29,"tag":88,"props":32576,"children":32577},{"style":163},[32578],{"type":34,"value":166},{"type":29,"tag":88,"props":32580,"children":32581},{"style":157},[32582],{"type":34,"value":32343},{"type":29,"tag":88,"props":32584,"children":32585},{"style":122},[32586],{"type":34,"value":424},{"type":29,"tag":88,"props":32588,"children":32589},{"class":90,"line":817},[32590],{"type":29,"tag":88,"props":32591,"children":32592},{"style":122},[32593],{"type":34,"value":433},{"type":29,"tag":88,"props":32595,"children":32596},{"class":90,"line":825},[32597],{"type":29,"tag":88,"props":32598,"children":32599},{"style":122},[32600],{"type":34,"value":442},{"type":29,"tag":30,"props":32602,"children":32603},{},[32604,32606,32611,32613,32618,32620,32626,32627,32633],{"type":34,"value":32605},"Dans cet exemple, nous avons une classe ",{"type":29,"tag":84,"props":32607,"children":32609},{"className":32608},[],[32610],{"type":34,"value":32276},{"type":34,"value":32612}," qui hérite de ",{"type":29,"tag":84,"props":32614,"children":32616},{"className":32615},[],[32617],{"type":34,"value":21585},{"type":34,"value":32619},". Un carré étant un cas particulier de rectangle où tous les côtés sont égaux, nous avons redéfini les méthodes ",{"type":29,"tag":84,"props":32621,"children":32623},{"className":32622},[],[32624],{"type":34,"value":32625},"setLargeur",{"type":34,"value":8982},{"type":29,"tag":84,"props":32628,"children":32630},{"className":32629},[],[32631],{"type":34,"value":32632},"setHauteur",{"type":34,"value":32634}," pour toujours appliquer la même valeur à la largeur et à la hauteur.",{"type":29,"tag":10576,"props":32636,"children":32638},{"id":32637},"problème-avec-le-lsp",[32639],{"type":34,"value":32640},"Problème avec le LSP",{"type":29,"tag":30,"props":32642,"children":32643},{},[32644,32646,32651],{"type":34,"value":32645},"Maintenant, utilisons ces classes dans un programme. Supposons que nous ayons une méthode qui teste les objets ",{"type":29,"tag":84,"props":32647,"children":32649},{"className":32648},[],[32650],{"type":34,"value":21585},{"type":34,"value":21063},{"type":29,"tag":77,"props":32653,"children":32655},{"className":81,"code":32654,"language":80,"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        \u002F\u002F Test avec un Rectangle\n        Rectangle rect = new Rectangle(2, 3);\n        testerRectangle(rect);\n\n        \u002F\u002F Test avec un Carre\n        Carre carre = new Carre(5);\n        testerRectangle(carre);\n    }\n}\n",[32656],{"type":29,"tag":84,"props":32657,"children":32658},{"__ignoreMap":8},[32659,32678,32685,32726,32755,32783,32817,32862,32869,32876,32919,32927,32972,32993,33000,33008,33045,33065,33072],{"type":29,"tag":88,"props":32660,"children":32661},{"class":90,"line":91},[32662,32666,32670,32674],{"type":29,"tag":88,"props":32663,"children":32664},{"style":105},[32665],{"type":34,"value":108},{"type":29,"tag":88,"props":32667,"children":32668},{"style":105},[32669],{"type":34,"value":113},{"type":29,"tag":88,"props":32671,"children":32672},{"style":116},[32673],{"type":34,"value":21224},{"type":29,"tag":88,"props":32675,"children":32676},{"style":122},[32677],{"type":34,"value":125},{"type":29,"tag":88,"props":32679,"children":32680},{"class":90,"line":101},[32681],{"type":29,"tag":88,"props":32682,"children":32683},{"emptyLinePlaceholder":13},[32684],{"type":34,"value":134},{"type":29,"tag":88,"props":32686,"children":32687},{"class":90,"line":128},[32688,32692,32696,32700,32705,32709,32713,32718,32722],{"type":29,"tag":88,"props":32689,"children":32690},{"style":105},[32691],{"type":34,"value":276},{"type":29,"tag":88,"props":32693,"children":32694},{"style":105},[32695],{"type":34,"value":12248},{"type":29,"tag":88,"props":32697,"children":32698},{"style":105},[32699],{"type":34,"value":1303},{"type":29,"tag":88,"props":32701,"children":32702},{"style":174},[32703],{"type":34,"value":32704}," testerRectangle",{"type":29,"tag":88,"props":32706,"children":32707},{"style":122},[32708],{"type":34,"value":181},{"type":29,"tag":88,"props":32710,"children":32711},{"style":151},[32712],{"type":34,"value":21585},{"type":29,"tag":88,"props":32714,"children":32715},{"style":298},[32716],{"type":34,"value":32717}," rect",{"type":29,"tag":88,"props":32719,"children":32720},{"style":122},[32721],{"type":34,"value":306},{"type":29,"tag":88,"props":32723,"children":32724},{"style":122},[32725],{"type":34,"value":125},{"type":29,"tag":88,"props":32727,"children":32728},{"class":90,"line":137},[32729,32734,32738,32742,32746,32751],{"type":29,"tag":88,"props":32730,"children":32731},{"style":157},[32732],{"type":34,"value":32733},"        rect",{"type":29,"tag":88,"props":32735,"children":32736},{"style":122},[32737],{"type":34,"value":338},{"type":29,"tag":88,"props":32739,"children":32740},{"style":174},[32741],{"type":34,"value":32625},{"type":29,"tag":88,"props":32743,"children":32744},{"style":122},[32745],{"type":34,"value":181},{"type":29,"tag":88,"props":32747,"children":32748},{"style":195},[32749],{"type":34,"value":32750},"5",{"type":29,"tag":88,"props":32752,"children":32753},{"style":122},[32754],{"type":34,"value":357},{"type":29,"tag":88,"props":32756,"children":32757},{"class":90,"line":211},[32758,32762,32766,32770,32774,32779],{"type":29,"tag":88,"props":32759,"children":32760},{"style":157},[32761],{"type":34,"value":32733},{"type":29,"tag":88,"props":32763,"children":32764},{"style":122},[32765],{"type":34,"value":338},{"type":29,"tag":88,"props":32767,"children":32768},{"style":174},[32769],{"type":34,"value":32632},{"type":29,"tag":88,"props":32771,"children":32772},{"style":122},[32773],{"type":34,"value":181},{"type":29,"tag":88,"props":32775,"children":32776},{"style":195},[32777],{"type":34,"value":32778},"10",{"type":29,"tag":88,"props":32780,"children":32781},{"style":122},[32782],{"type":34,"value":357},{"type":29,"tag":88,"props":32784,"children":32785},{"class":90,"line":262},[32786,32791,32796,32800,32804,32808,32813],{"type":29,"tag":88,"props":32787,"children":32788},{"style":105},[32789],{"type":34,"value":32790},"        int",{"type":29,"tag":88,"props":32792,"children":32793},{"style":157},[32794],{"type":34,"value":32795}," aire ",{"type":29,"tag":88,"props":32797,"children":32798},{"style":163},[32799],{"type":34,"value":166},{"type":29,"tag":88,"props":32801,"children":32802},{"style":157},[32803],{"type":34,"value":32717},{"type":29,"tag":88,"props":32805,"children":32806},{"style":122},[32807],{"type":34,"value":338},{"type":29,"tag":88,"props":32809,"children":32810},{"style":174},[32811],{"type":34,"value":32812},"calculerAire",{"type":29,"tag":88,"props":32814,"children":32815},{"style":122},[32816],{"type":34,"value":1810},{"type":29,"tag":88,"props":32818,"children":32819},{"class":90,"line":270},[32820,32824,32828,32832,32836,32840,32844,32849,32853,32858],{"type":29,"tag":88,"props":32821,"children":32822},{"style":157},[32823],{"type":34,"value":19726},{"type":29,"tag":88,"props":32825,"children":32826},{"style":122},[32827],{"type":34,"value":338},{"type":29,"tag":88,"props":32829,"children":32830},{"style":157},[32831],{"type":34,"value":18091},{"type":29,"tag":88,"props":32833,"children":32834},{"style":122},[32835],{"type":34,"value":338},{"type":29,"tag":88,"props":32837,"children":32838},{"style":174},[32839],{"type":34,"value":18100},{"type":29,"tag":88,"props":32841,"children":32842},{"style":122},[32843],{"type":34,"value":181},{"type":29,"tag":88,"props":32845,"children":32846},{"style":184},[32847],{"type":34,"value":32848},"\"Aire attendue : 50, Aire calculée : \"",{"type":29,"tag":88,"props":32850,"children":32851},{"style":163},[32852],{"type":34,"value":5485},{"type":29,"tag":88,"props":32854,"children":32855},{"style":157},[32856],{"type":34,"value":32857}," aire",{"type":29,"tag":88,"props":32859,"children":32860},{"style":122},[32861],{"type":34,"value":357},{"type":29,"tag":88,"props":32863,"children":32864},{"class":90,"line":313},[32865],{"type":29,"tag":88,"props":32866,"children":32867},{"style":122},[32868],{"type":34,"value":433},{"type":29,"tag":88,"props":32870,"children":32871},{"class":90,"line":360},[32872],{"type":29,"tag":88,"props":32873,"children":32874},{"emptyLinePlaceholder":13},[32875],{"type":34,"value":134},{"type":29,"tag":88,"props":32877,"children":32878},{"class":90,"line":409},[32879,32883,32887,32891,32895,32899,32903,32907,32911,32915],{"type":29,"tag":88,"props":32880,"children":32881},{"style":105},[32882],{"type":34,"value":276},{"type":29,"tag":88,"props":32884,"children":32885},{"style":105},[32886],{"type":34,"value":12248},{"type":29,"tag":88,"props":32888,"children":32889},{"style":105},[32890],{"type":34,"value":1303},{"type":29,"tag":88,"props":32892,"children":32893},{"style":174},[32894],{"type":34,"value":21248},{"type":29,"tag":88,"props":32896,"children":32897},{"style":122},[32898],{"type":34,"value":181},{"type":29,"tag":88,"props":32900,"children":32901},{"style":105},[32902],{"type":34,"value":695},{"type":29,"tag":88,"props":32904,"children":32905},{"style":122},[32906],{"type":34,"value":21261},{"type":29,"tag":88,"props":32908,"children":32909},{"style":298},[32910],{"type":34,"value":21266},{"type":29,"tag":88,"props":32912,"children":32913},{"style":122},[32914],{"type":34,"value":306},{"type":29,"tag":88,"props":32916,"children":32917},{"style":122},[32918],{"type":34,"value":125},{"type":29,"tag":88,"props":32920,"children":32921},{"class":90,"line":427},[32922],{"type":29,"tag":88,"props":32923,"children":32924},{"style":95},[32925],{"type":34,"value":32926},"        \u002F\u002F Test avec un Rectangle\n",{"type":29,"tag":88,"props":32928,"children":32929},{"class":90,"line":436},[32930,32935,32940,32944,32948,32952,32956,32960,32964,32968],{"type":29,"tag":88,"props":32931,"children":32932},{"style":151},[32933],{"type":34,"value":32934},"        Rectangle",{"type":29,"tag":88,"props":32936,"children":32937},{"style":157},[32938],{"type":34,"value":32939}," rect ",{"type":29,"tag":88,"props":32941,"children":32942},{"style":163},[32943],{"type":34,"value":166},{"type":29,"tag":88,"props":32945,"children":32946},{"style":105},[32947],{"type":34,"value":171},{"type":29,"tag":88,"props":32949,"children":32950},{"style":174},[32951],{"type":34,"value":21642},{"type":29,"tag":88,"props":32953,"children":32954},{"style":122},[32955],{"type":34,"value":181},{"type":29,"tag":88,"props":32957,"children":32958},{"style":195},[32959],{"type":34,"value":17459},{"type":29,"tag":88,"props":32961,"children":32962},{"style":122},[32963],{"type":34,"value":192},{"type":29,"tag":88,"props":32965,"children":32966},{"style":195},[32967],{"type":34,"value":15788},{"type":29,"tag":88,"props":32969,"children":32970},{"style":122},[32971],{"type":34,"value":357},{"type":29,"tag":88,"props":32973,"children":32974},{"class":90,"line":767},[32975,32980,32984,32989],{"type":29,"tag":88,"props":32976,"children":32977},{"style":174},[32978],{"type":34,"value":32979},"        testerRectangle",{"type":29,"tag":88,"props":32981,"children":32982},{"style":122},[32983],{"type":34,"value":181},{"type":29,"tag":88,"props":32985,"children":32986},{"style":157},[32987],{"type":34,"value":32988},"rect",{"type":29,"tag":88,"props":32990,"children":32991},{"style":122},[32992],{"type":34,"value":357},{"type":29,"tag":88,"props":32994,"children":32995},{"class":90,"line":792},[32996],{"type":29,"tag":88,"props":32997,"children":32998},{"emptyLinePlaceholder":13},[32999],{"type":34,"value":134},{"type":29,"tag":88,"props":33001,"children":33002},{"class":90,"line":817},[33003],{"type":29,"tag":88,"props":33004,"children":33005},{"style":95},[33006],{"type":34,"value":33007},"        \u002F\u002F Test avec un Carre\n",{"type":29,"tag":88,"props":33009,"children":33010},{"class":90,"line":825},[33011,33016,33021,33025,33029,33033,33037,33041],{"type":29,"tag":88,"props":33012,"children":33013},{"style":151},[33014],{"type":34,"value":33015},"        Carre",{"type":29,"tag":88,"props":33017,"children":33018},{"style":157},[33019],{"type":34,"value":33020}," carre ",{"type":29,"tag":88,"props":33022,"children":33023},{"style":163},[33024],{"type":34,"value":166},{"type":29,"tag":88,"props":33026,"children":33027},{"style":105},[33028],{"type":34,"value":171},{"type":29,"tag":88,"props":33030,"children":33031},{"style":174},[33032],{"type":34,"value":32300},{"type":29,"tag":88,"props":33034,"children":33035},{"style":122},[33036],{"type":34,"value":181},{"type":29,"tag":88,"props":33038,"children":33039},{"style":195},[33040],{"type":34,"value":32750},{"type":29,"tag":88,"props":33042,"children":33043},{"style":122},[33044],{"type":34,"value":357},{"type":29,"tag":88,"props":33046,"children":33047},{"class":90,"line":869},[33048,33052,33056,33061],{"type":29,"tag":88,"props":33049,"children":33050},{"style":174},[33051],{"type":34,"value":32979},{"type":29,"tag":88,"props":33053,"children":33054},{"style":122},[33055],{"type":34,"value":181},{"type":29,"tag":88,"props":33057,"children":33058},{"style":157},[33059],{"type":34,"value":33060},"carre",{"type":29,"tag":88,"props":33062,"children":33063},{"style":122},[33064],{"type":34,"value":357},{"type":29,"tag":88,"props":33066,"children":33067},{"class":90,"line":900},[33068],{"type":29,"tag":88,"props":33069,"children":33070},{"style":122},[33071],{"type":34,"value":433},{"type":29,"tag":88,"props":33073,"children":33074},{"class":90,"line":929},[33075],{"type":29,"tag":88,"props":33076,"children":33077},{"style":122},[33078],{"type":34,"value":442},{"type":29,"tag":10576,"props":33080,"children":33082},{"id":33081},"résultat",[33083],{"type":34,"value":33084},"Résultat :",{"type":29,"tag":453,"props":33086,"children":33087},{},[33088,33100],{"type":29,"tag":457,"props":33089,"children":33090},{},[33091,33093,33098],{"type":34,"value":33092},"Avec l'objet ",{"type":29,"tag":84,"props":33094,"children":33096},{"className":33095},[],[33097],{"type":34,"value":21585},{"type":34,"value":33099},", tout fonctionne comme prévu. L'aire calculée sera de 50 (5 * 10).",{"type":29,"tag":457,"props":33101,"children":33102},{},[33103,33104,33109,33111,33117],{"type":34,"value":33092},{"type":29,"tag":84,"props":33105,"children":33107},{"className":33106},[],[33108],{"type":34,"value":32276},{"type":34,"value":33110},", cependant, le calcul ne donnera pas le résultat attendu. En appelant ",{"type":29,"tag":84,"props":33112,"children":33114},{"className":33113},[],[33115],{"type":34,"value":33116},"setHauteur(10)",{"type":34,"value":33118},", nous changeons aussi la largeur à 10, et l'aire calculée sera 100 au lieu de 50.",{"type":29,"tag":30,"props":33120,"children":33121},{},[33122,33124,33129,33131,33136,33138,33143],{"type":34,"value":33123},"Ce comportement brise le LSP, car la classe ",{"type":29,"tag":84,"props":33125,"children":33127},{"className":33126},[],[33128],{"type":34,"value":32276},{"type":34,"value":33130}," ne respecte pas les attentes fixées par ",{"type":29,"tag":84,"props":33132,"children":33134},{"className":33133},[],[33135],{"type":34,"value":21585},{"type":34,"value":33137},". Cela peut causer des bugs ou des comportements inattendus dans les programmes qui s’attendent à ce qu’un ",{"type":29,"tag":84,"props":33139,"children":33141},{"className":33140},[],[33142],{"type":34,"value":21585},{"type":34,"value":33144}," fonctionne d’une certaine manière.",{"type":29,"tag":47,"props":33146,"children":33147},{},[],{"type":29,"tag":51,"props":33149,"children":33151},{"id":33150},"exemple-correct-respecter-le-lsp-ce-quil-faut-faire",[33152],{"type":34,"value":33153},"Exemple correct - Respecter le LSP : Ce qu’il faut faire",{"type":29,"tag":30,"props":33155,"children":33156},{},[33157,33159,33164,33165,33170],{"type":34,"value":33158},"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":29,"tag":84,"props":33160,"children":33162},{"className":33161},[],[33163],{"type":34,"value":21585},{"type":34,"value":31815},{"type":29,"tag":84,"props":33166,"children":33168},{"className":33167},[],[33169],{"type":34,"value":32276},{"type":34,"value":33171},", 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":29,"tag":10576,"props":33173,"children":33175},{"id":33174},"solution-séparer-les-concepts",[33176],{"type":34,"value":33177},"Solution : Séparer les concepts",{"type":29,"tag":30,"props":33179,"children":33180},{},[33181,33183,33188,33190,33195],{"type":34,"value":33182},"Une solution consiste à ne pas faire de ",{"type":29,"tag":84,"props":33184,"children":33186},{"className":33185},[],[33187],{"type":34,"value":32276},{"type":34,"value":33189}," une sous-classe de ",{"type":29,"tag":84,"props":33191,"children":33193},{"className":33192},[],[33194],{"type":34,"value":21585},{"type":34,"value":33196},". 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":29,"tag":10576,"props":33198,"children":33200},{"id":33199},"nouvelle-conception-classes-indépendantes-rectangle-et-carre",[33201,33203,33208,33209],{"type":34,"value":33202},"Nouvelle conception : Classes indépendantes ",{"type":29,"tag":84,"props":33204,"children":33206},{"className":33205},[],[33207],{"type":34,"value":21585},{"type":34,"value":8982},{"type":29,"tag":84,"props":33210,"children":33212},{"className":33211},[],[33213],{"type":34,"value":32276},{"type":29,"tag":30,"props":33215,"children":33216},{},[33217],{"type":34,"value":33218},"Voici comment nous pourrions concevoir cela correctement :",{"type":29,"tag":10576,"props":33220,"children":33222},{"id":33221},"classe-rectangle-1",[33223,33224,33229],{"type":34,"value":31828},{"type":29,"tag":84,"props":33225,"children":33227},{"className":33226},[],[33228],{"type":34,"value":21585},{"type":34,"value":21063},{"type":29,"tag":77,"props":33231,"children":33232},{"className":81,"code":31837,"language":80,"meta":8,"style":8},[33233],{"type":29,"tag":84,"props":33234,"children":33235},{"__ignoreMap":8},[33236,33255,33274,33293,33300,33343,33370,33397,33404,33411,33446,33473,33480,33487,33522,33549,33556,33563,33586,33625,33632],{"type":29,"tag":88,"props":33237,"children":33238},{"class":90,"line":91},[33239,33243,33247,33251],{"type":29,"tag":88,"props":33240,"children":33241},{"style":105},[33242],{"type":34,"value":108},{"type":29,"tag":88,"props":33244,"children":33245},{"style":105},[33246],{"type":34,"value":113},{"type":29,"tag":88,"props":33248,"children":33249},{"style":116},[33250],{"type":34,"value":21642},{"type":29,"tag":88,"props":33252,"children":33253},{"style":122},[33254],{"type":34,"value":125},{"type":29,"tag":88,"props":33256,"children":33257},{"class":90,"line":101},[33258,33262,33266,33270],{"type":29,"tag":88,"props":33259,"children":33260},{"style":105},[33261],{"type":34,"value":21654},{"type":29,"tag":88,"props":33263,"children":33264},{"style":105},[33265],{"type":34,"value":8608},{"type":29,"tag":88,"props":33267,"children":33268},{"style":157},[33269],{"type":34,"value":31876},{"type":29,"tag":88,"props":33271,"children":33272},{"style":122},[33273],{"type":34,"value":424},{"type":29,"tag":88,"props":33275,"children":33276},{"class":90,"line":128},[33277,33281,33285,33289],{"type":29,"tag":88,"props":33278,"children":33279},{"style":105},[33280],{"type":34,"value":21654},{"type":29,"tag":88,"props":33282,"children":33283},{"style":105},[33284],{"type":34,"value":8608},{"type":29,"tag":88,"props":33286,"children":33287},{"style":157},[33288],{"type":34,"value":15955},{"type":29,"tag":88,"props":33290,"children":33291},{"style":122},[33292],{"type":34,"value":424},{"type":29,"tag":88,"props":33294,"children":33295},{"class":90,"line":137},[33296],{"type":29,"tag":88,"props":33297,"children":33298},{"emptyLinePlaceholder":13},[33299],{"type":34,"value":134},{"type":29,"tag":88,"props":33301,"children":33302},{"class":90,"line":211},[33303,33307,33311,33315,33319,33323,33327,33331,33335,33339],{"type":29,"tag":88,"props":33304,"children":33305},{"style":105},[33306],{"type":34,"value":276},{"type":29,"tag":88,"props":33308,"children":33309},{"style":174},[33310],{"type":34,"value":21642},{"type":29,"tag":88,"props":33312,"children":33313},{"style":122},[33314],{"type":34,"value":181},{"type":29,"tag":88,"props":33316,"children":33317},{"style":105},[33318],{"type":34,"value":8622},{"type":29,"tag":88,"props":33320,"children":33321},{"style":298},[33322],{"type":34,"value":31876},{"type":29,"tag":88,"props":33324,"children":33325},{"style":122},[33326],{"type":34,"value":192},{"type":29,"tag":88,"props":33328,"children":33329},{"style":105},[33330],{"type":34,"value":8608},{"type":29,"tag":88,"props":33332,"children":33333},{"style":298},[33334],{"type":34,"value":15955},{"type":29,"tag":88,"props":33336,"children":33337},{"style":122},[33338],{"type":34,"value":306},{"type":29,"tag":88,"props":33340,"children":33341},{"style":122},[33342],{"type":34,"value":125},{"type":29,"tag":88,"props":33344,"children":33345},{"class":90,"line":262},[33346,33350,33354,33358,33362,33366],{"type":29,"tag":88,"props":33347,"children":33348},{"style":873},[33349],{"type":34,"value":876},{"type":29,"tag":88,"props":33351,"children":33352},{"style":122},[33353],{"type":34,"value":338},{"type":29,"tag":88,"props":33355,"children":33356},{"style":157},[33357],{"type":34,"value":31965},{"type":29,"tag":88,"props":33359,"children":33360},{"style":163},[33361],{"type":34,"value":166},{"type":29,"tag":88,"props":33363,"children":33364},{"style":157},[33365],{"type":34,"value":31876},{"type":29,"tag":88,"props":33367,"children":33368},{"style":122},[33369],{"type":34,"value":424},{"type":29,"tag":88,"props":33371,"children":33372},{"class":90,"line":270},[33373,33377,33381,33385,33389,33393],{"type":29,"tag":88,"props":33374,"children":33375},{"style":873},[33376],{"type":34,"value":876},{"type":29,"tag":88,"props":33378,"children":33379},{"style":122},[33380],{"type":34,"value":338},{"type":29,"tag":88,"props":33382,"children":33383},{"style":157},[33384],{"type":34,"value":31993},{"type":29,"tag":88,"props":33386,"children":33387},{"style":163},[33388],{"type":34,"value":166},{"type":29,"tag":88,"props":33390,"children":33391},{"style":157},[33392],{"type":34,"value":15955},{"type":29,"tag":88,"props":33394,"children":33395},{"style":122},[33396],{"type":34,"value":424},{"type":29,"tag":88,"props":33398,"children":33399},{"class":90,"line":313},[33400],{"type":29,"tag":88,"props":33401,"children":33402},{"style":122},[33403],{"type":34,"value":433},{"type":29,"tag":88,"props":33405,"children":33406},{"class":90,"line":360},[33407],{"type":29,"tag":88,"props":33408,"children":33409},{"emptyLinePlaceholder":13},[33410],{"type":34,"value":134},{"type":29,"tag":88,"props":33412,"children":33413},{"class":90,"line":409},[33414,33418,33422,33426,33430,33434,33438,33442],{"type":29,"tag":88,"props":33415,"children":33416},{"style":105},[33417],{"type":34,"value":276},{"type":29,"tag":88,"props":33419,"children":33420},{"style":105},[33421],{"type":34,"value":1303},{"type":29,"tag":88,"props":33423,"children":33424},{"style":174},[33425],{"type":34,"value":32035},{"type":29,"tag":88,"props":33427,"children":33428},{"style":122},[33429],{"type":34,"value":181},{"type":29,"tag":88,"props":33431,"children":33432},{"style":105},[33433],{"type":34,"value":8622},{"type":29,"tag":88,"props":33435,"children":33436},{"style":298},[33437],{"type":34,"value":31876},{"type":29,"tag":88,"props":33439,"children":33440},{"style":122},[33441],{"type":34,"value":306},{"type":29,"tag":88,"props":33443,"children":33444},{"style":122},[33445],{"type":34,"value":125},{"type":29,"tag":88,"props":33447,"children":33448},{"class":90,"line":427},[33449,33453,33457,33461,33465,33469],{"type":29,"tag":88,"props":33450,"children":33451},{"style":873},[33452],{"type":34,"value":876},{"type":29,"tag":88,"props":33454,"children":33455},{"style":122},[33456],{"type":34,"value":338},{"type":29,"tag":88,"props":33458,"children":33459},{"style":157},[33460],{"type":34,"value":31965},{"type":29,"tag":88,"props":33462,"children":33463},{"style":163},[33464],{"type":34,"value":166},{"type":29,"tag":88,"props":33466,"children":33467},{"style":157},[33468],{"type":34,"value":31876},{"type":29,"tag":88,"props":33470,"children":33471},{"style":122},[33472],{"type":34,"value":424},{"type":29,"tag":88,"props":33474,"children":33475},{"class":90,"line":436},[33476],{"type":29,"tag":88,"props":33477,"children":33478},{"style":122},[33479],{"type":34,"value":433},{"type":29,"tag":88,"props":33481,"children":33482},{"class":90,"line":767},[33483],{"type":29,"tag":88,"props":33484,"children":33485},{"emptyLinePlaceholder":13},[33486],{"type":34,"value":134},{"type":29,"tag":88,"props":33488,"children":33489},{"class":90,"line":792},[33490,33494,33498,33502,33506,33510,33514,33518],{"type":29,"tag":88,"props":33491,"children":33492},{"style":105},[33493],{"type":34,"value":276},{"type":29,"tag":88,"props":33495,"children":33496},{"style":105},[33497],{"type":34,"value":1303},{"type":29,"tag":88,"props":33499,"children":33500},{"style":174},[33501],{"type":34,"value":32112},{"type":29,"tag":88,"props":33503,"children":33504},{"style":122},[33505],{"type":34,"value":181},{"type":29,"tag":88,"props":33507,"children":33508},{"style":105},[33509],{"type":34,"value":8622},{"type":29,"tag":88,"props":33511,"children":33512},{"style":298},[33513],{"type":34,"value":15955},{"type":29,"tag":88,"props":33515,"children":33516},{"style":122},[33517],{"type":34,"value":306},{"type":29,"tag":88,"props":33519,"children":33520},{"style":122},[33521],{"type":34,"value":125},{"type":29,"tag":88,"props":33523,"children":33524},{"class":90,"line":817},[33525,33529,33533,33537,33541,33545],{"type":29,"tag":88,"props":33526,"children":33527},{"style":873},[33528],{"type":34,"value":876},{"type":29,"tag":88,"props":33530,"children":33531},{"style":122},[33532],{"type":34,"value":338},{"type":29,"tag":88,"props":33534,"children":33535},{"style":157},[33536],{"type":34,"value":31993},{"type":29,"tag":88,"props":33538,"children":33539},{"style":163},[33540],{"type":34,"value":166},{"type":29,"tag":88,"props":33542,"children":33543},{"style":157},[33544],{"type":34,"value":15955},{"type":29,"tag":88,"props":33546,"children":33547},{"style":122},[33548],{"type":34,"value":424},{"type":29,"tag":88,"props":33550,"children":33551},{"class":90,"line":825},[33552],{"type":29,"tag":88,"props":33553,"children":33554},{"style":122},[33555],{"type":34,"value":433},{"type":29,"tag":88,"props":33557,"children":33558},{"class":90,"line":869},[33559],{"type":29,"tag":88,"props":33560,"children":33561},{"emptyLinePlaceholder":13},[33562],{"type":34,"value":134},{"type":29,"tag":88,"props":33564,"children":33565},{"class":90,"line":900},[33566,33570,33574,33578,33582],{"type":29,"tag":88,"props":33567,"children":33568},{"style":105},[33569],{"type":34,"value":276},{"type":29,"tag":88,"props":33571,"children":33572},{"style":105},[33573],{"type":34,"value":8608},{"type":29,"tag":88,"props":33575,"children":33576},{"style":174},[33577],{"type":34,"value":32189},{"type":29,"tag":88,"props":33579,"children":33580},{"style":122},[33581],{"type":34,"value":1470},{"type":29,"tag":88,"props":33583,"children":33584},{"style":122},[33585],{"type":34,"value":125},{"type":29,"tag":88,"props":33587,"children":33588},{"class":90,"line":929},[33589,33593,33597,33601,33605,33609,33613,33617,33621],{"type":29,"tag":88,"props":33590,"children":33591},{"style":105},[33592],{"type":34,"value":415},{"type":29,"tag":88,"props":33594,"children":33595},{"style":873},[33596],{"type":34,"value":32209},{"type":29,"tag":88,"props":33598,"children":33599},{"style":122},[33600],{"type":34,"value":338},{"type":29,"tag":88,"props":33602,"children":33603},{"style":157},[33604],{"type":34,"value":31965},{"type":29,"tag":88,"props":33606,"children":33607},{"style":163},[33608],{"type":34,"value":8709},{"type":29,"tag":88,"props":33610,"children":33611},{"style":873},[33612],{"type":34,"value":32209},{"type":29,"tag":88,"props":33614,"children":33615},{"style":122},[33616],{"type":34,"value":338},{"type":29,"tag":88,"props":33618,"children":33619},{"style":157},[33620],{"type":34,"value":32234},{"type":29,"tag":88,"props":33622,"children":33623},{"style":122},[33624],{"type":34,"value":424},{"type":29,"tag":88,"props":33626,"children":33627},{"class":90,"line":937},[33628],{"type":29,"tag":88,"props":33629,"children":33630},{"style":122},[33631],{"type":34,"value":433},{"type":29,"tag":88,"props":33633,"children":33634},{"class":90,"line":945},[33635],{"type":29,"tag":88,"props":33636,"children":33637},{"style":122},[33638],{"type":34,"value":442},{"type":29,"tag":30,"props":33640,"children":33641},{},[33642,33644,33649],{"type":34,"value":33643},"La classe ",{"type":29,"tag":84,"props":33645,"children":33647},{"className":33646},[],[33648],{"type":34,"value":21585},{"type":34,"value":33650}," reste inchangée.",{"type":29,"tag":10576,"props":33652,"children":33654},{"id":33653},"classe-carre-indépendante",[33655,33656,33661],{"type":34,"value":31828},{"type":29,"tag":84,"props":33657,"children":33659},{"className":33658},[],[33660],{"type":34,"value":32276},{"type":34,"value":33662}," (indépendante) :",{"type":29,"tag":77,"props":33664,"children":33666},{"className":81,"code":33665,"language":80,"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",[33667],{"type":29,"tag":84,"props":33668,"children":33669},{"__ignoreMap":8},[33670,33689,33708,33715,33746,33774,33781,33788,33824,33851,33858,33865,33888,33927,33934],{"type":29,"tag":88,"props":33671,"children":33672},{"class":90,"line":91},[33673,33677,33681,33685],{"type":29,"tag":88,"props":33674,"children":33675},{"style":105},[33676],{"type":34,"value":108},{"type":29,"tag":88,"props":33678,"children":33679},{"style":105},[33680],{"type":34,"value":113},{"type":29,"tag":88,"props":33682,"children":33683},{"style":116},[33684],{"type":34,"value":32300},{"type":29,"tag":88,"props":33686,"children":33687},{"style":122},[33688],{"type":34,"value":125},{"type":29,"tag":88,"props":33690,"children":33691},{"class":90,"line":101},[33692,33696,33700,33704],{"type":29,"tag":88,"props":33693,"children":33694},{"style":105},[33695],{"type":34,"value":143},{"type":29,"tag":88,"props":33697,"children":33698},{"style":105},[33699],{"type":34,"value":8608},{"type":29,"tag":88,"props":33701,"children":33702},{"style":157},[33703],{"type":34,"value":32343},{"type":29,"tag":88,"props":33705,"children":33706},{"style":122},[33707],{"type":34,"value":424},{"type":29,"tag":88,"props":33709,"children":33710},{"class":90,"line":128},[33711],{"type":29,"tag":88,"props":33712,"children":33713},{"emptyLinePlaceholder":13},[33714],{"type":34,"value":134},{"type":29,"tag":88,"props":33716,"children":33717},{"class":90,"line":137},[33718,33722,33726,33730,33734,33738,33742],{"type":29,"tag":88,"props":33719,"children":33720},{"style":105},[33721],{"type":34,"value":276},{"type":29,"tag":88,"props":33723,"children":33724},{"style":174},[33725],{"type":34,"value":32300},{"type":29,"tag":88,"props":33727,"children":33728},{"style":122},[33729],{"type":34,"value":181},{"type":29,"tag":88,"props":33731,"children":33732},{"style":105},[33733],{"type":34,"value":8622},{"type":29,"tag":88,"props":33735,"children":33736},{"style":298},[33737],{"type":34,"value":32343},{"type":29,"tag":88,"props":33739,"children":33740},{"style":122},[33741],{"type":34,"value":306},{"type":29,"tag":88,"props":33743,"children":33744},{"style":122},[33745],{"type":34,"value":125},{"type":29,"tag":88,"props":33747,"children":33748},{"class":90,"line":211},[33749,33753,33757,33762,33766,33770],{"type":29,"tag":88,"props":33750,"children":33751},{"style":873},[33752],{"type":34,"value":876},{"type":29,"tag":88,"props":33754,"children":33755},{"style":122},[33756],{"type":34,"value":338},{"type":29,"tag":88,"props":33758,"children":33759},{"style":157},[33760],{"type":34,"value":33761},"taille ",{"type":29,"tag":88,"props":33763,"children":33764},{"style":163},[33765],{"type":34,"value":166},{"type":29,"tag":88,"props":33767,"children":33768},{"style":157},[33769],{"type":34,"value":32343},{"type":29,"tag":88,"props":33771,"children":33772},{"style":122},[33773],{"type":34,"value":424},{"type":29,"tag":88,"props":33775,"children":33776},{"class":90,"line":262},[33777],{"type":29,"tag":88,"props":33778,"children":33779},{"style":122},[33780],{"type":34,"value":433},{"type":29,"tag":88,"props":33782,"children":33783},{"class":90,"line":270},[33784],{"type":29,"tag":88,"props":33785,"children":33786},{"emptyLinePlaceholder":13},[33787],{"type":34,"value":134},{"type":29,"tag":88,"props":33789,"children":33790},{"class":90,"line":313},[33791,33795,33799,33804,33808,33812,33816,33820],{"type":29,"tag":88,"props":33792,"children":33793},{"style":105},[33794],{"type":34,"value":276},{"type":29,"tag":88,"props":33796,"children":33797},{"style":105},[33798],{"type":34,"value":1303},{"type":29,"tag":88,"props":33800,"children":33801},{"style":174},[33802],{"type":34,"value":33803}," setTaille",{"type":29,"tag":88,"props":33805,"children":33806},{"style":122},[33807],{"type":34,"value":181},{"type":29,"tag":88,"props":33809,"children":33810},{"style":105},[33811],{"type":34,"value":8622},{"type":29,"tag":88,"props":33813,"children":33814},{"style":298},[33815],{"type":34,"value":32343},{"type":29,"tag":88,"props":33817,"children":33818},{"style":122},[33819],{"type":34,"value":306},{"type":29,"tag":88,"props":33821,"children":33822},{"style":122},[33823],{"type":34,"value":125},{"type":29,"tag":88,"props":33825,"children":33826},{"class":90,"line":360},[33827,33831,33835,33839,33843,33847],{"type":29,"tag":88,"props":33828,"children":33829},{"style":873},[33830],{"type":34,"value":876},{"type":29,"tag":88,"props":33832,"children":33833},{"style":122},[33834],{"type":34,"value":338},{"type":29,"tag":88,"props":33836,"children":33837},{"style":157},[33838],{"type":34,"value":33761},{"type":29,"tag":88,"props":33840,"children":33841},{"style":163},[33842],{"type":34,"value":166},{"type":29,"tag":88,"props":33844,"children":33845},{"style":157},[33846],{"type":34,"value":32343},{"type":29,"tag":88,"props":33848,"children":33849},{"style":122},[33850],{"type":34,"value":424},{"type":29,"tag":88,"props":33852,"children":33853},{"class":90,"line":409},[33854],{"type":29,"tag":88,"props":33855,"children":33856},{"style":122},[33857],{"type":34,"value":433},{"type":29,"tag":88,"props":33859,"children":33860},{"class":90,"line":427},[33861],{"type":29,"tag":88,"props":33862,"children":33863},{"emptyLinePlaceholder":13},[33864],{"type":34,"value":134},{"type":29,"tag":88,"props":33866,"children":33867},{"class":90,"line":436},[33868,33872,33876,33880,33884],{"type":29,"tag":88,"props":33869,"children":33870},{"style":105},[33871],{"type":34,"value":276},{"type":29,"tag":88,"props":33873,"children":33874},{"style":105},[33875],{"type":34,"value":8608},{"type":29,"tag":88,"props":33877,"children":33878},{"style":174},[33879],{"type":34,"value":32189},{"type":29,"tag":88,"props":33881,"children":33882},{"style":122},[33883],{"type":34,"value":1470},{"type":29,"tag":88,"props":33885,"children":33886},{"style":122},[33887],{"type":34,"value":125},{"type":29,"tag":88,"props":33889,"children":33890},{"class":90,"line":767},[33891,33895,33899,33903,33907,33911,33915,33919,33923],{"type":29,"tag":88,"props":33892,"children":33893},{"style":105},[33894],{"type":34,"value":415},{"type":29,"tag":88,"props":33896,"children":33897},{"style":873},[33898],{"type":34,"value":32209},{"type":29,"tag":88,"props":33900,"children":33901},{"style":122},[33902],{"type":34,"value":338},{"type":29,"tag":88,"props":33904,"children":33905},{"style":157},[33906],{"type":34,"value":33761},{"type":29,"tag":88,"props":33908,"children":33909},{"style":163},[33910],{"type":34,"value":8709},{"type":29,"tag":88,"props":33912,"children":33913},{"style":873},[33914],{"type":34,"value":32209},{"type":29,"tag":88,"props":33916,"children":33917},{"style":122},[33918],{"type":34,"value":338},{"type":29,"tag":88,"props":33920,"children":33921},{"style":157},[33922],{"type":34,"value":32368},{"type":29,"tag":88,"props":33924,"children":33925},{"style":122},[33926],{"type":34,"value":424},{"type":29,"tag":88,"props":33928,"children":33929},{"class":90,"line":792},[33930],{"type":29,"tag":88,"props":33931,"children":33932},{"style":122},[33933],{"type":34,"value":433},{"type":29,"tag":88,"props":33935,"children":33936},{"class":90,"line":817},[33937],{"type":29,"tag":88,"props":33938,"children":33939},{"style":122},[33940],{"type":34,"value":442},{"type":29,"tag":30,"props":33942,"children":33943},{},[33944,33946,33951,33953,33958,33960,33965,33967,33972,33974,33979,33981,33986],{"type":34,"value":33945},"Dans cette version, ",{"type":29,"tag":84,"props":33947,"children":33949},{"className":33948},[],[33950],{"type":34,"value":32276},{"type":34,"value":33952}," n’hérite plus de ",{"type":29,"tag":84,"props":33954,"children":33956},{"className":33955},[],[33957],{"type":34,"value":21585},{"type":34,"value":33959},". Nous avons ainsi une classe ",{"type":29,"tag":84,"props":33961,"children":33963},{"className":33962},[],[33964],{"type":34,"value":32276},{"type":34,"value":33966}," totalement indépendante qui suit ses propres règles et n'interfère pas avec les attentes définies pour un ",{"type":29,"tag":84,"props":33968,"children":33970},{"className":33969},[],[33971],{"type":34,"value":21585},{"type":34,"value":33973},". Le carré a une seule dimension (",{"type":29,"tag":84,"props":33975,"children":33977},{"className":33976},[],[33978],{"type":34,"value":32368},{"type":34,"value":33980},"), et son comportement est cohérent avec son concept sans violer les principes de la classe ",{"type":29,"tag":84,"props":33982,"children":33984},{"className":33983},[],[33985],{"type":34,"value":21585},{"type":34,"value":338},{"type":29,"tag":10576,"props":33988,"children":33990},{"id":33989},"modification-du-programme-de-test",[33991],{"type":34,"value":33992},"Modification du programme de test :",{"type":29,"tag":30,"props":33994,"children":33995},{},[33996,33998,34003,34005,34010],{"type":34,"value":33997},"Puisque ",{"type":29,"tag":84,"props":33999,"children":34001},{"className":34000},[],[34002],{"type":34,"value":32276},{"type":34,"value":34004}," n’est plus une sous-classe de ",{"type":29,"tag":84,"props":34006,"children":34008},{"className":34007},[],[34009],{"type":34,"value":21585},{"type":34,"value":34011},", nous devons légèrement modifier notre méthode de test pour respecter cette nouvelle structure.",{"type":29,"tag":77,"props":34013,"children":34015},{"className":81,"code":34014,"language":80,"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        \u002F\u002F Test avec un Rectangle\n        Rectangle rect = new Rectangle(2, 3);\n        testerRectangle(rect);\n\n        \u002F\u002F Test avec un Carre\n        Carre carre = new Carre(5);\n\n\n        testerCarre(carre);\n    }\n}\n",[34016],{"type":29,"tag":84,"props":34017,"children":34018},{"__ignoreMap":8},[34019,34038,34045,34084,34111,34138,34169,34213,34220,34227,34268,34297,34328,34372,34379,34386,34429,34436,34479,34498,34505,34512,34547,34554,34561,34581,34588],{"type":29,"tag":88,"props":34020,"children":34021},{"class":90,"line":91},[34022,34026,34030,34034],{"type":29,"tag":88,"props":34023,"children":34024},{"style":105},[34025],{"type":34,"value":108},{"type":29,"tag":88,"props":34027,"children":34028},{"style":105},[34029],{"type":34,"value":113},{"type":29,"tag":88,"props":34031,"children":34032},{"style":116},[34033],{"type":34,"value":21224},{"type":29,"tag":88,"props":34035,"children":34036},{"style":122},[34037],{"type":34,"value":125},{"type":29,"tag":88,"props":34039,"children":34040},{"class":90,"line":101},[34041],{"type":29,"tag":88,"props":34042,"children":34043},{"emptyLinePlaceholder":13},[34044],{"type":34,"value":134},{"type":29,"tag":88,"props":34046,"children":34047},{"class":90,"line":128},[34048,34052,34056,34060,34064,34068,34072,34076,34080],{"type":29,"tag":88,"props":34049,"children":34050},{"style":105},[34051],{"type":34,"value":276},{"type":29,"tag":88,"props":34053,"children":34054},{"style":105},[34055],{"type":34,"value":12248},{"type":29,"tag":88,"props":34057,"children":34058},{"style":105},[34059],{"type":34,"value":1303},{"type":29,"tag":88,"props":34061,"children":34062},{"style":174},[34063],{"type":34,"value":32704},{"type":29,"tag":88,"props":34065,"children":34066},{"style":122},[34067],{"type":34,"value":181},{"type":29,"tag":88,"props":34069,"children":34070},{"style":151},[34071],{"type":34,"value":21585},{"type":29,"tag":88,"props":34073,"children":34074},{"style":298},[34075],{"type":34,"value":32717},{"type":29,"tag":88,"props":34077,"children":34078},{"style":122},[34079],{"type":34,"value":306},{"type":29,"tag":88,"props":34081,"children":34082},{"style":122},[34083],{"type":34,"value":125},{"type":29,"tag":88,"props":34085,"children":34086},{"class":90,"line":137},[34087,34091,34095,34099,34103,34107],{"type":29,"tag":88,"props":34088,"children":34089},{"style":157},[34090],{"type":34,"value":32733},{"type":29,"tag":88,"props":34092,"children":34093},{"style":122},[34094],{"type":34,"value":338},{"type":29,"tag":88,"props":34096,"children":34097},{"style":174},[34098],{"type":34,"value":32625},{"type":29,"tag":88,"props":34100,"children":34101},{"style":122},[34102],{"type":34,"value":181},{"type":29,"tag":88,"props":34104,"children":34105},{"style":195},[34106],{"type":34,"value":32750},{"type":29,"tag":88,"props":34108,"children":34109},{"style":122},[34110],{"type":34,"value":357},{"type":29,"tag":88,"props":34112,"children":34113},{"class":90,"line":211},[34114,34118,34122,34126,34130,34134],{"type":29,"tag":88,"props":34115,"children":34116},{"style":157},[34117],{"type":34,"value":32733},{"type":29,"tag":88,"props":34119,"children":34120},{"style":122},[34121],{"type":34,"value":338},{"type":29,"tag":88,"props":34123,"children":34124},{"style":174},[34125],{"type":34,"value":32632},{"type":29,"tag":88,"props":34127,"children":34128},{"style":122},[34129],{"type":34,"value":181},{"type":29,"tag":88,"props":34131,"children":34132},{"style":195},[34133],{"type":34,"value":32778},{"type":29,"tag":88,"props":34135,"children":34136},{"style":122},[34137],{"type":34,"value":357},{"type":29,"tag":88,"props":34139,"children":34140},{"class":90,"line":262},[34141,34145,34149,34153,34157,34161,34165],{"type":29,"tag":88,"props":34142,"children":34143},{"style":105},[34144],{"type":34,"value":32790},{"type":29,"tag":88,"props":34146,"children":34147},{"style":157},[34148],{"type":34,"value":32795},{"type":29,"tag":88,"props":34150,"children":34151},{"style":163},[34152],{"type":34,"value":166},{"type":29,"tag":88,"props":34154,"children":34155},{"style":157},[34156],{"type":34,"value":32717},{"type":29,"tag":88,"props":34158,"children":34159},{"style":122},[34160],{"type":34,"value":338},{"type":29,"tag":88,"props":34162,"children":34163},{"style":174},[34164],{"type":34,"value":32812},{"type":29,"tag":88,"props":34166,"children":34167},{"style":122},[34168],{"type":34,"value":1810},{"type":29,"tag":88,"props":34170,"children":34171},{"class":90,"line":270},[34172,34176,34180,34184,34188,34192,34196,34201,34205,34209],{"type":29,"tag":88,"props":34173,"children":34174},{"style":157},[34175],{"type":34,"value":19726},{"type":29,"tag":88,"props":34177,"children":34178},{"style":122},[34179],{"type":34,"value":338},{"type":29,"tag":88,"props":34181,"children":34182},{"style":157},[34183],{"type":34,"value":18091},{"type":29,"tag":88,"props":34185,"children":34186},{"style":122},[34187],{"type":34,"value":338},{"type":29,"tag":88,"props":34189,"children":34190},{"style":174},[34191],{"type":34,"value":18100},{"type":29,"tag":88,"props":34193,"children":34194},{"style":122},[34195],{"type":34,"value":181},{"type":29,"tag":88,"props":34197,"children":34198},{"style":184},[34199],{"type":34,"value":34200},"\"Aire attendue (Rectangle) : 50, Aire calculée : \"",{"type":29,"tag":88,"props":34202,"children":34203},{"style":163},[34204],{"type":34,"value":5485},{"type":29,"tag":88,"props":34206,"children":34207},{"style":157},[34208],{"type":34,"value":32857},{"type":29,"tag":88,"props":34210,"children":34211},{"style":122},[34212],{"type":34,"value":357},{"type":29,"tag":88,"props":34214,"children":34215},{"class":90,"line":313},[34216],{"type":29,"tag":88,"props":34217,"children":34218},{"style":122},[34219],{"type":34,"value":433},{"type":29,"tag":88,"props":34221,"children":34222},{"class":90,"line":360},[34223],{"type":29,"tag":88,"props":34224,"children":34225},{"emptyLinePlaceholder":13},[34226],{"type":34,"value":134},{"type":29,"tag":88,"props":34228,"children":34229},{"class":90,"line":409},[34230,34234,34238,34242,34247,34251,34255,34260,34264],{"type":29,"tag":88,"props":34231,"children":34232},{"style":105},[34233],{"type":34,"value":276},{"type":29,"tag":88,"props":34235,"children":34236},{"style":105},[34237],{"type":34,"value":12248},{"type":29,"tag":88,"props":34239,"children":34240},{"style":105},[34241],{"type":34,"value":1303},{"type":29,"tag":88,"props":34243,"children":34244},{"style":174},[34245],{"type":34,"value":34246}," testerCarre",{"type":29,"tag":88,"props":34248,"children":34249},{"style":122},[34250],{"type":34,"value":181},{"type":29,"tag":88,"props":34252,"children":34253},{"style":151},[34254],{"type":34,"value":32276},{"type":29,"tag":88,"props":34256,"children":34257},{"style":298},[34258],{"type":34,"value":34259}," carre",{"type":29,"tag":88,"props":34261,"children":34262},{"style":122},[34263],{"type":34,"value":306},{"type":29,"tag":88,"props":34265,"children":34266},{"style":122},[34267],{"type":34,"value":125},{"type":29,"tag":88,"props":34269,"children":34270},{"class":90,"line":427},[34271,34276,34280,34285,34289,34293],{"type":29,"tag":88,"props":34272,"children":34273},{"style":157},[34274],{"type":34,"value":34275},"        carre",{"type":29,"tag":88,"props":34277,"children":34278},{"style":122},[34279],{"type":34,"value":338},{"type":29,"tag":88,"props":34281,"children":34282},{"style":174},[34283],{"type":34,"value":34284},"setTaille",{"type":29,"tag":88,"props":34286,"children":34287},{"style":122},[34288],{"type":34,"value":181},{"type":29,"tag":88,"props":34290,"children":34291},{"style":195},[34292],{"type":34,"value":32750},{"type":29,"tag":88,"props":34294,"children":34295},{"style":122},[34296],{"type":34,"value":357},{"type":29,"tag":88,"props":34298,"children":34299},{"class":90,"line":436},[34300,34304,34308,34312,34316,34320,34324],{"type":29,"tag":88,"props":34301,"children":34302},{"style":105},[34303],{"type":34,"value":32790},{"type":29,"tag":88,"props":34305,"children":34306},{"style":157},[34307],{"type":34,"value":32795},{"type":29,"tag":88,"props":34309,"children":34310},{"style":163},[34311],{"type":34,"value":166},{"type":29,"tag":88,"props":34313,"children":34314},{"style":157},[34315],{"type":34,"value":34259},{"type":29,"tag":88,"props":34317,"children":34318},{"style":122},[34319],{"type":34,"value":338},{"type":29,"tag":88,"props":34321,"children":34322},{"style":174},[34323],{"type":34,"value":32812},{"type":29,"tag":88,"props":34325,"children":34326},{"style":122},[34327],{"type":34,"value":1810},{"type":29,"tag":88,"props":34329,"children":34330},{"class":90,"line":767},[34331,34335,34339,34343,34347,34351,34355,34360,34364,34368],{"type":29,"tag":88,"props":34332,"children":34333},{"style":157},[34334],{"type":34,"value":19726},{"type":29,"tag":88,"props":34336,"children":34337},{"style":122},[34338],{"type":34,"value":338},{"type":29,"tag":88,"props":34340,"children":34341},{"style":157},[34342],{"type":34,"value":18091},{"type":29,"tag":88,"props":34344,"children":34345},{"style":122},[34346],{"type":34,"value":338},{"type":29,"tag":88,"props":34348,"children":34349},{"style":174},[34350],{"type":34,"value":18100},{"type":29,"tag":88,"props":34352,"children":34353},{"style":122},[34354],{"type":34,"value":181},{"type":29,"tag":88,"props":34356,"children":34357},{"style":184},[34358],{"type":34,"value":34359},"\"Aire attendue (Carre) : 25, Aire calculée : \"",{"type":29,"tag":88,"props":34361,"children":34362},{"style":163},[34363],{"type":34,"value":5485},{"type":29,"tag":88,"props":34365,"children":34366},{"style":157},[34367],{"type":34,"value":32857},{"type":29,"tag":88,"props":34369,"children":34370},{"style":122},[34371],{"type":34,"value":357},{"type":29,"tag":88,"props":34373,"children":34374},{"class":90,"line":792},[34375],{"type":29,"tag":88,"props":34376,"children":34377},{"style":122},[34378],{"type":34,"value":433},{"type":29,"tag":88,"props":34380,"children":34381},{"class":90,"line":817},[34382],{"type":29,"tag":88,"props":34383,"children":34384},{"emptyLinePlaceholder":13},[34385],{"type":34,"value":134},{"type":29,"tag":88,"props":34387,"children":34388},{"class":90,"line":825},[34389,34393,34397,34401,34405,34409,34413,34417,34421,34425],{"type":29,"tag":88,"props":34390,"children":34391},{"style":105},[34392],{"type":34,"value":276},{"type":29,"tag":88,"props":34394,"children":34395},{"style":105},[34396],{"type":34,"value":12248},{"type":29,"tag":88,"props":34398,"children":34399},{"style":105},[34400],{"type":34,"value":1303},{"type":29,"tag":88,"props":34402,"children":34403},{"style":174},[34404],{"type":34,"value":21248},{"type":29,"tag":88,"props":34406,"children":34407},{"style":122},[34408],{"type":34,"value":181},{"type":29,"tag":88,"props":34410,"children":34411},{"style":105},[34412],{"type":34,"value":695},{"type":29,"tag":88,"props":34414,"children":34415},{"style":122},[34416],{"type":34,"value":21261},{"type":29,"tag":88,"props":34418,"children":34419},{"style":298},[34420],{"type":34,"value":21266},{"type":29,"tag":88,"props":34422,"children":34423},{"style":122},[34424],{"type":34,"value":306},{"type":29,"tag":88,"props":34426,"children":34427},{"style":122},[34428],{"type":34,"value":125},{"type":29,"tag":88,"props":34430,"children":34431},{"class":90,"line":869},[34432],{"type":29,"tag":88,"props":34433,"children":34434},{"style":95},[34435],{"type":34,"value":32926},{"type":29,"tag":88,"props":34437,"children":34438},{"class":90,"line":900},[34439,34443,34447,34451,34455,34459,34463,34467,34471,34475],{"type":29,"tag":88,"props":34440,"children":34441},{"style":151},[34442],{"type":34,"value":32934},{"type":29,"tag":88,"props":34444,"children":34445},{"style":157},[34446],{"type":34,"value":32939},{"type":29,"tag":88,"props":34448,"children":34449},{"style":163},[34450],{"type":34,"value":166},{"type":29,"tag":88,"props":34452,"children":34453},{"style":105},[34454],{"type":34,"value":171},{"type":29,"tag":88,"props":34456,"children":34457},{"style":174},[34458],{"type":34,"value":21642},{"type":29,"tag":88,"props":34460,"children":34461},{"style":122},[34462],{"type":34,"value":181},{"type":29,"tag":88,"props":34464,"children":34465},{"style":195},[34466],{"type":34,"value":17459},{"type":29,"tag":88,"props":34468,"children":34469},{"style":122},[34470],{"type":34,"value":192},{"type":29,"tag":88,"props":34472,"children":34473},{"style":195},[34474],{"type":34,"value":15788},{"type":29,"tag":88,"props":34476,"children":34477},{"style":122},[34478],{"type":34,"value":357},{"type":29,"tag":88,"props":34480,"children":34481},{"class":90,"line":929},[34482,34486,34490,34494],{"type":29,"tag":88,"props":34483,"children":34484},{"style":174},[34485],{"type":34,"value":32979},{"type":29,"tag":88,"props":34487,"children":34488},{"style":122},[34489],{"type":34,"value":181},{"type":29,"tag":88,"props":34491,"children":34492},{"style":157},[34493],{"type":34,"value":32988},{"type":29,"tag":88,"props":34495,"children":34496},{"style":122},[34497],{"type":34,"value":357},{"type":29,"tag":88,"props":34499,"children":34500},{"class":90,"line":937},[34501],{"type":29,"tag":88,"props":34502,"children":34503},{"emptyLinePlaceholder":13},[34504],{"type":34,"value":134},{"type":29,"tag":88,"props":34506,"children":34507},{"class":90,"line":945},[34508],{"type":29,"tag":88,"props":34509,"children":34510},{"style":95},[34511],{"type":34,"value":33007},{"type":29,"tag":88,"props":34513,"children":34514},{"class":90,"line":981},[34515,34519,34523,34527,34531,34535,34539,34543],{"type":29,"tag":88,"props":34516,"children":34517},{"style":151},[34518],{"type":34,"value":33015},{"type":29,"tag":88,"props":34520,"children":34521},{"style":157},[34522],{"type":34,"value":33020},{"type":29,"tag":88,"props":34524,"children":34525},{"style":163},[34526],{"type":34,"value":166},{"type":29,"tag":88,"props":34528,"children":34529},{"style":105},[34530],{"type":34,"value":171},{"type":29,"tag":88,"props":34532,"children":34533},{"style":174},[34534],{"type":34,"value":32300},{"type":29,"tag":88,"props":34536,"children":34537},{"style":122},[34538],{"type":34,"value":181},{"type":29,"tag":88,"props":34540,"children":34541},{"style":195},[34542],{"type":34,"value":32750},{"type":29,"tag":88,"props":34544,"children":34545},{"style":122},[34546],{"type":34,"value":357},{"type":29,"tag":88,"props":34548,"children":34549},{"class":90,"line":1021},[34550],{"type":29,"tag":88,"props":34551,"children":34552},{"emptyLinePlaceholder":13},[34553],{"type":34,"value":134},{"type":29,"tag":88,"props":34555,"children":34556},{"class":90,"line":1066},[34557],{"type":29,"tag":88,"props":34558,"children":34559},{"emptyLinePlaceholder":13},[34560],{"type":34,"value":134},{"type":29,"tag":88,"props":34562,"children":34563},{"class":90,"line":1082},[34564,34569,34573,34577],{"type":29,"tag":88,"props":34565,"children":34566},{"style":174},[34567],{"type":34,"value":34568},"        testerCarre",{"type":29,"tag":88,"props":34570,"children":34571},{"style":122},[34572],{"type":34,"value":181},{"type":29,"tag":88,"props":34574,"children":34575},{"style":157},[34576],{"type":34,"value":33060},{"type":29,"tag":88,"props":34578,"children":34579},{"style":122},[34580],{"type":34,"value":357},{"type":29,"tag":88,"props":34582,"children":34583},{"class":90,"line":1090},[34584],{"type":29,"tag":88,"props":34585,"children":34586},{"style":122},[34587],{"type":34,"value":433},{"type":29,"tag":88,"props":34589,"children":34590},{"class":90,"line":1098},[34591],{"type":29,"tag":88,"props":34592,"children":34593},{"style":122},[34594],{"type":34,"value":442},{"type":29,"tag":10576,"props":34596,"children":34598},{"id":34597},"résultat-1",[34599],{"type":34,"value":33084},{"type":29,"tag":453,"props":34601,"children":34602},{},[34603,34614],{"type":29,"tag":457,"props":34604,"children":34605},{},[34606,34607,34612],{"type":34,"value":10213},{"type":29,"tag":84,"props":34608,"children":34610},{"className":34609},[],[34611],{"type":34,"value":21585},{"type":34,"value":34613}," fonctionne comme prévu : l'aire est de 50.",{"type":29,"tag":457,"props":34615,"children":34616},{},[34617,34618,34623],{"type":34,"value":10213},{"type":29,"tag":84,"props":34619,"children":34621},{"className":34620},[],[34622],{"type":34,"value":32276},{"type":34,"value":34624}," fonctionne également correctement : l'aire est de 25 (5 * 5), et le comportement est bien conforme aux attentes.",{"type":29,"tag":8542,"props":34626,"children":34628},{"id":34627},"pourquoi-cela-respecte-t-il-le-lsp",[34629],{"type":34,"value":34630},"Pourquoi cela respecte-t-il le LSP ?",{"type":29,"tag":30,"props":34632,"children":34633},{},[34634,34636,34641,34642,34647,34649,34654,34655,34660],{"type":34,"value":34635},"Dans cette solution, nous avons séparé les deux concepts (",{"type":29,"tag":84,"props":34637,"children":34639},{"className":34638},[],[34640],{"type":34,"value":21585},{"type":34,"value":8982},{"type":29,"tag":84,"props":34643,"children":34645},{"className":34644},[],[34646],{"type":34,"value":32276},{"type":34,"value":34648},") afin que chaque classe respecte ses propres contraintes. Le LSP est respecté car les objets ",{"type":29,"tag":84,"props":34650,"children":34652},{"className":34651},[],[34653],{"type":34,"value":21585},{"type":34,"value":8982},{"type":29,"tag":84,"props":34656,"children":34658},{"className":34657},[],[34659],{"type":34,"value":32276},{"type":34,"value":34661}," ne sont plus liés par une relation d’héritage qui pourrait potentiellement briser les attentes du programme.",{"type":29,"tag":8542,"props":34663,"children":34665},{"id":34664},"autre-approche-utiliser-une-interface-commune",[34666],{"type":34,"value":34667},"Autre approche : utiliser une interface commune",{"type":29,"tag":30,"props":34669,"children":34670},{},[34671,34673,34678],{"type":34,"value":34672},"Si vous souhaitez toujours utiliser l’héritage ou l’interchangeabilité, une meilleure approche serait d’introduire une interface commune ",{"type":29,"tag":84,"props":34674,"children":34676},{"className":34675},[],[34677],{"type":34,"value":31731},{"type":34,"value":34679}," que les deux classes pourraient implémenter. Ainsi, elles partageraient des comportements communs tout en ayant leurs propres implémentations spécifiques.",{"type":29,"tag":10576,"props":34681,"children":34683},{"id":34682},"exemple-avec-une-interface-commune",[34684],{"type":34,"value":34685},"Exemple avec une interface commune",{"type":29,"tag":77,"props":34687,"children":34689},{"className":81,"code":34688,"language":80,"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",[34690],{"type":29,"tag":84,"props":34691,"children":34692},{"__ignoreMap":8},[34693,34713,34729,34736,34743,34770,34789,34808,34815,34858,34885,34912,34919,34926,34937,34960,34983,34990,34997,35004,35031,35050,35057,35088,35115,35122,35129,35140,35163,35187,35194],{"type":29,"tag":88,"props":34694,"children":34695},{"class":90,"line":91},[34696,34700,34704,34709],{"type":29,"tag":88,"props":34697,"children":34698},{"style":105},[34699],{"type":34,"value":108},{"type":29,"tag":88,"props":34701,"children":34702},{"style":105},[34703],{"type":34,"value":601},{"type":29,"tag":88,"props":34705,"children":34706},{"style":116},[34707],{"type":34,"value":34708}," Forme",{"type":29,"tag":88,"props":34710,"children":34711},{"style":122},[34712],{"type":34,"value":125},{"type":29,"tag":88,"props":34714,"children":34715},{"class":90,"line":101},[34716,34721,34725],{"type":29,"tag":88,"props":34717,"children":34718},{"style":105},[34719],{"type":34,"value":34720},"    int",{"type":29,"tag":88,"props":34722,"children":34723},{"style":174},[34724],{"type":34,"value":32189},{"type":29,"tag":88,"props":34726,"children":34727},{"style":122},[34728],{"type":34,"value":1810},{"type":29,"tag":88,"props":34730,"children":34731},{"class":90,"line":128},[34732],{"type":29,"tag":88,"props":34733,"children":34734},{"style":122},[34735],{"type":34,"value":442},{"type":29,"tag":88,"props":34737,"children":34738},{"class":90,"line":137},[34739],{"type":29,"tag":88,"props":34740,"children":34741},{"emptyLinePlaceholder":13},[34742],{"type":34,"value":134},{"type":29,"tag":88,"props":34744,"children":34745},{"class":90,"line":211},[34746,34750,34754,34758,34762,34766],{"type":29,"tag":88,"props":34747,"children":34748},{"style":105},[34749],{"type":34,"value":108},{"type":29,"tag":88,"props":34751,"children":34752},{"style":105},[34753],{"type":34,"value":113},{"type":29,"tag":88,"props":34755,"children":34756},{"style":116},[34757],{"type":34,"value":21642},{"type":29,"tag":88,"props":34759,"children":34760},{"style":105},[34761],{"type":34,"value":1134},{"type":29,"tag":88,"props":34763,"children":34764},{"style":116},[34765],{"type":34,"value":34708},{"type":29,"tag":88,"props":34767,"children":34768},{"style":122},[34769],{"type":34,"value":125},{"type":29,"tag":88,"props":34771,"children":34772},{"class":90,"line":262},[34773,34777,34781,34785],{"type":29,"tag":88,"props":34774,"children":34775},{"style":105},[34776],{"type":34,"value":143},{"type":29,"tag":88,"props":34778,"children":34779},{"style":105},[34780],{"type":34,"value":8608},{"type":29,"tag":88,"props":34782,"children":34783},{"style":157},[34784],{"type":34,"value":31876},{"type":29,"tag":88,"props":34786,"children":34787},{"style":122},[34788],{"type":34,"value":424},{"type":29,"tag":88,"props":34790,"children":34791},{"class":90,"line":270},[34792,34796,34800,34804],{"type":29,"tag":88,"props":34793,"children":34794},{"style":105},[34795],{"type":34,"value":143},{"type":29,"tag":88,"props":34797,"children":34798},{"style":105},[34799],{"type":34,"value":8608},{"type":29,"tag":88,"props":34801,"children":34802},{"style":157},[34803],{"type":34,"value":15955},{"type":29,"tag":88,"props":34805,"children":34806},{"style":122},[34807],{"type":34,"value":424},{"type":29,"tag":88,"props":34809,"children":34810},{"class":90,"line":313},[34811],{"type":29,"tag":88,"props":34812,"children":34813},{"emptyLinePlaceholder":13},[34814],{"type":34,"value":134},{"type":29,"tag":88,"props":34816,"children":34817},{"class":90,"line":360},[34818,34822,34826,34830,34834,34838,34842,34846,34850,34854],{"type":29,"tag":88,"props":34819,"children":34820},{"style":105},[34821],{"type":34,"value":276},{"type":29,"tag":88,"props":34823,"children":34824},{"style":174},[34825],{"type":34,"value":21642},{"type":29,"tag":88,"props":34827,"children":34828},{"style":122},[34829],{"type":34,"value":181},{"type":29,"tag":88,"props":34831,"children":34832},{"style":105},[34833],{"type":34,"value":8622},{"type":29,"tag":88,"props":34835,"children":34836},{"style":298},[34837],{"type":34,"value":31876},{"type":29,"tag":88,"props":34839,"children":34840},{"style":122},[34841],{"type":34,"value":192},{"type":29,"tag":88,"props":34843,"children":34844},{"style":105},[34845],{"type":34,"value":8608},{"type":29,"tag":88,"props":34847,"children":34848},{"style":298},[34849],{"type":34,"value":15955},{"type":29,"tag":88,"props":34851,"children":34852},{"style":122},[34853],{"type":34,"value":306},{"type":29,"tag":88,"props":34855,"children":34856},{"style":122},[34857],{"type":34,"value":125},{"type":29,"tag":88,"props":34859,"children":34860},{"class":90,"line":409},[34861,34865,34869,34873,34877,34881],{"type":29,"tag":88,"props":34862,"children":34863},{"style":873},[34864],{"type":34,"value":876},{"type":29,"tag":88,"props":34866,"children":34867},{"style":122},[34868],{"type":34,"value":338},{"type":29,"tag":88,"props":34870,"children":34871},{"style":157},[34872],{"type":34,"value":31965},{"type":29,"tag":88,"props":34874,"children":34875},{"style":163},[34876],{"type":34,"value":166},{"type":29,"tag":88,"props":34878,"children":34879},{"style":157},[34880],{"type":34,"value":31876},{"type":29,"tag":88,"props":34882,"children":34883},{"style":122},[34884],{"type":34,"value":424},{"type":29,"tag":88,"props":34886,"children":34887},{"class":90,"line":427},[34888,34892,34896,34900,34904,34908],{"type":29,"tag":88,"props":34889,"children":34890},{"style":873},[34891],{"type":34,"value":876},{"type":29,"tag":88,"props":34893,"children":34894},{"style":122},[34895],{"type":34,"value":338},{"type":29,"tag":88,"props":34897,"children":34898},{"style":157},[34899],{"type":34,"value":31993},{"type":29,"tag":88,"props":34901,"children":34902},{"style":163},[34903],{"type":34,"value":166},{"type":29,"tag":88,"props":34905,"children":34906},{"style":157},[34907],{"type":34,"value":15955},{"type":29,"tag":88,"props":34909,"children":34910},{"style":122},[34911],{"type":34,"value":424},{"type":29,"tag":88,"props":34913,"children":34914},{"class":90,"line":436},[34915],{"type":29,"tag":88,"props":34916,"children":34917},{"style":122},[34918],{"type":34,"value":433},{"type":29,"tag":88,"props":34920,"children":34921},{"class":90,"line":767},[34922],{"type":29,"tag":88,"props":34923,"children":34924},{"emptyLinePlaceholder":13},[34925],{"type":34,"value":134},{"type":29,"tag":88,"props":34927,"children":34928},{"class":90,"line":792},[34929,34933],{"type":29,"tag":88,"props":34930,"children":34931},{"style":1974},[34932],{"type":34,"value":3302},{"type":29,"tag":88,"props":34934,"children":34935},{"style":1980},[34936],{"type":34,"value":3307},{"type":29,"tag":88,"props":34938,"children":34939},{"class":90,"line":817},[34940,34944,34948,34952,34956],{"type":29,"tag":88,"props":34941,"children":34942},{"style":105},[34943],{"type":34,"value":276},{"type":29,"tag":88,"props":34945,"children":34946},{"style":105},[34947],{"type":34,"value":8608},{"type":29,"tag":88,"props":34949,"children":34950},{"style":174},[34951],{"type":34,"value":32189},{"type":29,"tag":88,"props":34953,"children":34954},{"style":122},[34955],{"type":34,"value":1470},{"type":29,"tag":88,"props":34957,"children":34958},{"style":122},[34959],{"type":34,"value":125},{"type":29,"tag":88,"props":34961,"children":34962},{"class":90,"line":825},[34963,34967,34971,34975,34979],{"type":29,"tag":88,"props":34964,"children":34965},{"style":105},[34966],{"type":34,"value":415},{"type":29,"tag":88,"props":34968,"children":34969},{"style":157},[34970],{"type":34,"value":15882},{"type":29,"tag":88,"props":34972,"children":34973},{"style":163},[34974],{"type":34,"value":8709},{"type":29,"tag":88,"props":34976,"children":34977},{"style":157},[34978],{"type":34,"value":15955},{"type":29,"tag":88,"props":34980,"children":34981},{"style":122},[34982],{"type":34,"value":424},{"type":29,"tag":88,"props":34984,"children":34985},{"class":90,"line":869},[34986],{"type":29,"tag":88,"props":34987,"children":34988},{"style":122},[34989],{"type":34,"value":433},{"type":29,"tag":88,"props":34991,"children":34992},{"class":90,"line":900},[34993],{"type":29,"tag":88,"props":34994,"children":34995},{"style":122},[34996],{"type":34,"value":442},{"type":29,"tag":88,"props":34998,"children":34999},{"class":90,"line":929},[35000],{"type":29,"tag":88,"props":35001,"children":35002},{"emptyLinePlaceholder":13},[35003],{"type":34,"value":134},{"type":29,"tag":88,"props":35005,"children":35006},{"class":90,"line":937},[35007,35011,35015,35019,35023,35027],{"type":29,"tag":88,"props":35008,"children":35009},{"style":105},[35010],{"type":34,"value":108},{"type":29,"tag":88,"props":35012,"children":35013},{"style":105},[35014],{"type":34,"value":113},{"type":29,"tag":88,"props":35016,"children":35017},{"style":116},[35018],{"type":34,"value":32300},{"type":29,"tag":88,"props":35020,"children":35021},{"style":105},[35022],{"type":34,"value":1134},{"type":29,"tag":88,"props":35024,"children":35025},{"style":116},[35026],{"type":34,"value":34708},{"type":29,"tag":88,"props":35028,"children":35029},{"style":122},[35030],{"type":34,"value":125},{"type":29,"tag":88,"props":35032,"children":35033},{"class":90,"line":945},[35034,35038,35042,35046],{"type":29,"tag":88,"props":35035,"children":35036},{"style":105},[35037],{"type":34,"value":143},{"type":29,"tag":88,"props":35039,"children":35040},{"style":105},[35041],{"type":34,"value":8608},{"type":29,"tag":88,"props":35043,"children":35044},{"style":157},[35045],{"type":34,"value":32343},{"type":29,"tag":88,"props":35047,"children":35048},{"style":122},[35049],{"type":34,"value":424},{"type":29,"tag":88,"props":35051,"children":35052},{"class":90,"line":981},[35053],{"type":29,"tag":88,"props":35054,"children":35055},{"emptyLinePlaceholder":13},[35056],{"type":34,"value":134},{"type":29,"tag":88,"props":35058,"children":35059},{"class":90,"line":1021},[35060,35064,35068,35072,35076,35080,35084],{"type":29,"tag":88,"props":35061,"children":35062},{"style":105},[35063],{"type":34,"value":276},{"type":29,"tag":88,"props":35065,"children":35066},{"style":174},[35067],{"type":34,"value":32300},{"type":29,"tag":88,"props":35069,"children":35070},{"style":122},[35071],{"type":34,"value":181},{"type":29,"tag":88,"props":35073,"children":35074},{"style":105},[35075],{"type":34,"value":8622},{"type":29,"tag":88,"props":35077,"children":35078},{"style":298},[35079],{"type":34,"value":32343},{"type":29,"tag":88,"props":35081,"children":35082},{"style":122},[35083],{"type":34,"value":306},{"type":29,"tag":88,"props":35085,"children":35086},{"style":122},[35087],{"type":34,"value":125},{"type":29,"tag":88,"props":35089,"children":35090},{"class":90,"line":1066},[35091,35095,35099,35103,35107,35111],{"type":29,"tag":88,"props":35092,"children":35093},{"style":873},[35094],{"type":34,"value":876},{"type":29,"tag":88,"props":35096,"children":35097},{"style":122},[35098],{"type":34,"value":338},{"type":29,"tag":88,"props":35100,"children":35101},{"style":157},[35102],{"type":34,"value":33761},{"type":29,"tag":88,"props":35104,"children":35105},{"style":163},[35106],{"type":34,"value":166},{"type":29,"tag":88,"props":35108,"children":35109},{"style":157},[35110],{"type":34,"value":32343},{"type":29,"tag":88,"props":35112,"children":35113},{"style":122},[35114],{"type":34,"value":424},{"type":29,"tag":88,"props":35116,"children":35117},{"class":90,"line":1082},[35118],{"type":29,"tag":88,"props":35119,"children":35120},{"style":122},[35121],{"type":34,"value":433},{"type":29,"tag":88,"props":35123,"children":35124},{"class":90,"line":1090},[35125],{"type":29,"tag":88,"props":35126,"children":35127},{"emptyLinePlaceholder":13},[35128],{"type":34,"value":134},{"type":29,"tag":88,"props":35130,"children":35131},{"class":90,"line":1098},[35132,35136],{"type":29,"tag":88,"props":35133,"children":35134},{"style":1974},[35135],{"type":34,"value":3302},{"type":29,"tag":88,"props":35137,"children":35138},{"style":1980},[35139],{"type":34,"value":3307},{"type":29,"tag":88,"props":35141,"children":35142},{"class":90,"line":1106},[35143,35147,35151,35155,35159],{"type":29,"tag":88,"props":35144,"children":35145},{"style":105},[35146],{"type":34,"value":276},{"type":29,"tag":88,"props":35148,"children":35149},{"style":105},[35150],{"type":34,"value":8608},{"type":29,"tag":88,"props":35152,"children":35153},{"style":174},[35154],{"type":34,"value":32189},{"type":29,"tag":88,"props":35156,"children":35157},{"style":122},[35158],{"type":34,"value":1470},{"type":29,"tag":88,"props":35160,"children":35161},{"style":122},[35162],{"type":34,"value":125},{"type":29,"tag":88,"props":35164,"children":35165},{"class":90,"line":1115},[35166,35170,35175,35179,35183],{"type":29,"tag":88,"props":35167,"children":35168},{"style":105},[35169],{"type":34,"value":415},{"type":29,"tag":88,"props":35171,"children":35172},{"style":157},[35173],{"type":34,"value":35174}," taille ",{"type":29,"tag":88,"props":35176,"children":35177},{"style":163},[35178],{"type":34,"value":8709},{"type":29,"tag":88,"props":35180,"children":35181},{"style":157},[35182],{"type":34,"value":32343},{"type":29,"tag":88,"props":35184,"children":35185},{"style":122},[35186],{"type":34,"value":424},{"type":29,"tag":88,"props":35188,"children":35189},{"class":90,"line":11},[35190],{"type":29,"tag":88,"props":35191,"children":35192},{"style":122},[35193],{"type":34,"value":433},{"type":29,"tag":88,"props":35195,"children":35196},{"class":90,"line":1180},[35197],{"type":29,"tag":88,"props":35198,"children":35199},{"style":122},[35200],{"type":34,"value":442},{"type":29,"tag":10576,"props":35202,"children":35204},{"id":35203},"exemple-dutilisation",[35205],{"type":34,"value":35206},"Exemple d'utilisation :",{"type":29,"tag":77,"props":35208,"children":35210},{"className":81,"code":35209,"language":80,"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);  \u002F\u002F Aire calculée : 50\n        afficherAire(carre);      \u002F\u002F Aire calculée : 25\n    }\n}\n",[35211],{"type":29,"tag":84,"props":35212,"children":35213},{"__ignoreMap":8},[35214,35233,35240,35281,35333,35340,35347,35390,35435,35470,35477,35503,35527,35534],{"type":29,"tag":88,"props":35215,"children":35216},{"class":90,"line":91},[35217,35221,35225,35229],{"type":29,"tag":88,"props":35218,"children":35219},{"style":105},[35220],{"type":34,"value":108},{"type":29,"tag":88,"props":35222,"children":35223},{"style":105},[35224],{"type":34,"value":113},{"type":29,"tag":88,"props":35226,"children":35227},{"style":116},[35228],{"type":34,"value":21224},{"type":29,"tag":88,"props":35230,"children":35231},{"style":122},[35232],{"type":34,"value":125},{"type":29,"tag":88,"props":35234,"children":35235},{"class":90,"line":101},[35236],{"type":29,"tag":88,"props":35237,"children":35238},{"emptyLinePlaceholder":13},[35239],{"type":34,"value":134},{"type":29,"tag":88,"props":35241,"children":35242},{"class":90,"line":128},[35243,35247,35251,35255,35260,35264,35268,35273,35277],{"type":29,"tag":88,"props":35244,"children":35245},{"style":105},[35246],{"type":34,"value":276},{"type":29,"tag":88,"props":35248,"children":35249},{"style":105},[35250],{"type":34,"value":12248},{"type":29,"tag":88,"props":35252,"children":35253},{"style":105},[35254],{"type":34,"value":1303},{"type":29,"tag":88,"props":35256,"children":35257},{"style":174},[35258],{"type":34,"value":35259}," afficherAire",{"type":29,"tag":88,"props":35261,"children":35262},{"style":122},[35263],{"type":34,"value":181},{"type":29,"tag":88,"props":35265,"children":35266},{"style":151},[35267],{"type":34,"value":31731},{"type":29,"tag":88,"props":35269,"children":35270},{"style":298},[35271],{"type":34,"value":35272}," forme",{"type":29,"tag":88,"props":35274,"children":35275},{"style":122},[35276],{"type":34,"value":306},{"type":29,"tag":88,"props":35278,"children":35279},{"style":122},[35280],{"type":34,"value":125},{"type":29,"tag":88,"props":35282,"children":35283},{"class":90,"line":137},[35284,35288,35292,35296,35300,35304,35308,35313,35317,35321,35325,35329],{"type":29,"tag":88,"props":35285,"children":35286},{"style":157},[35287],{"type":34,"value":19726},{"type":29,"tag":88,"props":35289,"children":35290},{"style":122},[35291],{"type":34,"value":338},{"type":29,"tag":88,"props":35293,"children":35294},{"style":157},[35295],{"type":34,"value":18091},{"type":29,"tag":88,"props":35297,"children":35298},{"style":122},[35299],{"type":34,"value":338},{"type":29,"tag":88,"props":35301,"children":35302},{"style":174},[35303],{"type":34,"value":18100},{"type":29,"tag":88,"props":35305,"children":35306},{"style":122},[35307],{"type":34,"value":181},{"type":29,"tag":88,"props":35309,"children":35310},{"style":184},[35311],{"type":34,"value":35312},"\"Aire calculée : \"",{"type":29,"tag":88,"props":35314,"children":35315},{"style":163},[35316],{"type":34,"value":5485},{"type":29,"tag":88,"props":35318,"children":35319},{"style":157},[35320],{"type":34,"value":35272},{"type":29,"tag":88,"props":35322,"children":35323},{"style":122},[35324],{"type":34,"value":338},{"type":29,"tag":88,"props":35326,"children":35327},{"style":174},[35328],{"type":34,"value":32812},{"type":29,"tag":88,"props":35330,"children":35331},{"style":122},[35332],{"type":34,"value":2958},{"type":29,"tag":88,"props":35334,"children":35335},{"class":90,"line":211},[35336],{"type":29,"tag":88,"props":35337,"children":35338},{"style":122},[35339],{"type":34,"value":433},{"type":29,"tag":88,"props":35341,"children":35342},{"class":90,"line":262},[35343],{"type":29,"tag":88,"props":35344,"children":35345},{"emptyLinePlaceholder":13},[35346],{"type":34,"value":134},{"type":29,"tag":88,"props":35348,"children":35349},{"class":90,"line":270},[35350,35354,35358,35362,35366,35370,35374,35378,35382,35386],{"type":29,"tag":88,"props":35351,"children":35352},{"style":105},[35353],{"type":34,"value":276},{"type":29,"tag":88,"props":35355,"children":35356},{"style":105},[35357],{"type":34,"value":12248},{"type":29,"tag":88,"props":35359,"children":35360},{"style":105},[35361],{"type":34,"value":1303},{"type":29,"tag":88,"props":35363,"children":35364},{"style":174},[35365],{"type":34,"value":21248},{"type":29,"tag":88,"props":35367,"children":35368},{"style":122},[35369],{"type":34,"value":181},{"type":29,"tag":88,"props":35371,"children":35372},{"style":105},[35373],{"type":34,"value":695},{"type":29,"tag":88,"props":35375,"children":35376},{"style":122},[35377],{"type":34,"value":21261},{"type":29,"tag":88,"props":35379,"children":35380},{"style":298},[35381],{"type":34,"value":21266},{"type":29,"tag":88,"props":35383,"children":35384},{"style":122},[35385],{"type":34,"value":306},{"type":29,"tag":88,"props":35387,"children":35388},{"style":122},[35389],{"type":34,"value":125},{"type":29,"tag":88,"props":35391,"children":35392},{"class":90,"line":313},[35393,35398,35403,35407,35411,35415,35419,35423,35427,35431],{"type":29,"tag":88,"props":35394,"children":35395},{"style":151},[35396],{"type":34,"value":35397},"        Forme",{"type":29,"tag":88,"props":35399,"children":35400},{"style":157},[35401],{"type":34,"value":35402}," rectangle ",{"type":29,"tag":88,"props":35404,"children":35405},{"style":163},[35406],{"type":34,"value":166},{"type":29,"tag":88,"props":35408,"children":35409},{"style":105},[35410],{"type":34,"value":171},{"type":29,"tag":88,"props":35412,"children":35413},{"style":174},[35414],{"type":34,"value":21642},{"type":29,"tag":88,"props":35416,"children":35417},{"style":122},[35418],{"type":34,"value":181},{"type":29,"tag":88,"props":35420,"children":35421},{"style":195},[35422],{"type":34,"value":32750},{"type":29,"tag":88,"props":35424,"children":35425},{"style":122},[35426],{"type":34,"value":192},{"type":29,"tag":88,"props":35428,"children":35429},{"style":195},[35430],{"type":34,"value":16138},{"type":29,"tag":88,"props":35432,"children":35433},{"style":122},[35434],{"type":34,"value":357},{"type":29,"tag":88,"props":35436,"children":35437},{"class":90,"line":360},[35438,35442,35446,35450,35454,35458,35462,35466],{"type":29,"tag":88,"props":35439,"children":35440},{"style":151},[35441],{"type":34,"value":35397},{"type":29,"tag":88,"props":35443,"children":35444},{"style":157},[35445],{"type":34,"value":33020},{"type":29,"tag":88,"props":35447,"children":35448},{"style":163},[35449],{"type":34,"value":166},{"type":29,"tag":88,"props":35451,"children":35452},{"style":105},[35453],{"type":34,"value":171},{"type":29,"tag":88,"props":35455,"children":35456},{"style":174},[35457],{"type":34,"value":32300},{"type":29,"tag":88,"props":35459,"children":35460},{"style":122},[35461],{"type":34,"value":181},{"type":29,"tag":88,"props":35463,"children":35464},{"style":195},[35465],{"type":34,"value":32750},{"type":29,"tag":88,"props":35467,"children":35468},{"style":122},[35469],{"type":34,"value":357},{"type":29,"tag":88,"props":35471,"children":35472},{"class":90,"line":409},[35473],{"type":29,"tag":88,"props":35474,"children":35475},{"emptyLinePlaceholder":13},[35476],{"type":34,"value":134},{"type":29,"tag":88,"props":35478,"children":35479},{"class":90,"line":427},[35480,35485,35489,35494,35498],{"type":29,"tag":88,"props":35481,"children":35482},{"style":174},[35483],{"type":34,"value":35484},"        afficherAire",{"type":29,"tag":88,"props":35486,"children":35487},{"style":122},[35488],{"type":34,"value":181},{"type":29,"tag":88,"props":35490,"children":35491},{"style":157},[35492],{"type":34,"value":35493},"rectangle",{"type":29,"tag":88,"props":35495,"children":35496},{"style":122},[35497],{"type":34,"value":203},{"type":29,"tag":88,"props":35499,"children":35500},{"style":95},[35501],{"type":34,"value":35502},"  \u002F\u002F Aire calculée : 50\n",{"type":29,"tag":88,"props":35504,"children":35505},{"class":90,"line":436},[35506,35510,35514,35518,35522],{"type":29,"tag":88,"props":35507,"children":35508},{"style":174},[35509],{"type":34,"value":35484},{"type":29,"tag":88,"props":35511,"children":35512},{"style":122},[35513],{"type":34,"value":181},{"type":29,"tag":88,"props":35515,"children":35516},{"style":157},[35517],{"type":34,"value":33060},{"type":29,"tag":88,"props":35519,"children":35520},{"style":122},[35521],{"type":34,"value":203},{"type":29,"tag":88,"props":35523,"children":35524},{"style":95},[35525],{"type":34,"value":35526},"      \u002F\u002F Aire calculée : 25\n",{"type":29,"tag":88,"props":35528,"children":35529},{"class":90,"line":767},[35530],{"type":29,"tag":88,"props":35531,"children":35532},{"style":122},[35533],{"type":34,"value":433},{"type":29,"tag":88,"props":35535,"children":35536},{"class":90,"line":792},[35537],{"type":29,"tag":88,"props":35538,"children":35539},{"style":122},[35540],{"type":34,"value":442},{"type":29,"tag":47,"props":35542,"children":35543},{},[],{"type":29,"tag":51,"props":35545,"children":35547},{"id":35546},"conclusion-et-conseils-pratiques",[35548],{"type":34,"value":35549},"Conclusion et conseils pratiques",{"type":29,"tag":30,"props":35551,"children":35552},{},[35553],{"type":34,"value":35554},"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":29,"tag":8542,"props":35556,"children":35558},{"id":35557},"récapitulatif-des-points-clés",[35559],{"type":34,"value":35560},"Récapitulatif des points clés :",{"type":29,"tag":453,"props":35562,"children":35563},{},[35564,35569,35574],{"type":29,"tag":457,"props":35565,"children":35566},{},[35567],{"type":34,"value":35568},"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":29,"tag":457,"props":35570,"children":35571},{},[35572],{"type":34,"value":35573},"Une sous-classe qui modifie les règles d'une classe parente brise le LSP.",{"type":29,"tag":457,"props":35575,"children":35576},{},[35577],{"type":34,"value":35578},"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":29,"tag":8542,"props":35580,"children":35582},{"id":35581},"conseils-pratiques",[35583],{"type":34,"value":35584},"Conseils pratiques :",{"type":29,"tag":453,"props":35586,"children":35587},{},[35588,35593,35598],{"type":29,"tag":457,"props":35589,"children":35590},{},[35591],{"type":34,"value":35592},"Testez régulièrement votre code pour vérifier que les sous-classes respectent bien le comportement des classes parentes.",{"type":29,"tag":457,"props":35594,"children":35595},{},[35596],{"type":34,"value":35597},"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":29,"tag":457,"props":35599,"children":35600},{},[35601],{"type":34,"value":35602},"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":29,"tag":47,"props":35604,"children":35605},{},[],{"type":29,"tag":2288,"props":35607,"children":35609},{"cta":5629,"href":5630,"title":35608,"type":5632},"Le LSP n'est qu'une pratique parmi 100 pour concevoir une hiérarchie qui tient",[35610],{"type":29,"tag":30,"props":35611,"children":35612},{},[35613],{"type":34,"value":35614},"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":29,"tag":47,"props":35616,"children":35617},{},[],{"type":29,"tag":51,"props":35619,"children":35621},{"id":35620},"faq-sur-le-principe-de-substitution-de-liskov-lsp",[35622],{"type":34,"value":35623},"FAQ sur le principe de substitution de Liskov (LSP)",{"type":29,"tag":5649,"props":35625,"children":35626},{},[35627,35632],{"type":29,"tag":5653,"props":35628,"children":35629},{},[35630],{"type":34,"value":35631},"1. Qu’est-ce que le LSP exactement ?",{"type":29,"tag":30,"props":35633,"children":35634},{},[35635],{"type":34,"value":35636},"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":29,"tag":5649,"props":35638,"children":35639},{},[35640,35645],{"type":29,"tag":5653,"props":35641,"children":35642},{},[35643],{"type":34,"value":35644},"2. Pourquoi est-ce que je dois respecter le LSP ?",{"type":29,"tag":30,"props":35646,"children":35647},{},[35648],{"type":34,"value":35649},"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":29,"tag":5649,"props":35651,"children":35652},{},[35653,35658,35663],{"type":29,"tag":5653,"props":35654,"children":35655},{},[35656],{"type":34,"value":35657},"3. Quels sont les signes indiquant que mon code ne respecte pas le LSP ?",{"type":29,"tag":30,"props":35659,"children":35660},{},[35661],{"type":34,"value":35662},"Voici quelques indices de violation du LSP :",{"type":29,"tag":453,"props":35664,"children":35665},{},[35666,35671,35676],{"type":29,"tag":457,"props":35667,"children":35668},{},[35669],{"type":34,"value":35670},"Ta sous-classe modifie ou redéfinit des méthodes de la classe parente de manière inattendue.",{"type":29,"tag":457,"props":35672,"children":35673},{},[35674],{"type":34,"value":35675},"Vous devez modifier le code existant lorsque vous ajoutez une nouvelle sous-classe.",{"type":29,"tag":457,"props":35677,"children":35678},{},[35679],{"type":34,"value":35680},"La sous-classe ne respecte pas les propriétés définies par la classe parente.",{"type":29,"tag":5649,"props":35682,"children":35683},{},[35684,35689],{"type":29,"tag":5653,"props":35685,"children":35686},{},[35687],{"type":34,"value":35688},"4. Quelle est la différence entre l’héritage classique et l’application du LSP ?",{"type":29,"tag":30,"props":35690,"children":35691},{},[35692],{"type":34,"value":35693},"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":29,"tag":5649,"props":35695,"children":35696},{},[35697,35702],{"type":29,"tag":5653,"props":35698,"children":35699},{},[35700],{"type":34,"value":35701},"5. Est-ce que le LSP est toujours applicable ?",{"type":29,"tag":30,"props":35703,"children":35704},{},[35705],{"type":34,"value":35706},"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":29,"tag":5649,"props":35708,"children":35709},{},[35710,35715],{"type":29,"tag":5653,"props":35711,"children":35712},{},[35713],{"type":34,"value":35714},"6. Comment tester si mon code respecte le LSP ?",{"type":29,"tag":30,"props":35716,"children":35717},{},[35718],{"type":34,"value":35719},"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":29,"tag":5649,"props":35721,"children":35722},{},[35723,35728],{"type":29,"tag":5653,"props":35724,"children":35725},{},[35726],{"type":34,"value":35727},"7. Quelles sont les alternatives si je n’arrive pas à respecter le LSP dans mon code ?",{"type":29,"tag":30,"props":35729,"children":35730},{},[35731],{"type":34,"value":35732},"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":29,"tag":47,"props":35734,"children":35735},{},[],{"type":29,"tag":2288,"props":35737,"children":35738},{"cta":31609,"href":10075,"title":31610,"type":5755},[35739],{"type":29,"tag":30,"props":35740,"children":35741},{},[35742],{"type":34,"value":31616},{"type":29,"tag":5763,"props":35744,"children":35745},{},[35746],{"type":34,"value":5767},{"title":8,"searchDepth":101,"depth":101,"links":35748},[35749,35750,35753,35754,35758,35762],{"id":31660,"depth":101,"text":31663},{"id":31695,"depth":101,"text":31698,"children":35751},[35752],{"id":31771,"depth":128,"text":31774},{"id":31800,"depth":101,"text":31803},{"id":33150,"depth":101,"text":33153,"children":35755},[35756,35757],{"id":34627,"depth":128,"text":34630},{"id":34664,"depth":128,"text":34667},{"id":35546,"depth":101,"text":35549,"children":35759},[35760,35761],{"id":35557,"depth":128,"text":35560},{"id":35581,"depth":128,"text":35584},{"id":35620,"depth":101,"text":35623},"content:fr:architecture-craft:principe-substitution-liskov-lsp-java.md","fr\u002Farchitecture-craft\u002Fprincipe-substitution-liskov-lsp-java.md","fr\u002Farchitecture-craft\u002Fprincipe-substitution-liskov-lsp-java",{"_path":19448,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":35767,"description":35768,"id":1451,"date":35769,"listed":13,"nocomments":7,"hidden":7,"categories":35770,"tags":35771,"cover":35772,"readingTime":35773,"body":35777,"_type":5777,"_id":37877,"_source":5779,"_file":37878,"_stem":37879,"_extension":5782},"Principe OCP en Software Craftsmanship, Guide Complet et Exemples Java","Découvrez comment appliquer le principe OCP (Open\u002FClosed Principle) en Software Craftsmanship. Apprenez avec des exemples concrets en Java à rendre...","2024-01-31",[6],[16,8453],"covers\u002Farticles\u002Fprincipe-ocp.jpg",{"text":21,"minutes":35774,"time":35775,"words":35776},8.565,513900,1713,{"type":26,"children":35778,"toc":37863},[35779,35785,35790,35802,35813,35816,35822,35845,35850,35863,35868,35874,35894,36285,36297,36320,36325,36331,36336,36870,36889,37004,37009,37017,37020,37029,37035,37062,37095,37103,37121,37124,37130,37135,37141,37146,37151,37646,37658,37666,37669,37675,37680,37724,37737,37750,37753,37759,37764,37781,37790,37793,37797,37810,37823,37836,37849,37852,37859],{"type":29,"tag":51,"props":35780,"children":35782},{"id":35781},"introduction",[35783],{"type":34,"value":35784},"Introduction",{"type":29,"tag":30,"props":35786,"children":35787},{},[35788],{"type":34,"value":35789},"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":29,"tag":30,"props":35791,"children":35792},{},[35793,35795,35800],{"type":34,"value":35794},"Le principe OCP (Open\u002FClosed 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":29,"tag":8474,"props":35796,"children":35797},{},[35798],{"type":34,"value":35799},"Object-Oriented Software Construction",{"type":34,"value":35801}," (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":29,"tag":30,"props":35803,"children":35804},{},[35805,35807,35811],{"type":34,"value":35806},"Cet article explique ce que recouvre vraiment OCP, son rôle en ",{"type":29,"tag":63,"props":35808,"children":35809},{"href":10180},[35810],{"type":34,"value":16975},{"type":34,"value":35812},", et comment l'appliquer dans des projets Java. Exemples de code à l'appui, avec les pièges classiques à éviter.",{"type":29,"tag":47,"props":35814,"children":35815},{},[],{"type":29,"tag":51,"props":35817,"children":35819},{"id":35818},"quest-ce-que-le-principe-ocp-openclosed-principle",[35820],{"type":34,"value":35821},"Qu’est-ce que le Principe OCP (Open\u002FClosed Principle) ?",{"type":29,"tag":30,"props":35823,"children":35824},{},[35825,35827,35831,35833,35838,35839,35844],{"type":34,"value":35826},"Le principe OCP fait partie des cinq ",{"type":29,"tag":63,"props":35828,"children":35829},{"href":9965},[35830],{"type":34,"value":9968},{"type":34,"value":35832},", qui sont des règles fondamentales pour concevoir du code propre, maintenable et évolutif. OCP signifie \"Ouvert\u002FFermé\", en référence à l'idée que les entités (classes, modules, fonctions) doivent être ",{"type":29,"tag":447,"props":35834,"children":35835},{},[35836],{"type":34,"value":35837},"ouvertes à l’extension",{"type":34,"value":20297},{"type":29,"tag":447,"props":35840,"children":35841},{},[35842],{"type":34,"value":35843},"fermées à la modification",{"type":34,"value":338},{"type":29,"tag":30,"props":35846,"children":35847},{},[35848],{"type":34,"value":35849},"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":29,"tag":8526,"props":35851,"children":35852},{"type":8528},[35853],{"type":29,"tag":30,"props":35854,"children":35855},{},[35856,35861],{"type":29,"tag":447,"props":35857,"children":35858},{},[35859],{"type":34,"value":35860},"Anticipez les axes d'extension qui ont déjà été identifiés",{"type":34,"value":35862}," 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":29,"tag":30,"props":35864,"children":35865},{},[35866],{"type":34,"value":35867},"Prenons un exemple concret pour illustrer cela.",{"type":29,"tag":8542,"props":35869,"children":35871},{"id":35870},"exemple-1-cas-classique-sans-ocp",[35872],{"type":34,"value":35873},"Exemple 1 : Cas classique sans OCP",{"type":29,"tag":30,"props":35875,"children":35876},{},[35877,35879,35884,35886,35892],{"type":34,"value":35878},"Imaginons que vous développez une application qui calcule les salaires d'employés. Vous avez une classe ",{"type":29,"tag":84,"props":35880,"children":35882},{"className":35881},[],[35883],{"type":34,"value":9538},{"type":34,"value":35885}," avec une méthode ",{"type":29,"tag":84,"props":35887,"children":35889},{"className":35888},[],[35890],{"type":34,"value":35891},"calculateSalary()",{"type":34,"value":35893}," qui calcule le salaire en fonction du type d'employé.",{"type":29,"tag":77,"props":35895,"children":35897},{"className":81,"code":35896,"language":80,"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",[35898],{"type":29,"tag":84,"props":35899,"children":35900},{"__ignoreMap":8},[35901,35916,35935,35955,35962,36005,36033,36061,36068,36075,36098,36138,36162,36210,36234,36249,36264,36271,36278],{"type":29,"tag":88,"props":35902,"children":35903},{"class":90,"line":91},[35904,35908,35912],{"type":29,"tag":88,"props":35905,"children":35906},{"style":105},[35907],{"type":34,"value":1225},{"type":29,"tag":88,"props":35909,"children":35910},{"style":116},[35911],{"type":34,"value":10627},{"type":29,"tag":88,"props":35913,"children":35914},{"style":122},[35915],{"type":34,"value":125},{"type":29,"tag":88,"props":35917,"children":35918},{"class":90,"line":101},[35919,35923,35927,35931],{"type":29,"tag":88,"props":35920,"children":35921},{"style":105},[35922],{"type":34,"value":143},{"type":29,"tag":88,"props":35924,"children":35925},{"style":151},[35926],{"type":34,"value":281},{"type":29,"tag":88,"props":35928,"children":35929},{"style":157},[35930],{"type":34,"value":20398},{"type":29,"tag":88,"props":35932,"children":35933},{"style":122},[35934],{"type":34,"value":424},{"type":29,"tag":88,"props":35936,"children":35937},{"class":90,"line":128},[35938,35942,35946,35951],{"type":29,"tag":88,"props":35939,"children":35940},{"style":105},[35941],{"type":34,"value":143},{"type":29,"tag":88,"props":35943,"children":35944},{"style":105},[35945],{"type":34,"value":10663},{"type":29,"tag":88,"props":35947,"children":35948},{"style":157},[35949],{"type":34,"value":35950}," baseSalary",{"type":29,"tag":88,"props":35952,"children":35953},{"style":122},[35954],{"type":34,"value":424},{"type":29,"tag":88,"props":35956,"children":35957},{"class":90,"line":137},[35958],{"type":29,"tag":88,"props":35959,"children":35960},{"emptyLinePlaceholder":13},[35961],{"type":34,"value":134},{"type":29,"tag":88,"props":35963,"children":35964},{"class":90,"line":211},[35965,35969,35973,35977,35981,35985,35989,35993,35997,36001],{"type":29,"tag":88,"props":35966,"children":35967},{"style":105},[35968],{"type":34,"value":276},{"type":29,"tag":88,"props":35970,"children":35971},{"style":174},[35972],{"type":34,"value":10627},{"type":29,"tag":88,"props":35974,"children":35975},{"style":122},[35976],{"type":34,"value":181},{"type":29,"tag":88,"props":35978,"children":35979},{"style":151},[35980],{"type":34,"value":695},{"type":29,"tag":88,"props":35982,"children":35983},{"style":298},[35984],{"type":34,"value":20398},{"type":29,"tag":88,"props":35986,"children":35987},{"style":122},[35988],{"type":34,"value":192},{"type":29,"tag":88,"props":35990,"children":35991},{"style":105},[35992],{"type":34,"value":10663},{"type":29,"tag":88,"props":35994,"children":35995},{"style":298},[35996],{"type":34,"value":35950},{"type":29,"tag":88,"props":35998,"children":35999},{"style":122},[36000],{"type":34,"value":306},{"type":29,"tag":88,"props":36002,"children":36003},{"style":122},[36004],{"type":34,"value":125},{"type":29,"tag":88,"props":36006,"children":36007},{"class":90,"line":262},[36008,36012,36016,36021,36025,36029],{"type":29,"tag":88,"props":36009,"children":36010},{"style":873},[36011],{"type":34,"value":876},{"type":29,"tag":88,"props":36013,"children":36014},{"style":122},[36015],{"type":34,"value":338},{"type":29,"tag":88,"props":36017,"children":36018},{"style":157},[36019],{"type":34,"value":36020},"type ",{"type":29,"tag":88,"props":36022,"children":36023},{"style":163},[36024],{"type":34,"value":166},{"type":29,"tag":88,"props":36026,"children":36027},{"style":157},[36028],{"type":34,"value":20398},{"type":29,"tag":88,"props":36030,"children":36031},{"style":122},[36032],{"type":34,"value":424},{"type":29,"tag":88,"props":36034,"children":36035},{"class":90,"line":270},[36036,36040,36044,36049,36053,36057],{"type":29,"tag":88,"props":36037,"children":36038},{"style":873},[36039],{"type":34,"value":876},{"type":29,"tag":88,"props":36041,"children":36042},{"style":122},[36043],{"type":34,"value":338},{"type":29,"tag":88,"props":36045,"children":36046},{"style":157},[36047],{"type":34,"value":36048},"baseSalary ",{"type":29,"tag":88,"props":36050,"children":36051},{"style":163},[36052],{"type":34,"value":166},{"type":29,"tag":88,"props":36054,"children":36055},{"style":157},[36056],{"type":34,"value":35950},{"type":29,"tag":88,"props":36058,"children":36059},{"style":122},[36060],{"type":34,"value":424},{"type":29,"tag":88,"props":36062,"children":36063},{"class":90,"line":313},[36064],{"type":29,"tag":88,"props":36065,"children":36066},{"style":122},[36067],{"type":34,"value":433},{"type":29,"tag":88,"props":36069,"children":36070},{"class":90,"line":360},[36071],{"type":29,"tag":88,"props":36072,"children":36073},{"emptyLinePlaceholder":13},[36074],{"type":34,"value":134},{"type":29,"tag":88,"props":36076,"children":36077},{"class":90,"line":409},[36078,36082,36086,36090,36094],{"type":29,"tag":88,"props":36079,"children":36080},{"style":105},[36081],{"type":34,"value":276},{"type":29,"tag":88,"props":36083,"children":36084},{"style":105},[36085],{"type":34,"value":10663},{"type":29,"tag":88,"props":36087,"children":36088},{"style":174},[36089],{"type":34,"value":12017},{"type":29,"tag":88,"props":36091,"children":36092},{"style":122},[36093],{"type":34,"value":1470},{"type":29,"tag":88,"props":36095,"children":36096},{"style":122},[36097],{"type":34,"value":125},{"type":29,"tag":88,"props":36099,"children":36100},{"class":90,"line":427},[36101,36105,36109,36113,36117,36121,36125,36130,36134],{"type":29,"tag":88,"props":36102,"children":36103},{"style":105},[36104],{"type":34,"value":2886},{"type":29,"tag":88,"props":36106,"children":36107},{"style":122},[36108],{"type":34,"value":2891},{"type":29,"tag":88,"props":36110,"children":36111},{"style":157},[36112],{"type":34,"value":20422},{"type":29,"tag":88,"props":36114,"children":36115},{"style":122},[36116],{"type":34,"value":338},{"type":29,"tag":88,"props":36118,"children":36119},{"style":174},[36120],{"type":34,"value":20431},{"type":29,"tag":88,"props":36122,"children":36123},{"style":122},[36124],{"type":34,"value":181},{"type":29,"tag":88,"props":36126,"children":36127},{"style":184},[36128],{"type":34,"value":36129},"\"Manager\"",{"type":29,"tag":88,"props":36131,"children":36132},{"style":122},[36133],{"type":34,"value":16195},{"type":29,"tag":88,"props":36135,"children":36136},{"style":122},[36137],{"type":34,"value":125},{"type":29,"tag":88,"props":36139,"children":36140},{"class":90,"line":436},[36141,36145,36150,36154,36158],{"type":29,"tag":88,"props":36142,"children":36143},{"style":105},[36144],{"type":34,"value":8100},{"type":29,"tag":88,"props":36146,"children":36147},{"style":157},[36148],{"type":34,"value":36149}," baseSalary ",{"type":29,"tag":88,"props":36151,"children":36152},{"style":163},[36153],{"type":34,"value":8709},{"type":29,"tag":88,"props":36155,"children":36156},{"style":195},[36157],{"type":34,"value":9193},{"type":29,"tag":88,"props":36159,"children":36160},{"style":122},[36161],{"type":34,"value":424},{"type":29,"tag":88,"props":36163,"children":36164},{"class":90,"line":767},[36165,36169,36173,36177,36181,36185,36189,36193,36197,36202,36206],{"type":29,"tag":88,"props":36166,"children":36167},{"style":122},[36168],{"type":34,"value":8169},{"type":29,"tag":88,"props":36170,"children":36171},{"style":105},[36172],{"type":34,"value":16544},{"type":29,"tag":88,"props":36174,"children":36175},{"style":105},[36176],{"type":34,"value":20508},{"type":29,"tag":88,"props":36178,"children":36179},{"style":122},[36180],{"type":34,"value":2891},{"type":29,"tag":88,"props":36182,"children":36183},{"style":157},[36184],{"type":34,"value":20422},{"type":29,"tag":88,"props":36186,"children":36187},{"style":122},[36188],{"type":34,"value":338},{"type":29,"tag":88,"props":36190,"children":36191},{"style":174},[36192],{"type":34,"value":20431},{"type":29,"tag":88,"props":36194,"children":36195},{"style":122},[36196],{"type":34,"value":181},{"type":29,"tag":88,"props":36198,"children":36199},{"style":184},[36200],{"type":34,"value":36201},"\"Developer\"",{"type":29,"tag":88,"props":36203,"children":36204},{"style":122},[36205],{"type":34,"value":16195},{"type":29,"tag":88,"props":36207,"children":36208},{"style":122},[36209],{"type":34,"value":125},{"type":29,"tag":88,"props":36211,"children":36212},{"class":90,"line":792},[36213,36217,36221,36225,36230],{"type":29,"tag":88,"props":36214,"children":36215},{"style":105},[36216],{"type":34,"value":8100},{"type":29,"tag":88,"props":36218,"children":36219},{"style":157},[36220],{"type":34,"value":36149},{"type":29,"tag":88,"props":36222,"children":36223},{"style":163},[36224],{"type":34,"value":8709},{"type":29,"tag":88,"props":36226,"children":36227},{"style":195},[36228],{"type":34,"value":36229}," 1.5",{"type":29,"tag":88,"props":36231,"children":36232},{"style":122},[36233],{"type":34,"value":424},{"type":29,"tag":88,"props":36235,"children":36236},{"class":90,"line":817},[36237,36241,36245],{"type":29,"tag":88,"props":36238,"children":36239},{"style":122},[36240],{"type":34,"value":8169},{"type":29,"tag":88,"props":36242,"children":36243},{"style":105},[36244],{"type":34,"value":16544},{"type":29,"tag":88,"props":36246,"children":36247},{"style":122},[36248],{"type":34,"value":125},{"type":29,"tag":88,"props":36250,"children":36251},{"class":90,"line":825},[36252,36256,36260],{"type":29,"tag":88,"props":36253,"children":36254},{"style":105},[36255],{"type":34,"value":8100},{"type":29,"tag":88,"props":36257,"children":36258},{"style":157},[36259],{"type":34,"value":35950},{"type":29,"tag":88,"props":36261,"children":36262},{"style":122},[36263],{"type":34,"value":424},{"type":29,"tag":88,"props":36265,"children":36266},{"class":90,"line":869},[36267],{"type":29,"tag":88,"props":36268,"children":36269},{"style":122},[36270],{"type":34,"value":2966},{"type":29,"tag":88,"props":36272,"children":36273},{"class":90,"line":900},[36274],{"type":29,"tag":88,"props":36275,"children":36276},{"style":122},[36277],{"type":34,"value":433},{"type":29,"tag":88,"props":36279,"children":36280},{"class":90,"line":929},[36281],{"type":29,"tag":88,"props":36282,"children":36283},{"style":122},[36284],{"type":34,"value":442},{"type":29,"tag":30,"props":36286,"children":36287},{},[36288,36290,36295],{"type":34,"value":36289},"À 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":29,"tag":84,"props":36291,"children":36293},{"className":36292},[],[36294],{"type":34,"value":35891},{"type":34,"value":36296}," 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":29,"tag":8526,"props":36298,"children":36300},{"type":36299},"WARNING",[36301],{"type":29,"tag":30,"props":36302,"children":36303},{},[36304,36306,36311,36312,36318],{"type":34,"value":36305},"** Plus votre code est rempli de conditions (comme les ",{"type":29,"tag":84,"props":36307,"children":36309},{"className":36308},[],[36310],{"type":34,"value":16120},{"type":34,"value":8982},{"type":29,"tag":84,"props":36313,"children":36315},{"className":36314},[],[36316],{"type":34,"value":36317},"else",{"type":34,"value":36319}," ici), plus il devient fragile. Chaque modification future peut casser une partie existante.",{"type":29,"tag":30,"props":36321,"children":36322},{},[36323],{"type":34,"value":36324},"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":29,"tag":8542,"props":36326,"children":36328},{"id":36327},"exemple-2-application-du-principe-ocp-avec-des-interfaces",[36329],{"type":34,"value":36330},"Exemple 2 : Application du principe OCP avec des interfaces",{"type":29,"tag":30,"props":36332,"children":36333},{},[36334],{"type":34,"value":36335},"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":29,"tag":77,"props":36337,"children":36339},{"className":81,"code":36338,"language":80,"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",[36340],{"type":29,"tag":84,"props":36341,"children":36342},{"__ignoreMap":8},[36343,36359,36386,36393,36400,36424,36435,36470,36493,36500,36507,36514,36538,36549,36584,36607,36614,36621,36628,36643,36662,36682,36689,36732,36759,36787,36794,36801,36824,36856,36863],{"type":29,"tag":88,"props":36344,"children":36345},{"class":90,"line":91},[36346,36350,36355],{"type":29,"tag":88,"props":36347,"children":36348},{"style":105},[36349],{"type":34,"value":26149},{"type":29,"tag":88,"props":36351,"children":36352},{"style":116},[36353],{"type":34,"value":36354}," SalaryCalculator",{"type":29,"tag":88,"props":36356,"children":36357},{"style":122},[36358],{"type":34,"value":125},{"type":29,"tag":88,"props":36360,"children":36361},{"class":90,"line":101},[36362,36366,36370,36374,36378,36382],{"type":29,"tag":88,"props":36363,"children":36364},{"style":105},[36365],{"type":34,"value":17625},{"type":29,"tag":88,"props":36367,"children":36368},{"style":174},[36369],{"type":34,"value":12017},{"type":29,"tag":88,"props":36371,"children":36372},{"style":122},[36373],{"type":34,"value":181},{"type":29,"tag":88,"props":36375,"children":36376},{"style":105},[36377],{"type":34,"value":11629},{"type":29,"tag":88,"props":36379,"children":36380},{"style":298},[36381],{"type":34,"value":35950},{"type":29,"tag":88,"props":36383,"children":36384},{"style":122},[36385],{"type":34,"value":357},{"type":29,"tag":88,"props":36387,"children":36388},{"class":90,"line":128},[36389],{"type":29,"tag":88,"props":36390,"children":36391},{"style":122},[36392],{"type":34,"value":442},{"type":29,"tag":88,"props":36394,"children":36395},{"class":90,"line":137},[36396],{"type":29,"tag":88,"props":36397,"children":36398},{"emptyLinePlaceholder":13},[36399],{"type":34,"value":134},{"type":29,"tag":88,"props":36401,"children":36402},{"class":90,"line":211},[36403,36407,36412,36416,36420],{"type":29,"tag":88,"props":36404,"children":36405},{"style":105},[36406],{"type":34,"value":1225},{"type":29,"tag":88,"props":36408,"children":36409},{"style":116},[36410],{"type":34,"value":36411}," ManagerSalaryCalculator",{"type":29,"tag":88,"props":36413,"children":36414},{"style":105},[36415],{"type":34,"value":1134},{"type":29,"tag":88,"props":36417,"children":36418},{"style":116},[36419],{"type":34,"value":36354},{"type":29,"tag":88,"props":36421,"children":36422},{"style":122},[36423],{"type":34,"value":125},{"type":29,"tag":88,"props":36425,"children":36426},{"class":90,"line":262},[36427,36431],{"type":29,"tag":88,"props":36428,"children":36429},{"style":1974},[36430],{"type":34,"value":3302},{"type":29,"tag":88,"props":36432,"children":36433},{"style":1980},[36434],{"type":34,"value":3307},{"type":29,"tag":88,"props":36436,"children":36437},{"class":90,"line":270},[36438,36442,36446,36450,36454,36458,36462,36466],{"type":29,"tag":88,"props":36439,"children":36440},{"style":105},[36441],{"type":34,"value":276},{"type":29,"tag":88,"props":36443,"children":36444},{"style":105},[36445],{"type":34,"value":10663},{"type":29,"tag":88,"props":36447,"children":36448},{"style":174},[36449],{"type":34,"value":12017},{"type":29,"tag":88,"props":36451,"children":36452},{"style":122},[36453],{"type":34,"value":181},{"type":29,"tag":88,"props":36455,"children":36456},{"style":105},[36457],{"type":34,"value":11629},{"type":29,"tag":88,"props":36459,"children":36460},{"style":298},[36461],{"type":34,"value":35950},{"type":29,"tag":88,"props":36463,"children":36464},{"style":122},[36465],{"type":34,"value":306},{"type":29,"tag":88,"props":36467,"children":36468},{"style":122},[36469],{"type":34,"value":125},{"type":29,"tag":88,"props":36471,"children":36472},{"class":90,"line":313},[36473,36477,36481,36485,36489],{"type":29,"tag":88,"props":36474,"children":36475},{"style":105},[36476],{"type":34,"value":415},{"type":29,"tag":88,"props":36478,"children":36479},{"style":157},[36480],{"type":34,"value":36149},{"type":29,"tag":88,"props":36482,"children":36483},{"style":163},[36484],{"type":34,"value":8709},{"type":29,"tag":88,"props":36486,"children":36487},{"style":195},[36488],{"type":34,"value":9193},{"type":29,"tag":88,"props":36490,"children":36491},{"style":122},[36492],{"type":34,"value":424},{"type":29,"tag":88,"props":36494,"children":36495},{"class":90,"line":360},[36496],{"type":29,"tag":88,"props":36497,"children":36498},{"style":122},[36499],{"type":34,"value":433},{"type":29,"tag":88,"props":36501,"children":36502},{"class":90,"line":409},[36503],{"type":29,"tag":88,"props":36504,"children":36505},{"style":122},[36506],{"type":34,"value":442},{"type":29,"tag":88,"props":36508,"children":36509},{"class":90,"line":427},[36510],{"type":29,"tag":88,"props":36511,"children":36512},{"emptyLinePlaceholder":13},[36513],{"type":34,"value":134},{"type":29,"tag":88,"props":36515,"children":36516},{"class":90,"line":436},[36517,36521,36526,36530,36534],{"type":29,"tag":88,"props":36518,"children":36519},{"style":105},[36520],{"type":34,"value":1225},{"type":29,"tag":88,"props":36522,"children":36523},{"style":116},[36524],{"type":34,"value":36525}," DeveloperSalaryCalculator",{"type":29,"tag":88,"props":36527,"children":36528},{"style":105},[36529],{"type":34,"value":1134},{"type":29,"tag":88,"props":36531,"children":36532},{"style":116},[36533],{"type":34,"value":36354},{"type":29,"tag":88,"props":36535,"children":36536},{"style":122},[36537],{"type":34,"value":125},{"type":29,"tag":88,"props":36539,"children":36540},{"class":90,"line":767},[36541,36545],{"type":29,"tag":88,"props":36542,"children":36543},{"style":1974},[36544],{"type":34,"value":3302},{"type":29,"tag":88,"props":36546,"children":36547},{"style":1980},[36548],{"type":34,"value":3307},{"type":29,"tag":88,"props":36550,"children":36551},{"class":90,"line":792},[36552,36556,36560,36564,36568,36572,36576,36580],{"type":29,"tag":88,"props":36553,"children":36554},{"style":105},[36555],{"type":34,"value":276},{"type":29,"tag":88,"props":36557,"children":36558},{"style":105},[36559],{"type":34,"value":10663},{"type":29,"tag":88,"props":36561,"children":36562},{"style":174},[36563],{"type":34,"value":12017},{"type":29,"tag":88,"props":36565,"children":36566},{"style":122},[36567],{"type":34,"value":181},{"type":29,"tag":88,"props":36569,"children":36570},{"style":105},[36571],{"type":34,"value":11629},{"type":29,"tag":88,"props":36573,"children":36574},{"style":298},[36575],{"type":34,"value":35950},{"type":29,"tag":88,"props":36577,"children":36578},{"style":122},[36579],{"type":34,"value":306},{"type":29,"tag":88,"props":36581,"children":36582},{"style":122},[36583],{"type":34,"value":125},{"type":29,"tag":88,"props":36585,"children":36586},{"class":90,"line":817},[36587,36591,36595,36599,36603],{"type":29,"tag":88,"props":36588,"children":36589},{"style":105},[36590],{"type":34,"value":415},{"type":29,"tag":88,"props":36592,"children":36593},{"style":157},[36594],{"type":34,"value":36149},{"type":29,"tag":88,"props":36596,"children":36597},{"style":163},[36598],{"type":34,"value":8709},{"type":29,"tag":88,"props":36600,"children":36601},{"style":195},[36602],{"type":34,"value":36229},{"type":29,"tag":88,"props":36604,"children":36605},{"style":122},[36606],{"type":34,"value":424},{"type":29,"tag":88,"props":36608,"children":36609},{"class":90,"line":825},[36610],{"type":29,"tag":88,"props":36611,"children":36612},{"style":122},[36613],{"type":34,"value":433},{"type":29,"tag":88,"props":36615,"children":36616},{"class":90,"line":869},[36617],{"type":29,"tag":88,"props":36618,"children":36619},{"style":122},[36620],{"type":34,"value":442},{"type":29,"tag":88,"props":36622,"children":36623},{"class":90,"line":900},[36624],{"type":29,"tag":88,"props":36625,"children":36626},{"emptyLinePlaceholder":13},[36627],{"type":34,"value":134},{"type":29,"tag":88,"props":36629,"children":36630},{"class":90,"line":929},[36631,36635,36639],{"type":29,"tag":88,"props":36632,"children":36633},{"style":105},[36634],{"type":34,"value":1225},{"type":29,"tag":88,"props":36636,"children":36637},{"style":116},[36638],{"type":34,"value":10627},{"type":29,"tag":88,"props":36640,"children":36641},{"style":122},[36642],{"type":34,"value":125},{"type":29,"tag":88,"props":36644,"children":36645},{"class":90,"line":937},[36646,36650,36654,36658],{"type":29,"tag":88,"props":36647,"children":36648},{"style":105},[36649],{"type":34,"value":143},{"type":29,"tag":88,"props":36651,"children":36652},{"style":105},[36653],{"type":34,"value":10663},{"type":29,"tag":88,"props":36655,"children":36656},{"style":157},[36657],{"type":34,"value":35950},{"type":29,"tag":88,"props":36659,"children":36660},{"style":122},[36661],{"type":34,"value":424},{"type":29,"tag":88,"props":36663,"children":36664},{"class":90,"line":945},[36665,36669,36673,36678],{"type":29,"tag":88,"props":36666,"children":36667},{"style":105},[36668],{"type":34,"value":143},{"type":29,"tag":88,"props":36670,"children":36671},{"style":151},[36672],{"type":34,"value":36354},{"type":29,"tag":88,"props":36674,"children":36675},{"style":157},[36676],{"type":34,"value":36677}," salaryCalculator",{"type":29,"tag":88,"props":36679,"children":36680},{"style":122},[36681],{"type":34,"value":424},{"type":29,"tag":88,"props":36683,"children":36684},{"class":90,"line":981},[36685],{"type":29,"tag":88,"props":36686,"children":36687},{"emptyLinePlaceholder":13},[36688],{"type":34,"value":134},{"type":29,"tag":88,"props":36690,"children":36691},{"class":90,"line":1021},[36692,36696,36700,36704,36708,36712,36716,36720,36724,36728],{"type":29,"tag":88,"props":36693,"children":36694},{"style":105},[36695],{"type":34,"value":276},{"type":29,"tag":88,"props":36697,"children":36698},{"style":174},[36699],{"type":34,"value":10627},{"type":29,"tag":88,"props":36701,"children":36702},{"style":122},[36703],{"type":34,"value":181},{"type":29,"tag":88,"props":36705,"children":36706},{"style":105},[36707],{"type":34,"value":11629},{"type":29,"tag":88,"props":36709,"children":36710},{"style":298},[36711],{"type":34,"value":35950},{"type":29,"tag":88,"props":36713,"children":36714},{"style":122},[36715],{"type":34,"value":192},{"type":29,"tag":88,"props":36717,"children":36718},{"style":151},[36719],{"type":34,"value":36354},{"type":29,"tag":88,"props":36721,"children":36722},{"style":298},[36723],{"type":34,"value":36677},{"type":29,"tag":88,"props":36725,"children":36726},{"style":122},[36727],{"type":34,"value":306},{"type":29,"tag":88,"props":36729,"children":36730},{"style":122},[36731],{"type":34,"value":125},{"type":29,"tag":88,"props":36733,"children":36734},{"class":90,"line":1066},[36735,36739,36743,36747,36751,36755],{"type":29,"tag":88,"props":36736,"children":36737},{"style":873},[36738],{"type":34,"value":876},{"type":29,"tag":88,"props":36740,"children":36741},{"style":122},[36742],{"type":34,"value":338},{"type":29,"tag":88,"props":36744,"children":36745},{"style":157},[36746],{"type":34,"value":36048},{"type":29,"tag":88,"props":36748,"children":36749},{"style":163},[36750],{"type":34,"value":166},{"type":29,"tag":88,"props":36752,"children":36753},{"style":157},[36754],{"type":34,"value":35950},{"type":29,"tag":88,"props":36756,"children":36757},{"style":122},[36758],{"type":34,"value":424},{"type":29,"tag":88,"props":36760,"children":36761},{"class":90,"line":1082},[36762,36766,36770,36775,36779,36783],{"type":29,"tag":88,"props":36763,"children":36764},{"style":873},[36765],{"type":34,"value":876},{"type":29,"tag":88,"props":36767,"children":36768},{"style":122},[36769],{"type":34,"value":338},{"type":29,"tag":88,"props":36771,"children":36772},{"style":157},[36773],{"type":34,"value":36774},"salaryCalculator ",{"type":29,"tag":88,"props":36776,"children":36777},{"style":163},[36778],{"type":34,"value":166},{"type":29,"tag":88,"props":36780,"children":36781},{"style":157},[36782],{"type":34,"value":36677},{"type":29,"tag":88,"props":36784,"children":36785},{"style":122},[36786],{"type":34,"value":424},{"type":29,"tag":88,"props":36788,"children":36789},{"class":90,"line":1090},[36790],{"type":29,"tag":88,"props":36791,"children":36792},{"style":122},[36793],{"type":34,"value":433},{"type":29,"tag":88,"props":36795,"children":36796},{"class":90,"line":1098},[36797],{"type":29,"tag":88,"props":36798,"children":36799},{"emptyLinePlaceholder":13},[36800],{"type":34,"value":134},{"type":29,"tag":88,"props":36802,"children":36803},{"class":90,"line":1106},[36804,36808,36812,36816,36820],{"type":29,"tag":88,"props":36805,"children":36806},{"style":105},[36807],{"type":34,"value":276},{"type":29,"tag":88,"props":36809,"children":36810},{"style":105},[36811],{"type":34,"value":10663},{"type":29,"tag":88,"props":36813,"children":36814},{"style":174},[36815],{"type":34,"value":12017},{"type":29,"tag":88,"props":36817,"children":36818},{"style":122},[36819],{"type":34,"value":1470},{"type":29,"tag":88,"props":36821,"children":36822},{"style":122},[36823],{"type":34,"value":125},{"type":29,"tag":88,"props":36825,"children":36826},{"class":90,"line":1115},[36827,36831,36835,36839,36843,36847,36852],{"type":29,"tag":88,"props":36828,"children":36829},{"style":105},[36830],{"type":34,"value":415},{"type":29,"tag":88,"props":36832,"children":36833},{"style":157},[36834],{"type":34,"value":36677},{"type":29,"tag":88,"props":36836,"children":36837},{"style":122},[36838],{"type":34,"value":338},{"type":29,"tag":88,"props":36840,"children":36841},{"style":174},[36842],{"type":34,"value":13249},{"type":29,"tag":88,"props":36844,"children":36845},{"style":122},[36846],{"type":34,"value":181},{"type":29,"tag":88,"props":36848,"children":36849},{"style":157},[36850],{"type":34,"value":36851},"baseSalary",{"type":29,"tag":88,"props":36853,"children":36854},{"style":122},[36855],{"type":34,"value":357},{"type":29,"tag":88,"props":36857,"children":36858},{"class":90,"line":11},[36859],{"type":29,"tag":88,"props":36860,"children":36861},{"style":122},[36862],{"type":34,"value":433},{"type":29,"tag":88,"props":36864,"children":36865},{"class":90,"line":1180},[36866],{"type":29,"tag":88,"props":36867,"children":36868},{"style":122},[36869],{"type":34,"value":442},{"type":29,"tag":30,"props":36871,"children":36872},{},[36873,36875,36880,36882,36888],{"type":34,"value":36874},"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":29,"tag":84,"props":36876,"children":36878},{"className":36877},[],[36879],{"type":34,"value":9538},{"type":34,"value":36881},". Vous créez simplement une nouvelle classe qui implémente ",{"type":29,"tag":84,"props":36883,"children":36885},{"className":36884},[],[36886],{"type":34,"value":36887},"SalaryCalculator",{"type":34,"value":21063},{"type":29,"tag":77,"props":36890,"children":36892},{"className":81,"code":36891,"language":80,"meta":8,"style":8},"class DesignerSalaryCalculator implements SalaryCalculator {\n    @Override\n    public double calculateSalary(double baseSalary) {\n        return baseSalary * 1.8;\n    }\n}\n",[36893],{"type":29,"tag":84,"props":36894,"children":36895},{"__ignoreMap":8},[36896,36920,36931,36966,36990,36997],{"type":29,"tag":88,"props":36897,"children":36898},{"class":90,"line":91},[36899,36903,36908,36912,36916],{"type":29,"tag":88,"props":36900,"children":36901},{"style":105},[36902],{"type":34,"value":1225},{"type":29,"tag":88,"props":36904,"children":36905},{"style":116},[36906],{"type":34,"value":36907}," DesignerSalaryCalculator",{"type":29,"tag":88,"props":36909,"children":36910},{"style":105},[36911],{"type":34,"value":1134},{"type":29,"tag":88,"props":36913,"children":36914},{"style":116},[36915],{"type":34,"value":36354},{"type":29,"tag":88,"props":36917,"children":36918},{"style":122},[36919],{"type":34,"value":125},{"type":29,"tag":88,"props":36921,"children":36922},{"class":90,"line":101},[36923,36927],{"type":29,"tag":88,"props":36924,"children":36925},{"style":1974},[36926],{"type":34,"value":3302},{"type":29,"tag":88,"props":36928,"children":36929},{"style":1980},[36930],{"type":34,"value":3307},{"type":29,"tag":88,"props":36932,"children":36933},{"class":90,"line":128},[36934,36938,36942,36946,36950,36954,36958,36962],{"type":29,"tag":88,"props":36935,"children":36936},{"style":105},[36937],{"type":34,"value":276},{"type":29,"tag":88,"props":36939,"children":36940},{"style":105},[36941],{"type":34,"value":10663},{"type":29,"tag":88,"props":36943,"children":36944},{"style":174},[36945],{"type":34,"value":12017},{"type":29,"tag":88,"props":36947,"children":36948},{"style":122},[36949],{"type":34,"value":181},{"type":29,"tag":88,"props":36951,"children":36952},{"style":105},[36953],{"type":34,"value":11629},{"type":29,"tag":88,"props":36955,"children":36956},{"style":298},[36957],{"type":34,"value":35950},{"type":29,"tag":88,"props":36959,"children":36960},{"style":122},[36961],{"type":34,"value":306},{"type":29,"tag":88,"props":36963,"children":36964},{"style":122},[36965],{"type":34,"value":125},{"type":29,"tag":88,"props":36967,"children":36968},{"class":90,"line":137},[36969,36973,36977,36981,36986],{"type":29,"tag":88,"props":36970,"children":36971},{"style":105},[36972],{"type":34,"value":415},{"type":29,"tag":88,"props":36974,"children":36975},{"style":157},[36976],{"type":34,"value":36149},{"type":29,"tag":88,"props":36978,"children":36979},{"style":163},[36980],{"type":34,"value":8709},{"type":29,"tag":88,"props":36982,"children":36983},{"style":195},[36984],{"type":34,"value":36985}," 1.8",{"type":29,"tag":88,"props":36987,"children":36988},{"style":122},[36989],{"type":34,"value":424},{"type":29,"tag":88,"props":36991,"children":36992},{"class":90,"line":211},[36993],{"type":29,"tag":88,"props":36994,"children":36995},{"style":122},[36996],{"type":34,"value":433},{"type":29,"tag":88,"props":36998,"children":36999},{"class":90,"line":262},[37000],{"type":29,"tag":88,"props":37001,"children":37002},{"style":122},[37003],{"type":34,"value":442},{"type":29,"tag":30,"props":37005,"children":37006},{},[37007],{"type":34,"value":37008},"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":29,"tag":8526,"props":37010,"children":37011},{"type":8528},[37012],{"type":29,"tag":30,"props":37013,"children":37014},{},[37015],{"type":34,"value":37016},"** 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":29,"tag":47,"props":37018,"children":37019},{},[],{"type":29,"tag":2288,"props":37021,"children":37023},{"cta":2290,"href":2291,"title":37022,"type":2293},"Vous voulez concevoir vos classes pour les étendre sans jamais les rouvrir ?",[37024],{"type":29,"tag":30,"props":37025,"children":37026},{},[37027],{"type":34,"value":37028},"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":29,"tag":51,"props":37030,"children":37032},{"id":37031},"pourquoi-ocp-est-essentiel-dans-le-software-craftsmanship",[37033],{"type":34,"value":37034},"Pourquoi OCP est essentiel dans le Software Craftsmanship",{"type":29,"tag":30,"props":37036,"children":37037},{},[37038,37040,37047,37049,37054,37055,37060],{"type":34,"value":37039},"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":29,"tag":447,"props":37041,"children":37042},{},[37043],{"type":29,"tag":63,"props":37044,"children":37045},{"href":10180},[37046],{"type":34,"value":16975},{"type":34,"value":37048},", un mouvement qui prône l’écriture de code non seulement fonctionnel, mais aussi ",{"type":29,"tag":447,"props":37050,"children":37051},{},[37052],{"type":34,"value":37053},"élégant",{"type":34,"value":8982},{"type":29,"tag":447,"props":37056,"children":37057},{},[37058],{"type":34,"value":37059},"maintenable",{"type":34,"value":37061},". Respecter le principe OCP vous aide à :",{"type":29,"tag":17095,"props":37063,"children":37064},{},[37065,37075,37085],{"type":29,"tag":457,"props":37066,"children":37067},{},[37068,37073],{"type":29,"tag":447,"props":37069,"children":37070},{},[37071],{"type":34,"value":37072},"Réduire les risques de régressions",{"type":34,"value":37074}," : 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":29,"tag":457,"props":37076,"children":37077},{},[37078,37083],{"type":29,"tag":447,"props":37079,"children":37080},{},[37081],{"type":34,"value":37082},"Faciliter les extensions",{"type":34,"value":37084}," : ajouter une nouvelle fonctionnalité devient une opération chirurgicale, sans avoir à plonger dans des classes complexes pour y greffer une modification.",{"type":29,"tag":457,"props":37086,"children":37087},{},[37088,37093],{"type":29,"tag":447,"props":37089,"children":37090},{},[37091],{"type":34,"value":37092},"Améliorer la collaboration en équipe",{"type":34,"value":37094}," : 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":29,"tag":8526,"props":37096,"children":37097},{"type":36299},[37098],{"type":29,"tag":30,"props":37099,"children":37100},{},[37101],{"type":34,"value":37102},"** 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":29,"tag":30,"props":37104,"children":37105},{},[37106,37108,37112,37114,37119],{"type":34,"value":37107},"Dans le contexte du ",{"type":29,"tag":63,"props":37109,"children":37110},{"href":10180},[37111],{"type":34,"value":16975},{"type":34,"value":37113},", suivre OCP revient à ",{"type":29,"tag":447,"props":37115,"children":37116},{},[37117],{"type":34,"value":37118},"prendre soin de son code",{"type":34,"value":37120}," 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":29,"tag":47,"props":37122,"children":37123},{},[],{"type":29,"tag":51,"props":37125,"children":37127},{"id":37126},"comment-appliquer-ocp-dans-vos-projets-java",[37128],{"type":34,"value":37129},"Comment appliquer OCP dans vos projets Java",{"type":29,"tag":30,"props":37131,"children":37132},{},[37133],{"type":34,"value":37134},"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":29,"tag":8542,"props":37136,"children":37138},{"id":37137},"exemple-3-utilisation-de-classes-abstraites-pour-respecter-ocp",[37139],{"type":34,"value":37140},"Exemple 3 : Utilisation de classes abstraites pour respecter OCP",{"type":29,"tag":30,"props":37142,"children":37143},{},[37144],{"type":34,"value":37145},"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":29,"tag":30,"props":37147,"children":37148},{},[37149],{"type":34,"value":37150},"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":29,"tag":77,"props":37152,"children":37154},{"className":81,"code":37153,"language":80,"meta":8,"style":8},"abstract class Employee {\n    protected double baseSalary;\n\n    public Employee(double baseSalary) {\n        this.baseSalary = baseSalary;\n    }\n\n    \u002F\u002F 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",[37155],{"type":29,"tag":84,"props":37156,"children":37157},{"__ignoreMap":8},[37158,37178,37197,37204,37235,37262,37269,37276,37284,37308,37315,37322,37345,37376,37395,37402,37409,37420,37443,37466,37473,37480,37487,37511,37542,37561,37568,37575,37586,37609,37632,37639],{"type":29,"tag":88,"props":37159,"children":37160},{"class":90,"line":91},[37161,37166,37170,37174],{"type":29,"tag":88,"props":37162,"children":37163},{"style":105},[37164],{"type":34,"value":37165},"abstract",{"type":29,"tag":88,"props":37167,"children":37168},{"style":105},[37169],{"type":34,"value":113},{"type":29,"tag":88,"props":37171,"children":37172},{"style":116},[37173],{"type":34,"value":10627},{"type":29,"tag":88,"props":37175,"children":37176},{"style":122},[37177],{"type":34,"value":125},{"type":29,"tag":88,"props":37179,"children":37180},{"class":90,"line":101},[37181,37185,37189,37193],{"type":29,"tag":88,"props":37182,"children":37183},{"style":105},[37184],{"type":34,"value":21654},{"type":29,"tag":88,"props":37186,"children":37187},{"style":105},[37188],{"type":34,"value":10663},{"type":29,"tag":88,"props":37190,"children":37191},{"style":157},[37192],{"type":34,"value":35950},{"type":29,"tag":88,"props":37194,"children":37195},{"style":122},[37196],{"type":34,"value":424},{"type":29,"tag":88,"props":37198,"children":37199},{"class":90,"line":128},[37200],{"type":29,"tag":88,"props":37201,"children":37202},{"emptyLinePlaceholder":13},[37203],{"type":34,"value":134},{"type":29,"tag":88,"props":37205,"children":37206},{"class":90,"line":137},[37207,37211,37215,37219,37223,37227,37231],{"type":29,"tag":88,"props":37208,"children":37209},{"style":105},[37210],{"type":34,"value":276},{"type":29,"tag":88,"props":37212,"children":37213},{"style":174},[37214],{"type":34,"value":10627},{"type":29,"tag":88,"props":37216,"children":37217},{"style":122},[37218],{"type":34,"value":181},{"type":29,"tag":88,"props":37220,"children":37221},{"style":105},[37222],{"type":34,"value":11629},{"type":29,"tag":88,"props":37224,"children":37225},{"style":298},[37226],{"type":34,"value":35950},{"type":29,"tag":88,"props":37228,"children":37229},{"style":122},[37230],{"type":34,"value":306},{"type":29,"tag":88,"props":37232,"children":37233},{"style":122},[37234],{"type":34,"value":125},{"type":29,"tag":88,"props":37236,"children":37237},{"class":90,"line":211},[37238,37242,37246,37250,37254,37258],{"type":29,"tag":88,"props":37239,"children":37240},{"style":873},[37241],{"type":34,"value":876},{"type":29,"tag":88,"props":37243,"children":37244},{"style":122},[37245],{"type":34,"value":338},{"type":29,"tag":88,"props":37247,"children":37248},{"style":157},[37249],{"type":34,"value":36048},{"type":29,"tag":88,"props":37251,"children":37252},{"style":163},[37253],{"type":34,"value":166},{"type":29,"tag":88,"props":37255,"children":37256},{"style":157},[37257],{"type":34,"value":35950},{"type":29,"tag":88,"props":37259,"children":37260},{"style":122},[37261],{"type":34,"value":424},{"type":29,"tag":88,"props":37263,"children":37264},{"class":90,"line":262},[37265],{"type":29,"tag":88,"props":37266,"children":37267},{"style":122},[37268],{"type":34,"value":433},{"type":29,"tag":88,"props":37270,"children":37271},{"class":90,"line":270},[37272],{"type":29,"tag":88,"props":37273,"children":37274},{"emptyLinePlaceholder":13},[37275],{"type":34,"value":134},{"type":29,"tag":88,"props":37277,"children":37278},{"class":90,"line":313},[37279],{"type":29,"tag":88,"props":37280,"children":37281},{"style":95},[37282],{"type":34,"value":37283},"    \u002F\u002F Méthode abstraite que chaque sous-classe implémentera\n",{"type":29,"tag":88,"props":37285,"children":37286},{"class":90,"line":360},[37287,37291,37296,37300,37304],{"type":29,"tag":88,"props":37288,"children":37289},{"style":105},[37290],{"type":34,"value":276},{"type":29,"tag":88,"props":37292,"children":37293},{"style":105},[37294],{"type":34,"value":37295}," abstract",{"type":29,"tag":88,"props":37297,"children":37298},{"style":105},[37299],{"type":34,"value":10663},{"type":29,"tag":88,"props":37301,"children":37302},{"style":174},[37303],{"type":34,"value":12017},{"type":29,"tag":88,"props":37305,"children":37306},{"style":122},[37307],{"type":34,"value":1810},{"type":29,"tag":88,"props":37309,"children":37310},{"class":90,"line":409},[37311],{"type":29,"tag":88,"props":37312,"children":37313},{"style":122},[37314],{"type":34,"value":442},{"type":29,"tag":88,"props":37316,"children":37317},{"class":90,"line":427},[37318],{"type":29,"tag":88,"props":37319,"children":37320},{"emptyLinePlaceholder":13},[37321],{"type":34,"value":134},{"type":29,"tag":88,"props":37323,"children":37324},{"class":90,"line":436},[37325,37329,37333,37337,37341],{"type":29,"tag":88,"props":37326,"children":37327},{"style":105},[37328],{"type":34,"value":1225},{"type":29,"tag":88,"props":37330,"children":37331},{"style":116},[37332],{"type":34,"value":29480},{"type":29,"tag":88,"props":37334,"children":37335},{"style":105},[37336],{"type":34,"value":21954},{"type":29,"tag":88,"props":37338,"children":37339},{"style":116},[37340],{"type":34,"value":10627},{"type":29,"tag":88,"props":37342,"children":37343},{"style":122},[37344],{"type":34,"value":125},{"type":29,"tag":88,"props":37346,"children":37347},{"class":90,"line":767},[37348,37352,37356,37360,37364,37368,37372],{"type":29,"tag":88,"props":37349,"children":37350},{"style":105},[37351],{"type":34,"value":276},{"type":29,"tag":88,"props":37353,"children":37354},{"style":174},[37355],{"type":34,"value":29480},{"type":29,"tag":88,"props":37357,"children":37358},{"style":122},[37359],{"type":34,"value":181},{"type":29,"tag":88,"props":37361,"children":37362},{"style":105},[37363],{"type":34,"value":11629},{"type":29,"tag":88,"props":37365,"children":37366},{"style":298},[37367],{"type":34,"value":35950},{"type":29,"tag":88,"props":37369,"children":37370},{"style":122},[37371],{"type":34,"value":306},{"type":29,"tag":88,"props":37373,"children":37374},{"style":122},[37375],{"type":34,"value":125},{"type":29,"tag":88,"props":37377,"children":37378},{"class":90,"line":792},[37379,37383,37387,37391],{"type":29,"tag":88,"props":37380,"children":37381},{"style":6490},[37382],{"type":34,"value":32359},{"type":29,"tag":88,"props":37384,"children":37385},{"style":122},[37386],{"type":34,"value":181},{"type":29,"tag":88,"props":37388,"children":37389},{"style":157},[37390],{"type":34,"value":36851},{"type":29,"tag":88,"props":37392,"children":37393},{"style":122},[37394],{"type":34,"value":357},{"type":29,"tag":88,"props":37396,"children":37397},{"class":90,"line":817},[37398],{"type":29,"tag":88,"props":37399,"children":37400},{"style":122},[37401],{"type":34,"value":433},{"type":29,"tag":88,"props":37403,"children":37404},{"class":90,"line":825},[37405],{"type":29,"tag":88,"props":37406,"children":37407},{"emptyLinePlaceholder":13},[37408],{"type":34,"value":134},{"type":29,"tag":88,"props":37410,"children":37411},{"class":90,"line":869},[37412,37416],{"type":29,"tag":88,"props":37413,"children":37414},{"style":1974},[37415],{"type":34,"value":3302},{"type":29,"tag":88,"props":37417,"children":37418},{"style":1980},[37419],{"type":34,"value":3307},{"type":29,"tag":88,"props":37421,"children":37422},{"class":90,"line":900},[37423,37427,37431,37435,37439],{"type":29,"tag":88,"props":37424,"children":37425},{"style":105},[37426],{"type":34,"value":276},{"type":29,"tag":88,"props":37428,"children":37429},{"style":105},[37430],{"type":34,"value":10663},{"type":29,"tag":88,"props":37432,"children":37433},{"style":174},[37434],{"type":34,"value":12017},{"type":29,"tag":88,"props":37436,"children":37437},{"style":122},[37438],{"type":34,"value":1470},{"type":29,"tag":88,"props":37440,"children":37441},{"style":122},[37442],{"type":34,"value":125},{"type":29,"tag":88,"props":37444,"children":37445},{"class":90,"line":929},[37446,37450,37454,37458,37462],{"type":29,"tag":88,"props":37447,"children":37448},{"style":105},[37449],{"type":34,"value":415},{"type":29,"tag":88,"props":37451,"children":37452},{"style":157},[37453],{"type":34,"value":36149},{"type":29,"tag":88,"props":37455,"children":37456},{"style":163},[37457],{"type":34,"value":8709},{"type":29,"tag":88,"props":37459,"children":37460},{"style":195},[37461],{"type":34,"value":9193},{"type":29,"tag":88,"props":37463,"children":37464},{"style":122},[37465],{"type":34,"value":424},{"type":29,"tag":88,"props":37467,"children":37468},{"class":90,"line":937},[37469],{"type":29,"tag":88,"props":37470,"children":37471},{"style":122},[37472],{"type":34,"value":433},{"type":29,"tag":88,"props":37474,"children":37475},{"class":90,"line":945},[37476],{"type":29,"tag":88,"props":37477,"children":37478},{"style":122},[37479],{"type":34,"value":442},{"type":29,"tag":88,"props":37481,"children":37482},{"class":90,"line":981},[37483],{"type":29,"tag":88,"props":37484,"children":37485},{"emptyLinePlaceholder":13},[37486],{"type":34,"value":134},{"type":29,"tag":88,"props":37488,"children":37489},{"class":90,"line":1021},[37490,37494,37499,37503,37507],{"type":29,"tag":88,"props":37491,"children":37492},{"style":105},[37493],{"type":34,"value":1225},{"type":29,"tag":88,"props":37495,"children":37496},{"style":116},[37497],{"type":34,"value":37498}," Developer",{"type":29,"tag":88,"props":37500,"children":37501},{"style":105},[37502],{"type":34,"value":21954},{"type":29,"tag":88,"props":37504,"children":37505},{"style":116},[37506],{"type":34,"value":10627},{"type":29,"tag":88,"props":37508,"children":37509},{"style":122},[37510],{"type":34,"value":125},{"type":29,"tag":88,"props":37512,"children":37513},{"class":90,"line":1066},[37514,37518,37522,37526,37530,37534,37538],{"type":29,"tag":88,"props":37515,"children":37516},{"style":105},[37517],{"type":34,"value":276},{"type":29,"tag":88,"props":37519,"children":37520},{"style":174},[37521],{"type":34,"value":37498},{"type":29,"tag":88,"props":37523,"children":37524},{"style":122},[37525],{"type":34,"value":181},{"type":29,"tag":88,"props":37527,"children":37528},{"style":105},[37529],{"type":34,"value":11629},{"type":29,"tag":88,"props":37531,"children":37532},{"style":298},[37533],{"type":34,"value":35950},{"type":29,"tag":88,"props":37535,"children":37536},{"style":122},[37537],{"type":34,"value":306},{"type":29,"tag":88,"props":37539,"children":37540},{"style":122},[37541],{"type":34,"value":125},{"type":29,"tag":88,"props":37543,"children":37544},{"class":90,"line":1082},[37545,37549,37553,37557],{"type":29,"tag":88,"props":37546,"children":37547},{"style":6490},[37548],{"type":34,"value":32359},{"type":29,"tag":88,"props":37550,"children":37551},{"style":122},[37552],{"type":34,"value":181},{"type":29,"tag":88,"props":37554,"children":37555},{"style":157},[37556],{"type":34,"value":36851},{"type":29,"tag":88,"props":37558,"children":37559},{"style":122},[37560],{"type":34,"value":357},{"type":29,"tag":88,"props":37562,"children":37563},{"class":90,"line":1090},[37564],{"type":29,"tag":88,"props":37565,"children":37566},{"style":122},[37567],{"type":34,"value":433},{"type":29,"tag":88,"props":37569,"children":37570},{"class":90,"line":1098},[37571],{"type":29,"tag":88,"props":37572,"children":37573},{"emptyLinePlaceholder":13},[37574],{"type":34,"value":134},{"type":29,"tag":88,"props":37576,"children":37577},{"class":90,"line":1106},[37578,37582],{"type":29,"tag":88,"props":37579,"children":37580},{"style":1974},[37581],{"type":34,"value":3302},{"type":29,"tag":88,"props":37583,"children":37584},{"style":1980},[37585],{"type":34,"value":3307},{"type":29,"tag":88,"props":37587,"children":37588},{"class":90,"line":1115},[37589,37593,37597,37601,37605],{"type":29,"tag":88,"props":37590,"children":37591},{"style":105},[37592],{"type":34,"value":276},{"type":29,"tag":88,"props":37594,"children":37595},{"style":105},[37596],{"type":34,"value":10663},{"type":29,"tag":88,"props":37598,"children":37599},{"style":174},[37600],{"type":34,"value":12017},{"type":29,"tag":88,"props":37602,"children":37603},{"style":122},[37604],{"type":34,"value":1470},{"type":29,"tag":88,"props":37606,"children":37607},{"style":122},[37608],{"type":34,"value":125},{"type":29,"tag":88,"props":37610,"children":37611},{"class":90,"line":11},[37612,37616,37620,37624,37628],{"type":29,"tag":88,"props":37613,"children":37614},{"style":105},[37615],{"type":34,"value":415},{"type":29,"tag":88,"props":37617,"children":37618},{"style":157},[37619],{"type":34,"value":36149},{"type":29,"tag":88,"props":37621,"children":37622},{"style":163},[37623],{"type":34,"value":8709},{"type":29,"tag":88,"props":37625,"children":37626},{"style":195},[37627],{"type":34,"value":36229},{"type":29,"tag":88,"props":37629,"children":37630},{"style":122},[37631],{"type":34,"value":424},{"type":29,"tag":88,"props":37633,"children":37634},{"class":90,"line":1180},[37635],{"type":29,"tag":88,"props":37636,"children":37637},{"style":122},[37638],{"type":34,"value":433},{"type":29,"tag":88,"props":37640,"children":37641},{"class":90,"line":1240},[37642],{"type":29,"tag":88,"props":37643,"children":37644},{"style":122},[37645],{"type":34,"value":442},{"type":29,"tag":30,"props":37647,"children":37648},{},[37649,37651,37656],{"type":34,"value":37650},"Avec cette approche, la classe ",{"type":29,"tag":84,"props":37652,"children":37654},{"className":37653},[],[37655],{"type":34,"value":9538},{"type":34,"value":37657}," 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":29,"tag":8526,"props":37659,"children":37660},{"type":8528},[37661],{"type":29,"tag":30,"props":37662,"children":37663},{},[37664],{"type":34,"value":37665},"** Les classes abstraites sont très utiles pour éviter la duplication de code commun tout en respectant OCP.",{"type":29,"tag":47,"props":37667,"children":37668},{},[],{"type":29,"tag":51,"props":37670,"children":37672},{"id":37671},"les-pièges-courants-et-comment-les-éviter",[37673],{"type":34,"value":37674},"Les pièges courants et comment les éviter",{"type":29,"tag":30,"props":37676,"children":37677},{},[37678],{"type":34,"value":37679},"OCP a l'air simple sur le papier. L'appliquer sans déraper l'est moins. Trois erreurs reviennent constamment :",{"type":29,"tag":17095,"props":37681,"children":37682},{},[37683,37707],{"type":29,"tag":457,"props":37684,"children":37685},{},[37686,37691,37693,37698,37700,37705],{"type":29,"tag":447,"props":37687,"children":37688},{},[37689],{"type":34,"value":37690},"Complexité inutile",{"type":34,"value":37692}," : OCP doit rendre le code ",{"type":29,"tag":447,"props":37694,"children":37695},{},[37696],{"type":34,"value":37697},"extensible",{"type":34,"value":37699},", pas ",{"type":29,"tag":447,"props":37701,"children":37702},{},[37703],{"type":34,"value":37704},"complexe",{"type":34,"value":37706},". 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":29,"tag":457,"props":37708,"children":37709},{},[37710,37715,37717,37722],{"type":29,"tag":447,"props":37711,"children":37712},{},[37713],{"type":34,"value":37714},"Abus d'héritage",{"type":34,"value":37716}," : 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":29,"tag":447,"props":37718,"children":37719},{},[37720],{"type":34,"value":37721},"la composition",{"type":34,"value":37723}," (utiliser des objets plutôt que des sous-classes) donne un résultat plus flexible.",{"type":29,"tag":8526,"props":37725,"children":37726},{"type":8528},[37727],{"type":29,"tag":30,"props":37728,"children":37729},{},[37730,37735],{"type":29,"tag":447,"props":37731,"children":37732},{},[37733],{"type":34,"value":37734},"Entre héritage et composition, préférez la composition.",{"type":34,"value":37736}," Vous obtenez des modules plus flexibles et plus réutilisables.",{"type":29,"tag":17095,"props":37738,"children":37739},{"start":128},[37740],{"type":29,"tag":457,"props":37741,"children":37742},{},[37743,37748],{"type":29,"tag":447,"props":37744,"children":37745},{},[37746],{"type":34,"value":37747},"Modifier le code existant alors qu'on pourrait l'éviter",{"type":34,"value":37749}," : 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":29,"tag":47,"props":37751,"children":37752},{},[],{"type":29,"tag":51,"props":37754,"children":37756},{"id":37755},"conclusion-rendre-votre-code-plus-flexible-avec-ocp",[37757],{"type":34,"value":37758},"Conclusion : Rendre votre code plus flexible avec OCP",{"type":29,"tag":30,"props":37760,"children":37761},{},[37762],{"type":34,"value":37763},"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":29,"tag":30,"props":37765,"children":37766},{},[37767,37769,37773,37775,37779],{"type":34,"value":37768},"Interfaces, classes abstraites ou composition : peu importe l'outil, OCP donne à vos applications la marge d'adaptation aux changements futurs. En ",{"type":29,"tag":63,"props":37770,"children":37771},{"href":10180},[37772],{"type":34,"value":16975},{"type":34,"value":37774},", respecter ce principe signale un engagement clair : écrire du code qui fonctionne ",{"type":29,"tag":8474,"props":37776,"children":37777},{},[37778],{"type":34,"value":9930},{"type":34,"value":37780}," qui évolue avec élégance.",{"type":29,"tag":2288,"props":37782,"children":37784},{"cta":5629,"href":5630,"title":37783,"type":5632},"OCP n'est qu'une pratique parmi les 100 que j'applique pour coder propre",[37785],{"type":29,"tag":30,"props":37786,"children":37787},{},[37788],{"type":34,"value":37789},"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":29,"tag":47,"props":37791,"children":37792},{},[],{"type":29,"tag":51,"props":37794,"children":37795},{"id":15513},[37796],{"type":34,"value":15516},{"type":29,"tag":5649,"props":37798,"children":37799},{},[37800,37805],{"type":29,"tag":5653,"props":37801,"children":37802},{},[37803],{"type":34,"value":37804},"1. Comment savoir si j’applique correctement le principe OCP ?",{"type":29,"tag":30,"props":37806,"children":37807},{},[37808],{"type":34,"value":37809},"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":29,"tag":5649,"props":37811,"children":37812},{},[37813,37818],{"type":29,"tag":5653,"props":37814,"children":37815},{},[37816],{"type":34,"value":37817},"2. Est-ce que suivre OCP rend le code plus compliqué ?",{"type":29,"tag":30,"props":37819,"children":37820},{},[37821],{"type":34,"value":37822},"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":29,"tag":5649,"props":37824,"children":37825},{},[37826,37831],{"type":29,"tag":5653,"props":37827,"children":37828},{},[37829],{"type":34,"value":37830},"3. Que faire si j’ai déjà du code qui ne respecte pas OCP ?",{"type":29,"tag":30,"props":37832,"children":37833},{},[37834],{"type":34,"value":37835},"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":29,"tag":5649,"props":37837,"children":37838},{},[37839,37844],{"type":29,"tag":5653,"props":37840,"children":37841},{},[37842],{"type":34,"value":37843},"4. OCP est-il toujours applicable ?",{"type":29,"tag":30,"props":37845,"children":37846},{},[37847],{"type":34,"value":37848},"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":29,"tag":47,"props":37850,"children":37851},{},[],{"type":29,"tag":2288,"props":37853,"children":37854},{"cta":31609,"href":10075,"title":31610,"type":5755},[37855],{"type":29,"tag":30,"props":37856,"children":37857},{},[37858],{"type":34,"value":31616},{"type":29,"tag":5763,"props":37860,"children":37861},{},[37862],{"type":34,"value":5767},{"title":8,"searchDepth":101,"depth":101,"links":37864},[37865,37866,37870,37871,37874,37875,37876],{"id":35781,"depth":101,"text":35784},{"id":35818,"depth":101,"text":35821,"children":37867},[37868,37869],{"id":35870,"depth":128,"text":35873},{"id":36327,"depth":128,"text":36330},{"id":37031,"depth":101,"text":37034},{"id":37126,"depth":101,"text":37129,"children":37872},[37873],{"id":37137,"depth":128,"text":37140},{"id":37671,"depth":101,"text":37674},{"id":37755,"depth":101,"text":37758},{"id":15513,"depth":101,"text":15516},"content:fr:architecture-craft:principe-ocp-software-craftsmanship-exemples-java.md","fr\u002Farchitecture-craft\u002Fprincipe-ocp-software-craftsmanship-exemples-java.md","fr\u002Farchitecture-craft\u002Fprincipe-ocp-software-craftsmanship-exemples-java",{"_path":19437,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":37881,"description":37882,"id":3231,"date":37883,"listed":13,"nocomments":7,"hidden":7,"categories":37884,"tags":37885,"cover":37886,"readingTime":37887,"body":37891,"_type":5777,"_id":40306,"_source":5779,"_file":40307,"_stem":40308,"_extension":5782},"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...","2024-01-16",[6],[16,8453],"covers\u002Farticles\u002Fprincipe-srp.jpg",{"text":8457,"minutes":37888,"time":37889,"words":37890},7.345,440700,1469,{"type":26,"children":37892,"toc":40291},[37893,37899,37917,37937,37942,37948,37965,37970,37975,38200,38220,38225,38496,38523,38532,38538,38551,38557,38562,38568,38573,38579,38584,38590,38596,38609,38879,38884,39279,39285,39297,39620,39625,40077,40080,40086,40091,40144,40150,40156,40161,40167,40172,40178,40183,40189,40194,40203,40206,40212,40225,40238,40251,40264,40277,40280,40287],{"type":29,"tag":51,"props":37894,"children":37896},{"id":37895},"principe-srp-en-software-craftsmanship-explications-et-exemples-en-java",[37897],{"type":34,"value":37898},"Principe SRP en Software Craftsmanship : Explications et Exemples en Java",{"type":29,"tag":30,"props":37900,"children":37901},{},[37902,37904,37909,37911,37915],{"type":34,"value":37903},"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":29,"tag":447,"props":37905,"children":37906},{},[37907],{"type":34,"value":37908},"principe SRP (Single Responsibility Principle)",{"type":34,"value":37910},". Robert C. Martin, qui l'a formalisé dans ",{"type":29,"tag":8474,"props":37912,"children":37913},{},[37914],{"type":34,"value":8478},{"type":34,"value":37916},", le résume ainsi : une classe ne devrait avoir qu'une seule raison de changer.",{"type":29,"tag":30,"props":37918,"children":37919},{},[37920,37922,37926,37928,37935],{"type":34,"value":37921},"Le SRP est l'un des cinq ",{"type":29,"tag":63,"props":37923,"children":37924},{"href":9965},[37925],{"type":34,"value":9968},{"type":34,"value":37927},", piliers du ",{"type":29,"tag":447,"props":37929,"children":37930},{},[37931],{"type":29,"tag":63,"props":37932,"children":37933},{"href":10180},[37934],{"type":34,"value":10183},{"type":34,"value":37936},". 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":29,"tag":30,"props":37938,"children":37939},{},[37940],{"type":34,"value":37941},"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":29,"tag":51,"props":37943,"children":37945},{"id":37944},"introduction-au-principe-srp",[37946],{"type":34,"value":37947},"Introduction au principe SRP",{"type":29,"tag":30,"props":37949,"children":37950},{},[37951,37952,37956,37958,37963],{"type":34,"value":10213},{"type":29,"tag":447,"props":37953,"children":37954},{},[37955],{"type":34,"value":25217},{"type":34,"value":37957},", ou principe de responsabilité unique, est souvent résumé ainsi : ",{"type":29,"tag":447,"props":37959,"children":37960},{},[37961],{"type":34,"value":37962},"\"Une classe ne devrait avoir qu'une seule raison de changer.\"",{"type":34,"value":37964}," Autrement dit, une classe doit se concentrer sur une seule tâche ou responsabilité.",{"type":29,"tag":30,"props":37966,"children":37967},{},[37968],{"type":34,"value":37969},"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":29,"tag":30,"props":37971,"children":37972},{},[37973],{"type":34,"value":37974},"Prenons un exemple simple :",{"type":29,"tag":77,"props":37976,"children":37978},{"className":81,"code":37977,"language":80,"meta":8,"style":8},"public class UserManager {\n    public void createUser(String username, String password) {\n        \u002F\u002F Logique pour créer un utilisateur\n    }\n\n    public void log(String message) {\n        \u002F\u002F Logique pour enregistrer un log\n    }\n\n    public void sendEmail(String email, String message) {\n        \u002F\u002F Logique pour envoyer un email\n    }\n}\n",[37979],{"type":29,"tag":84,"props":37980,"children":37981},{"__ignoreMap":8},[37982,38002,38051,38059,38066,38073,38109,38117,38124,38131,38178,38186,38193],{"type":29,"tag":88,"props":37983,"children":37984},{"class":90,"line":91},[37985,37989,37993,37998],{"type":29,"tag":88,"props":37986,"children":37987},{"style":105},[37988],{"type":34,"value":108},{"type":29,"tag":88,"props":37990,"children":37991},{"style":105},[37992],{"type":34,"value":113},{"type":29,"tag":88,"props":37994,"children":37995},{"style":116},[37996],{"type":34,"value":37997}," UserManager",{"type":29,"tag":88,"props":37999,"children":38000},{"style":122},[38001],{"type":34,"value":125},{"type":29,"tag":88,"props":38003,"children":38004},{"class":90,"line":101},[38005,38009,38013,38017,38021,38025,38030,38034,38038,38043,38047],{"type":29,"tag":88,"props":38006,"children":38007},{"style":105},[38008],{"type":34,"value":276},{"type":29,"tag":88,"props":38010,"children":38011},{"style":105},[38012],{"type":34,"value":1303},{"type":29,"tag":88,"props":38014,"children":38015},{"style":174},[38016],{"type":34,"value":7945},{"type":29,"tag":88,"props":38018,"children":38019},{"style":122},[38020],{"type":34,"value":181},{"type":29,"tag":88,"props":38022,"children":38023},{"style":151},[38024],{"type":34,"value":695},{"type":29,"tag":88,"props":38026,"children":38027},{"style":298},[38028],{"type":34,"value":38029}," username",{"type":29,"tag":88,"props":38031,"children":38032},{"style":122},[38033],{"type":34,"value":192},{"type":29,"tag":88,"props":38035,"children":38036},{"style":151},[38037],{"type":34,"value":281},{"type":29,"tag":88,"props":38039,"children":38040},{"style":298},[38041],{"type":34,"value":38042}," password",{"type":29,"tag":88,"props":38044,"children":38045},{"style":122},[38046],{"type":34,"value":306},{"type":29,"tag":88,"props":38048,"children":38049},{"style":122},[38050],{"type":34,"value":125},{"type":29,"tag":88,"props":38052,"children":38053},{"class":90,"line":128},[38054],{"type":29,"tag":88,"props":38055,"children":38056},{"style":95},[38057],{"type":34,"value":38058},"        \u002F\u002F Logique pour créer un utilisateur\n",{"type":29,"tag":88,"props":38060,"children":38061},{"class":90,"line":137},[38062],{"type":29,"tag":88,"props":38063,"children":38064},{"style":122},[38065],{"type":34,"value":433},{"type":29,"tag":88,"props":38067,"children":38068},{"class":90,"line":211},[38069],{"type":29,"tag":88,"props":38070,"children":38071},{"emptyLinePlaceholder":13},[38072],{"type":34,"value":134},{"type":29,"tag":88,"props":38074,"children":38075},{"class":90,"line":262},[38076,38080,38084,38089,38093,38097,38101,38105],{"type":29,"tag":88,"props":38077,"children":38078},{"style":105},[38079],{"type":34,"value":276},{"type":29,"tag":88,"props":38081,"children":38082},{"style":105},[38083],{"type":34,"value":1303},{"type":29,"tag":88,"props":38085,"children":38086},{"style":174},[38087],{"type":34,"value":38088}," log",{"type":29,"tag":88,"props":38090,"children":38091},{"style":122},[38092],{"type":34,"value":181},{"type":29,"tag":88,"props":38094,"children":38095},{"style":151},[38096],{"type":34,"value":695},{"type":29,"tag":88,"props":38098,"children":38099},{"style":298},[38100],{"type":34,"value":23950},{"type":29,"tag":88,"props":38102,"children":38103},{"style":122},[38104],{"type":34,"value":306},{"type":29,"tag":88,"props":38106,"children":38107},{"style":122},[38108],{"type":34,"value":125},{"type":29,"tag":88,"props":38110,"children":38111},{"class":90,"line":270},[38112],{"type":29,"tag":88,"props":38113,"children":38114},{"style":95},[38115],{"type":34,"value":38116},"        \u002F\u002F Logique pour enregistrer un log\n",{"type":29,"tag":88,"props":38118,"children":38119},{"class":90,"line":313},[38120],{"type":29,"tag":88,"props":38121,"children":38122},{"style":122},[38123],{"type":34,"value":433},{"type":29,"tag":88,"props":38125,"children":38126},{"class":90,"line":360},[38127],{"type":29,"tag":88,"props":38128,"children":38129},{"emptyLinePlaceholder":13},[38130],{"type":34,"value":134},{"type":29,"tag":88,"props":38132,"children":38133},{"class":90,"line":409},[38134,38138,38142,38146,38150,38154,38158,38162,38166,38170,38174],{"type":29,"tag":88,"props":38135,"children":38136},{"style":105},[38137],{"type":34,"value":276},{"type":29,"tag":88,"props":38139,"children":38140},{"style":105},[38141],{"type":34,"value":1303},{"type":29,"tag":88,"props":38143,"children":38144},{"style":174},[38145],{"type":34,"value":23937},{"type":29,"tag":88,"props":38147,"children":38148},{"style":122},[38149],{"type":34,"value":181},{"type":29,"tag":88,"props":38151,"children":38152},{"style":151},[38153],{"type":34,"value":695},{"type":29,"tag":88,"props":38155,"children":38156},{"style":298},[38157],{"type":34,"value":700},{"type":29,"tag":88,"props":38159,"children":38160},{"style":122},[38161],{"type":34,"value":192},{"type":29,"tag":88,"props":38163,"children":38164},{"style":151},[38165],{"type":34,"value":281},{"type":29,"tag":88,"props":38167,"children":38168},{"style":298},[38169],{"type":34,"value":23950},{"type":29,"tag":88,"props":38171,"children":38172},{"style":122},[38173],{"type":34,"value":306},{"type":29,"tag":88,"props":38175,"children":38176},{"style":122},[38177],{"type":34,"value":125},{"type":29,"tag":88,"props":38179,"children":38180},{"class":90,"line":427},[38181],{"type":29,"tag":88,"props":38182,"children":38183},{"style":95},[38184],{"type":34,"value":38185},"        \u002F\u002F Logique pour envoyer un email\n",{"type":29,"tag":88,"props":38187,"children":38188},{"class":90,"line":436},[38189],{"type":29,"tag":88,"props":38190,"children":38191},{"style":122},[38192],{"type":34,"value":433},{"type":29,"tag":88,"props":38194,"children":38195},{"class":90,"line":767},[38196],{"type":29,"tag":88,"props":38197,"children":38198},{"style":122},[38199],{"type":34,"value":442},{"type":29,"tag":30,"props":38201,"children":38202},{},[38203,38204,38210,38212,38218],{"type":34,"value":32257},{"type":29,"tag":84,"props":38205,"children":38207},{"className":38206},[],[38208],{"type":34,"value":38209},"UserManager",{"type":34,"value":38211}," 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":29,"tag":84,"props":38213,"children":38215},{"className":38214},[],[38216],{"type":34,"value":38217},"createUser",{"type":34,"value":38219},", vous risquez de casser des fonctionnalités de logging ou d'emailing, car tout est couplé dans une seule classe.",{"type":29,"tag":30,"props":38221,"children":38222},{},[38223],{"type":34,"value":38224},"Pour appliquer le SRP, vous devez découper cette classe en plusieurs classes, chacune ayant une responsabilité bien définie :",{"type":29,"tag":77,"props":38226,"children":38228},{"className":81,"code":38227,"language":80,"meta":8,"style":8},"public class UserManager {\n    public void createUser(String username, String password) {\n        \u002F\u002F Logique pour créer un utilisateur\n    }\n}\n\npublic class Logger {\n    public void log(String message) {\n        \u002F\u002F Logique pour enregistrer un log\n    }\n}\n\npublic class EmailService {\n    public void sendEmail(String email, String message) {\n        \u002F\u002F Logique pour envoyer un email\n    }\n}\n",[38229],{"type":29,"tag":84,"props":38230,"children":38231},{"__ignoreMap":8},[38232,38251,38298,38305,38312,38319,38326,38346,38381,38388,38395,38402,38409,38428,38475,38482,38489],{"type":29,"tag":88,"props":38233,"children":38234},{"class":90,"line":91},[38235,38239,38243,38247],{"type":29,"tag":88,"props":38236,"children":38237},{"style":105},[38238],{"type":34,"value":108},{"type":29,"tag":88,"props":38240,"children":38241},{"style":105},[38242],{"type":34,"value":113},{"type":29,"tag":88,"props":38244,"children":38245},{"style":116},[38246],{"type":34,"value":37997},{"type":29,"tag":88,"props":38248,"children":38249},{"style":122},[38250],{"type":34,"value":125},{"type":29,"tag":88,"props":38252,"children":38253},{"class":90,"line":101},[38254,38258,38262,38266,38270,38274,38278,38282,38286,38290,38294],{"type":29,"tag":88,"props":38255,"children":38256},{"style":105},[38257],{"type":34,"value":276},{"type":29,"tag":88,"props":38259,"children":38260},{"style":105},[38261],{"type":34,"value":1303},{"type":29,"tag":88,"props":38263,"children":38264},{"style":174},[38265],{"type":34,"value":7945},{"type":29,"tag":88,"props":38267,"children":38268},{"style":122},[38269],{"type":34,"value":181},{"type":29,"tag":88,"props":38271,"children":38272},{"style":151},[38273],{"type":34,"value":695},{"type":29,"tag":88,"props":38275,"children":38276},{"style":298},[38277],{"type":34,"value":38029},{"type":29,"tag":88,"props":38279,"children":38280},{"style":122},[38281],{"type":34,"value":192},{"type":29,"tag":88,"props":38283,"children":38284},{"style":151},[38285],{"type":34,"value":281},{"type":29,"tag":88,"props":38287,"children":38288},{"style":298},[38289],{"type":34,"value":38042},{"type":29,"tag":88,"props":38291,"children":38292},{"style":122},[38293],{"type":34,"value":306},{"type":29,"tag":88,"props":38295,"children":38296},{"style":122},[38297],{"type":34,"value":125},{"type":29,"tag":88,"props":38299,"children":38300},{"class":90,"line":128},[38301],{"type":29,"tag":88,"props":38302,"children":38303},{"style":95},[38304],{"type":34,"value":38058},{"type":29,"tag":88,"props":38306,"children":38307},{"class":90,"line":137},[38308],{"type":29,"tag":88,"props":38309,"children":38310},{"style":122},[38311],{"type":34,"value":433},{"type":29,"tag":88,"props":38313,"children":38314},{"class":90,"line":211},[38315],{"type":29,"tag":88,"props":38316,"children":38317},{"style":122},[38318],{"type":34,"value":442},{"type":29,"tag":88,"props":38320,"children":38321},{"class":90,"line":262},[38322],{"type":29,"tag":88,"props":38323,"children":38324},{"emptyLinePlaceholder":13},[38325],{"type":34,"value":134},{"type":29,"tag":88,"props":38327,"children":38328},{"class":90,"line":270},[38329,38333,38337,38342],{"type":29,"tag":88,"props":38330,"children":38331},{"style":105},[38332],{"type":34,"value":108},{"type":29,"tag":88,"props":38334,"children":38335},{"style":105},[38336],{"type":34,"value":113},{"type":29,"tag":88,"props":38338,"children":38339},{"style":116},[38340],{"type":34,"value":38341}," Logger",{"type":29,"tag":88,"props":38343,"children":38344},{"style":122},[38345],{"type":34,"value":125},{"type":29,"tag":88,"props":38347,"children":38348},{"class":90,"line":313},[38349,38353,38357,38361,38365,38369,38373,38377],{"type":29,"tag":88,"props":38350,"children":38351},{"style":105},[38352],{"type":34,"value":276},{"type":29,"tag":88,"props":38354,"children":38355},{"style":105},[38356],{"type":34,"value":1303},{"type":29,"tag":88,"props":38358,"children":38359},{"style":174},[38360],{"type":34,"value":38088},{"type":29,"tag":88,"props":38362,"children":38363},{"style":122},[38364],{"type":34,"value":181},{"type":29,"tag":88,"props":38366,"children":38367},{"style":151},[38368],{"type":34,"value":695},{"type":29,"tag":88,"props":38370,"children":38371},{"style":298},[38372],{"type":34,"value":23950},{"type":29,"tag":88,"props":38374,"children":38375},{"style":122},[38376],{"type":34,"value":306},{"type":29,"tag":88,"props":38378,"children":38379},{"style":122},[38380],{"type":34,"value":125},{"type":29,"tag":88,"props":38382,"children":38383},{"class":90,"line":360},[38384],{"type":29,"tag":88,"props":38385,"children":38386},{"style":95},[38387],{"type":34,"value":38116},{"type":29,"tag":88,"props":38389,"children":38390},{"class":90,"line":409},[38391],{"type":29,"tag":88,"props":38392,"children":38393},{"style":122},[38394],{"type":34,"value":433},{"type":29,"tag":88,"props":38396,"children":38397},{"class":90,"line":427},[38398],{"type":29,"tag":88,"props":38399,"children":38400},{"style":122},[38401],{"type":34,"value":442},{"type":29,"tag":88,"props":38403,"children":38404},{"class":90,"line":436},[38405],{"type":29,"tag":88,"props":38406,"children":38407},{"emptyLinePlaceholder":13},[38408],{"type":34,"value":134},{"type":29,"tag":88,"props":38410,"children":38411},{"class":90,"line":767},[38412,38416,38420,38424],{"type":29,"tag":88,"props":38413,"children":38414},{"style":105},[38415],{"type":34,"value":108},{"type":29,"tag":88,"props":38417,"children":38418},{"style":105},[38419],{"type":34,"value":113},{"type":29,"tag":88,"props":38421,"children":38422},{"style":116},[38423],{"type":34,"value":7300},{"type":29,"tag":88,"props":38425,"children":38426},{"style":122},[38427],{"type":34,"value":125},{"type":29,"tag":88,"props":38429,"children":38430},{"class":90,"line":792},[38431,38435,38439,38443,38447,38451,38455,38459,38463,38467,38471],{"type":29,"tag":88,"props":38432,"children":38433},{"style":105},[38434],{"type":34,"value":276},{"type":29,"tag":88,"props":38436,"children":38437},{"style":105},[38438],{"type":34,"value":1303},{"type":29,"tag":88,"props":38440,"children":38441},{"style":174},[38442],{"type":34,"value":23937},{"type":29,"tag":88,"props":38444,"children":38445},{"style":122},[38446],{"type":34,"value":181},{"type":29,"tag":88,"props":38448,"children":38449},{"style":151},[38450],{"type":34,"value":695},{"type":29,"tag":88,"props":38452,"children":38453},{"style":298},[38454],{"type":34,"value":700},{"type":29,"tag":88,"props":38456,"children":38457},{"style":122},[38458],{"type":34,"value":192},{"type":29,"tag":88,"props":38460,"children":38461},{"style":151},[38462],{"type":34,"value":281},{"type":29,"tag":88,"props":38464,"children":38465},{"style":298},[38466],{"type":34,"value":23950},{"type":29,"tag":88,"props":38468,"children":38469},{"style":122},[38470],{"type":34,"value":306},{"type":29,"tag":88,"props":38472,"children":38473},{"style":122},[38474],{"type":34,"value":125},{"type":29,"tag":88,"props":38476,"children":38477},{"class":90,"line":817},[38478],{"type":29,"tag":88,"props":38479,"children":38480},{"style":95},[38481],{"type":34,"value":38185},{"type":29,"tag":88,"props":38483,"children":38484},{"class":90,"line":825},[38485],{"type":29,"tag":88,"props":38486,"children":38487},{"style":122},[38488],{"type":34,"value":433},{"type":29,"tag":88,"props":38490,"children":38491},{"class":90,"line":869},[38492],{"type":29,"tag":88,"props":38493,"children":38494},{"style":122},[38495],{"type":34,"value":442},{"type":29,"tag":30,"props":38497,"children":38498},{},[38499,38501,38506,38508,38514,38516,38521],{"type":34,"value":38500},"Maintenant, chaque classe a une seule responsabilité : ",{"type":29,"tag":84,"props":38502,"children":38504},{"className":38503},[],[38505],{"type":34,"value":38209},{"type":34,"value":38507}," s'occupe de la création d'utilisateur, ",{"type":29,"tag":84,"props":38509,"children":38511},{"className":38510},[],[38512],{"type":34,"value":38513},"Logger",{"type":34,"value":38515}," gère les logs, et ",{"type":29,"tag":84,"props":38517,"children":38519},{"className":38518},[],[38520],{"type":34,"value":23894},{"type":34,"value":38522}," est responsable de l'envoi des emails. Cela rend le code plus propre et plus facile à maintenir.",{"type":29,"tag":2288,"props":38524,"children":38526},{"cta":2290,"href":2291,"title":38525,"type":2293},"Vous voulez sentir où découper une classe sans tomber dans la sur-fragmentation ?",[38527],{"type":29,"tag":30,"props":38528,"children":38529},{},[38530],{"type":34,"value":38531},"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":29,"tag":51,"props":38533,"children":38535},{"id":38534},"pourquoi-le-srp-est-il-important-dans-le-software-craftsmanship",[38536],{"type":34,"value":38537},"Pourquoi le SRP est-il important dans le Software Craftsmanship ?",{"type":29,"tag":30,"props":38539,"children":38540},{},[38541,38542,38549],{"type":34,"value":10213},{"type":29,"tag":447,"props":38543,"children":38544},{},[38545],{"type":29,"tag":63,"props":38546,"children":38547},{"href":10180},[38548],{"type":34,"value":10183},{"type":34,"value":38550}," 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":29,"tag":10576,"props":38552,"children":38554},{"id":38553},"simplification-et-maintenabilité",[38555],{"type":34,"value":38556},"Simplification et maintenabilité",{"type":29,"tag":30,"props":38558,"children":38559},{},[38560],{"type":34,"value":38561},"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":29,"tag":10576,"props":38563,"children":38565},{"id":38564},"facilite-les-tests-unitaires",[38566],{"type":34,"value":38567},"Facilite les tests unitaires",{"type":29,"tag":30,"props":38569,"children":38570},{},[38571],{"type":34,"value":38572},"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":29,"tag":10576,"props":38574,"children":38576},{"id":38575},"favorise-lévolutivité",[38577],{"type":34,"value":38578},"Favorise l’évolutivité",{"type":29,"tag":30,"props":38580,"children":38581},{},[38582],{"type":34,"value":38583},"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":29,"tag":8542,"props":38585,"children":38587},{"id":38586},"_3-comment-appliquer-le-srp-en-java-exemples-concrets",[38588],{"type":34,"value":38589},"3. Comment appliquer le SRP en Java : exemples concrets",{"type":29,"tag":10576,"props":38591,"children":38593},{"id":38592},"exemple-1-gestion-des-utilisateurs",[38594],{"type":34,"value":38595},"Exemple 1 : Gestion des utilisateurs",{"type":29,"tag":30,"props":38597,"children":38598},{},[38599,38601,38607],{"type":34,"value":38600},"Voici un exemple de violation du SRP avec une classe ",{"type":29,"tag":84,"props":38602,"children":38604},{"className":38603},[],[38605],{"type":34,"value":38606},"UserService",{"type":34,"value":38608}," qui gère à la fois la création d'utilisateurs et l'envoi d'emails.",{"type":29,"tag":77,"props":38610,"children":38612},{"className":81,"code":38611,"language":80,"meta":8,"style":8},"public class UserService {\n    public void createUser(String username, String password) {\n        \u002F\u002F Logique pour créer un utilisateur\n        System.out.println(\"Utilisateur créé avec succès !\");\n        \n        \u002F\u002F Envoyer un email de bienvenue\n        sendWelcomeEmail(username);\n    }\n\n    public void sendWelcomeEmail(String username) {\n        \u002F\u002F Logique pour envoyer un email de bienvenue\n        System.out.println(\"Email envoyé à \" + username);\n    }\n}\n",[38613],{"type":29,"tag":84,"props":38614,"children":38615},{"__ignoreMap":8},[38616,38636,38683,38690,38726,38734,38742,38763,38770,38777,38813,38821,38865,38872],{"type":29,"tag":88,"props":38617,"children":38618},{"class":90,"line":91},[38619,38623,38627,38632],{"type":29,"tag":88,"props":38620,"children":38621},{"style":105},[38622],{"type":34,"value":108},{"type":29,"tag":88,"props":38624,"children":38625},{"style":105},[38626],{"type":34,"value":113},{"type":29,"tag":88,"props":38628,"children":38629},{"style":116},[38630],{"type":34,"value":38631}," UserService",{"type":29,"tag":88,"props":38633,"children":38634},{"style":122},[38635],{"type":34,"value":125},{"type":29,"tag":88,"props":38637,"children":38638},{"class":90,"line":101},[38639,38643,38647,38651,38655,38659,38663,38667,38671,38675,38679],{"type":29,"tag":88,"props":38640,"children":38641},{"style":105},[38642],{"type":34,"value":276},{"type":29,"tag":88,"props":38644,"children":38645},{"style":105},[38646],{"type":34,"value":1303},{"type":29,"tag":88,"props":38648,"children":38649},{"style":174},[38650],{"type":34,"value":7945},{"type":29,"tag":88,"props":38652,"children":38653},{"style":122},[38654],{"type":34,"value":181},{"type":29,"tag":88,"props":38656,"children":38657},{"style":151},[38658],{"type":34,"value":695},{"type":29,"tag":88,"props":38660,"children":38661},{"style":298},[38662],{"type":34,"value":38029},{"type":29,"tag":88,"props":38664,"children":38665},{"style":122},[38666],{"type":34,"value":192},{"type":29,"tag":88,"props":38668,"children":38669},{"style":151},[38670],{"type":34,"value":281},{"type":29,"tag":88,"props":38672,"children":38673},{"style":298},[38674],{"type":34,"value":38042},{"type":29,"tag":88,"props":38676,"children":38677},{"style":122},[38678],{"type":34,"value":306},{"type":29,"tag":88,"props":38680,"children":38681},{"style":122},[38682],{"type":34,"value":125},{"type":29,"tag":88,"props":38684,"children":38685},{"class":90,"line":128},[38686],{"type":29,"tag":88,"props":38687,"children":38688},{"style":95},[38689],{"type":34,"value":38058},{"type":29,"tag":88,"props":38691,"children":38692},{"class":90,"line":137},[38693,38697,38701,38705,38709,38713,38717,38722],{"type":29,"tag":88,"props":38694,"children":38695},{"style":157},[38696],{"type":34,"value":19726},{"type":29,"tag":88,"props":38698,"children":38699},{"style":122},[38700],{"type":34,"value":338},{"type":29,"tag":88,"props":38702,"children":38703},{"style":157},[38704],{"type":34,"value":18091},{"type":29,"tag":88,"props":38706,"children":38707},{"style":122},[38708],{"type":34,"value":338},{"type":29,"tag":88,"props":38710,"children":38711},{"style":174},[38712],{"type":34,"value":18100},{"type":29,"tag":88,"props":38714,"children":38715},{"style":122},[38716],{"type":34,"value":181},{"type":29,"tag":88,"props":38718,"children":38719},{"style":184},[38720],{"type":34,"value":38721},"\"Utilisateur créé avec succès !\"",{"type":29,"tag":88,"props":38723,"children":38724},{"style":122},[38725],{"type":34,"value":357},{"type":29,"tag":88,"props":38727,"children":38728},{"class":90,"line":211},[38729],{"type":29,"tag":88,"props":38730,"children":38731},{"style":157},[38732],{"type":34,"value":38733},"        \n",{"type":29,"tag":88,"props":38735,"children":38736},{"class":90,"line":262},[38737],{"type":29,"tag":88,"props":38738,"children":38739},{"style":95},[38740],{"type":34,"value":38741},"        \u002F\u002F Envoyer un email de bienvenue\n",{"type":29,"tag":88,"props":38743,"children":38744},{"class":90,"line":270},[38745,38750,38754,38759],{"type":29,"tag":88,"props":38746,"children":38747},{"style":174},[38748],{"type":34,"value":38749},"        sendWelcomeEmail",{"type":29,"tag":88,"props":38751,"children":38752},{"style":122},[38753],{"type":34,"value":181},{"type":29,"tag":88,"props":38755,"children":38756},{"style":157},[38757],{"type":34,"value":38758},"username",{"type":29,"tag":88,"props":38760,"children":38761},{"style":122},[38762],{"type":34,"value":357},{"type":29,"tag":88,"props":38764,"children":38765},{"class":90,"line":313},[38766],{"type":29,"tag":88,"props":38767,"children":38768},{"style":122},[38769],{"type":34,"value":433},{"type":29,"tag":88,"props":38771,"children":38772},{"class":90,"line":360},[38773],{"type":29,"tag":88,"props":38774,"children":38775},{"emptyLinePlaceholder":13},[38776],{"type":34,"value":134},{"type":29,"tag":88,"props":38778,"children":38779},{"class":90,"line":409},[38780,38784,38788,38793,38797,38801,38805,38809],{"type":29,"tag":88,"props":38781,"children":38782},{"style":105},[38783],{"type":34,"value":276},{"type":29,"tag":88,"props":38785,"children":38786},{"style":105},[38787],{"type":34,"value":1303},{"type":29,"tag":88,"props":38789,"children":38790},{"style":174},[38791],{"type":34,"value":38792}," sendWelcomeEmail",{"type":29,"tag":88,"props":38794,"children":38795},{"style":122},[38796],{"type":34,"value":181},{"type":29,"tag":88,"props":38798,"children":38799},{"style":151},[38800],{"type":34,"value":695},{"type":29,"tag":88,"props":38802,"children":38803},{"style":298},[38804],{"type":34,"value":38029},{"type":29,"tag":88,"props":38806,"children":38807},{"style":122},[38808],{"type":34,"value":306},{"type":29,"tag":88,"props":38810,"children":38811},{"style":122},[38812],{"type":34,"value":125},{"type":29,"tag":88,"props":38814,"children":38815},{"class":90,"line":427},[38816],{"type":29,"tag":88,"props":38817,"children":38818},{"style":95},[38819],{"type":34,"value":38820},"        \u002F\u002F Logique pour envoyer un email de bienvenue\n",{"type":29,"tag":88,"props":38822,"children":38823},{"class":90,"line":436},[38824,38828,38832,38836,38840,38844,38848,38853,38857,38861],{"type":29,"tag":88,"props":38825,"children":38826},{"style":157},[38827],{"type":34,"value":19726},{"type":29,"tag":88,"props":38829,"children":38830},{"style":122},[38831],{"type":34,"value":338},{"type":29,"tag":88,"props":38833,"children":38834},{"style":157},[38835],{"type":34,"value":18091},{"type":29,"tag":88,"props":38837,"children":38838},{"style":122},[38839],{"type":34,"value":338},{"type":29,"tag":88,"props":38841,"children":38842},{"style":174},[38843],{"type":34,"value":18100},{"type":29,"tag":88,"props":38845,"children":38846},{"style":122},[38847],{"type":34,"value":181},{"type":29,"tag":88,"props":38849,"children":38850},{"style":184},[38851],{"type":34,"value":38852},"\"Email envoyé à \"",{"type":29,"tag":88,"props":38854,"children":38855},{"style":163},[38856],{"type":34,"value":5485},{"type":29,"tag":88,"props":38858,"children":38859},{"style":157},[38860],{"type":34,"value":38029},{"type":29,"tag":88,"props":38862,"children":38863},{"style":122},[38864],{"type":34,"value":357},{"type":29,"tag":88,"props":38866,"children":38867},{"class":90,"line":767},[38868],{"type":29,"tag":88,"props":38869,"children":38870},{"style":122},[38871],{"type":34,"value":433},{"type":29,"tag":88,"props":38873,"children":38874},{"class":90,"line":792},[38875],{"type":29,"tag":88,"props":38876,"children":38877},{"style":122},[38878],{"type":34,"value":442},{"type":29,"tag":30,"props":38880,"children":38881},{},[38882],{"type":34,"value":38883},"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":29,"tag":77,"props":38885,"children":38887},{"className":81,"code":38886,"language":80,"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        \u002F\u002F Logique pour créer un utilisateur\n        System.out.println(\"Utilisateur créé avec succès !\");\n        \n        \u002F\u002F 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        \u002F\u002F Logique pour envoyer un email de bienvenue\n        System.out.println(\"Email envoyé à \" + username);\n    }\n}\n",[38888],{"type":29,"tag":84,"props":38889,"children":38890},{"__ignoreMap":8},[38891,38910,38929,38936,38967,38994,39001,39008,39055,39062,39097,39104,39112,39140,39147,39154,39161,39180,39215,39222,39265,39272],{"type":29,"tag":88,"props":38892,"children":38893},{"class":90,"line":91},[38894,38898,38902,38906],{"type":29,"tag":88,"props":38895,"children":38896},{"style":105},[38897],{"type":34,"value":108},{"type":29,"tag":88,"props":38899,"children":38900},{"style":105},[38901],{"type":34,"value":113},{"type":29,"tag":88,"props":38903,"children":38904},{"style":116},[38905],{"type":34,"value":38631},{"type":29,"tag":88,"props":38907,"children":38908},{"style":122},[38909],{"type":34,"value":125},{"type":29,"tag":88,"props":38911,"children":38912},{"class":90,"line":101},[38913,38917,38921,38925],{"type":29,"tag":88,"props":38914,"children":38915},{"style":105},[38916],{"type":34,"value":143},{"type":29,"tag":88,"props":38918,"children":38919},{"style":151},[38920],{"type":34,"value":7300},{"type":29,"tag":88,"props":38922,"children":38923},{"style":157},[38924],{"type":34,"value":7305},{"type":29,"tag":88,"props":38926,"children":38927},{"style":122},[38928],{"type":34,"value":424},{"type":29,"tag":88,"props":38930,"children":38931},{"class":90,"line":128},[38932],{"type":29,"tag":88,"props":38933,"children":38934},{"emptyLinePlaceholder":13},[38935],{"type":34,"value":134},{"type":29,"tag":88,"props":38937,"children":38938},{"class":90,"line":137},[38939,38943,38947,38951,38955,38959,38963],{"type":29,"tag":88,"props":38940,"children":38941},{"style":105},[38942],{"type":34,"value":276},{"type":29,"tag":88,"props":38944,"children":38945},{"style":174},[38946],{"type":34,"value":38631},{"type":29,"tag":88,"props":38948,"children":38949},{"style":122},[38950],{"type":34,"value":181},{"type":29,"tag":88,"props":38952,"children":38953},{"style":151},[38954],{"type":34,"value":23894},{"type":29,"tag":88,"props":38956,"children":38957},{"style":298},[38958],{"type":34,"value":7305},{"type":29,"tag":88,"props":38960,"children":38961},{"style":122},[38962],{"type":34,"value":306},{"type":29,"tag":88,"props":38964,"children":38965},{"style":122},[38966],{"type":34,"value":125},{"type":29,"tag":88,"props":38968,"children":38969},{"class":90,"line":211},[38970,38974,38978,38982,38986,38990],{"type":29,"tag":88,"props":38971,"children":38972},{"style":873},[38973],{"type":34,"value":876},{"type":29,"tag":88,"props":38975,"children":38976},{"style":122},[38977],{"type":34,"value":338},{"type":29,"tag":88,"props":38979,"children":38980},{"style":157},[38981],{"type":34,"value":7404},{"type":29,"tag":88,"props":38983,"children":38984},{"style":163},[38985],{"type":34,"value":166},{"type":29,"tag":88,"props":38987,"children":38988},{"style":157},[38989],{"type":34,"value":7305},{"type":29,"tag":88,"props":38991,"children":38992},{"style":122},[38993],{"type":34,"value":424},{"type":29,"tag":88,"props":38995,"children":38996},{"class":90,"line":262},[38997],{"type":29,"tag":88,"props":38998,"children":38999},{"style":122},[39000],{"type":34,"value":433},{"type":29,"tag":88,"props":39002,"children":39003},{"class":90,"line":270},[39004],{"type":29,"tag":88,"props":39005,"children":39006},{"emptyLinePlaceholder":13},[39007],{"type":34,"value":134},{"type":29,"tag":88,"props":39009,"children":39010},{"class":90,"line":313},[39011,39015,39019,39023,39027,39031,39035,39039,39043,39047,39051],{"type":29,"tag":88,"props":39012,"children":39013},{"style":105},[39014],{"type":34,"value":276},{"type":29,"tag":88,"props":39016,"children":39017},{"style":105},[39018],{"type":34,"value":1303},{"type":29,"tag":88,"props":39020,"children":39021},{"style":174},[39022],{"type":34,"value":7945},{"type":29,"tag":88,"props":39024,"children":39025},{"style":122},[39026],{"type":34,"value":181},{"type":29,"tag":88,"props":39028,"children":39029},{"style":151},[39030],{"type":34,"value":695},{"type":29,"tag":88,"props":39032,"children":39033},{"style":298},[39034],{"type":34,"value":38029},{"type":29,"tag":88,"props":39036,"children":39037},{"style":122},[39038],{"type":34,"value":192},{"type":29,"tag":88,"props":39040,"children":39041},{"style":151},[39042],{"type":34,"value":281},{"type":29,"tag":88,"props":39044,"children":39045},{"style":298},[39046],{"type":34,"value":38042},{"type":29,"tag":88,"props":39048,"children":39049},{"style":122},[39050],{"type":34,"value":306},{"type":29,"tag":88,"props":39052,"children":39053},{"style":122},[39054],{"type":34,"value":125},{"type":29,"tag":88,"props":39056,"children":39057},{"class":90,"line":360},[39058],{"type":29,"tag":88,"props":39059,"children":39060},{"style":95},[39061],{"type":34,"value":38058},{"type":29,"tag":88,"props":39063,"children":39064},{"class":90,"line":409},[39065,39069,39073,39077,39081,39085,39089,39093],{"type":29,"tag":88,"props":39066,"children":39067},{"style":157},[39068],{"type":34,"value":19726},{"type":29,"tag":88,"props":39070,"children":39071},{"style":122},[39072],{"type":34,"value":338},{"type":29,"tag":88,"props":39074,"children":39075},{"style":157},[39076],{"type":34,"value":18091},{"type":29,"tag":88,"props":39078,"children":39079},{"style":122},[39080],{"type":34,"value":338},{"type":29,"tag":88,"props":39082,"children":39083},{"style":174},[39084],{"type":34,"value":18100},{"type":29,"tag":88,"props":39086,"children":39087},{"style":122},[39088],{"type":34,"value":181},{"type":29,"tag":88,"props":39090,"children":39091},{"style":184},[39092],{"type":34,"value":38721},{"type":29,"tag":88,"props":39094,"children":39095},{"style":122},[39096],{"type":34,"value":357},{"type":29,"tag":88,"props":39098,"children":39099},{"class":90,"line":427},[39100],{"type":29,"tag":88,"props":39101,"children":39102},{"style":157},[39103],{"type":34,"value":38733},{"type":29,"tag":88,"props":39105,"children":39106},{"class":90,"line":436},[39107],{"type":29,"tag":88,"props":39108,"children":39109},{"style":95},[39110],{"type":34,"value":39111},"        \u002F\u002F Utilisation de l'EmailService pour envoyer l'email\n",{"type":29,"tag":88,"props":39113,"children":39114},{"class":90,"line":767},[39115,39119,39123,39128,39132,39136],{"type":29,"tag":88,"props":39116,"children":39117},{"style":157},[39118],{"type":34,"value":7670},{"type":29,"tag":88,"props":39120,"children":39121},{"style":122},[39122],{"type":34,"value":338},{"type":29,"tag":88,"props":39124,"children":39125},{"style":174},[39126],{"type":34,"value":39127},"sendWelcomeEmail",{"type":29,"tag":88,"props":39129,"children":39130},{"style":122},[39131],{"type":34,"value":181},{"type":29,"tag":88,"props":39133,"children":39134},{"style":157},[39135],{"type":34,"value":38758},{"type":29,"tag":88,"props":39137,"children":39138},{"style":122},[39139],{"type":34,"value":357},{"type":29,"tag":88,"props":39141,"children":39142},{"class":90,"line":792},[39143],{"type":29,"tag":88,"props":39144,"children":39145},{"style":122},[39146],{"type":34,"value":433},{"type":29,"tag":88,"props":39148,"children":39149},{"class":90,"line":817},[39150],{"type":29,"tag":88,"props":39151,"children":39152},{"style":122},[39153],{"type":34,"value":442},{"type":29,"tag":88,"props":39155,"children":39156},{"class":90,"line":825},[39157],{"type":29,"tag":88,"props":39158,"children":39159},{"emptyLinePlaceholder":13},[39160],{"type":34,"value":134},{"type":29,"tag":88,"props":39162,"children":39163},{"class":90,"line":869},[39164,39168,39172,39176],{"type":29,"tag":88,"props":39165,"children":39166},{"style":105},[39167],{"type":34,"value":108},{"type":29,"tag":88,"props":39169,"children":39170},{"style":105},[39171],{"type":34,"value":113},{"type":29,"tag":88,"props":39173,"children":39174},{"style":116},[39175],{"type":34,"value":7300},{"type":29,"tag":88,"props":39177,"children":39178},{"style":122},[39179],{"type":34,"value":125},{"type":29,"tag":88,"props":39181,"children":39182},{"class":90,"line":900},[39183,39187,39191,39195,39199,39203,39207,39211],{"type":29,"tag":88,"props":39184,"children":39185},{"style":105},[39186],{"type":34,"value":276},{"type":29,"tag":88,"props":39188,"children":39189},{"style":105},[39190],{"type":34,"value":1303},{"type":29,"tag":88,"props":39192,"children":39193},{"style":174},[39194],{"type":34,"value":38792},{"type":29,"tag":88,"props":39196,"children":39197},{"style":122},[39198],{"type":34,"value":181},{"type":29,"tag":88,"props":39200,"children":39201},{"style":151},[39202],{"type":34,"value":695},{"type":29,"tag":88,"props":39204,"children":39205},{"style":298},[39206],{"type":34,"value":38029},{"type":29,"tag":88,"props":39208,"children":39209},{"style":122},[39210],{"type":34,"value":306},{"type":29,"tag":88,"props":39212,"children":39213},{"style":122},[39214],{"type":34,"value":125},{"type":29,"tag":88,"props":39216,"children":39217},{"class":90,"line":929},[39218],{"type":29,"tag":88,"props":39219,"children":39220},{"style":95},[39221],{"type":34,"value":38820},{"type":29,"tag":88,"props":39223,"children":39224},{"class":90,"line":937},[39225,39229,39233,39237,39241,39245,39249,39253,39257,39261],{"type":29,"tag":88,"props":39226,"children":39227},{"style":157},[39228],{"type":34,"value":19726},{"type":29,"tag":88,"props":39230,"children":39231},{"style":122},[39232],{"type":34,"value":338},{"type":29,"tag":88,"props":39234,"children":39235},{"style":157},[39236],{"type":34,"value":18091},{"type":29,"tag":88,"props":39238,"children":39239},{"style":122},[39240],{"type":34,"value":338},{"type":29,"tag":88,"props":39242,"children":39243},{"style":174},[39244],{"type":34,"value":18100},{"type":29,"tag":88,"props":39246,"children":39247},{"style":122},[39248],{"type":34,"value":181},{"type":29,"tag":88,"props":39250,"children":39251},{"style":184},[39252],{"type":34,"value":38852},{"type":29,"tag":88,"props":39254,"children":39255},{"style":163},[39256],{"type":34,"value":5485},{"type":29,"tag":88,"props":39258,"children":39259},{"style":157},[39260],{"type":34,"value":38029},{"type":29,"tag":88,"props":39262,"children":39263},{"style":122},[39264],{"type":34,"value":357},{"type":29,"tag":88,"props":39266,"children":39267},{"class":90,"line":945},[39268],{"type":29,"tag":88,"props":39269,"children":39270},{"style":122},[39271],{"type":34,"value":433},{"type":29,"tag":88,"props":39273,"children":39274},{"class":90,"line":981},[39275],{"type":29,"tag":88,"props":39276,"children":39277},{"style":122},[39278],{"type":34,"value":442},{"type":29,"tag":10576,"props":39280,"children":39282},{"id":39281},"exemple-2-traitement-des-paiements",[39283],{"type":34,"value":39284},"Exemple 2 : Traitement des paiements",{"type":29,"tag":30,"props":39286,"children":39287},{},[39288,39290,39295],{"type":34,"value":39289},"Prenons l’exemple d’une classe ",{"type":29,"tag":84,"props":39291,"children":39293},{"className":39292},[],[39294],{"type":34,"value":20341},{"type":34,"value":39296}," qui viole le SRP en gérant à la fois le traitement des paiements et l’envoi des reçus.",{"type":29,"tag":77,"props":39298,"children":39300},{"className":81,"code":39299,"language":80,"meta":8,"style":8},"public class PaymentProcessor {\n    public void processPayment(String creditCard, double amount) {\n        \u002F\u002F Logique pour traiter le paiement\n        System.out.println(\"Paiement de \" + amount + \"€ traité avec la carte \" + creditCard);\n\n        \u002F\u002F Envoyer un reçu par email\n        sendReceipt(creditCard, amount);\n    }\n\n    private void sendReceipt(String creditCard, double amount) {\n        \u002F\u002F Logique pour envoyer un reçu\n        System.out.println(\"Reçu envoyé pour un paiement de \" + amount + \"€.\");\n    }\n}\n",[39301],{"type":29,"tag":84,"props":39302,"children":39303},{"__ignoreMap":8},[39304,39323,39371,39378,39440,39447,39455,39483,39490,39497,39545,39553,39606,39613],{"type":29,"tag":88,"props":39305,"children":39306},{"class":90,"line":91},[39307,39311,39315,39319],{"type":29,"tag":88,"props":39308,"children":39309},{"style":105},[39310],{"type":34,"value":108},{"type":29,"tag":88,"props":39312,"children":39313},{"style":105},[39314],{"type":34,"value":113},{"type":29,"tag":88,"props":39316,"children":39317},{"style":116},[39318],{"type":34,"value":20366},{"type":29,"tag":88,"props":39320,"children":39321},{"style":122},[39322],{"type":34,"value":125},{"type":29,"tag":88,"props":39324,"children":39325},{"class":90,"line":101},[39326,39330,39334,39338,39342,39346,39351,39355,39359,39363,39367],{"type":29,"tag":88,"props":39327,"children":39328},{"style":105},[39329],{"type":34,"value":276},{"type":29,"tag":88,"props":39331,"children":39332},{"style":105},[39333],{"type":34,"value":1303},{"type":29,"tag":88,"props":39335,"children":39336},{"style":174},[39337],{"type":34,"value":12508},{"type":29,"tag":88,"props":39339,"children":39340},{"style":122},[39341],{"type":34,"value":181},{"type":29,"tag":88,"props":39343,"children":39344},{"style":151},[39345],{"type":34,"value":695},{"type":29,"tag":88,"props":39347,"children":39348},{"style":298},[39349],{"type":34,"value":39350}," creditCard",{"type":29,"tag":88,"props":39352,"children":39353},{"style":122},[39354],{"type":34,"value":192},{"type":29,"tag":88,"props":39356,"children":39357},{"style":105},[39358],{"type":34,"value":10663},{"type":29,"tag":88,"props":39360,"children":39361},{"style":298},[39362],{"type":34,"value":2472},{"type":29,"tag":88,"props":39364,"children":39365},{"style":122},[39366],{"type":34,"value":306},{"type":29,"tag":88,"props":39368,"children":39369},{"style":122},[39370],{"type":34,"value":125},{"type":29,"tag":88,"props":39372,"children":39373},{"class":90,"line":128},[39374],{"type":29,"tag":88,"props":39375,"children":39376},{"style":95},[39377],{"type":34,"value":13738},{"type":29,"tag":88,"props":39379,"children":39380},{"class":90,"line":137},[39381,39385,39389,39393,39397,39401,39405,39410,39414,39419,39423,39428,39432,39436],{"type":29,"tag":88,"props":39382,"children":39383},{"style":157},[39384],{"type":34,"value":19726},{"type":29,"tag":88,"props":39386,"children":39387},{"style":122},[39388],{"type":34,"value":338},{"type":29,"tag":88,"props":39390,"children":39391},{"style":157},[39392],{"type":34,"value":18091},{"type":29,"tag":88,"props":39394,"children":39395},{"style":122},[39396],{"type":34,"value":338},{"type":29,"tag":88,"props":39398,"children":39399},{"style":174},[39400],{"type":34,"value":18100},{"type":29,"tag":88,"props":39402,"children":39403},{"style":122},[39404],{"type":34,"value":181},{"type":29,"tag":88,"props":39406,"children":39407},{"style":184},[39408],{"type":34,"value":39409},"\"Paiement de \"",{"type":29,"tag":88,"props":39411,"children":39412},{"style":163},[39413],{"type":34,"value":5485},{"type":29,"tag":88,"props":39415,"children":39416},{"style":157},[39417],{"type":34,"value":39418}," amount ",{"type":29,"tag":88,"props":39420,"children":39421},{"style":163},[39422],{"type":34,"value":5495},{"type":29,"tag":88,"props":39424,"children":39425},{"style":184},[39426],{"type":34,"value":39427}," \"€ traité avec la carte \"",{"type":29,"tag":88,"props":39429,"children":39430},{"style":163},[39431],{"type":34,"value":5485},{"type":29,"tag":88,"props":39433,"children":39434},{"style":157},[39435],{"type":34,"value":39350},{"type":29,"tag":88,"props":39437,"children":39438},{"style":122},[39439],{"type":34,"value":357},{"type":29,"tag":88,"props":39441,"children":39442},{"class":90,"line":211},[39443],{"type":29,"tag":88,"props":39444,"children":39445},{"emptyLinePlaceholder":13},[39446],{"type":34,"value":134},{"type":29,"tag":88,"props":39448,"children":39449},{"class":90,"line":262},[39450],{"type":29,"tag":88,"props":39451,"children":39452},{"style":95},[39453],{"type":34,"value":39454},"        \u002F\u002F Envoyer un reçu par email\n",{"type":29,"tag":88,"props":39456,"children":39457},{"class":90,"line":270},[39458,39463,39467,39471,39475,39479],{"type":29,"tag":88,"props":39459,"children":39460},{"style":174},[39461],{"type":34,"value":39462},"        sendReceipt",{"type":29,"tag":88,"props":39464,"children":39465},{"style":122},[39466],{"type":34,"value":181},{"type":29,"tag":88,"props":39468,"children":39469},{"style":157},[39470],{"type":34,"value":21372},{"type":29,"tag":88,"props":39472,"children":39473},{"style":122},[39474],{"type":34,"value":192},{"type":29,"tag":88,"props":39476,"children":39477},{"style":157},[39478],{"type":34,"value":2472},{"type":29,"tag":88,"props":39480,"children":39481},{"style":122},[39482],{"type":34,"value":357},{"type":29,"tag":88,"props":39484,"children":39485},{"class":90,"line":313},[39486],{"type":29,"tag":88,"props":39487,"children":39488},{"style":122},[39489],{"type":34,"value":433},{"type":29,"tag":88,"props":39491,"children":39492},{"class":90,"line":360},[39493],{"type":29,"tag":88,"props":39494,"children":39495},{"emptyLinePlaceholder":13},[39496],{"type":34,"value":134},{"type":29,"tag":88,"props":39498,"children":39499},{"class":90,"line":409},[39500,39504,39508,39513,39517,39521,39525,39529,39533,39537,39541],{"type":29,"tag":88,"props":39501,"children":39502},{"style":105},[39503],{"type":34,"value":143},{"type":29,"tag":88,"props":39505,"children":39506},{"style":105},[39507],{"type":34,"value":1303},{"type":29,"tag":88,"props":39509,"children":39510},{"style":174},[39511],{"type":34,"value":39512}," sendReceipt",{"type":29,"tag":88,"props":39514,"children":39515},{"style":122},[39516],{"type":34,"value":181},{"type":29,"tag":88,"props":39518,"children":39519},{"style":151},[39520],{"type":34,"value":695},{"type":29,"tag":88,"props":39522,"children":39523},{"style":298},[39524],{"type":34,"value":39350},{"type":29,"tag":88,"props":39526,"children":39527},{"style":122},[39528],{"type":34,"value":192},{"type":29,"tag":88,"props":39530,"children":39531},{"style":105},[39532],{"type":34,"value":10663},{"type":29,"tag":88,"props":39534,"children":39535},{"style":298},[39536],{"type":34,"value":2472},{"type":29,"tag":88,"props":39538,"children":39539},{"style":122},[39540],{"type":34,"value":306},{"type":29,"tag":88,"props":39542,"children":39543},{"style":122},[39544],{"type":34,"value":125},{"type":29,"tag":88,"props":39546,"children":39547},{"class":90,"line":427},[39548],{"type":29,"tag":88,"props":39549,"children":39550},{"style":95},[39551],{"type":34,"value":39552},"        \u002F\u002F Logique pour envoyer un reçu\n",{"type":29,"tag":88,"props":39554,"children":39555},{"class":90,"line":436},[39556,39560,39564,39568,39572,39576,39580,39585,39589,39593,39597,39602],{"type":29,"tag":88,"props":39557,"children":39558},{"style":157},[39559],{"type":34,"value":19726},{"type":29,"tag":88,"props":39561,"children":39562},{"style":122},[39563],{"type":34,"value":338},{"type":29,"tag":88,"props":39565,"children":39566},{"style":157},[39567],{"type":34,"value":18091},{"type":29,"tag":88,"props":39569,"children":39570},{"style":122},[39571],{"type":34,"value":338},{"type":29,"tag":88,"props":39573,"children":39574},{"style":174},[39575],{"type":34,"value":18100},{"type":29,"tag":88,"props":39577,"children":39578},{"style":122},[39579],{"type":34,"value":181},{"type":29,"tag":88,"props":39581,"children":39582},{"style":184},[39583],{"type":34,"value":39584},"\"Reçu envoyé pour un paiement de \"",{"type":29,"tag":88,"props":39586,"children":39587},{"style":163},[39588],{"type":34,"value":5485},{"type":29,"tag":88,"props":39590,"children":39591},{"style":157},[39592],{"type":34,"value":39418},{"type":29,"tag":88,"props":39594,"children":39595},{"style":163},[39596],{"type":34,"value":5495},{"type":29,"tag":88,"props":39598,"children":39599},{"style":184},[39600],{"type":34,"value":39601}," \"€.\"",{"type":29,"tag":88,"props":39603,"children":39604},{"style":122},[39605],{"type":34,"value":357},{"type":29,"tag":88,"props":39607,"children":39608},{"class":90,"line":767},[39609],{"type":29,"tag":88,"props":39610,"children":39611},{"style":122},[39612],{"type":34,"value":433},{"type":29,"tag":88,"props":39614,"children":39615},{"class":90,"line":792},[39616],{"type":29,"tag":88,"props":39617,"children":39618},{"style":122},[39619],{"type":34,"value":442},{"type":29,"tag":30,"props":39621,"children":39622},{},[39623],{"type":34,"value":39624},"Ici, la classe gère deux responsabilités. En appliquant le SRP, on peut diviser cela en deux classes distinctes.",{"type":29,"tag":77,"props":39626,"children":39628},{"className":81,"code":39627,"language":80,"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        \u002F\u002F Logique pour traiter le paiement\n        System.out.println(\"Paiement de \" + amount + \"€ traité avec la carte \" + creditCard);\n\n        \u002F\u002F 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        \u002F\u002F Logique pour envoyer un reçu\n        System.out.println(\"Reçu envoyé pour un paiement de \" + amount + \"€.\");\n    }\n}\n",[39629],{"type":29,"tag":84,"props":39630,"children":39631},{"__ignoreMap":8},[39632,39651,39672,39679,39711,39739,39746,39753,39800,39807,39866,39873,39881,39918,39925,39932,39939,39958,40005,40012,40063,40070],{"type":29,"tag":88,"props":39633,"children":39634},{"class":90,"line":91},[39635,39639,39643,39647],{"type":29,"tag":88,"props":39636,"children":39637},{"style":105},[39638],{"type":34,"value":108},{"type":29,"tag":88,"props":39640,"children":39641},{"style":105},[39642],{"type":34,"value":113},{"type":29,"tag":88,"props":39644,"children":39645},{"style":116},[39646],{"type":34,"value":20366},{"type":29,"tag":88,"props":39648,"children":39649},{"style":122},[39650],{"type":34,"value":125},{"type":29,"tag":88,"props":39652,"children":39653},{"class":90,"line":101},[39654,39658,39663,39668],{"type":29,"tag":88,"props":39655,"children":39656},{"style":105},[39657],{"type":34,"value":143},{"type":29,"tag":88,"props":39659,"children":39660},{"style":151},[39661],{"type":34,"value":39662}," ReceiptSender",{"type":29,"tag":88,"props":39664,"children":39665},{"style":157},[39666],{"type":34,"value":39667}," receiptSender",{"type":29,"tag":88,"props":39669,"children":39670},{"style":122},[39671],{"type":34,"value":424},{"type":29,"tag":88,"props":39673,"children":39674},{"class":90,"line":128},[39675],{"type":29,"tag":88,"props":39676,"children":39677},{"emptyLinePlaceholder":13},[39678],{"type":34,"value":134},{"type":29,"tag":88,"props":39680,"children":39681},{"class":90,"line":137},[39682,39686,39690,39694,39699,39703,39707],{"type":29,"tag":88,"props":39683,"children":39684},{"style":105},[39685],{"type":34,"value":276},{"type":29,"tag":88,"props":39687,"children":39688},{"style":174},[39689],{"type":34,"value":20366},{"type":29,"tag":88,"props":39691,"children":39692},{"style":122},[39693],{"type":34,"value":181},{"type":29,"tag":88,"props":39695,"children":39696},{"style":151},[39697],{"type":34,"value":39698},"ReceiptSender",{"type":29,"tag":88,"props":39700,"children":39701},{"style":298},[39702],{"type":34,"value":39667},{"type":29,"tag":88,"props":39704,"children":39705},{"style":122},[39706],{"type":34,"value":306},{"type":29,"tag":88,"props":39708,"children":39709},{"style":122},[39710],{"type":34,"value":125},{"type":29,"tag":88,"props":39712,"children":39713},{"class":90,"line":211},[39714,39718,39722,39727,39731,39735],{"type":29,"tag":88,"props":39715,"children":39716},{"style":873},[39717],{"type":34,"value":876},{"type":29,"tag":88,"props":39719,"children":39720},{"style":122},[39721],{"type":34,"value":338},{"type":29,"tag":88,"props":39723,"children":39724},{"style":157},[39725],{"type":34,"value":39726},"receiptSender ",{"type":29,"tag":88,"props":39728,"children":39729},{"style":163},[39730],{"type":34,"value":166},{"type":29,"tag":88,"props":39732,"children":39733},{"style":157},[39734],{"type":34,"value":39667},{"type":29,"tag":88,"props":39736,"children":39737},{"style":122},[39738],{"type":34,"value":424},{"type":29,"tag":88,"props":39740,"children":39741},{"class":90,"line":262},[39742],{"type":29,"tag":88,"props":39743,"children":39744},{"style":122},[39745],{"type":34,"value":433},{"type":29,"tag":88,"props":39747,"children":39748},{"class":90,"line":270},[39749],{"type":29,"tag":88,"props":39750,"children":39751},{"emptyLinePlaceholder":13},[39752],{"type":34,"value":134},{"type":29,"tag":88,"props":39754,"children":39755},{"class":90,"line":313},[39756,39760,39764,39768,39772,39776,39780,39784,39788,39792,39796],{"type":29,"tag":88,"props":39757,"children":39758},{"style":105},[39759],{"type":34,"value":276},{"type":29,"tag":88,"props":39761,"children":39762},{"style":105},[39763],{"type":34,"value":1303},{"type":29,"tag":88,"props":39765,"children":39766},{"style":174},[39767],{"type":34,"value":12508},{"type":29,"tag":88,"props":39769,"children":39770},{"style":122},[39771],{"type":34,"value":181},{"type":29,"tag":88,"props":39773,"children":39774},{"style":151},[39775],{"type":34,"value":695},{"type":29,"tag":88,"props":39777,"children":39778},{"style":298},[39779],{"type":34,"value":39350},{"type":29,"tag":88,"props":39781,"children":39782},{"style":122},[39783],{"type":34,"value":192},{"type":29,"tag":88,"props":39785,"children":39786},{"style":105},[39787],{"type":34,"value":10663},{"type":29,"tag":88,"props":39789,"children":39790},{"style":298},[39791],{"type":34,"value":2472},{"type":29,"tag":88,"props":39793,"children":39794},{"style":122},[39795],{"type":34,"value":306},{"type":29,"tag":88,"props":39797,"children":39798},{"style":122},[39799],{"type":34,"value":125},{"type":29,"tag":88,"props":39801,"children":39802},{"class":90,"line":360},[39803],{"type":29,"tag":88,"props":39804,"children":39805},{"style":95},[39806],{"type":34,"value":13738},{"type":29,"tag":88,"props":39808,"children":39809},{"class":90,"line":409},[39810,39814,39818,39822,39826,39830,39834,39838,39842,39846,39850,39854,39858,39862],{"type":29,"tag":88,"props":39811,"children":39812},{"style":157},[39813],{"type":34,"value":19726},{"type":29,"tag":88,"props":39815,"children":39816},{"style":122},[39817],{"type":34,"value":338},{"type":29,"tag":88,"props":39819,"children":39820},{"style":157},[39821],{"type":34,"value":18091},{"type":29,"tag":88,"props":39823,"children":39824},{"style":122},[39825],{"type":34,"value":338},{"type":29,"tag":88,"props":39827,"children":39828},{"style":174},[39829],{"type":34,"value":18100},{"type":29,"tag":88,"props":39831,"children":39832},{"style":122},[39833],{"type":34,"value":181},{"type":29,"tag":88,"props":39835,"children":39836},{"style":184},[39837],{"type":34,"value":39409},{"type":29,"tag":88,"props":39839,"children":39840},{"style":163},[39841],{"type":34,"value":5485},{"type":29,"tag":88,"props":39843,"children":39844},{"style":157},[39845],{"type":34,"value":39418},{"type":29,"tag":88,"props":39847,"children":39848},{"style":163},[39849],{"type":34,"value":5495},{"type":29,"tag":88,"props":39851,"children":39852},{"style":184},[39853],{"type":34,"value":39427},{"type":29,"tag":88,"props":39855,"children":39856},{"style":163},[39857],{"type":34,"value":5485},{"type":29,"tag":88,"props":39859,"children":39860},{"style":157},[39861],{"type":34,"value":39350},{"type":29,"tag":88,"props":39863,"children":39864},{"style":122},[39865],{"type":34,"value":357},{"type":29,"tag":88,"props":39867,"children":39868},{"class":90,"line":427},[39869],{"type":29,"tag":88,"props":39870,"children":39871},{"emptyLinePlaceholder":13},[39872],{"type":34,"value":134},{"type":29,"tag":88,"props":39874,"children":39875},{"class":90,"line":436},[39876],{"type":29,"tag":88,"props":39877,"children":39878},{"style":95},[39879],{"type":34,"value":39880},"        \u002F\u002F Utilisation de ReceiptSender pour envoyer le reçu\n",{"type":29,"tag":88,"props":39882,"children":39883},{"class":90,"line":767},[39884,39889,39893,39898,39902,39906,39910,39914],{"type":29,"tag":88,"props":39885,"children":39886},{"style":157},[39887],{"type":34,"value":39888},"        receiptSender",{"type":29,"tag":88,"props":39890,"children":39891},{"style":122},[39892],{"type":34,"value":338},{"type":29,"tag":88,"props":39894,"children":39895},{"style":174},[39896],{"type":34,"value":39897},"sendReceipt",{"type":29,"tag":88,"props":39899,"children":39900},{"style":122},[39901],{"type":34,"value":181},{"type":29,"tag":88,"props":39903,"children":39904},{"style":157},[39905],{"type":34,"value":21372},{"type":29,"tag":88,"props":39907,"children":39908},{"style":122},[39909],{"type":34,"value":192},{"type":29,"tag":88,"props":39911,"children":39912},{"style":157},[39913],{"type":34,"value":2472},{"type":29,"tag":88,"props":39915,"children":39916},{"style":122},[39917],{"type":34,"value":357},{"type":29,"tag":88,"props":39919,"children":39920},{"class":90,"line":792},[39921],{"type":29,"tag":88,"props":39922,"children":39923},{"style":122},[39924],{"type":34,"value":433},{"type":29,"tag":88,"props":39926,"children":39927},{"class":90,"line":817},[39928],{"type":29,"tag":88,"props":39929,"children":39930},{"style":122},[39931],{"type":34,"value":442},{"type":29,"tag":88,"props":39933,"children":39934},{"class":90,"line":825},[39935],{"type":29,"tag":88,"props":39936,"children":39937},{"emptyLinePlaceholder":13},[39938],{"type":34,"value":134},{"type":29,"tag":88,"props":39940,"children":39941},{"class":90,"line":869},[39942,39946,39950,39954],{"type":29,"tag":88,"props":39943,"children":39944},{"style":105},[39945],{"type":34,"value":108},{"type":29,"tag":88,"props":39947,"children":39948},{"style":105},[39949],{"type":34,"value":113},{"type":29,"tag":88,"props":39951,"children":39952},{"style":116},[39953],{"type":34,"value":39662},{"type":29,"tag":88,"props":39955,"children":39956},{"style":122},[39957],{"type":34,"value":125},{"type":29,"tag":88,"props":39959,"children":39960},{"class":90,"line":900},[39961,39965,39969,39973,39977,39981,39985,39989,39993,39997,40001],{"type":29,"tag":88,"props":39962,"children":39963},{"style":105},[39964],{"type":34,"value":276},{"type":29,"tag":88,"props":39966,"children":39967},{"style":105},[39968],{"type":34,"value":1303},{"type":29,"tag":88,"props":39970,"children":39971},{"style":174},[39972],{"type":34,"value":39512},{"type":29,"tag":88,"props":39974,"children":39975},{"style":122},[39976],{"type":34,"value":181},{"type":29,"tag":88,"props":39978,"children":39979},{"style":151},[39980],{"type":34,"value":695},{"type":29,"tag":88,"props":39982,"children":39983},{"style":298},[39984],{"type":34,"value":39350},{"type":29,"tag":88,"props":39986,"children":39987},{"style":122},[39988],{"type":34,"value":192},{"type":29,"tag":88,"props":39990,"children":39991},{"style":105},[39992],{"type":34,"value":10663},{"type":29,"tag":88,"props":39994,"children":39995},{"style":298},[39996],{"type":34,"value":2472},{"type":29,"tag":88,"props":39998,"children":39999},{"style":122},[40000],{"type":34,"value":306},{"type":29,"tag":88,"props":40002,"children":40003},{"style":122},[40004],{"type":34,"value":125},{"type":29,"tag":88,"props":40006,"children":40007},{"class":90,"line":929},[40008],{"type":29,"tag":88,"props":40009,"children":40010},{"style":95},[40011],{"type":34,"value":39552},{"type":29,"tag":88,"props":40013,"children":40014},{"class":90,"line":937},[40015,40019,40023,40027,40031,40035,40039,40043,40047,40051,40055,40059],{"type":29,"tag":88,"props":40016,"children":40017},{"style":157},[40018],{"type":34,"value":19726},{"type":29,"tag":88,"props":40020,"children":40021},{"style":122},[40022],{"type":34,"value":338},{"type":29,"tag":88,"props":40024,"children":40025},{"style":157},[40026],{"type":34,"value":18091},{"type":29,"tag":88,"props":40028,"children":40029},{"style":122},[40030],{"type":34,"value":338},{"type":29,"tag":88,"props":40032,"children":40033},{"style":174},[40034],{"type":34,"value":18100},{"type":29,"tag":88,"props":40036,"children":40037},{"style":122},[40038],{"type":34,"value":181},{"type":29,"tag":88,"props":40040,"children":40041},{"style":184},[40042],{"type":34,"value":39584},{"type":29,"tag":88,"props":40044,"children":40045},{"style":163},[40046],{"type":34,"value":5485},{"type":29,"tag":88,"props":40048,"children":40049},{"style":157},[40050],{"type":34,"value":39418},{"type":29,"tag":88,"props":40052,"children":40053},{"style":163},[40054],{"type":34,"value":5495},{"type":29,"tag":88,"props":40056,"children":40057},{"style":184},[40058],{"type":34,"value":39601},{"type":29,"tag":88,"props":40060,"children":40061},{"style":122},[40062],{"type":34,"value":357},{"type":29,"tag":88,"props":40064,"children":40065},{"class":90,"line":945},[40066],{"type":29,"tag":88,"props":40067,"children":40068},{"style":122},[40069],{"type":34,"value":433},{"type":29,"tag":88,"props":40071,"children":40072},{"class":90,"line":981},[40073],{"type":29,"tag":88,"props":40074,"children":40075},{"style":122},[40076],{"type":34,"value":442},{"type":29,"tag":47,"props":40078,"children":40079},{},[],{"type":29,"tag":51,"props":40081,"children":40083},{"id":40082},"les-avantages-pratiques-du-srp",[40084],{"type":34,"value":40085},"Les avantages pratiques du SRP",{"type":29,"tag":30,"props":40087,"children":40088},{},[40089],{"type":34,"value":40090},"Appliquer le SRP apporte plusieurs avantages concrets :",{"type":29,"tag":453,"props":40092,"children":40093},{},[40094,40104,40114,40124,40134],{"type":29,"tag":457,"props":40095,"children":40096},{},[40097,40102],{"type":29,"tag":447,"props":40098,"children":40099},{},[40100],{"type":34,"value":40101},"Lisibilité accrue",{"type":34,"value":40103}," : chaque classe porte une seule tâche, la compréhension du code est immédiate.",{"type":29,"tag":457,"props":40105,"children":40106},{},[40107,40112],{"type":29,"tag":447,"props":40108,"children":40109},{},[40110],{"type":34,"value":40111},"Maintenance et évolutions",{"type":34,"value":40113}," : modifier une fonctionnalité n'impacte plus le reste du système.",{"type":29,"tag":457,"props":40115,"children":40116},{},[40117,40122],{"type":29,"tag":447,"props":40118,"children":40119},{},[40120],{"type":34,"value":40121},"Tests unitaires plus simples",{"type":34,"value":40123}," : responsabilité unique = peu de dépendances à mocker.",{"type":29,"tag":457,"props":40125,"children":40126},{},[40127,40132],{"type":29,"tag":447,"props":40128,"children":40129},{},[40130],{"type":34,"value":40131},"Couplage réduit",{"type":34,"value":40133}," : le découpage des responsabilités casse les dépendances entre composants.",{"type":29,"tag":457,"props":40135,"children":40136},{},[40137,40142],{"type":29,"tag":447,"props":40138,"children":40139},{},[40140],{"type":34,"value":40141},"Réutilisabilité accrue",{"type":34,"value":40143}," : les classes spécialisées trouvent leur place dans d'autres projets.",{"type":29,"tag":51,"props":40145,"children":40147},{"id":40146},"quand-et-pourquoi-le-srp-peut-poser-des-défis",[40148],{"type":34,"value":40149},"Quand et pourquoi le SRP peut poser des défis",{"type":29,"tag":8542,"props":40151,"children":40153},{"id":40152},"risque-de-sur-fragmentation",[40154],{"type":34,"value":40155},"Risque de sur-fragmentation",{"type":29,"tag":30,"props":40157,"children":40158},{},[40159],{"type":34,"value":40160},"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":29,"tag":8542,"props":40162,"children":40164},{"id":40163},"complexité-dans-les-petites-applications",[40165],{"type":34,"value":40166},"Complexité dans les petites applications",{"type":29,"tag":30,"props":40168,"children":40169},{},[40170],{"type":34,"value":40171},"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":29,"tag":8542,"props":40173,"children":40175},{"id":40174},"difficulté-à-identifier-les-responsabilités",[40176],{"type":34,"value":40177},"Difficulté à identifier les responsabilités",{"type":29,"tag":30,"props":40179,"children":40180},{},[40181],{"type":34,"value":40182},"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":29,"tag":8542,"props":40184,"children":40186},{"id":40185},"refactorisation-dans-les-projets-existants",[40187],{"type":34,"value":40188},"Refactorisation dans les projets existants",{"type":29,"tag":30,"props":40190,"children":40191},{},[40192],{"type":34,"value":40193},"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":29,"tag":2288,"props":40195,"children":40197},{"cta":5629,"href":5630,"title":40196,"type":5632},"Le SRP n'est qu'une pratique parmi 100 pour coder propre",[40198],{"type":29,"tag":30,"props":40199,"children":40200},{},[40201],{"type":34,"value":40202},"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":29,"tag":47,"props":40204,"children":40205},{},[],{"type":29,"tag":51,"props":40207,"children":40209},{"id":40208},"faq-questions-fréquemment-posées-sur-le-srp",[40210],{"type":34,"value":40211},"FAQ : Questions fréquemment posées sur le SRP",{"type":29,"tag":5649,"props":40213,"children":40214},{},[40215,40220],{"type":29,"tag":5653,"props":40216,"children":40217},{},[40218],{"type":34,"value":40219},"1. Qu’est-ce que le principe de responsabilité unique (SRP) ?",{"type":29,"tag":30,"props":40221,"children":40222},{},[40223],{"type":34,"value":40224},"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":29,"tag":5649,"props":40226,"children":40227},{},[40228,40233],{"type":29,"tag":5653,"props":40229,"children":40230},{},[40231],{"type":34,"value":40232},"2. Pourquoi est-il important de suivre le SRP ?",{"type":29,"tag":30,"props":40234,"children":40235},{},[40236],{"type":34,"value":40237},"Le SRP améliore la lisibilité, la maintenabilité et la testabilité du code, et réduit le couplage entre composants.",{"type":29,"tag":5649,"props":40239,"children":40240},{},[40241,40246],{"type":29,"tag":5653,"props":40242,"children":40243},{},[40244],{"type":34,"value":40245},"3. Comment savoir si une classe viole le SRP ?",{"type":29,"tag":30,"props":40247,"children":40248},{},[40249],{"type":34,"value":40250},"Si une classe a plusieurs responsabilités ou plusieurs raisons de changer, elle viole probablement le SRP.",{"type":29,"tag":5649,"props":40252,"children":40253},{},[40254,40259],{"type":29,"tag":5653,"props":40255,"children":40256},{},[40257],{"type":34,"value":40258},"4. Le SRP n’augmente-t-il pas le nombre de classes et la complexité du projet ?",{"type":29,"tag":30,"props":40260,"children":40261},{},[40262],{"type":34,"value":40263},"Le SRP augmente effectivement le nombre de classes, mais chaque classe devient triviale à comprendre, et le projet, plus simple à maintenir.",{"type":29,"tag":5649,"props":40265,"children":40266},{},[40267,40272],{"type":29,"tag":5653,"props":40268,"children":40269},{},[40270],{"type":34,"value":40271},"5. Dois-je toujours appliquer le SRP, même dans les petits projets ?",{"type":29,"tag":30,"props":40273,"children":40274},{},[40275],{"type":34,"value":40276},"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":29,"tag":47,"props":40278,"children":40279},{},[],{"type":29,"tag":2288,"props":40281,"children":40282},{"cta":19356,"href":10075,"title":19357,"type":5755},[40283],{"type":29,"tag":30,"props":40284,"children":40285},{},[40286],{"type":34,"value":25432},{"type":29,"tag":5763,"props":40288,"children":40289},{},[40290],{"type":34,"value":5767},{"title":8,"searchDepth":101,"depth":101,"links":40292},[40293,40294,40295,40298,40299,40305],{"id":37895,"depth":101,"text":37898},{"id":37944,"depth":101,"text":37947},{"id":38534,"depth":101,"text":38537,"children":40296},[40297],{"id":38586,"depth":128,"text":38589},{"id":40082,"depth":101,"text":40085},{"id":40146,"depth":101,"text":40149,"children":40300},[40301,40302,40303,40304],{"id":40152,"depth":128,"text":40155},{"id":40163,"depth":128,"text":40166},{"id":40174,"depth":128,"text":40177},{"id":40185,"depth":128,"text":40188},{"id":40208,"depth":101,"text":40211},"content:fr:architecture-craft:principe-srp-software-craftsmanship-exemples-java.md","fr\u002Farchitecture-craft\u002Fprincipe-srp-software-craftsmanship-exemples-java.md","fr\u002Farchitecture-craft\u002Fprincipe-srp-software-craftsmanship-exemples-java",1784113924641]