Avoid over-streamlining temporary variables-refactoring
During the refactoring process, a problem occurred in my code and an endless loop occurred!
An important means of refactoring is to remove the hateful temporary variables and change them to method calls. This is an idea that Martin Fowler emphasizes.
A major means and goal of
Source: Peer system RepayCalc.cs, this code may refer to the system from the offlineA functional language usage problem1) backdate Date type to datetime, you can not use string concatenation2) Calculation error on repayment day (1 months! = 30 days)3) Object-oriented programming, not all through function calculation4) constructor instead of string concatenation, string concatenation and type conversion consume CPU5) Redundant code deletion, error condition: The first repayment day is later than
As PHP transforms from a simple scripting language into a mature programming language, the complexity of a typical PHP application's code base increases. To control the support and maintenance of these applications, we can use a variety of test tools to automate the process. One is unit testing, which allows you to directly test the correctness of the code you write. However, the usual legacy code base is not suitable for this kind of testing. This article describes
Mind Mapping
IntroducedTake the following PHP talk about refactoring-improving the design of existing code to reorganize your function to continue refactoring. This chapter focuses on the reconstruction of data. 1. The voice of controversy-access field directly or through a function (Accessor)
2. Modify the array to object: When you see an array that resembles a data structure, you can use the Replace arra
Mind Mapping
Index:Ømove Method (removal function) Ømove Field (move range) Øextract Class (Refinement Class) Øinline class (inline class, that is, merge the current class into another class) Øhide Delegate (hidden delegate relationship) Ø Remove middle man (remove middleman) Øintroduce Foreign Method (Introducing an additional function) Øintroduce local Extension (introduction of local extensions) introduction to the above-mentioned PHP "refactoring
Chapter 1 of refactoring-experience reconstruction magic RefactorSample, magic baby logging experience
The lab has been settled, and the environment and atmosphere are very good. Today, the teacher invited Sun, manager of Zhuo Er in Beijing, to talk a lot. The biggest surprise is that Mr. Ren is a cloud computing engineer, java is bound to be connected to cloud computing.
After a month, I did not write my blog seriously, nor did I study it seriously.
understand : Often write code, there are some computational logic more complex methods, write down a very long and long method, we can put this method, according to the function, decomposition into a few small methods alone. This will not only increase the maintainability of the code, but also increase legibility.Detailed :Refactoring Pre-code:1 Public classReceipt2 {3 Privateilistdecimal> Discounts {Get;Set; }4 Privateilistdecima
Understanding : The "Extract factory class" In this article refers to the complexity of the code if you are creating many objects. A good way to do this is to extract the factory class. In general, we need to set up some objects in our code in order to get their state, so that we can use objects, so-called settings are often the way to create an instance of an object and invoke an object. Sometimes the code becomes complex if you want to create a lot of objects. This is where the factory model
Refactoring purpose
The same code is best to appear only once
Primary and Secondary methods
Main method
Contains only sub-methods that implement complete logic
Clear thinking, easy to read
Secondary method
Implement specific logic functions
After the test passes, almost no maintenance is followed
Steps for Refactoring
provided the service itself, but if you need to use the function multiple times, you have to repeat the code, remember?
Repeating code is the root of the software.
These duplicate codes should be pumped out using extract method to put into the same function, of course, if you have to perform this refactoring, this also gives you a clear signal: This function should be implemented in the class that provides the service.If you find that y
Mind MapIntroductionIn the previous series of articles, I pay more attention to Today we are talking about "interfaces", which are not "interfaces" but collectively referred to as "interfaces. Generally, we can call a function or url (usually used to provide data) for others' use as an interface. -- There may be other meanings. After all, I still belong to cainiao. please correct me if you have any misunderstanding.We know that "easy to understand and use interfaces" is the key to developing goo
Written for many years, C + + code, but also written for many years of Java code, C + + in order to implement efficiency, development efficiency constantly evolve, and constantly introduce new features, new Standard library. Used to develop a single function is really convenient and quick, once the UI and the complexity of the function, the C + + library is not enough. With its simple syntax, memory management, and cross-platform advantages, Java has won the first place in the programming langua
JavaScript problem, about refactoring Window.alert (), and then invoking window's original Window.alert () methodBig God, ask a question, if the script tag in the first line to write, refactoring the method of Window.alert (), if you do not move the above refactoring on the basis of the code can only use a statement directly call the original Window.alert () meth
Eclipse refactoring menu uses eclipse refactoringWe often need to modify the class name in project development, but if other classes depend on the class, we need to spend a lot of time modifying the class name.But the Eclipse refactoring feature can automatically detect class dependencies and modify class names, saving us a lot of time.You can open the refactoring
Today began to optimize for someone else to write the project, I first put the relationship between the class to think well, began to move the method, corresponding to move the corresponding class attributes, change to the back, found that the more changes, basically changed all the method of refactoring on all completed, but the change is very large, and the middle of the opportunity to test, has been wrong Coupling is too close, can not be step-by-s
Refactoring: longer and longer switches... case and if... else, switchcase
In Code, conditional expressions such as switch... case or if... else are usually expanded with a Type Code. As the business logic of the project increases and the code is modified over years, these conditional judgment logics become increasingly lengthy. Especially when the same logic judgment appears in multiple places (the structure is illustrated below), the code readabilit
Conditional logic may be very complex. Therefore, this chapter provides some refactoring techniques to simplify their mind map.
Click to view the chart.
The introduction of conditional logic may be very complicated. Therefore, this chapter provides some refactoring techniques to simplify them.
Full text description(You can skip the following content) core refactoring
Once the program finds that the write is not ideal, it needs to be reconstructed, and it finds that the write is not ideal for refactoring.
In the morning, I wrote an article titled design patterns-Builder patterns: http://www.cnblogs.com/insus/p/4259620.html. Is the application and demonstration design pattern (Builder) in the ASP. NET environment ). Now Insus. NET downloads the source program from the last download link in the blog. It is not ideal
"mobile". Front-end engineers are limited to their own mobile phone or product manager's ipad or iphone, and the specific Iqiyi users are distributed with no data to support, so that the product facing the ipad or product for the iphone swing. So before development, figure out what the target users are, and apply enough test machines.Refactoring:Project Introduction(i). Development of the "Summer animation house Activity" in the later page This project is a reconstruction of the project withou
In the previous article, "The Path of Android Project refactoring: Architecture", the project's architecture has been briefly explained, and the project is divided into four levels: Model layer, Interface layer, core layer, interface layer. Among them, the top interface, is the most frequent change of a level, but also the most complex and most prone to problems of a level, if the planning is not good, it is easy to do, and mess.To plan the interface
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.