I posted in the beginner forums regarding limiting the number of methods we use in a single statement. Should we go with the "Law of Demeter" or should we go with the "one line, one thing" approach?
If it is in the style guide, please forgive me for not seeing it. If not, could it be introduced so we have clear guidance on how much is too far?
Also, what do you (the nitpickers) want us to limit our ternary statements to? I asked about this as well. It looks like some people love em, some only like em, some are reluctant, and some don't know what is going on. Should we limit it to 2 or 3, or just a single statement?
Again, I hope this isn't taken as duplicating a topic. I'd just like to know what the nitpickers want before I send in something they don't like that I could have avoided by knowing what is acceptable.
The very existence of flamethrowers proves that at some time, some where, some place, someone once said to themselves "I'd really like to set those people on fire over there, but I just can't get close enough".
Links are helpful when referring to a different thread. In this case, I believe one of the threads you are referring to is this thread, but I couldn't seem to find the other one.
I would have to agree with Scott that "it depends". In general, I think that one line per method is better, but this is not always the case.
We've had a few conversations about the ternary operator here in the Cattle Drive forum. You can click on the "Search" link in the top right corner of this page to find those conversations (search on "ternary"). The number of ternary operators is not "limited", but, depending on the code, may or may not be the most readable way to write the application. That's the advantage of having real people review your code rather than trying to follow a rule book that's 600 pages long because it's trying to cover every possible way the code might be written. There is not only one "correct" solution for each assignment.
JavaBeginnersFaq "Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Joined: Nov 26, 2006
Ok, sorry for not posting links. And regarding the ternary, I think a simple
is pretty straightforward, but we had started talking about stuff like
And I've also seen people do stuff like put the logical and/or operators in their ternary statements. Aha, found the link. Ternary Question [ January 02, 2007: Message edited by: Nathan Leniz ]