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

Software Engineering For Students: A Programming Approach Part 19. 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 | 158 Chapter 12 Design patterns These relationships between components are the essence of the MVC pattern. The advantages are that the model the view or the controller can be changed without affecting any other part of the system. Furthermore additional views and controls can be added easily. Mediator In the software for the cyberspace invaders game there must be a method or methods that test to see whether a laser has hit an alien and whether a bomb has hit the defender. The question is Where are these methods One option is to place this collision detection within class Laser and class Bomb. Unfortunately this leads to a complex structure in which every bomb has to know about the defender object and every laser has to know about every alien object. This is high coupling. For example if we introduce additional objects into the game we will need to modify class Bomb and class Laser. A better approach is to create a mediator class. As its name suggests this is responsible for handling relationships between objects - termed colleague objects. The essence of the mediator pattern is that colleague objects are changing because in this example they are moving . This is how the pattern is implemented. First all the colleague objects register with the mediator object. Thereafter when a colleague object changes its state in this example when it moves it calls the mediator object. The mediator decides whether a notable event has occurred a collision in this example and if necessary notifies appropriate colleague objects the objects involved in the collision . The advantages are all the dependency logic is in one place the colleague objects are simpler because they do not embody code to check dependencies. SELF-TEST QUESTION Identify differences between the Mediator pattern and the MVC pattern. Pipe and Filter This pattern describes a way of building software from a group of components that collaborate by passing a stream of information. The components behave .