[Reading Notes]clean Code (8-end)

Source: Internet
Author: User

I forgot to send it.
Date: 2016/5/6  Friday
Reading the second half of the book today, there are two different points: 1. Level, the first half is trivial detail, and the latter part is based on the first half but stands at a higher point in terms of how to write the code. 2. The second half also summarizes the first half, telling you a little bit about how those rules were used in an instance. Nine, unit Test 1. The law of TDD before writing a unit test that cannot be passed, the production code can only write the unit test that just can't pass, not compile or not by writing just enough to pass the current failure test of Production Code-----These three write a little bit, my understanding is: To put the test code when the production code to write, Testing is also important. 2. Five big Rules (F.I.R.S.T) Fast: Code quality is good, efficient and independent: each test should be independent and repeatable: it is in various environments can be tested through self-sufficiency verification: testing does not rely on manual operation to know whether to pass the timely: testing should be in the raw Production code before writing ten, the class main note a point, the class should be short, there are two ways to achieve this goal: 1. Single-duty: One class should not have too many responsibilities, too many will have to consider splitting into multiple classes 2. High cohesion: The class's entity variables should be as few as possible, and the methods in the class are used as much as possible to these variables Xi. System 1. System construction and use separate factory: Use the factory method to decide when to create the instance, but the construction details depend on the injection elsewhere: when a has a dependency on B, A is not responsible for the instantiation of B (this is the single principle of the class of responsibility) 2. The latter part of this chapter refers to the AOP,ASPECTJ, such as the SPRING,EJB, such as the framework for example, it is unclear, it is unclear what the author wants to express, temporarily did not understand. 12, fell into the chapter mentioned in the point not much 1. Run all the tests: for the convenience of testing, our production code is short enough, the coupling degree is 2. Refactoring: In the process of writing code in time to refactor, keep the code elegant 3. Non-repeatable: existing code to use , de-duplication 4. Strong expression: This should be a goal or result, do a good job in front of the work can naturally reach 13, concurrent programming 1. Why: It can decouple the "purpose" from "timing" and decouple 2. The principle of concurrent defense single responsibility: The main concern is that concurrency-related code should be separated Come out for this, three suggestions: 1). Restrict Data scope 2). Use a copy of the data: this is not threadlocsal ~ ~ 3). Threads should be as independent as possible 3. Learn alreadyClass Library: Concurrency Packages in Java and the like okay, the basic thing is these, the following chapters are some example code. 

"Reprint Please specify the source"

GitHub Address: https://github.com/MummyDing

Source: blog.csdn.net/mummyding


[Reading Notes]clean Code (8-end)

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.