Скачать презентацию Identification of Refused Bequest Code Smells E Ligu Скачать презентацию Identification of Refused Bequest Code Smells E Ligu

8ff0069b1538254193fafc8461573836.ppt

  • Количество слайдов: 9

Identification of Refused Bequest Code Smells E. Ligu, A. Chatzigeorgiou, T. Chaikalis, N. Ygeionomakis Identification of Refused Bequest Code Smells E. Ligu, A. Chatzigeorgiou, T. Chaikalis, N. Ygeionomakis Department of Applied Informatics University of Macedonia, Greece ICSM’ 2013, Early Research Achievements Track, September 24, 2013

Context Mammal In the world of OO systems, inheritance is not a panacea + Context Mammal In the world of OO systems, inheritance is not a panacea + breathe. Air() + regulate. Body. Temp() + give. Birth. To. Live. Young() + produce. Milk. If. Female() + swim()

Problem Goal: Identification of Refused Bequest Code Smells Refused Bequest: “a subclass does not Problem Goal: Identification of Refused Bequest Code Smells Refused Bequest: “a subclass does not want to support the interface inherited from its parent class” [Fowler] non-trivial problem to resolve Appropriate Refactoring: Replace Inheritance with Delegation Famous quote: “Favor Composition over Inheritance” [Go. F]

Key Concept public interface which is inherited OK is the subclass using the inherited Key Concept public interface which is inherited OK is the subclass using the inherited interface? indication of Refused Bequest

Smell Thermometer Signs of Refused Bequest : - no superclass method is overridden - Smell Thermometer Signs of Refused Bequest : - no superclass method is overridden - no inherited method is invoked on subclass instances - no super class method invocations No argument in favor of inheritance Refused Bequest is highly improbable: - inherited methods have been reimplemented to provide functionality that is specific to the subclass -> goal is to enable polymorphism. - the presence of errors -> inherited functionality is actually employed.

Example Sweet. Home 3 D v. 4. 0 LOC: 76 K, 460 classes, 69 Example Sweet. Home 3 D v. 4. 0 LOC: 76 K, 460 classes, 69 hierarchies, 42 test cases

Tool Implementation on top of the JDeodorant tool http: //java. uom. gr/ref_bequest/ Tool Implementation on top of the JDeodorant tool http: //java. uom. gr/ref_bequest/

Threat to Validity Assumption: unit tests exercise thoroughly system functionality Threat to construct validity: Threat to Validity Assumption: unit tests exercise thoroughly system functionality Threat to construct validity: introduced errors might not lead to test failures because tests have not been designed to cause the invocation of the corresponding methods and not because the methods are not actually utilized. Mitigation: perform identification on projects with extensive test coverage

Question 1 (academic): Would you trust an automated tool to identify and resolve design Question 1 (academic): Would you trust an automated tool to identify and resolve design defects on its own? Question 2 (provocative): Do you think that industrial engineers actually regard the resolution of smells as a (serious) way to improve the code? ICSM’ 2013, Early Research Achievements Track, September 24, 2013