In a situation where, there are a number of conditions to be checked for performing different actions, we tend to use a chain of IF - ELSE IF statements. Such a code looses its readability, making understanding and maintenance difficult. Also if while writing such a code if the braces are not matched properly, some conditions does not produce the required output. But in such a cases if Switch Case statements are used, the code becomes very easy to understand and maintain. |
Use Switch Case Statements where ever possible instead of IF - ELSE IF statements |
1 Introduction This paper describes the use of object-oriented software design patterns, as presented in Design Patterns: Elements of Reusable Object-Oriented Software by Gamma et al., within the Microsoft Foundation Class Library (MFC). MFC is used for implementing applications for Microsoft Windows operating systems. Because of the size of the MFC library, a complete analysis would have been beyond the scope of this assignment. Instead, we identified various possible locations for design patterns, using the class hierachy diagram of MFC, and studied the source carefully at these locations. When we did not find a pattern where we expected one, we have documented it anyway, with examples of how the particular problem could have been solved differently, perhaps more elegantly, using design patterns. We have included a brief introduction to MFC in Section 2 , as background information. The analysis has been split into three parts, with one section for each major design pattern ca...
Comments