Dominare il codice legacy

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Favorite

    Dominare il codice legacy - Presentation Transcript

    1. Dominare il codice ereditato Tommaso Torti e Matteo Vaccari Agile Day 2007, Bologna, 23 novembre (cc) Some rights reserved.
    2. ReadMe Per vedere funzionare l'applicazione: * modifica /etc/hosts inserendo 1 2 7 . 0 . 0 . 1 x x x . y y y. i t 10.0.1.2 xxx.zzz.it * inserisci i seguenti plugin di Firefox: * M o d i f i c a g l i h e a d e r : https://addons.mozilla.org/en-US/firefox/addon/967 v a i s u To o l s - > M o d i f y H e a d e r s e a g g i u n g i : MSISDN = 393928390078 PA RT Y- I D = 3 4 3 5 3 2 5 2 * U s e r a g e n t sw i t c h e r : https://addons.mozilla.org/en-US/firefox/addon/59 s a l v a r e i l f i l e h t t p : / / x x x . s o u r c e s e n s e . c o m / f i l e s / z e r o 9 / u s e r a g e n t s w i t c h e r. x m l e importarlo * esegui \"script/create_databases.sh\" * esegui \"script/start.sh\" * p u n t a i l b row s e r a http://localhost:8080/progetto/p.do?page=Home
    3. create_databases.sh #!/bin/bash if [ ! -d db ]; then echo \"Questo script deve essere eseguito nella dir principale del progetto\" exit 1 fi echo 'Drop databases...' mysqladmin -uroot --force drop db mysqladmin -uroot --force drop db_test echo 'Create databases...' mysqladmin -uroot create db mysqladmin -uroot create db_test echo \"grant all on db.* to db@localhost identified by 'db';\" | mysql -uroot echo \"grant all on db_test.* to db@localhost identified by 'db';\" | mysql -uroot echo 'Build schema...' cat db/db-schema.sql | mysql -udb db -pdb cat db/db-schema.sql | mysql -udb db_test -pdb echo 'Populate development...' mysql -udb -pdb db < db/populate_db.sql echo 'Done!'
    4. start.sh #!/bin/bash if [ -z \"${CMT_DEVELOPMENT_UPLOAD}\" ] ; then echo \"Deve essere settata la variabile di ambiente CMT_DEVELOPMENT_UPLOAD\"; exit 1; fi ABS_PATH=$(cd $(dirname $0); cd ..; pwd) CATALINA_HOME=\"$ABS_PATH/tomcat-5.5.25\" rm -rf $CATALINA_HOME/logs/* rm -rf $CATALINA_HOME/webapps/progetto* ant clean ant deploy ln -s /tmp $CATALINA_HOME/webapps/progetto/dynamicImages/upload $CATALINA_HOME/bin/catalina.sh jpda start tail -f $CATALINA_HOME/logs/catalina.out
    5. Log
    6. Log log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target=System.out log4j.appender.stdout.layout= org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern= %5p %c{1}:%L - %m%n log4j.rootLogger=INFO, stdout
    7. Refactoring servlet Spot the differences
    8. Il dilemma • Non posso rifattorizzare senza test • Ma il codice è così ingarbugliato, che • Non posso testare senza rifattorizzare
    9. Il dilemma • Non posso cambiare il codice senza testare • Non posso testare senza cambiare il codice
    10. L’algoritmo • Trova il punto da modificare • Rompi le dipendenze • Scrivi i test • Modifica; rifattorizza
    11. Rompere le dipendenze • Controfigure • Cuciture • Oggetti umili
    12. Controfigure • Come testare una servlet? • Senza usare un web server? • HttpServletRequest: 54 metodi!
    13. Extract method
    14. Sfrutta le cuciture
    15. Test di integrazione
    16. http://httpunit.sourceforge.net/
    17. Refactoring servlet
    18. Sensazioni
    19. Tentazioni xkcd.com
    20. Test jsp @Test public void testHomePage() throws Exception { FakePageContext pc = new FakePageContext(); setRequestAttribute(\"DEVICECAPABILITIES\", pc.capabilities); get(\"/home.jsp\"); output().shouldContain(\"NO-CACHE\"); } .... protected void request(String path, String httpMethod) throws Exception { JspCompiler compiler = JspCompilerFactory.newInstance(); compiler.setWebRoot(getWebRoot()); compiler.setOutputDirectory(getOutputDirectory()); Jsp jsp = compiler.compile(path, substituteTaglibs); execution = jsp.request(httpMethod, requestAttributes, sessionAttributes); } http://sourceforge.net/projects/jsptest
    21. Dipendenze JavaGameRetriever BillingService public JavaGameRetriever() { this(new BillingService()); } public JavaGameRetriever(BillingService billingService) public class FakeBillingService extends BillingService FakeBillingService
    22. Configurazioni <target name=\"prepare\"> <copy todir=\"./web/WEB-INF/\"> <fileset dir=\"${conf.dir}\"> <include name=\"ApplicationResource.properties\"/> <include name=\"web.xml\" /> </fileset> ... <target name=\"clean\"> <delete file=\"./web/WEB-INF/ ApplicationResource.properties\"/> <delete file=\"./web/WEB-INF/web.xml\" /> createWarForPreProduction.sh #!/bin/bash ant clean ant war -Dconf.dir=conf/preproduction
    23. Risultati Dopo Prima ...di tutto il progetto
    24. Risultati Dopo Prima ...delle servlet
    25. Risultati > Coverage: 10 % su 26056 loc > Tempi: consegna on time - 7 settimane in un team di 3
    26. Non perdere la testa • Pianifica per feature • Automatizza tutto • Scrivi test • Rifattorizza • Lavora (interattivamente) il meno possibile!
    27. (cc) Tommaso Torti & Matteo Vaccari 2007. Published in Italy. Attribuzione – Non commerciale – Condividi allo stesso modo 2.5

    + torti.tommasotorti.tommaso, 2 years ago

    custom

    677 views, 1 favs, 0 embeds more stats

    More Info

    © All Rights Reserved

    Go to text version
    • Total Views 677
      • 677 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 5
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as innappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel

    Categories