Original link: https://chenyan98.cn/3182.html
Designing a class is to complete the design of properties and methods! Attribute: What data the class needs to encapsulate! Method: What functions (tasks) the class should implement! Considering that everyone’s thinking angle is different, the methods used are different, and the attributes and methods of the final design are also different. As long as it makes sense, it is reasonable! What is the reason for this? Today we are learning this “truth”! And this truth is the various object-oriented principles we have to master! Learning object-oriented is learning a series of principles, methods, techniques, experiences, design patterns, etc.! The advanced skill points in the back are relatively easy! Six Object-Oriented Principles [1] Single Responsibility (SRP) In Single Responsibility SRP, the task to be completed by an object should be clearly abbreviated as the object responsibility is clear. That is, we do not design a universal class! Bad practice: Some people design form classes or other functional classes, and there are 12,000 lines in a class […]
This article is reproduced from: https://chenyan98.cn/3182.html
This site is for inclusion only, and the copyright belongs to the original author.