Академический Документы
Профессиональный Документы
Культура Документы
1. OK! I already know that routines are great, so what do you want me to do about it?
2. Valid Reasons to Create a Routine
• Reduce complexity
• minimizing code size
• hide information hat you won’t need to think about it (you should be able to forget the details
and use the routine without any knowledge of its internal workings.) nroudou belna but without
the abstractive power of routines,
malazemnach n5aliyouha abstract de telle facons el methode bech t5ali l code mta3na as3ab w akthar
complexité
• Reduce the containing routine’s complexity: Each routine should do ONE thing and do it
well
ki tel9ana ne5dem fi algorithme wala 9a3din ndevelopiyou w kol matra nest7a9ou ena ne9elbou chaine
chnou na3mlou nesn3ou methode reversmethode w kol mara n3aytioulha 5ir meli kol mara nektbouh l
code awal 7aja china9as 3lina t3ab wel l ktiba el code mta3nabech youn lesible akthar w mafhoum 7ata
kif na9raweh (n7awel n7ot example )
• Modifications will be easier : La modification plus faciles car vous devrez modifier le code
dans un seul emplacement.
• Support subclassing yo9sed beha surcharge mta3 l methode mta3na
kifeh l methode y3awena fel overide subclass ? Ena nest3mlou des methode bien factoriser fel overide
fel les classe fils 5ir meli neesta3mlou code yebda compliqué
• Hide sequences :
methode max(x,y) ykoun 3andi methode max_In_Arbre lena chnesta3mal max(x’y) maghir
manest7a9 eni na3rafha hiya kifeh te5dem
EXMPLE :
VS
==>>Si cette ligne de code originale avait encore été dans une douzaine d’endroits, le test aurait été
répété une douzaine de fois, pour un total de 36 nouvelles lignes de code. Une routine simple réduite
les 36 nouvelles lignes à 3.
7.2 Design at the Routine Level
• do one thing well and not do anything else: High cohesion is when you have a class that does
a well defined job.
Bech nothemnou tkoun 3ana cohésion 9wiya lezem l role ta3 l methode ykoun 3ala haja
wahda
//*********** VS
comparaison :
• 50 percent of the highly cohesive routines with out error
• 18 percent of routines with low cohesion with out error
• error in routines with low cohesion cost 20 times to fix
}
// donc l methode hethi 9a3da te5dem f 2 role calcule age et la retraite
• Communicational cohesion: