Lab Manuals for
Software Construction
Lab-4
Debugging, Exception Handling, and Defensive Programming
School of Computer Science and Technology Harbin Institute of Technology Spring 2020
Lab Manuals Lab-4 Debugging, Exception Handling, and Defensive Programming
Ŀ¼
1. ʵÑéÄ¿±ê …………………………………………………………………………………………………………………………… 1
2. ʵÑé»·¾³ …………………………………………………………………………………………………………………………… 1
3. ʵÑéÒªÇó …………………………………………………………………………………………………………………………… 2
3.1. Error and Exception Handling …………………………………………………………………………………… 2
3.2. Assertion and Defensive Programming …………………………………………………………………….. 3
3.3. Logging ………………………………………………………………………………………………………………………. 4
3.4. Testing for Robustness and Correctness…………………………………………………………………….4
3.5. Using SpotBugs tool ………………………………………………………………………………………………… 5
3.6. Debugging ………………………………………………………………………………………………………………….. 5
4. ʵÑ鱨¸æ …………………………………………………………………………………………………………………………… 6
5. Ìá½»·½Ê½ …………………………………………………………………………………………………………………………… 7
6. ÆÀ·Ö·½Ê½ …………………………………………………………………………………………………………………………… 7
Lab Manuals Lab-4 Debugging, Exception Handling, and Defensive Programming
1. ʵÑéÄ¿±ê
Lab 3 ÖÐдºÃµÄ ADT ´úÂëºÍ»ùÓڸà ADT µÄÈý¸öÓ¦ÓõĴúÂ룬ʹÓà ÒÔϼ¼Êõ½øÐиÄÔ죬Ìá¸ßÆ佡׳ÐÔºÍÕýÈ·ÐÔ:
l l l l l l
2. ʵÑé»·¾³
ʵÑé»·¾³ÉèÖÃÇë²Î¼û Lab-0 ʵÑéÖ¸ÄÏ¡£
³ý´ËÖ®Í⣬±¾´ÎʵÑéÐèÒªÄãÔÚ Eclipse IDE Öа²×°ÅäÖà SpotBugs(ÓÃÓÚ Java ´úÂ뾲̬·ÖÎöµÄ¹¤¾ß)¡£Çë·ÃÎÊ https://spotbugs.github.io£¬Á˽âËü²¢Ñ§Ï°Æä°²×°¡¢ ÅäÖúÍʹÓá£
±¾´ÎʵÑéÔÚ GitHub Classroom ÖÐµÄ URL µØַΪ: https://classroom.github.com/a/mnFCZ30Y
Çë·ÃÎʸà URL£¬°´ÕÕÌáʾ½¨Á¢×Ô¼ºµÄ Lab4 ²Ö¿â²¢¹ØÁªÖÁ×Ô¼ºµÄѧºÅ¡£
ÓÉÓÚ±¾´ÎʵÑéÊÇ Lab3 µÄ¼ÌÐø£¬ÇëÊ×ÏȽ«Äã Lab3 ÖÐ master ·ÖÖ§µÄ×îÖÕ´úÂë ¸´ÖÆÒ»·Ý£¬ÍÆË͵½ Lab4 µÄ²Ö¿âÀȻºóÆä»ù´¡ÉÏÍê³É±¾´ÎʵÑéÈÎÎñ¡£±¾´ÎʵÑé ²»ÄÜÓ°Ïì Lab3 ºÍ Lab3 ²Ö¿âÀïµÄÄÚÈÝÓë commit ÀúÊ·¡£
±¾µØ¿ª·¢Ê±£¬±¾´ÎʵÑéÖ»Ð轨Á¢Ò»¸öÏîÄ¿£¬Í³Ò»Ïò GitHub ²Ö¿âÌá½»¡£ÊµÑé°ü º¬µÄ¶àÏîÈÎÎñ·Ö±ðÔÚ²»Í¬µÄĿ¼ÄÚ¿ª·¢£¬¾ßÌåĿ¼×éÖ¯·½Ê½²Î¼û¸÷ÈÎÎñ×îºóÒ»²¿ ·ÖµÄ˵Ã÷¡£ÇëÎñ±Ø×ñÑĿ¼½á¹¹£¬ÒÔ±ãÓÚ½Ìʦ/TA ½øÐвâÊÔ¡£
±¾´ÎʵÑéÖصãѵÁ·Ñ§ÉúÃæÏò½¡×³ÐÔºÍÕýÈ·ÐԵıà³Ì¼¼ÄÜ£¬ÀûÓôíÎóºÍÒì³£´¦
Àí¡¢¶ÏÑÔÓë·ÀÓùʽ±à³Ì¼¼Êõ¡¢ÈÕÖ¾/¶ÏµãµÈµ÷ÊÔ¼¼Êõ¡¢ºÚºÐ²âÊÔ±à³Ì¼¼Êõ£¬Ê¹³ÌÐò
¿ÉÔÚ²»Í¬µÄ½¡×³ÐÔ/ÕýÈ·ÐÔÐèÇóÏÂÄÜÇ¡µ±µÄ´¦Àí¸÷ÖÖÀýÍâÓë´íÎóÇé¿ö£¬ÔÚ³ö´íºó
¿ÉÓÅÑŵÄÍ˳ö»ò¼ÌÐøÖ´ÐУ¬·¢ÏÖ´íÎóÖ®ºó¿ÉÓÐЧµÄ¶¨Î»´íÎó²¢×ö³öÐ޸ġ£
ʵÑéÕë¶Ô
´íÎó´¦Àí
Òì³£´¦Àí
Assertion ºÍ·ÀÓùʽ±à³Ì
ÈÕÖ¾
µ÷ÊÔ¼¼Êõ
ºÚºÐ²âÊÔ¼°´úÂ븲¸Ç¶È
1
Lab Manuals Lab-4 Debugging, Exception Handling, and Defensive Programming
3. ʵÑéÒªÇó
3.1. Error and Exception Handling
Õë¶Ô¸÷ÖÖ checked exception£¬ÏàÐÅÄãÔÚ Lab 3 µÄ³ÌÐòÖоùÒѾ±»¡°Ç¿ÖÆ¡±¿¼ ÂǹýÁË¡£±¾½Úͨ¹ý×Ô¶¨Òå Exception ÀàÐÍ£¬±íʾ³ÌÐòµÄһЩ³£¼û´íÎóÀàÐÍ£¬Îª ´úÂë¿ÉÄÜ·¢ÉúµÄÎÊÌâÌṩеĺ¬Ò壬Çø·Ö´úÂëÔËÐÐʱ¿ÉÄܳöÏÖµÄÏàËÆÎÊÌ⣬»ò¸ø ³ö³ÌÐòÖÐÒ»×é¹²ÐÔ´íÎóµÄÌØÊ⺬Òå¡£
¿¼ÂÇÒÔϸ÷¸ö³¡¾°£¬Ê¹Óà exception ºÍ³£¼ûµÄ´íÎó»úÖÆÀ´´¦ÀíËüÃÇ¡£ÎªÃ¿ÖÖ´í ÎóÀàÐͽ¨Á¢Ð嵀 checked Òì³£À࣬ÔÚ Lab3 µÄ´úÂëÖÐÔö¼Ó´íÎóºÍÒì³£´¦Àí´úÂ룬 ÔÚÌض¨º¯ÊýÉÏÉùÃ÷Òì³£(throws)¡¢Å׳öÒì³£(throw)¡¢²¶»ñ²¢´¦ÀíÒì³£(try-catch- finally¡¢try-with-resources)¡£
l ÊäÈëÎļþÖдæÔÚ²»·ûºÏÓï·¨¹æÔòµÄÓï¾ä¡£ÀýÈçij¸öÔªËض¨ÒåµÄ±êÇ©·Ç·¨¡¢ ÔªËض¨ÒåµÄÄÚÈݸñʽÓëÓï·¨¹æ·¶²»Ò»ÖÂ(ÀýÈç×î¶à 1 λСÊýµ«Ê¹ÓÃÁË 2 λСÊý¡¢ÒªÇó 2 λ´óд×ÖĸºÍ 2-4 λÊý×Öµ«È´Ê¹ÓÃÁË·Ç´óд×Öĸ»ò³¬¹ý 4 λÊý×ÖµÈ)¡¢ÔªËض¨ÒåÖзÖÁ¿µÄÊýÄ¿»ò´ÎÐòÓë¹æ·¶²»·ûºÏ(ÀýÈ纽°àºÅ ÔÚÈÕÆÚÇ°Ãæ³öÏÖ£¬»òȱÉÙÈÕÆÚµÈ)µÈ¡£ÕâÀï²»Ò»Ò»Áо١£Õë¶ÔÄãËù¿ª·¢ µÄ¡°º½°à¡±Ó¦Óã¬ÒªÄܹ»¿¼ÂÇÖÁÉÙ 8 ÖÖ²»Í¬µÄ¡°²»·ûºÏÓï·¨¹æÔò¡±µÄÇé ¿ö²¢¼ÓÒÔ´¦Àí¡£
l ÊäÈëÎļþÖдæÔÚ±êÇ©ÍêÈ«Ò»ÑùµÄÔªËØ¡£ÀýÈç´æÔÚ¶à¸öº½°à¼Æ»®ÏîµÄ¡°ÈÕ ÆÚ,º½°àºÅ¡±ÐÅÏ¢ÍêÈ«Ò»Ñù¡£
l ÊäÈëÎļþÖи÷ÔªËØÖ®¼äµÄÒÀÀµ¹Øϵ²»ÕýÈ·¡£ÀýÈç:µÚÒ»ÐгöÏֵĺ½°àÈÕ ÆÚÓëÄÚ²¿³öÏÖµÄÆð·Éʱ¼äÖеÄÈÕÆÚ²»Ò»ÖÂ;½µÂäʱ¼äÖеÄÈÕÆÚÓ뺽°àÈÕ ÆÚ²î¾à´óÓÚ 1 Ìì;ͬһ¸öº½°àºÅ£¬ËäÈ»ÈÕÆÚ²»Í¬£¬µ«Æä³ö·¢»òµ½´ï»ú³¡¡¢ ³ö·¢»òµ½´ïʱ¼äÓвîÒì;ÔÚ²»Í¬º½°à¼Æ»®ÏîÖгöÏÖ±àºÅÒ»ÑùµÄ·É»ú£¬µ« ·É»úµÄÀàÐÍ¡¢×ùλÊý»ò»úÁäÈ´²»Ò»ÖÂ;µÈµÈ¡£ÕâÀï²»Ò»Ò»Áо١£Õë¶ÔÄ㠵ġ°º½°à¡±Ó¦Óã¬ÒªÄܹ»¿¼ÂÇÖÁÉÙ 4 ÖÖ²»Í¬µÄ¡°ÒÀÀµ¹Øϵ²»ÕýÈ·¡±µÄÇé ¿ö²¢¼ÓÒÔ´¦Àí¡£
ÔÚʹÓÃÕýÔò±í´ïʽ½øÐÐÎı¾½âÎöµÄ¹ý³ÌÖУ¬³ÌÐòÒ»µ©·¢ÏÖÕâЩ·Ç·¨Çé¿ö£¬Ó¦ ²¶»ñÒì³££¬½øÐÐÒì³£´¦Àí:Ìáʾ´íÎ󣬽áÊø´ËÎļþµÄ¶ÁÈ¡£¬½«µ±Ç°ËùÓöµ½µÄ²»ºÏ ·¨Ö®´¦Ìáʾ¸øÓû§£¬²¢ÈÃÓû§Ñ¡ÔñÆäËûÎı¾Îļþ¡£
×¢ 1:ÉÏÃæÖ»ÊǸø³öÁËÈô¸ÉÀý×Ó£¬²¢²»´ú±íÄãÖ»ÐèÒª´¦ÀíÕ⼸¸öÇé¿ö¡£Çë×Ð
ϸÔĶÁ Lab3 ʵÑéÊÖ²áÖеÄ˵Ã÷£¬ÔÚ½âÎöÊäÈëÎļþʱ¿¼ÂǸ÷ÖÖ¿ÉÄܵIJ»ºÏ·¨/²»Ò»
ÖµÄÇé¿ö£¬²¢×ÔÐÐÉè¼Æ´íÎóºÍÒì³£´¦Àí»úÖÆ¡£
2
Lab Manuals Lab-4 Debugging, Exception Handling, and Defensive Programming
×¢ 2:ÉÏÃæµÄÒªÇóÖÐÌáµ½¡°³ÌÐòÒ»µ©·¢ÏÖÕâЩ·Ç·¨Çé¿ö£¬Ó¦²¶»ñÒì³££¬½øÐÐ Òì³£´¦Àí¡±£¬ÕâÒâζ×ÅÄãµÄ³ÌÐò²»Äܼòµ¥Å׳öÒ»¸ö unchecked exception ʹӦÓÃÖ± ½ÓÍ˳ö£¬¶øÊÇҪʹÓà checked exception ½øÐд¦Àí¡£
×¢ 3:Çë×ÔÐй¹Ôì°üº¬ÉÏÊö¸÷ÖÖ´íÎóµÄÊäÈëÎı¾£¬ÓÃÓÚ²âÊÔÄãµÄÒì³£´¦Àí´ú ÂëÊÇ·ñÕý³£¹¤×÷£¬²¢½«ÕâЩÎı¾ÎļþËæÄãµÄÏîÄ¿Ò»ÆðÌá½»ÖÁ GitHub¡£
½ÓÏÂÀ´£¬¿¼ÂÇ 3.12 ½Ú¸÷ÖÖ client ²Ù×÷ʱ³öÏÖµÄÒÔÏ¡°Òì³£¡±²Ù×÷£¬²ÉÓÃ×Ô¶¨ Òå checked exception ºÍÏàÓ¦µÄÒì³£´¦Àí»úÖƸÄÔìÄãµÄ´úÂ룬Ìá¸ß½¡×³ÐÔ:
l ÔÚɾ³ýij×ÊÔ´µÄʱºò£¬Èç¹ûÓÐÉÐδ½áÊøµÄ¼Æ»®ÏîÕýÔÚÕ¼ÓøÃ×ÊÔ´;
l ÔÚɾ³ýijλÖõÄʱºò£¬Èç¹ûÓÐÉÐδ½áÊøµÄ¼Æ»®Ïî»áÔÚ¸ÃλÖÃÖ´ÐÐ;
l ÔÚÈ¡Ïûij¼Æ»®ÏîµÄʱºò£¬Èç¹û¸Ã¼Æ»®ÏîµÄµ±Ç°×´Ì¬²»ÔÊÐíÈ¡Ïû;
l ÔÚΪij¼Æ»®Ïî·ÖÅäij×ÊÔ´µÄʱºò£¬Èç¹û·ÖÅäºó»áµ¼ÖÂÓëÒÑÓеÄÆäËû¼Æ»®
Ïî²úÉú¡°×ÊÔ´¶ÀÕ¼³åÍ»¡±;
l ÔÚΪij¼Æ»®Ïî±ä¸üλÖõÄʱºò£¬Èç¹û±ä¸üºó»áµ¼ÖÂÓëÒÑÓеÄÆäËû¼Æ»®Ïî
²úÉú¡°Î»ÖöÀÕ¼³åÍ»¡±¡£
»¹Òª¿¼ÂÇ Lab3 ÊÖ²áÖиø³öµÄ¸÷¸öÓ¦ÓÃÓ¦×ñѵĸ÷ÖֺϷ¨ÐÔÏÞ¶¨¹æÔò(ÀýÈç 3.3.2 ½Ú±í¸ñ)¡£ÓÐЩÏÞ¶¨¹æÔò¿Éͨ¹ý ADT µÄ rep invariants ºÍ checkRep()¼ÓÒÔ ±£Ö¤£¬ÓÐЩ¿ÉÔÚÕâÀïͨ¹ý checked exception ½øÐд¦Àí£¬°ïÖúÄã·¢ÏÖ³ÌÐòÖеÄDZÔÚ bug¡£
3.2. Assertion and Defensive Programming
»ùÓÚÄãÔÚ Lab 3 ÀïΪ¸÷¸ö ADT Ëù׫дµÄ rep invariants (RI)¡¢Abstraction Function (AF)£¬ÒÔ¼°ËüÃǵÄÿ¸ö·½·¨µÄ spec(pre-condition ºÍ post-condition)£¬¶Ô ´úÂë½øÐзÀÓùʽ¸ÄÔì¡£
Õë¶Ôÿ¸öÀ࣬ËüÃÇÓÐÃ÷È·µÄ RI(Èç¹ûÄãûÓÐÔÚ Lab 3 µÄ ADT ´úÂëÖвûÊöÇå ³þÕâЩ invariants£¬Ðè¶ÔÕÕ Lab 3 ʵÑéÊÖ²á×Ðϸ²¹³ä)£¬Çë¾Ý´Ë׫д checkRep() ²¢¼ÓÈë¸÷·½·¨¡£ÀýÈç(µ«ÄãµÄʵÏÖ²»Ó¦½öÏÞÓÚÕâÁ½¸öÀý×Ó):
l º½°àµÄÆð·Éʱ¼ä±ØÐëÒªÔçÓÚ½µÂäʱ¼ä£¬Æð·ÉºÍ½µÂäµÄ»ú³¡²»Ïàͬ;
l ¸ßÌúµÄÆðÖÁÕ¾ºÍ¸÷;¾³µÕ¾²»ÄÜÖظ´£¬Ëù·ÖÅäµÄ¸÷¸ö³µÏá²»ÄÜÓÐÏàͬµÄ
񅧏;
Õë¶Ôÿ¸ö·½·¨£¬ËüÃÇÓÐÃ÷È·µÄ spec£¬Çë¾Ý´ËÔÚ¸÷·½·¨ÖÐͨ¹ý assertion »òÒì³£
»úÖÆ·Ö±ð´¦Àí pre-condition ºÍ post-condition£¬¾¡¿ÉÄÜ fail fast¡£ ×¢Òâ:ÉÏÊöÖ»ÊÇÔÚ¾ÙÀý£¬ÄãÐèÒª¶ÔËùÓеÄÀàºÍ·½·¨½øÐзÀÓùʽ¸ÄÔ죬²¢ÒÔ×¢
Ê͵ÄÐÎʽ˵Çå³þÄãµÄ¡°·ÀÓù²ßÂÔ¡±¡£
3
Lab Manuals Lab-4 Debugging, Exception Handling, and Defensive Programming
ÁíÍâ:Èç¹ûÄãÔÚ Lab3 ÖÐÒѾ×öÁË×ã¹»¶àµÄ¡°·ÀÓù¹¤×÷¡±£¬¸ÃÈÎÎñÖ»ÐèÔÚʵÑé ±¨¸æÖÐ˵Çå³þÄãµÄÿһ¸ö·ÀÓù²ßÂÔºÍÏàÓ¦µÄʵÏÖ¼´¿É¡£
3.3. Logging
ʹÓà java logging(»òÆäËûµÚÈý·½ java ÈÕÖ¾¿âÈç log4j¡¢SLF4J)£¬Îª 3.1 ºÍ 3.2 ½Ú¾¹ýÒì³£´¦Àí¡¢´íÎó´¦Àí¡¢¶ÏÑÔ´¦ÀíµÄ³ÌÐòÔö¼ÓÈÕÖ¾¹¦ÄÜ¡£ÈÕÖ¾ÐèÒª¼Ç ¼ÒÔÏÂÐÅÏ¢:
l ËùÓеÄÒì³£/´íÎó:·¢ÉúµÄʱ¼ä¡¢Òì³£/´íÎóÀàÐÍ¡¢Òì³£/´íÎó·¢ÉúµÄÀàÃûºÍ ·½·¨Ãû£¬Òì³£/´íÎóµÄ¾ßÌåÐÅÏ¢¡¢Òì³£/´íÎó´¦ÀíµÄ½á¹û;
l Èý¸öÓ¦ÓÃϵͳÖеÄËùÓвÙ×÷£¬¾ßÌå²Î¼û Lab3 ÊÖ²á 3.12 ½ÚµÄ¾ßÌåÒªÇó¡£
ΪӦÓÃÌí¼ÓÈÕÖ¾²éѯ¹¦ÄÜ£¬Óû§¿ÉÊäÈë¹ýÂËÌõ¼þ(ÀýÈ簴ʱ¼ä¶Î¡¢°´²Ù×÷Àà ÐÍ¡¢°´¼Æ»®ÏîÃû×Ö£¬»òÕßÕâЩÌõ¼þµÄ×éºÏ)½øÐÐÈÕÖ¾²éѯ¡£×¢Òâ:²éѯ½á¹û²»Òª Ö±½ÓÏÔʾÔʼÈÕÖ¾¼Ç¼£¬ÐèÒª¾ßÓÐÁ¼ºÃµÄ¿ÉÀí½âÐÔ¡£
3.4. Testing for Robustness and Correctness
ʹÓõȼÛÀàºÍ±ß½çÖµµÄ²âÊÔ˼Ï룬Ϊ¸÷ ADT Ìí¼Ó testing strategy¡£
¿¼ÂÇ 3.1 ½ÚÖгöÏֵĶàÖÖ·Ç·¨ÇéÐΣ¬Éè¼ÆÒ»×é²âÊÔÓÃÀý£¬ÈËΪÖÆÔì°üº¬¡°·Ç ·¨¡±µÄÎı¾Îļþ£¬¶Ô³ÌÐò½øÐн¡×³ÐÔºÍÕýÈ·ÐÔ²âÊÔ£¬Ïë·½Éè·¨ÈóÌÐò±ÀÀ£(¼´Ñé Ö¤³ÌÐòÊÇ·ñÓÐÈÝ´íÄÜÁ¦)¡£
ʹÓà JUnit ΪÉÏÊö²âÊÔÓÃÀý±àд´úÂ룬²¢ÔËÐвâÊÔ¡£
ʹÓà EclEmma ²é¿´²âÊÔµÄÓï¾ä¸²¸Ç¶È(Instruction Counters)¡£Çл»Îª·ÖÖ§¸² ¸Ç¶È(Branch Counters)ºÍ·¾¶¸²¸Ç¶È(Complexity)£¬¶Ô±ÈÒ»ÏÂÈýÖÖ¸²¸Ç¶ÈµÄ²î Òì¡£Èô¸²¸Ç¶È¹ýµÍ£¬¼ÌÐøÔö¼Ó²âÊÔÓÃÀý£¬Ê¹¸²¸Ç¶È±ä¸ß¡£×îÖÕ£¬Éú³É EclEmma µÄ ²âÊÔ¸²¸Ç¶È±¨¸æ¡£
EclEmma µÄÑ¡Ïî²Ëµ¥ 4
Lab Manuals Lab-4 Debugging, Exception Handling, and Defensive Programming
EclEmma ÓÒ¼ü²Ëµ¥µ¼³ö¸²¸Ç¶È±¨¸æ(HTML)
Èç¹ûÄãÔÚ Lab3 ÖÐÒѾ×öÁË×ã¹»¶àµÄ¡°²âÊÔ¹¤×÷¡±£¬¸ÃÈÎÎñÖ»ÐèÔÚʵÑ鱨¸æÖÐ
˵Çå³þÄãµÄ²âÊÔ²ßÂÔºÍÏàÓ¦µÄʵÏÖ¼´¿É¡£·ñÔò£¬ÇëÏêϸ²¹È«ÄãµÄ²âÊÔ¡£
3.5. UsingSpotBugstool
ʹÓà SpotBugs ¹¤¾ß£¬¼ì²éÄ㵽ĿǰΪֹµÄ´úÂ룬¸ù¾Ý¹¤¾ßËùÌáʾµÄDZÔÚ bug
¼°ÆäΣº¦³Ì¶È£¬ÖðÏîÏû³ý£¬²¢ÔÚºóÐø±à³ÌÖбÜÃâ´ËÀàÎÊÌâ¡£
ÔÚÏîÄ¿Éϵã»÷ÓÒ¼ü£¬Ñ¡Ôñ SpotBugs
3.6. Debugging
¸Ã½ÚÈÎÎñ²»Õë¶Ô Lab 3 µÄ±³¾°£¬¶øÊÇÕë¶ÔÒÑÓеijÌÐò£¬Í¨¹ý²âÊԺ͵÷ÊÔ·¢ÏÖ ÆäÖдæÔÚµÄ bug ²¢½«ÆäÐÞ¸´¡£
5
Lab Manuals Lab-4 Debugging, Exception Handling, and Defensive Programming
Çë´Ó https://github.com/rainywang/Spring2020_HITCS_SC_Lab4 ÏÂÔØ´ýÐÞ¸´µÄ ³ÌÐòÔ´Îļþ£¬Ã¿¸ö³ÌÐòÖÐÔ̺¬´íÎó»òÕßÓëÐèÇó/spec ²»·ûµÄµØ·½£¬ÎÞ·¨°´ÆÚÍûÖ´ Ðеõ½½á¹û¡£Ò»¹²ÓÐÈý¸ö¶ÀÁ¢µÄ³ÌÐò(EventManager¡¢LowestPrice¡¢ FlightClient/Flight/Plane)£¬ÀûÓÃÄãµÄ¾ÑéºÍÏà¹Ø¹¤¾ß½øÐÐ debug£¬·¢ÏÖÎÊ ÌâËùÔÚ£¬½«´úÂëÐÞ¸ÄÕýÈ·£¬¸ø³ö²âÊÔÓÃÀý£¬²¢Ìá½»¡£²»Òª¸Ä¶¯ÀàÃûºÍÎļþÃû¡£
ÐÞ¸´ºóµÄ´úÂëÖÐÐèÒªÔö¼Ó±ØÒªµÄ×¢ÊÍÒÔ±ê×¢³öÐÞ¸ÄÖ®´¦ºÍÔÒò£¬ÒÔ°ïÖú¶ÁÕß Àí½âÄãËù×öµÄÐ޸ġ£
×¢ 1:ÔÚ debug ֮ǰ£¬ÇëÀûÓø÷³ÌÐòÇ°ÃæµÄ spec£¬¸ù¾ÝµÈ¼ÛÀàºÍ±ß½çÖµ·½·¨ ׫д³ä×ãµÄ JUnit ²âÊÔÓÃÀý(ÒÔ¼°×¢ÊÍÐÎʽµÄ testing strategy)£¬¸ù¾Ý²âÊÔ½á¹û½ø ÐÐÖð²½µ÷ÊÔ£¬·¢ÏÖ´íÎó²¢ÐÞ¸´¡£Ìá½»½á¹ûÖÐÇëÎñ±ØÔÚ test/debug Ï°üº¬ÄãÕë¶ÔÈý ¸ö³ÌÐòµÄËùÓвâÊÔÓÃÀý¡£
×¢ 2:²»ÒªÊÔͼÁíÆð¯ÔîÖØÐÂдһ¸ö³ÌÐòÍê³É spec ÀïµÄ¹¦ÄÜ£¬¶øÊÇÒªÔÚ×ñÑ Ô³ÌÐòµÄ˼·»ù´¡ÉϽøÐÐÐ޸ġ£
ÌύĿ¼:
¸ÃÈÎÎñ²»ÊDZà³Ì¾ºÈü£¬¶øÊǸøÄãÌṩһ¸öѵÁ·
debug ¼¼ÇɵĻú»á£¬ÎÞÐèÓÃȫеĴúÂëÕ¹ÏÖÄãµÄ±à³Ìˮƽ¡£
ÏîÄ¿Ãû³Æ: Lab4-ѧºÅ Ŀ¼: src ×ÓĿ¼: debug
(ÐÞ¸´ºóµÄÔ´Îļþ).java test
debug
…Test.java
4. ʵÑ鱨¸æ
Õë¶ÔÉÏÊöÈÎÎñ£¬Çë×ñѸø³öµÄ±¨¸æÄ£°å£¬×«Ð´¼òÃ÷¶óÒªµÄʵÑ鱨¸æ¡£
ʵÑ鱨¸æµÄÄ¿µÄÊǼǼÄãµÄʵÑé¹ý³Ì£¬ÓÈÆäÊÇÓöµ½µÄÀ§ÄÑÓë½â¾öµÄ;¾¶¡£²» ÐèÒª³¤ÆªÀÛë¹£¬¼Ç¼¹Ø¼üÒªµã¼´¿É£¬µ«ÐèÈ·±£±¨¸æ¸²¸ÇÁ˱¾´ÎʵÑéËùÓпª·¢ÈÎÎñ¡£
×¢Òâ:
l ʵÑ鱨¸æ²»ÐèÒª°üº¬ËùÓÐÔ´´úÂ룬Çë¸ù¾ÝÉÏÊöÄ¿µÄÓÐÑ¡ÔñµÄ¼ÓÈë¹Ø¼üÔ´
´úÂ룬×÷Ϊ¸¨Öú˵Ã÷¡£
l ÇëÈ·±£±¨¸æ¸ñʽÇåÎú¡¢Ò»Ö£¬¹ÊÇë×ñÑÄ¿Ç°Ä£°åÀïÉèÖõÄ×ÖÌå¡¢×ֺš¢
Ðмä¾à¡¢Ëõ½ø;
l ʵÑ鱨¸æÌύǰ£¬Ç롰Ŀ¼¡±ÉÏÓÒ»÷£¬È»ºóÑ¡Ôñ¡°¸üÐÂÓò¡±£¬ÒÔÈ·±£ÄãµÄ
Ŀ¼±êÌâ/Ò³ÂëÓëÕýÎÄÏà¶ÔÓ¦¡£ 6
Lab Manuals Lab-4 Debugging, Exception Handling, and Defensive Programming
l ʵÑ鱨¸æÎļþ¿É²ÉÓà Word »ò PDF ¸ñʽ£¬ÃüÃû¹æÔò:Lab4-ѧºÅ-Report¡£ 5. Ìá½»·½Ê½
½ØÖ¹ÈÕÆÚ:µÚ 15 ÖÜÖÜÈÕÒ¹¼ä 23:55¡£
Ô´´úÂë:´Ó±¾µØ Git ²Ö¿âÍÆËÍÖÁ¸öÈË GitHub µÄ Lab4 ²Ö¿âÄÚ¡£ ʵÑ鱨¸æ:Ëæ´úÂë²Ö¿â(doc)Ŀ¼Ìá½»ÖÁ GitHub¡£
6. ÆÀ·Ö·½Ê½
TA ÔÚµÚ 13-15 ÖÜʵÑé¿ÎÉÏÏÖ³¡ÑéÊÕ:ѧÉú×öÍêʵÑéÖ®ºó£¬Ïò TA Ìá³öÑéÊÕÉê Ç룬TA ¸ù¾ÝʵÑéÒªÇ󿼺ËѧÉúµÄ³ÌÐòÔËÐнá¹û²¢´ò·Ö¡£ÏÖ³¡ÑéÊÕ²¢·Ç±ØÐ裬ÓÉ Ñ§ÉúÖ÷¶¯Ïò TA Ìá³öÉêÇë¡£
Deadline Ö®ºó£¬½ÌʦʹÓóÖÐø¼¯³É¹¤¾ß¶ÔѧÉúÔÚ GitHub ÉϵĴúÂë½øÐвâÊÔ¡£ ½ÌʦºÍ TA ÔĶÁʵÑ鱨¸æ£¬×ö³öÏàÓ¦ÆÀ·Ö¡£
7