|
I feel your pain.
Every time I see single line if statements without braces I think about rage quitting myself
|
|
|
|
|
okay, that's fair.
but when i did try to use braces, i made a bug, which you caught. I lost my mojo.
Removed the braces and replaced them with a return and everything worked fine.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
string result = null;
if (something)
{
variable.GetString();
}
return result;
string result = null;
if (something) return variable.GetString();
return result;
string result = null;
if (something)
return variable.GetString();
return result;
string result = null;
if (something)
{
return variable.GetString();
}
return result;
string result = null;
if (something)
{
result = variable.GetString();
}
return result; As you see, you can either agree with me or be wrong
|
|
|
|
|
good luck trying that technique whilst writing a state machine.
sometimes you still need a goto.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
|
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
I would like to see you programming a PLC in LAD or a PIC in Assembly without using JMP (a.k.a. goto)
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
|
As many things in life... if used properly is not bad.
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Actual code from one of my projects (there are entire files like this)
public static int GetDistance(this string x,string y){if(string.IsNullOrEmpty(x))return string.IsNullOrEmpty(y)?0:y.Length;else if(string.IsNullOrEmpty(y))return x.Length;int n=x.Length,m=y.Length;int[,]d=new int[n+1,m+1];if(0==m)return n;for(int i=0;i<=n;d[i,0]=i++);for(int j=0;j<=m;d[0,j]=j++);for(int i=1;i<=n;++i)for(int j=1;j<=m;++j)d[i,j]=Math.Min(Math.Min(d[i-1,j]+1,d[i,j-1]+1),d[i-1,j-1]+((y[j-1]==x[i-1])?0:1));return d[n,m];}
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
Did you just minify C#?
I'd know this to be a joke if you were literally anybody except you, except you're you...
|
|
|
|
|
yes. yes i did.
would it have been better or worse if i told you i just write code that way?
It's part of my "let me substitute this source sharing system for Microsoft's lack of static linking in .NET"
if i had a reliable way to distribute these files as binary and link them into other .NET modules i wouldn't use this method, but ILMerge is dodgy last i checked, and last time i tried to make a tool using it it got flagged by my virus scanner.
These files aren't intended to be modified. They are generated from other files, which are merged into one big "code brick" with all source dependencies included so you can just drop it into your project - like a static linked library.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
honey the codewitch wrote: would it have been better or worse if i told you i just write code that way? Neither, you'd just write according to my expectations
|
|
|
|
|
When you get to be as old as I am, brackets and whitespace just aren't important anymore.
Now get offa my lawn!
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
honey the codewitch wrote: When you get to be as old as I am, brackets and whitespace just aren't important anymore.
You young'un. Must be a cyclical thing, 'cuz I need them now more than ever.
|
|
|
|
|
perhaps.
Honestly though, I used to be a stickler about coding style when i worked in shops.
And as I was usually lead I was the one who enforced them.
Maybe that's why I am so fast and loose these days. It's kind of liberating to be able to make stuff for (mainly) me and code it my way i guess.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
You should swap that code for Damerau-Levenshtein distance, which also handles transpositions.
I can send you the code if you'd like. I'll even minify it for you if it's to hard to read.
|
|
|
|
|
I'd be interested in the code. unminified. the whole point of the minification, other than making the file smaller, is so it isn't modified. I immediately know when i wind up in source i'm not supposed to touch.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
string result = something ? variable.GetString() : null;
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
How could I have missed that!
Not only have I missed it, it gets my approval as well
|
|
|
|
|
Sander Rossel wrote: How could I have missed that! Lack of or lack of ?
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
I don't drink either
Maybe a lack of tea or syrup?
Or maybe I'm just generally lacking?
|
|
|
|
|
> This might be why i don't work in software anymore
Correction - this is why I don't work with other so-called developers anymore.
Sadly the reality is that I do have to work with other developers, I just limit my contact.
|
|
|
|
|
Marc Clifton wrote: Sadly the reality is that I do have to work with other developers
That's most people's. Even telecommuting wasn't enough though. The last gig i worked for, the one developer they had basically wrote his own jquery and he was doing php where he should have been using SQL - and the boss expected to be able to bring other devs on and have them just be up to speed on this arcane mess he had developed.
And I respected him professionally as a developer. He is talented when it comes to front end stuff and with some coaching could do back end pretty easily. He picked up SQL once i showed him, and his pages from then on used it.
But my life would have been easier if i had been starting without him and his tools.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
Yeah, them PHP database servers are the worst
modified 20-Oct-19 21:02pm.
|
|
|
|