Which is easier to read:

Train

Lifer
Jun 22, 2000
13,572
66
91
www.bing.com
Another coder at work has been going through my app and changing this:

ProductItem productItem = new ProductItem(pd.RGB, pd.Name, index, pd.ProductGroup, "User Defined");

With this:
ProductItem productItem
= new ProductItem
(pd.RGB
, pd.Name
, index
, pd.ProductGroup
, "User Defined"
);

And its driving me nuts. Am I the only one who thinks breaking every method or constructor call down to one param per line is a waste?
 

presidentender

Golden Member
Jan 23, 2008
1,166
0
76
One param per line is a waste of screen real estate. Get a style guide and stick to it. If there is no style guide, then it's your code, and he should keep to your conventions when modifying it.
 

Drakkon

Diamond Member
Aug 14, 2001
8,401
1
0
ive used one param per line when setting up fairly lengthy calls (i.e. when it wraps to 1 or more lines) but not for ALL calls.
 

Cogman

Lifer
Sep 19, 2000
10,283
134
106
sometimes I do something like

Blah = new Longblahwithlotsofstuff(thing1 thing, thing2 thing
thing3 thing, thing4 thing);

Where thing3 is lined up with the parenthesis.
 

mundane

Diamond Member
Jun 7, 2002
5,603
8
81
Originally posted by: Drakkon
ive used one param per line when setting up fairly lengthy calls (i.e. when it wraps to 1 or more lines) but not for ALL calls.
 

drebo

Diamond Member
Feb 24, 2006
7,034
1
81
Option 1 is much easier to read.

I've used similar to Option 2, but only ever in very long SQL queries.

For general programming, Option 2 is a waste of time and screen space.

Maybe he works under the Peter Principle.
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
I only break method signatures to preserve width restrictions, then I simply wrap and indent by the normal amount.
 

jjones

Lifer
Oct 9, 2001
15,424
2
0
Originally posted by: drebo
Option 1 is much easier to read.

I've used similar to Option 2, but only ever in very long SQL queries.

For general programming, Option 2 is a waste of time and screen space.

Agreed.
 

tfinch2

Lifer
Feb 3, 2004
22,114
1
0
If I do something like option two it looks like:

ProductItem productItem = new ProductItem(pd.RGB,
pd.Name,
index,
pd.ProductGroup,
"User Defined");

Where the first char of each arg is aligned. This is for functions with 7 or more args. I don't waste my time with 5...
 

degibson

Golden Member
Mar 21, 2008
1,389
0
0
I like to maintain 80-character (or depending on the project style restraints, sometimes 60 or 70) width. I wrap parameters to maintain that width... I don't believe in using one style in all cases. It also varies by language.
However, my default is no wrapping.
 

techfuzz

Diamond Member
Feb 11, 2001
3,107
0
76
Originally posted by: degibson
I like to maintain 80-character (or depending on the project style restraints, sometimes 60 or 70) width. I wrap parameters to maintain that width... I don't believe in using one style in all cases. It also varies by language.
However, my default is no wrapping.

Get a wider monitor

techfuzz
 

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0
#2 ONLY IF you are going to self document each parameter
 

KB

Diamond Member
Nov 8, 1999
5,402
386
126
Get this guy something else to do. Maybe he can work on the database or the Reports.
 

clamum

Lifer
Feb 13, 2003
26,252
403
126
Option 2 looks weird. Not sure I've seen another coder do that. One line fo sho.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |