|
Hey, at least with open source you can find that stuff much easier. If a person knows everyone in the world can see the source code they will try to write the best code they can. When the code is hidden things get much worse.
One time after much wrangling I was finally able to sign an NDA to gain access the source code to some e-commerce software that a customer was using but had become discontinued. I can completely understand their reluctance--even "on error goto" style exception handling would be better than nothing. And, it being e-commerce it would've been nice if the transactions were atomic. Even if I wasn't legally obligated to keep the identity of the "offender" a secret I probably still would--it just be cruel to mock them; they deserve our pity.
I have gained access to closed source via NDA on more than one occasion and horror code has ALWAYS been present and prominent. Every. Single. Time. It is a really big factor in why I do not use closed source software to run my business anymore. It is kind of like how people who have worked in a fast food restaurant chains sometimes stop eating the food there.
|
|
|
|
|
Firstly I'm not dissing Open Source. Just making an observation. I'm quite sure that there is similarly 'bad' code hidden in proprietary. I use nothing but OSS at home(except nvidia) and as much as work will let me, which is why I was trawling the kernel. Besides, the section was in an 'Opened' module which had originally been written as proprietary in the 90s.
|
|
|
|
|
|
It certainly works. But when the labelled line merely sets a return value, it would have been more in keeping with C to use multiple return paths.(Perhaps the code was so old the then-compilers couldn't check multiple paths?)
|
|
|
|
|
Well, this is keeping with kernel C style, since having one exit point is a well established pattern (not only) there; it makes it easier to argue about the correctness no matter eventual compiler warnings.
|
|
|
|
|
Oh, what would be of us without VB.Net?
To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson
----
Our heads are round so our thoughts can change direction - Francis Picabia
|
|
|
|
|
I guess using a For Each is out of the question
|
|
|
|
|
Well I guess he/she didn't know about arrays or for loops.
|
|
|
|
|
What data are we tracking here with 50 double textboxes on a single screen?
Oops. 4.75255314 should have been in textbox 35 not 37..
|
|
|
|
|
That's what's even worse than the code and the design: it's an invoicing system, and these are for the prices he's going to invoice to the customer ... hence the total
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|
|
I think the OP is working at my place nowadays[^].
Be excellent to each other. And... PARTY ON, DUDES!
Abraham Lincoln
|
|
|
|
|
What's wrong with that code?
|
|
|
|
|
Remind me never to employ you!
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|
|
I will just use that code as my resume and the reminding shall occur.
|
|
|
|
|
Absolutely no comments.
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
Isn't this the original Excel source code?
|
|
|
|
|
I don think so. If it was, it would more likely be
ptotal = Double.Parse(Me.txttA.Text) + Double.Parse(Me.txttB.Text) + Double.Parse(Me.txttC.Text) + _
Double.Parse(Me.txttD.Text) + Double.Parse(Me.txttE.Text) + Double.Parse(Me.txttF.Text) + _
Double.Parse(Me.txttG.Text) + Double.Parse(Me.txttH.Text) + Double.Parse(Me.txttI.Text) + _
Double.Parse(Me.txttA0.Text) + Double.Parse(Me.txttAA.Text) + Double.Parse(Me.txttAB.Text) + _
Double.Parse(Me.txttAC.Text) + Double.Parse(Me.txttAD.Text) + Double.Parse(Me.txttAE.Text) + _
Double.Parse(Me.txttAF.Text) + Double.Parse(Me.txttAG.Text) + Double.Parse(Me.txttAH.Text) + _
Double.Parse(Me.txttAI.Text) + Double.Parse(Me.txttB0.Text) + Double.Parse(Me.txttBA.Text) + _
Double.Parse(Me.txttBB.Text) + Double.Parse(Me.txttBC.Text) + Double.Parse(Me.txttBD.Text) + _
Double.Parse(Me.txttBE.Text) + Double.Parse(Me.txttBF.Text) + Double.Parse(Me.txttBG.Text) + _
Double.Parse(Me.txttBH.Text) + Double.Parse(Me.txttBI.Text) + Double.Parse(Me.txttC0.Text) + _
Double.Parse(Me.txttCA.Text) + Double.Parse(Me.txttCB.Text) + Double.Parse(Me.txttCC.Text) + _
Double.Parse(Me.txttCD.Text) + Double.Parse(Me.txttCE.Text) + Double.Parse(Me.txttCF.Text) + _
Double.Parse(Me.txttCG.Text) + Double.Parse(Me.txttCH.Text) + Double.Parse(Me.txttCI.Text) + _
Double.Parse(Me.txttD0.Text) + Double.Parse(Me.txttDA.Text) + Double.Parse(Me.txttDB.Text) + _
Double.Parse(Me.txttDC.Text) + Double.Parse(Me.txttDD.Text) + Double.Parse(Me.txttDE.Text) + _
Double.Parse(Me.txttDF.Text) + Double.Parse(Me.txttDG.Text) + Double.Parse(Me.txttDH.Text) + _
Double.Parse(Me.txttDI.Text) + Double.Parse(Me.txttE0.Text)
Greetings - Jacek
|
|
|
|
|
What else can you do? Well lets seeeeee......
double ptotal = 0;
foreach(Control ctrl in this.controls)
{
if(ctrl is TextBox)
ptotal += Double.Parse(ctrl.Text);
}
|
|
|
|
|
I haven't been on these forums in a while. But I've come across a coding atrocity so horrible, so offensive, that I have to document it.
This is a Windows service. Can you see how the developer accesses database data? (Answer below)
Dim ResultDS As New SqlDataSource
ResultDS.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("JaguarReportingConnectionString").ToString()
ResultDS.SelectCommand = "<select statement>"
ResultDS.[Select](DataSourceSelectArguments.Empty)
Dim dg As New GridView
dg.DataSource = ResultDS
dg.DataBind()
Dim dv As New DataView
Dim dt As New DataTable
dv = ResultDS.Select(DataSourceSelectArguments.Empty)
dt = dv.ToTable()
Hint: GridView is from the Web UI control namespace. Did I mention this is a Windows service?
|
|
|
|
|
Kill it! Kill it with fire!
|
|
|
|
|
It could be worse. The developer could have started an instance of one of the Microsoft Office applications to do the job (in a service).
Software Zen: delete this;
|
|
|
|
|
Yep. And for extra credit he could have used ActiveX to start it on the client!
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|
|
Why you had to bring ActiveX into this ?
|
|
|
|
|
Because I am the AntiChrist, and it's my job to introduce Evil to the world?
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|
|
You're creeping me out. That is exactly what he did with the DataSet!
|
|
|
|