Reconstruction-Reading Notes

Source: Internet
Author: User
# Reading Notes # The Key to encapsulate collection is to create a function for adding and removing cluster elements respectively, and encapsulate get as readonly. Otherwise, the client of the cluster secretly changes the elements, but the cluster owner knows nothing. In C #, readonlycollection or asreadonly () can be used. Http://stackoverflow.com/questions/1710902/unmodifiable-lists-in-c

# Reading Notes # The value of assertion is: Help Program Personnel understanding Code Necessary Conditions for proper running.

 

# Reading Notes # We often write this judgment "If (customer = NULL) xxxx", where the judgment conditions may be repeated in multiple places, in this case, we can use introduce Null Object (introduce Null Object) to create a null customer class that inherits the original customer class and concentrate the judgment conditions on the location where the customer is obtained, with polymorphism, the same judgment conditions can be removed. For details, see P260.

# Reading Notes # Remove control flag (remove control flag) is a classic explanation of Fowler's opposition to the "Single Exit" principle. He believes that this principle will add annoying control labels to your code, greatly reducing the readability of conditional expressions. He suggested replacing the control mark with a break statement, a continue statement, or a return statement ".

# Reading Notes # Finally, you can see the long-awaited introduce parameter object (introducing parameter objects). When some parameters always appear naturally at the same time, "replace these parameters with one object ". After you organize these parameters together, you will soon find some actions that can be moved to the new class, p295.

# Reading Notes # the comprehensibility of the Code should be our goal.

 

# Reading Notes # If a condition is extremely rare, it should be checked separately and immediately returned from the function when the condition is true. Such a separate check is often referred to as the guard clause )". The essence of replace nested conditional with guard clses is to assign special attention to a branch. If you use the if-then-else structure, you pay the same attention to the IF Branch and the else branch.

# Reading Notes # the core value of the MVC model is that it uses the user interface code (view and view) it is separated from the domain logic (the so-called model. The presentation class only contains the logic used to process the user interface. The domain class does not contain any Code related to the program appearance, but only business logic code.

# Recommended books # reconstruction: translated by Martin Fowler Hou Jie and Xiong Jie. : Http://ishare.iask.sina.com.cn/f/5597581.html # reading Sense # dozens of effective reconstruction method introduction and drills, close to the reality, indeed as the preface said, after reading this book, the idea should become a part of your blood, the design model should be a reference book on your desk at any time.

 

 

 

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.