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
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [email protected]
