Which is easier to read:

Page 3 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.

trexpesto

Golden Member
Jun 3, 2004
1,237
0
0
Originally posted by: net

int x
= 5;

val
=
5
+
6
%
2

i guess in crazy land this might be good way to program?

Har! I lolled! I do vary as well, depending. For a constructor, no, it should not be necessary. If doing the indented list style, me likes to have it include up to the ( on the first line, just reads better. You know it's a method for one thing. Also, commas come at the end of the line, obviously. Rarely used, more often with extra-long variable names than these.

ProductItem productItem = ProductItemFactory.createProductItem(
        pd.RGB,
        pd.Name,
        index, // It does allow compact arg-specific comments!
        pd.ProductGroup, // using ProductGroup of the sirene
        "User Defined" // requires new password at first login
);
 

SunnyD

Belgian Waffler
Jan 2, 2001
32,675
146
106
www.neftastic.com
I guess I need to come clean - I do occasionally do this... however the only time I break parameters on a function call is when the parameter list is huge and parameters for the function are grouped by type or functionality. For example, if a function takes 3 pointers, a string, 2 integers and a boolean... I'd do the following:

Foo(&var1, &var2, &var3,
......"Some big long const string goes here",
......int1, int2, FALSE);

But usually only if the variable names are long enough to make it too cumbersome. Some Win32 calls have related variables, such as a pointer followed by a data length parameter for that pointer, which I will usually try to group together in similar fashion, but I will put as many groups on a single line as I can.
 

Journer

Banned
Jun 30, 2005
4,355
0
0
i usually keep things on one line until word wrap and tab over:

thisthing - thatthingthatislongandstupid(this,that,theother,somemore,
evenmore,moreyet,etc);