Is there any reason to write short code in Java / C # / C ++?

Have you ever written complex code in Java, C # or C ++?

If so, why? Do you think there are situations where this should be acceptable, given the situations in which these languages ​​are used?

+5
source share
12 answers

The code should be as concise as possible and no more. :)

Putting aside comments, there are several factors that influence how short (or otherwise) it should be:

  • Lifespan

    • Often longer than you think :)
  • The probability of errors.

    • How likely is a dependency on many things, but the source encoder has a big role to play in this.
  • Reading computers (parsing).

    • , intellisense ..
    • raw, , diff tools.
    • , .
  • .

, , .

- . , , .

:

.

, . , , (, , ). - , (ab) - - , . . , .

.

, , , . , //, Foo, Foo , Foo- . .

, / , , , . , , "i", , , , .
. , . , , . / , , . , , , .

Lifespan

, , . ( , ), . , , , .

, , . , , , ( ). , .

, , , -, , , , , , , , . , , .

( , , lambdas, ). , . , .

, //, , (, if ), .

, , , . flibble x = new flibble(), var x = new flibble() ( , ). var flibble = SomeMethodWhoseReturnTypeIsNotClear(). , intellisense , , , .

( ) :

  • .
  • (++ x x ++ , )
  • , .
  • "" , . , ( ) , , , .
  • . if , , . ( / , )
+14

'terse'.

" ", .

"", .

+23

, "". , , . , , LINQ , "" .. , - .

, , . . :

Foo x = null;
if (condition)
{
    x = y;
}
else
{
    x = z;
}

, :

Foo x = condition ? y : z;

, "", "y" "z" , . , "y" "z", , if/else, , .

, , . , , .

+12

. , .

? 6 , . , .

+4

( ). IE:

var result = GetResultFromFoo(GetOtherResult()).DoSomeCalculation(CallAnotherMethod());

, . , ;

var result = GetOthereEsult();
var fooResult = GetResultFromFoo(result);
var anotherMethodResult = CallAnotherMethod();
var finalResult = fooResult.DoSomeCalculation(anotherMethodResult);

.

, , , , - (, JavaScript, ) , , . , , , , .

+3

, , .

+2

, , , ( ). , , , , , , .

" ", .

+2

@j_random_hacker ( )

, 6 , .

+1

, . "" , :

int af = yb; 
while(af<ex){af++;af*=4;}

, , , . , , . . - , , . , , , .

+1

, LONG.

, . , . , . , , , , .

. :)

+1

, "terse" "" :

, . ++ . , - .

( "-" ) , .

0

java: JVM. , . jar == () .

, , , , "" .

, , , .

0

All Articles