Beautiful code is like poetry!

xiaoxiao2021-03-06  72

There have been discussions on the online day programmer code style, in fact, I don't like it.

Let us see how the US programmer is doing.

The following is taken from "Code Reading Method and Practice" Section 2.9 P32-36.

The first code:

OP = & (! x? (! uPleft: (y == bottom? loweft: (x == last? (! y? Upright: (y == BOTTOM? Lowright: Right)) :( ! y? Upper: (y == BOTTOM? LOWER: NORMAL)))) [W -> Orientation];

Oh! I hope I have not been wrong. I haven't understood this code for ten minutes.

In general, it can be changed to the following.

Struct Options * Locations [3] [3] = {{UPLEFT, UPPER, UPRIGHT}; {Left, Normal, Right}, (Lowleft, Lower, Lowringt};

INT XLocation, YLOCATION;

IF (x == 0) XLocation = 0; Else IF (x == last) xlocation = 2; else xlocation = 1;

IF (y == 0) YLOCATION = 0; else if (y == bottom) YLOCATION = 2; else ylocation = 1;

OP = & (Location) [W-> Orientotion};

However, a code called Guy Steler has submitted the following code.

Op = & (! y? (x? uper: upright): y! = bottom? (x? left: x! = Last? Normal: Right): (x? lowleft: x! = Last? Lower: LowRight:) [W -> Orientation];

Who said that the readability and efficiency of the code cannot be taken into account.

转载请注明原文地址:https://www.9cbs.com/read-119718.html

New Post(0)