|
It is better to have principles, like a coding style. It helps to avoid mistakes and makes achieving greater goals easier: "Safety first" !! rules rockom bottom
My personal life experience is, that people more often get into trouble if they have to less principles.
Like: "Dont drink [to much] and drive"
Greetings from Germany
|
|
|
|
|
Another one from my boss! lol.
This is actually from a final production software developed by my boss a couple years ago, now we are going to .net and he told me to "Do the same that this module".
so here is part of the code:
tmpAdd = tmpAdd + Format(tmp5, "###,##0") + Chr(9)
tmpAdd = tmpAdd + Format(tmp6, "###,##0") + Chr(9)
tmpAdd = tmpAdd + Format(tmp3 + tmp5, "###,##0") + Chr(9)
tmpAdd = tmpAdd + Format(tmp4 + tmp6, "###,##0") + Chr(9)
mTotalesMSF(6) = mTotalesMSF(6) + tmp6 + tmp4
If tmp1 = 0 Then
tmpCero = 100
Else
If tmp3 + tmp5 = 0 Then
tmpCero = 0
Else
tmpCero = ((tmp3 + tmp5) / tmp1) * 100
End If
End If
tmpAdd = tmpAdd + Format(tmp3 + tmp5 - tmp1, "#,##0") + Chr(9)
tmpAdd = tmpAdd + Format(tmpCero, "#,##0") + "%" + Chr(9)
If tmp2 = 0 Then
tmpCero = 100
Else
If tmp4 + tmp6 = 0 Then
tmpCero = 0
Else
tmpCero = ((tmp4 + tmp6) / tmp2) * 100
End If
End If
tmpAdd = tmpAdd + Format(tmp4 + tmp6 - tmp2, "#,##0") + Chr(9)
tmpAdd = tmpAdd + Format(tmpCero, "#,##0") + "%"
mTotalesMSF(7) = mTotalesMSF(7) + tmp4 + tmp6 - tmp2
If tmp1 + tmp2 + tmp3 + tmp4 + tmp5 + tmp6 <> 0 Then msfConsulta.AddItem tmpAdd
rstmp.MoveNext
At last, tmp4,6,7,2,3 etc are variables with things like, total sales, proyected sales, pending orders, etc..
|
|
|
|
|
It was obvious that your boss is a moron when it comes to coding after the first post. What is the point of later posts? To humiliate the man?
I've met my deal of people who take pride in bashing others, and honestly I'm sick of them. I dislike people who write lousy code, but I dislike idiots who heal their own frustrations by laughing at others even more. Are you fed up with idiotic algorithms of your boss? Sit down with him and talk about your views on coding. He doesn't want that? Fine, ignore him, or quit the job.
(rant on doing stupid things... could offended someone, so I deleted it)
That said, I truly hope that one day you'll be the boss and have not one, but several employees like you.
|
|
|
|
|
nice answer.. U got my 5..
|
|
|
|
|
Wait a second!
This is a form to post "Coding Horrors". Just because he keeps looking to the same person (and that person is unbelievably bad) does not make him a person who takes pride in "bashing" others. Posting bad code is the point of this forum. Myself, I've enjoyed looking at these code examples for exactly the reason I am browsing this board -- to shake my head in disbelief.
|
|
|
|
|
This one rocks...
Private Sub Run_Click()
On Error Resume Next
OLE1.SourceDoc = pat & Grid
OLE1.SourceItem = pat & Grid
OLE1.Action = 1
DoEvents
OLE1.Action = 7
DoEvents
OLE1.Action = 10
End Sub
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
gajatko wrote: On Error Resume Next
Thats VB for you.
If you're struggling developing software, then I'd recommend gardening.
|
|
|
|
|
norm .net wrote: That's
Yes, but 's can be expanded now to "was", not "is"
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
I think you worded it incorrectly. Surely it should be "This one sucks..."
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
DoEvents: generating unexpected recursion since 1991.
|
|
|
|
|
Mike Dimmick wrote: DoEvents: generating unexpected recursion since 1991.
Commonly read in the VB forums:
"What's so bad about DoEvents?"
The early bird who catches the worm works for someone who comes in late and owns the worm farm. -- Travis McGee
|
|
|
|
|
The good: it allows other events to occur, so they don't end up massively queued up with your application unresponsive while you perform some complex task.
The bad: it allows all other events to occur, so you can end up re-entering the current block of code and ultimately end up with stack overflow. Also, if you happen to include it in a COM callback, or a paint handler when you've already made a COM call to another process, and one of the events that fires tries to make a COM call to another process, you get a 'cannot call out within message filter' error.
That one caused a lot of head-scratching, I can tell you. You end up having to break up your big routine littered with DoEvents into lots of little event handlers and somehow have a way of transferring control between them by some other object raising an event. Timers work, of course, but the minimum timer duration is about 15ms on Windows XP, which is eons in computing time. (I wrote a component in C++ which merely posts a message back to a hidden window, and raises an event when this occurs, cutting that down to tiny amounts.)
DoEvents : Generating unexpected recursion since 1991
|
|
|
|
|
Whats good about VB, absolutely nothing, zilch.
If you're struggling developing software, then I'd recommend gardening.
|
|
|
|
|
norm .net wrote: Whats good about VB, absolutely nothing, zilch.
My first post on this board is in vehement agreement with this wise poster.
Hello!
|
|
|
|
|
Welcome to the club of many hundreds of thousands of developers who share the same sentiments about VB.
Chuck Norris counted to infinity - twice.
|
|
|
|
|
It's a real shame they included this in .NET's WinForms implementation. I utterly rebuke any code that uses it.
Thank God they didn't such an easily abusable API in WPF.
In WinForms, if you really need to do lots of work and don't want to back up the UI thread, split up your work and execute it inside Application.Idle event. Much more scalable, no scary re-entry issues to deal with.
Or alternately just use a background thread.
|
|
|
|
|
I like the first line most.
Greetings from Germany
|
|
|
|
|
While trying to debug some legacy code, I ran into this unique take on an infinite loop:
''' <summary><br />
''' Initializes the trouble ticket display for stations<br />
''' </summary><br />
Public Sub initalizeTTick(ByVal stationID As String)<br />
'Database <br />
Dim db As New LabConsoleDB()<br />
<br />
Try<br />
Dim dr As DataRow = db.StationDetailedRecord(stationID)<br />
If dr Is Nothing Then Return<br />
<br />
'Populate the textbox for the trouble ticket<br />
txtTTick.Text = "Location:" & vbTab & stationID("stnName").ToString().ToUpper() & vbCrLf<br />
txtTTick.Text = txtTTick.Text & "Model:" & vbTab & dr("machManuf").ToString() & " " & dr("machModel").ToString() & vbCrLf<br />
txtTTick.Text = txtTTick.Text & "Serial:" & vbTab & stationID("machSerial").ToString() & vbCrLf<br />
txtTTick.Text = txtTTick.Text & "ICN:" & vbTab & dr("machICN").ToString() & vbCrLf<br />
txtTTick.Text = txtTTick.Text & "" & vbCrLf<br />
txtTTick.Text = txtTTick.Text & "Problem:" & vbTab & vbCrLf<br />
lblStnName.Text = dr("stnName").ToString().ToUpper()<br />
<br />
'Show the form<br />
Me.StartPosition = FormStartPosition.CenterScreen<br />
Me.Show()<br />
Catch<br />
Call initalizeTTick(stationID)<br />
End Try<br />
End Sub
|
|
|
|
|
Oooh. So - if I fail, I try me again and again. Well that's nice and defensive. I assume that the user sees a MessageBox saying Time Remaining. 1 second for the next 4 hours.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Well, being recursive it'll blow the stack... and the catch will fire again?
|
|
|
|
|
PIEBALDconsult wrote: and the catch will fire again
Hehe I read that as 'will catch fire again'!
I have no blog...
|
|
|
|
|
|
Isn't StackOverflowException one of those exception that doesn't get cought in ordinary catch?
edit:
Indeed it is (in .NET 2.0) Clickey[^]
-- modified at 6:59 Wednesday 19th September, 2007
[ My Blog] "Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - Rüdiger Klaehn "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
Public Sub initalizeTTick(ByVal stationID As String)
stationID("stnName").ToString().ToUpper()
What the hell is that suppose to do?
|
|
|
|
|
Well, in this case, it throws a runtime error... which is caught by the exception.
Yes, not only is the code written so that if there are errors it recurses forever, it is written in such a way that this is GUARANTEED to happen.
|
|
|
|