Compact vs Verbose

32 views
Skip to first unread message

David Avendasora

unread,
Mar 28, 2012, 8:49:33 PM3/28/12
to WebObjects-Dev Mailing List List
Moved here to not distract from original thread's conversation.

On Mar 28, 2012, at 3:31 PM, Farrukh Ijaz wrote:

return contentDisposition != null && (contentDisposition.indexOf("inline"> -|| contentDisposition.indexOf("attachment"> -1);

Seriously, who can read that and make sense of it immediately?!

This is programmers shorthand. They master it with time. If you find these statements somewhere in the code, consider that piece of code been written by an experienced programmer which is less likely to have bugs. This is style is still not difficult than what you can find in a TopCoder algorithm which contains is full of boolean and bit manipulation operators.

I have to  _vehemently_  disagree. One way many people learn how to be good coders it by looking at other people's code and being able to see what it does. Not only that, but the assumption that it's less likely to have bugs because it is obtuse?! Are you serious?

You've the freedom agree or disagree but not _vehemently_. Everyone should respect other's opinion and so do I with respectfully.

Er… um… yeah. Sorry about that. This is something that I am very frustrated by whenever I dig into the Wonder code. It always just feels like the developer that wrote it is saying "Ha, ha, Dave! I'm better than you! I made something work that will take you hours to figure out how I did it! Why don't you just give up now and go back to being a business analyst."

But, that's my own issue. I  know developers aren't saying that. Well, most aren't. Okay, Chuck is, but nobody besides him. (It huts me, Chuck. My therapist told me to be honest with you.)

One must learn the language syntax. Why should I use such a verbosity in code when it's already easy to understand.

int max = (x > y) ? x : y;

is much better in readability than:

int max = 0;

if (x > y) {
max = x;
} else {
max = y;
}

See, that's the thing, I find the second form much easier to read and to be sure that I know exactly what is happening. Now in such a simple example the first's syntax isn't all that hard (even for me) to read either, but I do need to stop and basically translate it into the second in my head. That's just the way I am.

I'm not saying that all code should be in the second's form, I'm just saying that there should be a middle ground somewhere.

I'm not a human compiler. I wish I were. There is some amazing features in Wonder written by people who can think in code, but I just don't. After almost 8 years  using Wonder, I still have a hard very hard time understanding what many parts of Wonder do. 

I guess my issue isn't really about verbose vs compact, but clear vs cryptic. 

This is one of the most elitist things I've heard said on the WO-dev list.

If this is so bad practice

Let me be clear, I'm not saying it is always a bad practice. I just think it is disingenuous to say "Everyone should contribute to Wonder. Look at the code for examples of how to do things." and then say "Sorry you don't understand what we elite coders write, once you are better you'll work it out."

then why Project Coin introduces Strings in switches, developer can still do if-elseif-elseif-elseif...else coding. This is in fact elite coding style :) Following is excerpt for String.java

public boolean equalsIgnoreCase(String s)
    {
        return this != s ? s != null && s.count == count && regionMatches(true, 0, s, 0, count) : true;
    }

We really shouldn't go into coding convention domain. I respect everyone's style and we should try to learn the best practices. Trust me verbosity is good for examples but in practice, we should compact our code as much as we can.

Why? Please explain to me the benefits of being compact to the point that a new developer, or an old one like myself, will find it cryptic.

Refills of braces, tabs, spaces and carriage returns for the eclipse text editor are very inexpensive, and only a few baby platypuses are killed to make them these days, so I know it can't be concern about using too many. :-)

Dave


—————————————————————————————
WebObjects - so easy that even Dave Avendasora can do it!™
—————————————————————————————
David Avendasora
Senior Software Abuser
Kaiten, Inc.




Chuck Hill

unread,
Mar 28, 2012, 9:10:48 PM3/28/12
to David Avendasora, WebObjects-Dev Mailing List List

On 2012-03-28, at 5:49 PM, David Avendasora wrote:

> Moved here to not distract from original thread's conversation.
>
>>> On Mar 28, 2012, at 3:31 PM, Farrukh Ijaz wrote:
>>>
>>>>> return contentDisposition != null && (contentDisposition.indexOf("inline") > -1 || contentDisposition.indexOf("attachment") > -1);
>>>>>
>>>>> Seriously, who can read that and make sense of it immediately?!
>>>>
>>>> This is programmers shorthand. They master it with time. If you find these statements somewhere in the code, consider that piece of code been written by an experienced programmer which is less likely to have bugs.

I would not consider that at all. I'd consider it was written by a programmer who did not care who came after and had to read that. That it compact code, but that is not good code. The compiler does not care how compact your code is, complier optimizations of whatever you write tend to be pretty amazing. But people read code and code is read more often than it is written. So good code should be clear and easy to ready quickly. That return statement fails that criteria.


>>>> This is style is still not difficult than what you can find in a TopCoder algorithm which contains is full of boolean and bit manipulation operators.

TrickyCoder != TopCode IMHO


>>> I have to _vehemently_ disagree. One way many people learn how to be good coders it by looking at other people's code and being able to see what it does. Not only that, but the assumption that it's less likely to have bugs because it is obtuse?! Are you serious?
>>
>> You've the freedom agree or disagree but not _vehemently_. Everyone should respect other's opinion and so do I with respectfully.
>
> Er… um… yeah. Sorry about that. This is something that I am very frustrated by whenever I dig into the Wonder code. It always just feels like the developer that wrote it is saying "Ha, ha, Dave! I'm better than you! I made something work that will take you hours to figure out how I did it! Why don't you just give up now and go back to being a business analyst."

I agree that much of the code in Wonder is not something that I would hold up as a model for formatting, commenting, or clarity. Some of it is quite good in the sense of the complex problems it addresses.


> But, that's my own issue. I know developers aren't saying that. Well, most aren't. Okay, Chuck is, but nobody besides him. (It huts me, Chuck. My therapist told me to be honest with you.)

No worries, I paid him to say that to torment you.


>> One must learn the language syntax. Why should I use such a verbosity in code when it's already easy to understand.
>>
>> int max = (x > y) ? x : y;
>>
>> is much better in readability than:
>>
>> int max = 0;
>>
>> if (x > y) {
>> max = x;
>> } else {
>> max = y;
>> }
>
> See, that's the thing, I find the second form much easier to read and to be sure that I know exactly what is happening.

In this particular case, I'd prefer the former as it is small, short and requires less reading to understand the intent of the code. That said, the ternary operator should be used with caution when the line gets longer.

> Now in such a simple example the first's syntax isn't all that hard (even for me) to read either, but I do need to stop and basically translate it into the second in my head. That's just the way I am.

Broken? :-P


> I'm not saying that all code should be in the second's form, I'm just saying that there should be a middle ground somewhere.
>
> I'm not a human compiler. I wish I were. There is some amazing features in Wonder written by people who can think in code, but I just don't. After almost 8 years using Wonder, I still have a hard very hard time understanding what many parts of Wonder do.
>
> I guess my issue isn't really about verbose vs compact, but clear vs cryptic.

I think that is the essential distinction.


>>> This is one of the most elitist things I've heard said on the WO-dev list.
>>
>> If this is so bad practice
>
> Let me be clear, I'm not saying it is always a bad practice. I just think it is disingenuous to say "Everyone should contribute to Wonder. Look at the code for examples of how to do things." and then say "Sorry you don't understand what we elite coders write, once you are better you'll work it out."

I hope that no one said that meaning it was a model for formatting, commenting, or clarity.


>> then why Project Coin introduces Strings in switches, developer can still do if-elseif-elseif-elseif...else coding. This is in fact elite coding style :) Following is excerpt for String.java
>>
>> public boolean equalsIgnoreCase(String s)
>> {
>> return this != s ? s != null && s.count == count && regionMatches(true, 0, s, 0, count) : true;
>> }
>>
>> We really shouldn't go into coding convention domain. I respect everyone's style and we should try to learn the best practices. Trust me verbosity is good for examples but in practice, we should compact our code as much as we can.
>
> Why? Please explain to me the benefits of being compact to the point that a new developer, or an old one like myself, will find it cryptic.

I agree, clarity rules the day.


> Refills of braces, tabs, spaces and carriage returns for the eclipse text editor are very inexpensive, and only a few baby platypuses are killed to make them these days, so I know it can't be concern about using too many. :-)

LOL


Chuck

--
Chuck Hill Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/gvc/practical_webobjects


Ramsey Gurley

unread,
Mar 29, 2012, 12:55:36 PM3/29/12
to Chuck Hill, WebObjects-Dev Mailing List List

On Mar 28, 2012, at 6:10 PM, Chuck Hill wrote:

>>> One must learn the language syntax. Why should I use such a verbosity in code when it's already easy to understand.
>>>
>>> int max = (x > y) ? x : y;
>>>
>>> is much better in readability than:
>>>
>>> int max = 0;
>>>
>>> if (x > y) {
>>> max = x;
>>> } else {
>>> max = y;
>>> }
>>
>> See, that's the thing, I find the second form much easier to read and to be sure that I know exactly what is happening.
>
> In this particular case, I'd prefer the former as it is small, short and requires less reading to understand the intent of the code. That said, the ternary operator should be used with caution when the line gets longer.

Longer? Just nest them!

a?
b?
f():
c?
g():
h():
d?
i():
j();

Next time, I'll show you how to combine them with bitwise operations, inside of switches with labeled breaks! ;-) I say this half jokingly. I'm guilty of using nested elvis operators on occasion. Looks perfectly intelligible to me. I try to refrain as I know everyone else wants to cut my fingers off whenever they see them. :-D

Ramsey
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (Webobje...@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/webobjects-dev-garchive-31333%40googlegroups.com

This email sent to webobjects-dev...@googlegroups.com

Chuck Hill

unread,
Mar 29, 2012, 12:58:13 PM3/29/12
to Ramsey Gurley, WebObjects-Dev Mailing List List

On 2012-03-29, at 9:55 AM, Ramsey Gurley wrote:
>
> Longer? Just nest them!
>
> a?
> b?
> f():
> c?
> g():
> h():
> d?
> i():
> j();


Avendasora's lips are going to get sore trying to decipher that! :-P

Farrukh Ijaz

unread,
Mar 29, 2012, 4:02:00 PM3/29/12
to Chuck Hill, Ramsey Gurley, David Avendasora, WebObjects-Dev Mailing List List
Heard you guys, I'll make sure my submission gets compiled and run within the constraints set in community contribution :)

Farrukh

> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list (Webobje...@lists.apple.com)
> Help/Unsubscribe/Update your Subscription:

> https://lists.apple.com/mailman/options/webobjects-dev/farrukh.ijaz%40fuegodigitalmedia.com
>
> This email sent to farruk...@fuegodigitalmedia.com

David Avendasora

unread,
Mar 29, 2012, 9:50:22 PM3/29/12
to Chuck Hill, WebObjects-Dev Mailing List List

On Mar 30, 2012, at 12:58 AM, Chuck Hill wrote:

>>
>> Longer? Just nest them!
>>
>> a?
>> b?
>> f():
>> c?
>> g():
>> h():
>> d?
>> i():
>> j();
>
>
> Avendasora's lips are going to get sore trying to decipher that! :-P

Nah, I didn't even try, but the monkeys on the back fence screeched back.

On a positive note though, they didn't fling any poop this time, so it's a banner day in Borneo!

Dave


—————————————————————————————
WebObjects - so easy that even Dave Avendasora can do it!™
—————————————————————————————
David Avendasora
Senior Software Abuser
Kaiten, Inc.

_______________________________________________

David Avendasora

unread,
Mar 29, 2012, 9:56:20 PM3/29/12
to Farrukh Ijaz, WebObjects-Dev Mailing List List

On Mar 30, 2012, at 4:02 AM, Farrukh Ijaz wrote:

> Heard you guys, I'll make sure my submission gets compiled and run within the constraints set in community contribution :)

Thanks, Farrukh. I really do apologize for being a bit of an ass earlier. :-)

Dave


————————————————————————————————
WebObjects - so easy that even that ass Dave Avendasora can do it!™
————————————————————————————————
David Avendasora
Senior Software Ass
Kaiten, Inc.

Reply all
Reply to author
Forward
0 new messages