In a series of boolean expressions, a variable carries a "control flag.Replace the control mark with a break or return statement.
Motivation: In a series of conditional expressions, you will often see the control mark used to determine when to
90% , to reduce the function size, you only need to use extract method (extraction function) find the part of the function that is suitable for aggregation, extract them to form new functions.
If a function contains a large number of
Reuse is often regarded as the ultimate goal of objects. However, the significance of reuse is often overestimated: Most objects only need to be enough. But it is undeniable that many programming technologies are built onProgramLibrary.
Database
The so-calledData classThey have some fields and functions used to access these fields. Such classes are just data containers that do not speak, and they must be controlled by other classes excessively. These classes may havePublicFields, so you
You have a data item that must be used together with other data and actions to make sense.Convert data items into objects.
Motivation: at the initial stage of development, you often decide to use simple data items to indicate simple situations.
You need to check whether an object is null again and again.Replace null with a null object.
Motivation: the most fundamental benefit of polymorphism is that you don't have to ask the object "What type are you?" and then call a behavior of the
Subclass should inherit the functions and data of superclasses. But what if they don't want to or do not need inheritance? They get all the gifts, but they just pick a few of them to play.
Traditionally, this means that the design of the
C # provides a lot of formatting methods for numbers or strings. However, in project development, there are many formats that cannot be implemented as needed, so we need to define iformatprovider, which is actually very simple, you only need to
2Child classes have the same fields.Move this field to the superclass.
Motivation: if each subclass is developed separately or combined during the refactoring process, you will often find that they have repeated features, especially fields that
I don't know much about the theory. Let's take an example for a preliminary introduction! Sorry! Thank you for your comments!
First read an XML document
XML
Code highlighting produced by Actipro CodeHighlighter
If an abstract class does not really work, use collapse Hierarch (collapse inheritance system) . You can use inline class (to link classes) for unnecessary delegation) remove. If some parameters of the function are not used, you can remove
There is a function that has never been used by any other class.Modify this function to private.
Motivation: refactoring often prompts you to modify the visibility of a function. It is easy to imagine that another class needs to use a function, so
A function returns a set.Let this function return a read-only copy of the set and provide a function to add/remove the element of the set in this class.
Motivation: we often use a set in a class to store a group of instances. Such classes also
The object calls a function and passes the result as a parameter to another function. The function that accepts this parameter can also call the previous function.Let the parameter receiver remove this parameter and directly call the previous
Flex itself has poor support for mouse styles, so if you want a better mouse experience, you need to customize your mouse styles.
Flex supports three types of mouse styles: Normal, manual, and busy. You can set the parameters in the following
The rows of the datagridview rocontains A headercell which can be used to set the row title text. However, after sorting, the text is cleared. therefore, this method is not feasible. next I will introduce a new method .. that is, when the
YourProgramA temporary variable is assigned more than once. It is neither a cyclic variable nor used to collect computing results.Creates an independent temporary variable for each assignment.
DoubleTemp = 2 + (_ height + _ width );
Controls are often used in Web development. Although some of them already exist in the toolbox, sometimes they need to be developed according to their own requirements.Suitable for your own controls. Web control development has become a
You have some constructors in each subclass, and their ontology is almost identical.Create a new constructor in the superclass and call it in the subclass constructor.
Motivation: constructor is a wonderful thing. They are not common functions, and
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service