Reverse mode, long duration... List

Source: Internet
Author: User

As for antipattern, you may know that its only function is to avoid reverse pattern during actual development. The main introduction in Baidu encyclopedia is as follows:

Recognized anti-pattern in software development

Anti-pattern in project management

Smoke and mirrors: demonstrate to people what functions are not yet implemented. Yingwenyuan's magic means: let out smoke and use a mirror to cover an object, making it seem to have disappeared.

Software expansion: As the version upgrade, the software will consume more and more system resources.

Poor management: Manage a project without a sufficient understanding of the subject.

Anti-pattern in general design

Anti-Abstract: the required functions are not exposed to users. As a result, users need to re-implement some functions at a higher level.

Generally, a design model can expose different interfaces to users. Different interfaces represent different aspects of the model. However, mixing different functions is a common bad design.

Mess ball: the system has no recognizable structure, just like a mess.

Wan Yingling: an object knows too many things, or wants to do too many things, as if they are omnipotent.

No complex design is necessary.

Race Hazard: the consequences of unforeseen events in different order.

Anti-pattern in Object-Oriented Design

Omnipotent class: in the design of a class, too many functions are gathered.

Noisy: an object is created to send messages to other objects.

Slide problem: the structure (such as inheritance) is extremely fragmented and lengthy, and it must be learned with great effort.

Programming anti-Pattern

Hard code: it is also called hard code. Deploy the operating environment of the system for a specific purpose.

DisorderCode: Almost incomprehensible structure, especially because of abuse of code structure.

Super boolean logic: Unnecessary comparison or overly Abstract Boolean computing.

Useless Exception Handling: A condition is inserted to prevent runtime exceptions, but throw is true when the condition is false (for example, if a not null then process () else throw null-exception endif ).

Method anti-Pattern

Copy-n-paste programming: You 'd rather copy (and modify) existing code than create a common solution.

Anti-refactoring: the process of "Removing functionality and replacing it with annotations.

Golden Hammer: assuming that the solution to personal preferences is universal in the world.

False alarms: Assume that a known bug does not appear.

Immature optimization: optimization based on insufficient information.

Re-create a wheel: refuse to adopt the existing solution and rewrite one.

Building a square wheel: When an excellent solution exists, it creates a poor solution.

Anti-pattern in structure management

Dependency hell: problems caused by mismatched product versions, especially in Unix/Linux.

DLL hell: problems caused by the version, existence, and repetition of the dynamic Connection Library, especially in Microsoft Windows.

Jar hell: problems caused by jar files of different versions or addresses, often resulting in lack of modules.

Extension conflict: Different Extensions of Mac OS attempt to patch the same system part.

Some organizational anti-patterns

Analysis of paralysis: The project analysis process is no longer proportional, but you can leave it alone.

Cash Tree Project: a profitable product that keeps New Products intact.

Permanent Revolution: we always need to transplant existing systems to a new environment without any cost.

Team-based management. No space for tolerating objections.

Scope creep: Allow project scope to grow without proper control

 

Wikipedia (Chinese) has a wide range of anti-pattern introductions, with an endless stream of highlights. If you are interested, you can click the link to observe and observe. The opposite pattern of object-oriented design is called"Another layer of TMD"I laughed at it directly (but I think I didn't seem to be doing such a thing too much), and thatGod objectIt seems familiar. The number of people who compiled these wikis is estimated to be less affected by the anti-pattern.

 

Reference: http://baike.baidu.com/view/2825154.htm

Http://zh.wikipedia.org/wiki/%E5%8F%8D%E6%A8%A1%E5%BC%8F

 

Appendix: rounding and banker rounding

The rounding rule should be very familiar to everyone. Its rule is relatively simple. When the number of rounding digits is smaller than 5, the number is directly rounded off. When the number of rounding digits is greater than or equal to 5, move forward when this digit is removed. Keep a note to keep you informed:"Four, five".

 

Bankers have complicated rounding rules. The following is an excerpt from Baidu Encyclopedia:

The so-called bankers rounding method is essentially a four-house six-in-five pair (also known as four-house six-in-five-stay pair) method. The rule is: when the value of the deviation is less than 5, the deviation is directly performed. When the value of the deviation is greater than or equal to 6, the deviation is performed first while the deviation is performed; when the value of the deprecated digit is equal to 5, if the value of the forward digit is odd, the value is rounded up to the forward digit. If the value of the forward digit is even, the value is directly rounded up.

Simply put, it is:Four Homes, six homes, five homes, five homes, non-zero homes, five homes, zero homes, parity, five homes, odd homes

Italic text above Source: http://baike.baidu.com/view/3058685.htm

 

1. Rounding in C #

A common overload method of math. Round, which we are familiar with during development, implements the banner Rounding Method by default. The verification code is as follows:

Math. RoundConsole. writeline (math. Round (3.144, 2 ));// 3.14. sisheConsole. writeline (math. Round (3.1451, 2 ));// After the fifth day of 3.15, a non-zero entry will occur.Console. writeline (math. Round (3.145, 2 ));// 3.14. After the 5th day, check for parity. If the 5th day is the same as the 5th day, discard it.Console. writeline (math. Round (3.135, 2 ));// After the fifth day of the 1949th, check the parity. The fifth day is an odd one.Console. writeline (math. Round (3.146, 2 ));// 3.15. six entries

 

The negative number is processed as follows:

Math. RoundConsole. writeline (math. Round (-3.144, 2 ));//-3.14. sisheConsole. writeline (math. Round (-3.1451, 2 ));//-After 3.15, a non-zero entry is obtained.Console. writeline (math. Round (-3.145, 2 ));//-3.14. After the fifth day, the system will show zero parity, and the fifth day will be taken away as an even.Console. writeline (math. Round (-3.135, 2 ));//-After the fifth day of the 1949th, the values are equal to or equal to the first day of the fifth day.Console. writeline (math. Round (-3.146, 2 ));//-3.15. 6

 

How can we turn to what we are familiar?

Math. Round has a three-number reset method, where the third parameter mode correspondsMidpointroundingEnumeration, which is as follows:

Midpointrounding// Summary:// Specify how the mathematical rounding method processes the median between two numbers.[Comvisible (True)]Public EnumMidpointrounding {// Summary:// When a number is the median of the other two numbers, it is rounded to the nearest even number.Toeven = 0,//// Summary:// When a number is the median of the other two numbers, it is rounded to a value with a smaller absolute value.Awayfromzero = 1 ,}

 

The following code shows the expected Rounding:

Math. RoundConsole. writeline (math. Round (3.144, 2, midpointrounding. awayfromzero ));// 3.14. sisheConsole. writeline (math. Round (3.1451, 2, midpointrounding. awayfromzero ));// 3.15 roundedConsole. writeline (math. Round (3.145, 2, midpointrounding. awayfromzero ));// 3.15. RoundingConsole. writeline (math. Round (3.135, 2, midpointrounding. awayfromzero ));// 3.14 roundedConsole. writeline (math. Round (3.146, 2, midpointrounding. awayfromzero ));// 3.15. six entries

 

PS: In the math class, there are two functions, floor and ceiling, which are often used to process decimal integers. We usually remember the meanings of floor and ceiling to understand the functions of these two functions.

 

2. Rounding in Python

In python2.6 and earlier versions, round performs rounding by default. This is strange:

 
Round>>> Round (3.14) 3.0 >>> round (3.14, 2) 3.1400000000000001 >>> round (3.145, 2) 3.1499999999999999 >>> round (-3.14) -3.0 >>> round (-3.145, 2)-3.1499999999999999 >>>

 

In addition, the above statement may vary with versions earlier than python2.6. Here we can be certain that the Rounding Rule of the Round Function of python2.6 is neither a banker's rounding nor a common Rounding Rule. SomeArticleIt is said that the rounding of python can be processed by string formatting. Although the result is returned, it does not fundamentally solve the problem. It is a bit tricky.

Fortunately, python2.7 and later versions have fixed this issue and you can directly use the round function.

 

3. Rounding in Javascript

Similarly, we can use math to process rounding in JavaScript. the round function is defined as "round a number to the nearest integer", and there is no second round precision parameter value:

Math. Round (2.5 );// 3Math. Round (-2.50 );//-2Math. Round (-2.51 );//-3

It seems that this function is powerless to round the number of digits to a specified number. We can write a processing function by ourselves, which is similar to the method in C:

Powerround/** Function: rounds powerround (Num, decimals): * parameter description: * 1. Number of input digits to be rounded down by num, and * 2. Number of decimals to be retained by decimals. */FunctionPowerround (Num, decimals ){VaRResult =Math. Round (Math. Abs (Num )*Math. Pow (10, decimals ))/Math. Pow (10, decimals );If(Num <0 ){Return-Result ;}ReturnResult ;}

 

This function can be rounded to positive and negative numbers:

PowerroundoutputPowerround (3.144, 2 );// 3.14Powerround (3.1451, 2 );// 3.15Powerround (3.145, 2 );// 3.15Powerround (3.135, 2 );// 3.14Powerround (3.146, 2 );// 3.15Powerround (-3.144, 2 );//-3.14Powerround (-3.1451, 2 );//-3.15Powerround (-3.145, 2 );//-3.15Powerround (-3.135, 2 );//-3.14Powerround (-3.146, 2 );//-3.15

 

Summary: some of our application systems often have to deal with orders, financial data, and other processing systems. In the actual development process, no matter whether the background business logic or front-end UI display, there will always be some data that is not ideal for processing, and there will always be a trap-filled convert in your maintenance projects. will the forced conversion of toxxx make you feel bad? It may only be possible to understand the importance of processing the digits after the decimal point during reconciliation.

 

Appendix: Murphy's Law

There are a lot of familiar sentences in the computer and technology categories of Murphy's Law. It seems that I have seen them a long time ago and they are quite interesting and interesting. For example, the following two rules for computer software development are summarized:

Program Complexity grows until it exceeds the capability of the programmer who must maintain it.

ProgramThe complexity will continue to increase until the programmer in charge of maintenance is unable to continue.

Note: The translation here seems to be a little exaggerated. The actual situation is not exaggerated at all. Do you want to maintain thousands of lines of scripts?

 

Adding manpower to a late software project makes it later.

Adding manpower to a software project that cannot keep up with the schedule can only make it lag behind the schedule.

 

The rules in technology are also quite classic, such:

If it works in theory, it won't work in practice. If it works in practice it won't work in theory.

It is feasible in theory, not in practice; it is feasible in practice, not in theory.

 

I also saw a sentence, which seems to me similar to the above sentence:

In theory there is no difference between theory and practice, but in practice there is.

Theoretically, there is no difference between theory and practice. In practice, the two are completely different.

 

Refer:

Http://www.murphys-laws.com/murphy/murphy-computer.html

Http://www.murphys-laws.com/murphy/murphy-technology.html

Http://www.murphys-laws.com/

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.