Taste programming is not simply based on the knowledge in books, but summarized in the practical development process. There may be multiple methods for a problem, however, no matter which method you use, remember that you must consider the Code's scalability, readability, and robustness, and check whether the code you write is reasonable. This requires your own efforts, design with your heart. Do not be ambiguous in code design!
In the following example, a Font class is designed, but the two results are completely different.
Example 1:
Size { ; Unit{; Name { ; Style { ;
Example 2: pay more attention to code readability, scalability, and rationality. Although the code length is increased, it is not too long. It is friendly for upper-level developers.
= = = = = FontSize(== Size { ; Unit Unit { ; FontSize Size { ; Name { ; FontStyle Style { ;
Provides a method for outputting a font style.
IEnumerable<> ((fontStyle & FontStyle.Bold) == ((fontStyle & FontStyle.Italic) == ((fontStyle & FontStyle.Strikeout) == ((fontStyle & FontStyle.Underline) == (fontStyle ==
OK, perform a test.
Font font = = = FontSize(= FontStyle.Bold |=>
Result
In fact, from example 2, we can see a lot of things. It uses classes, structures, enumerations, iterations, and so on. We can see that the FontStyle enumeration is identified by the Flags feature, in this case, it supports bitwise operations. In this example, a method is provided to return the result set of bitwise operations in an iterative manner. This is a bright spot. Through this method, it can be extended to other enumeration types, such as user permission design (view, delete, add, update) and file attribute design (read-only, archive, hidden). For underlying developers, you need to develop the corresponding methods for these types. Such a design is very friendly for surface developers!