Psst! Did you know DevelopmentNow is a mobile web site design agency?

Contact us for help mobilizing your site, or to sign up for our beta Mobile Web SDK!
all groups > dotnet framework > july 2004 >

dotnet framework : Is this kind of practice accepted


Kyril Magnos
7/29/2004 9:34:47 AM
I agree... Plus, much easier to set breakpoints on the multiple lines of
code.

--
HTH

Kyril Magnos
"I'm not a developer anymore, I'm a software engineer now!" :-)

[quoted text, click to view]
| > i see your point, but from my C++ days we were taught to read from the
end
| > of the line inwards. a reasonably talented programmer should have not
| > problems with this construct since it is a basic tenet of programming.
|
| There's a difference between "be able to read after a while" and "the
| most readable form of the code".
|
| I would personally prefer the several line version.
|
| --
| Jon Skeet - <skeet@pobox.com>
| http://www.pobox.com/~skeet
| If replying to the group, please do not mail me too

mikeb
7/29/2004 10:12:44 AM
[quoted text, click to view]

At least one debugger developer disagrees with you:

http://blogs.msdn.com/greggm/archive/2004/06/07/150323.aspx

--
Alvin Bruney [MVP]
7/29/2004 10:51:33 AM
Consider this:

Data.Biz.User user = new
Data.Biz.User(Logic.Biz.User.connectionstring,Logic.Biz.User.Lib);
//returns a datatable
DataTable dt = user.UserInfoSearch(buffer.ToString());
DataSet ds = new DataSet();
ds.Tables.Add(dt);
return ds;

can be turned into this peice of poetry

System.Data.DataSet ds = new System.Data.DataSet();
ds.Tables.Add(new
Data.Biz.User(Logic.Biz.User.connectionstring,Logic.Biz.User.Lib).GetAgents());

return ds;

I find it very sexy that i can do everything in one line of code. Anybody
see readability problems with that? I'm thinking if you can't read this code
you shouldn't be working on the project anyway. Any recommended patterns and
practices against this approach?

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok

Alvin Bruney [MVP]
7/29/2004 11:17:31 AM
i see your point, but from my C++ days we were taught to read from the end
of the line inwards. a reasonably talented programmer should have not
problems with this construct since it is a basic tenet of programming.

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
[quoted text, click to view]

Alvin Bruney [MVP]
7/29/2004 11:40:16 AM
well the break point is really not an issue since you can step into the
function or choose to break on an exception. i still am a bit awestruck that
this code is not immediately readable, or is it just that we are accustomed
to one line of code does one thing...

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
[quoted text, click to view]

Marina
7/29/2004 11:57:33 AM
Bunching up 5 lines of code into 1 definitely makes it less readable. And
it's not that one can't read it - it's that it becomes more difficult for
someone unfamiliar with the code to figure out what's going on.

Perhaps you can find a compromise someplace in the middle. So not have 5
nested calls all in one line - but not have too many lines of code either.

[quoted text, click to view]
Data.Biz.User(Logic.Biz.User.connectionstring,Logic.Biz.User.Lib).GetAgents(
));
[quoted text, click to view]

Bert Hyman
7/29/2004 12:07:14 PM
vapor at steaming post office (Alvin Bruney [MVP]) wrote in
news:ugLp$PYdEHA.1356@TK2MSFTNGP09.phx.gbl:

[quoted text, click to view]

Put yourself in the shoes of the person who will come after you and
have to maintain that piece of "poetry".

Do you think he'll marvel at your cleverness and skill, or do you
suppose he might be thinking something else entirely?

--
Alvin Bruney [MVP]
7/29/2004 1:39:31 PM
very nice read.

i believe i need to adjust my faulty ways tehehehe

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
[quoted text, click to view]

Alvin Bruney [MVP]
7/29/2004 3:27:35 PM
he won't come, it's called job security. they'll contract me to come and
adjust the poetry.

point well taken though

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
[quoted text, click to view]

Jon Skeet [C# MVP]
7/29/2004 5:27:47 PM
[quoted text, click to view]

There's a difference between "be able to read after a while" and "the
most readable form of the code".

I would personally prefer the several line version.

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
Jon Skeet [C# MVP]
7/29/2004 6:11:52 PM
[quoted text, click to view]

It makes it harder to break into one particular bit of code flow at
exactly the right point though.

[quoted text, click to view]

The line is 98 characters long even before you take into account any
whitespace preceding it. While it's occasionally worth having long
lines if you can't easily split them up, in this case you've shown that
there's a perfectly simple way of splitting it up.

It's definitely not immediately readable - not as readable as the
multi-line version.

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
Andy Becker
7/30/2004 10:24:26 AM
[quoted text, click to view]

I've done a whole lot of this sort of thing in the past (and present) for
many of the same reasons. It's just plain cool how much power you can wrap
up into one line of code. Seeing those same lines of code, years later when
my mind is not buzzing from total immersion in the project, I often ask
myself "WTF was I thinking?". They make perfect sense when I am "in it",
and none when I am not. And rarely do they make sense to someone else on
the project with me, in much the same way as their one-line beauties don't
make sense to me. They are sort of like artistic creations open to
interpretation (in fact, requiring interpretation!). That's where the
breakdown occurs, and people give up, and toss out your code. And mine.

For a program/application/system to have a long and healthy life, it helps
immensely if the intent of a code fragment is as clear as possible, as soon
as you look at it. I might even consider this to be mandatory. Having to
think about a line of code is not something you want to do when you are
maintaining someone else's code. Frankly, it just pisses me off, and this
is even worse when it's my own damn code.

So, I have a question for you:

If breaking it up and/or spelling it out results in code which is easier for
others to understand, easier to debug, and runs the same as the single line
version, then why not do it?

Best Regards,

Andy

Jerry Pisk
7/30/2004 12:21:25 PM
Because if it was difficult to write it should be difficult to read ;)

Jerry

[quoted text, click to view]

Andy Becker
7/30/2004 3:50:59 PM
[quoted text, click to view]

This gave me an ear to ear grin when I read it, which was sorely needed
today (does it show?!). In the Compuserve days we used to call them BFGs.

Best Regards,

Andy

Alvin Bruney [MVP]
7/30/2004 10:49:32 PM
some of us are freshly out of school - what does BFG's mean

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
[quoted text, click to view]

james
7/31/2004 10:15:45 PM
Big F***ing Grin.
james

[quoted text, click to view]

AddThis Social Bookmark Button