TAILIEUCHUNG - Software Engineering For Students: A Programming Approach Part 20

Software Engineering For Students: A Programming Approach Part 20. This fully revised version of Doug Bell's Software Engineering: A Programming Approach continues to use the successful formula of the previous editions. The author's approach is to present the main principles, techniques and tools used in software engineering, one by one, chapter by chapter. This book is a unique introduction to software engineering for all students of computer science and its related disciplines. It is also ideal for practitioners wishing to remain current with new developments in the area | 168 Chapter 13 Refactoring One way in which a class can become very small is when it has been the subject of the Move Method and the Move Variable refactorings so that it has become sucked dry. This illustrates how many of the refactorings are interconnected - using one leads to using another and so on. SELF-TEST QUESTION Compare the factoring Inline Class with the factoring Extract Class. Identify composition or inheritance Once we have identified the classes within a software system the next step is to review the relationships between the classes. The classes that make up the software collaborate with each other to achieve the required behavior but they use each other in different ways. There are two ways in which classes relate to each other 1. composition - one object creates another object from a class using new. An example is a window object that creates a button object. 2. inheritance - one class inherits from another. An example is a class that extends the library Frame class. The important task of design is to distinguish these two cases so that inheritance can be successfully applied or avoided. One way of checking that we have correctly identified the appropriate relationships between classes is to use the is-a or has-a test the use of the phrase is-a in the description of an object or class signifies that it is probably an inheritance relationship. the use of the phrase has-a indicates that there is no inheritance relationship. Instead the relationship is composition. An alternative phrase that has the same meaning is consists-of . We return to the cyberspace invaders game designed in Chapter 11 seeking to find any inheritance relationships. If we can find any such relationships we can simplify and shorten the program making good use of reuse. In the game several of the classes - Defender Alien Laser and Bomb - incorporate the same methods. These methods are getX getY getHeight and getWidth that obtain the position and size of the graphical .