Calgarypuck Forums - The Unofficial Calgary Flames Fan Community
Old 03-24-2010, 05:20 PM   #21
Kerplunk
Powerplay Quarterback
 
Kerplunk's Avatar
 
Join Date: Mar 2006
Location: Trapped in my own code!!
Exp:
Default

If it's a simple assignment, I'll occasionally use the ternary operator, such as when I get a string from the database which should be a boolean value...depends on the kind of day I'm having.

Now function pointers embedded in ternary operators written in macros...those are a pain to read.
Kerplunk is offline   Reply With Quote
Old 03-24-2010, 05:41 PM   #22
photon
The new goggles also do nothing.
 
photon's Avatar
 
Join Date: Oct 2001
Location: Calgary
Exp:
Default

In related news for Java developers, I'm working in Java again lately and I found out there's a community edition of IntelliJ, the expensive Java IDE.

I usually use Eclipse but giving IntelliJ a try and am liking it quite a bit for the most part.. some real annoyances on how it handles tabs and spaces and where I click (i.e. in Eclipse I click on the white space on a line and it places the cursor at the end of the line, in IntelliJ it puts it where I actually click, ANNOYING!).
__________________
Uncertainty is an uncomfortable position.
But certainty is an absurd one.
photon is offline   Reply With Quote
Old 03-24-2010, 06:10 PM   #23
llama64
First Line Centre
 
llama64's Avatar
 
Join Date: Nov 2006
Location: /dev/null
Exp:
Default

Personally I can't stand the conditional operator. It's wholly unreadable to me - and the way I approach coding is that if the code isn't readable, it's useless code.

I'd rather read some code that uses a verbose if/else statement then tries to be cute with an operator. Maybe my brain just can't process it, but when ever I encounter one, I have to break it out on paper just to figure out what the hell is going on.
llama64 is offline   Reply With Quote
Old 03-24-2010, 06:48 PM   #24
FanIn80
GOAT!
 
FanIn80's Avatar
 
Join Date: Jun 2006
Exp:
Default

I remember handing in an assignment in my VB class that I was pretty happy with. It was full of really neat ways to save lines of code and reduce typing, etc.

I got 100% because it worked and there were no faults in my syntax, etc... but he had a note on it about wanting to talk to me about "readability." His point was that it's one thing to be efficient, but it's quite another thing to be unreadable. The amount of time I was saving by typing less statements was nothing compared to the amount of time it was going to take other people to figure out wtf I was doing...

I probably learned more from that single 10 minute discussion after class, than I did in most of the in-class material we worked on (it was an "Intro to VB" class).


Edit: Here's the code from the assignment. He wasn't really saying that my code was specifically hard to read, just wanted to talk to me about readability since he could see I was going in a certain direction...

Code:
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        With cboMaker.Items
            .Add("Honda")
            .Add("Toyota")
            .Add("Subaru")
            .Add("KIA")
            .Add("Hyundai")
        End With

    End Sub

    Private Sub btnApply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnApply.Click

        lstLog.Items.Clear()

        lstLog.Items.Add("Car is " & cboMaker.Text)
        If radIntBlue.Checked Then lstLog.Items.Add("Interior color is Blue")
        If radIntBlack.Checked Then lstLog.Items.Add("Interior color is Black")
        If radExtEmerald.Checked Then lstLog.Items.Add("Exterior color is Emerald")
        If radExtNavy.Checked Then lstLog.Items.Add("Exterior color is Navy")
        lstLog.Items.Add("A/C is " & IIf(chkAC.Checked = False, "NOT ", "") & "desired")
        lstLog.Items.Add("Sunroof is " & IIf(chkSun.Checked = False, "NOT ", "") & "desired")
        lstLog.Items.Add("MAG wheels are " & IIf(chkMags.Checked = False, "NOT ", "") & "desired")

    End Sub

End Class
I like what was said earlier about how not wanting to read new ways of doing things just kind of perpetuates the whole thing, though. That was a very good point.

Last edited by FanIn80; 03-24-2010 at 07:04 PM.
FanIn80 is offline   Reply With Quote
Old 03-24-2010, 07:39 PM   #25
Mad Mel
First Line Centre
 
Mad Mel's Avatar
 
Join Date: Mar 2009
Location: Brisbane, Australia
Exp:
Default

^ I dunno, generally your code is pretty readable. I'd add some blank lines to break up the contents of the btnApply_Click procedure into some logical blocks and although the code is pretty self-explanatory, comment before each block. A lot of people hate the inline If...Then statements, but I love 'em.

Haha, so easy to critique someone else's code. Mine's perfect, of course. There's some stuff I'd do differently than how you did (such as data-driven or settings-driven control contents), but hey, it's all subjective.

The With block is nice. I don't use them enough, they're great for readability.
Mad Mel is offline   Reply With Quote
Old 03-24-2010, 07:41 PM   #26
photon
The new goggles also do nothing.
 
photon's Avatar
 
Join Date: Oct 2001
Location: Calgary
Exp:
Default

I don't like inline if then statements because each then will be at a different place so I have to scan each line fully even if I only care about what's in the then and want to ignore the if part.

The nice part about modern IDEs is if you don't like a code's format, just change the format settings and tell it to reformat the code for you!
__________________
Uncertainty is an uncomfortable position.
But certainty is an absurd one.
photon is offline   Reply With Quote
Old 03-24-2010, 07:47 PM   #27
wooohooo
#1 Goaltender
 
wooohooo's Avatar
 
Join Date: Apr 2006
Exp:
Default

Holy hell. I am happy I did not go into computing science.
wooohooo is offline   Reply With Quote
Old 03-24-2010, 07:50 PM   #28
Mad Mel
First Line Centre
 
Mad Mel's Avatar
 
Join Date: Mar 2009
Location: Brisbane, Australia
Exp:
Default

Quote:
Originally Posted by photon View Post
I don't like inline if then statements because each then will be at a different place so I have to scan each line fully even if I only care about what's in the then and want to ignore the if part.
You know, after I read that, I just realized that it annoys me too. And here I was perfectly happy before. Screw you!
Mad Mel is offline   Reply With Quote
Old 03-24-2010, 07:51 PM   #29
FanIn80
GOAT!
 
FanIn80's Avatar
 
Join Date: Jun 2006
Exp:
Default

Haha nice.
FanIn80 is offline   Reply With Quote
Old 03-24-2010, 07:55 PM   #30
photon
The new goggles also do nothing.
 
photon's Avatar
 
Join Date: Oct 2001
Location: Calgary
Exp:
Default

Quote:
Originally Posted by Mad Mel View Post
You know, after I read that, I just realized that it annoys me too. And here I was perfectly happy before. Screw you!
Your brain thanks me.
__________________
Uncertainty is an uncomfortable position.
But certainty is an absurd one.
photon is offline   Reply With Quote
Old 03-24-2010, 10:04 PM   #31
Shazam
Franchise Player
 
Shazam's Avatar
 
Join Date: Aug 2005
Location: Memento Mori
Exp:
Default

Code:
lstLog.Items.Add("A/C is " & IIf(chkAC.Checked = False, "NOT ", "") & "desired")
lstLog.Items.Add("Sunroof is " & IIf(chkSun.Checked = False, "NOT ", "") & "desired")
lstLog.Items.Add("MAG wheels are " & IIf(chkMags.Checked = False, "NOT ", "") & "desired")
I'd burn you alive if you ever did this in code that you got paid for.
__________________
If you don't pass this sig to ten of your friends, you will become an Oilers fan.
Shazam is offline   Reply With Quote
Old 03-25-2010, 09:18 AM   #32
kermitology
It's not easy being green!
 
kermitology's Avatar
 
Join Date: Oct 2001
Location: In the tubes to Vancouver Island
Exp:
Default

Code:
NSRange http = [[NSString stringWithUTF8String:url] rangeOfString:@"http://"];
if ( local_kml_file = ( NSNotFound == http.location ) ? true : false )
{
	...
}
This is infuriating me this morning..

How is that simpler than this:
Code:
if( NSNotFound == http.location )
{
       kml_local_file = TRUE;
}
__________________
Who is in charge of this product and why haven't they been fired yet?

Last edited by kermitology; 03-25-2010 at 09:29 AM.
kermitology is offline   Reply With Quote
Old 03-25-2010, 12:26 PM   #33
BlackEleven
Redundant Minister of Redundancy
 
BlackEleven's Avatar
 
Join Date: Apr 2004
Location: Montreal
Exp:
Default

Both seem like overkill to me. Putting true and false after the ternary operator is completely redundant.

local_kml_file = (NSNotFound == http.location);

edit: I'd also like to add I hate objective C syntax. That is all.

Last edited by BlackEleven; 03-25-2010 at 12:30 PM.
BlackEleven is offline   Reply With Quote
Old 03-25-2010, 12:39 PM   #34
kermitology
It's not easy being green!
 
kermitology's Avatar
 
Join Date: Oct 2001
Location: In the tubes to Vancouver Island
Exp:
Default

Quote:
Originally Posted by BlackEleven View Post
Both seem like overkill to me. Putting true and false after the ternary operator is completely redundant.

local_kml_file = (NSNotFound == http.location);

edit: I'd also like to add I hate objective C syntax. That is all.
Well, there are other parts of code that I snipped out.
__________________
Who is in charge of this product and why haven't they been fired yet?
kermitology is offline   Reply With Quote
Old 03-25-2010, 01:06 PM   #35
amorak
Lifetime Suspension
 
Join Date: Apr 2008
Location: 51.04177 -114.19704
Exp:
Default

if (ate)

then (the bowl)
amorak is offline   Reply With Quote
Old 03-25-2010, 08:19 PM   #36
Rathji
Franchise Player
 
Rathji's Avatar
 
Join Date: Nov 2006
Location: Supporting Urban Sprawl
Exp:
Default

This thread made me think of this comic:

__________________
"Wake up, Luigi! The only time plumbers sleep on the job is when we're working by the hour."
Rathji is offline   Reply With Quote
The Following User Says Thank You to Rathji For This Useful Post:
Old 03-25-2010, 08:35 PM   #37
FanIn80
GOAT!
 
FanIn80's Avatar
 
Join Date: Jun 2006
Exp:
Default

Quote:
Originally Posted by Shazam View Post
Code:
lstLog.Items.Add("A/C is " & IIf(chkAC.Checked = False, "NOT ", "") & "desired")
lstLog.Items.Add("Sunroof is " & IIf(chkSun.Checked = False, "NOT ", "") & "desired")
lstLog.Items.Add("MAG wheels are " & IIf(chkMags.Checked = False, "NOT ", "") & "desired")
I'd burn you alive if you ever did this in code that you got paid for.
You sound like one of those guys that would be a real blast to work with. Do you actually keep cauldrons of boiling oil handy for when you deal with your co-workers, or do you usually have to send out for them and then throw the guy in it at a later date?

You saw the part of my post that mentioned it was an assignment in an "intro to VB" class, right?


Last edited by FanIn80; 03-25-2010 at 08:39 PM.
FanIn80 is offline   Reply With Quote
Old 03-25-2010, 08:46 PM   #38
gottabekd
Powerplay Quarterback
 
Join Date: Mar 2006
Exp:
Default

Quote:
Originally Posted by photon View Post
Oh wait, or do you mean the specific ( a > b ? a : b ) thing?
Nope, never really learned about it when learning various programming languages, so don't make use of it now.

Every time I come across that in code, it slows me down for a beat or two.
gottabekd is offline   Reply With Quote
Old 03-25-2010, 08:48 PM   #39
Rathji
Franchise Player
 
Rathji's Avatar
 
Join Date: Nov 2006
Location: Supporting Urban Sprawl
Exp:
Default

Quote:
Originally Posted by gottabekd View Post
Nope, never really learned about it when learning various programming languages, so don't make use of it now.

Every time I come across that in code, it slows me down for a beat or two.
This is exactly my thoughts on the matter.
__________________
"Wake up, Luigi! The only time plumbers sleep on the job is when we're working by the hour."
Rathji is offline   Reply With Quote
Old 03-26-2010, 01:06 PM   #40
Kerplunk
Powerplay Quarterback
 
Kerplunk's Avatar
 
Join Date: Mar 2006
Location: Trapped in my own code!!
Exp:
Default

Quote:
Originally Posted by FanIn80 View Post
You sound like one of those guys that would be a real blast to work with. Do you actually keep cauldrons of boiling oil handy for when you deal with your co-workers, or do you usually have to send out for them and then throw the guy in it at a later date?
We keep various sticks around the office, from golf club shafts to table legs, just in case. The testing manager swears that is the only way to get through to developers...in some cases, I have to agree.
Kerplunk is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 06:55 AM.

Calgary Flames
2024-25




Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright Calgarypuck 2021 | See Our Privacy Policy