"Pragmatic Programmer" the fourth book review

22 Death does not lie 
early collapse. Do not destroy the (trash), write incorrect data

23 assertion programming
if it can not happen, with the assertion sure it does not happen.

Do not have side effects assertion

24 When to use exceptions 
understanding of the requirements, the anomaly is reserved for unforeseen events

25 How to trim the resources
to stay the course: the allocation of resources, use it, release it

Nested distribution (not just a one-time resources)

·  To reverse the order and resource allocation deallocate resources, if a resource contains a reference to another resource, it will not result in resources being abandoned
·  assign the same set of resources in different places of the code, they are always assigned the same order this will reduce the possibility of deadlock.

26 decoupling with Demeter rules
to follow too although Demeter law can reduce the dependencies between modules, but will bring a lot delegate methods appear not only increase independent code, but also affect the execution speed of the code, so according to different needs scenes compromise, violate norms to win improved performance.

27 yuan Programming 
Metadata

·  Metadata (metadata): description of the application configuration options: Tune parameters, user preferences
is data on the metadata in the strict sense, is to describe the data to any application on a broad sense. (In addition to preferences, there are resources, etc.)
·  metadata is accessed and used at runtime rather than at compile time.
In the abstract code procedure the details on element

Coupling time 28

A start time of the program is to carry out the order. But once required complicated by, there have been trouble.

Use UML activity diagram, the analysis workflow.

29 It just view
us based on the concept of divide and rule the program is divided into several modules, but how does a management organization relies problem between the different modules (class).

We proceed from the concept of the event (event), to send the new changes to the object of interest. ,

If from Baidu Encyclopedia through a routine (function interface is a collection of routines or services provided outside of a system, such as the operating system API, and so is the service routine). Then the routine need to know the interaction between the various objects have a close understanding. Obviously, we can use a subscription model / release allows a subscriber to accept it only event of interest.

CORBA Event Service object is allowed to participate in the event by sending and receiving a notification channel (public bus).

MVC (Model - View = Controller) mode effectively make the model separated from the GUI, and separated from control management view.

Model: icon represents the abstract data model objects. Model to any view or controller have no direct knowledge of
view: to explain how the model. It changes a given business model logical event from the controller and
the controller: controls the view. Pathway model to provide new data. It also announced an event to view the model.

There are still coupled, love to see the blackboard next section

30 blackboard 
The detective handling the case example of the clues pointed out that the information posted on the blackboard blackboard method of characteristics:
- no additional objects need to know about the existence of other objects, they view information from the blackboard and add their findings.
- Use the blackboard objects or modules have one thing in common around the same goal or function, as in the example is to solve the case.

For complex workflow, we can blackboard to coordinate.

·  Order data arrives is irrelevant
·  trigger the appropriate rules will receive particular fact.

31 programming by coincidence 

Why can not rely on coincidence programming (see starting to work):

·  It might boundary conditions that knowledge is not really rely on the work of chance, in another condition can not work
not entered in the document may behave with the next release of library changes
·  extra call to make the code slower
·  excess calls may introduce bug
deliberate programming

·  Always aware of what they are doing
·  Do not blindly programmed to build applications do not fully understand and use your unfamiliar technology
·  act in accordance with the plan, methodically! ! !
·  Rely on reliable things, such as solid library.
·  Establish document your assumptions.
·  Work for you prioritize, time spent on important and most difficult aspect.
·  Not slaves of history, to join the existing code does not apply, and replace as soon as possible.

32 Rate Algorithm 
For resource algorithm. Processing, memory estimate.

O () notation of the things we measure the value of setting an upper limit.

Some common O () notation
O (. 1)
O (LG (n-))
O (n-)
O (NLG (n-))
O (n-^ 2)
O (n-^. 3)
O (C ^ n-)
While we You do not have to write sorting algorithm design, but the order of favorable estimation algorithm we have some understanding of the operation of their own written procedures

33 Reconstruction
Reconstruction rewritable = + re + architecture Redo

When reconstructed:

·  Repeat (DRY)
non-orthogonal design
·  outdated knowledge
·  performance
early reconstruction, often reconstructed

How Reconstruction:

·  Do not increased in refactorings
·  Make sure you have a good test before the start of the reconstruction, often run these tests as much as possible, so early detection of problems.
·  Take short steps and test after each step to avoid prolonged debugging.

34 easy to test code

Unit testing: testing for the contract.

Designed for testing:

When even a single routine design module design which both code for the contract is also designed to test the contract.

35 evil wizards
do not use the wizard the code you do not understand

36 requirements of the pit
do not collect demand, mining them.

Should clear declarative sentences express their needs. Sometimes statements will demand carries commercial policy, commercial policy is constantly changing. So we need to do to distinguish between needs and business policies.

In discussing the user interface, the difference between demand, policy and implementation may become blurred.

Key
to find out the reasons why users do specific things, rather than what they are currently doing this thing the way.

Establish requirements document: The use case (use cases) to describe the specific use of the system.

Example template with the corresponding

Abstract live longer than details

Maintaining the Glossary project, conducive to communication.

37 puzzles to unlock impossible to unravel
when a stray encounters difficult to solve, the solution may not be within the scope of your current thinking. So it is necessary to re-determine the method of restraint, some constraints are absolute constraint, the constraint is some preconceptions.

Do not think outside the box - to find the box: We need to identify the problem of freedom is constrained
to think about Trojan

There must be an easier way

·  There is an easier way?
·  You are still trying to solve the problem is to divert attention outside of technical problem
this is a question why things
·  What makes it difficult to solve
it must be done in such a way it?
·  It really must be done right?

38 you're ready 
to listen recurring doubts - you're ready to start again

Good judgment or delay
- the delay: "waste of time" boredom appears to proof of concept
- good judgment, along with the progress of the prototype, we are willing to get a revelation at some point, suddenly a meaning to the premise is wrong.

39 specification trap 
for some things, "doing" rather than "Description"

40 circles and arrows
not in the form of a slave method

Tools are just tools, as I used to.

Guess you like

Origin www.cnblogs.com/xiangyu721/p/11963888.html