|
Nagy Vilmos wrote: have you tried re-booting the developer?
FTFY
|
|
|
|
|
That's what you get if you code on an early Monday morning.
"Don't confuse experts with facts" - Eric_V
|
|
|
|
|
Stuff like that can keep me busy for hours!
It's an OO world.
|
|
|
|
|
that's funny. That reminds me of the time my web page kept returning an error when I was trying to view a text file. That is until I realised, the file contained text of a web page error. It must have been a Monday.
|
|
|
|
|
How to generate an ASP.NET menu, if you are an evil genius
First one must define what it is we are to show (apologies for the odd characters, it is badly endoded arabic):
private string memberMenu = @"<table border=0 cellpadding=1 cellspacing=1 width=100% dir=rtl style=font-family:Tahoma;font-size:12px;><tr><td><a href=# onclick=""top.SetLocation(\'\',\'\',\'MembersResearchList.aspx?t=\'+(new Date()).toLocaleTimeString().replace(\':\',\'\'));top.SetTitle(\'ÃÈÍÇË æÏÑÇÓÇÊ\');return false;"" class=""navMenu"">ÃÈÍÇË æÏÑÇÓÇÊ</a></td></tr><tr><td><a href=# onclick=""top.SetLocation(\'\',\'\',\'AddMembersExperience.aspx\');top.SetTitle(\'ÇáÎÈÑÇÊ\');return false;"" class=""navMenu"">ÇáÎÈÑÇÊ</a></td></tr><tr><td><a href=# onclick=""top.SetLocation(\'\',\'\',\'AddMembersAcademicRank.aspx\');top.SetTitle(\'ÇáÑÊÈÉ ÇáÚáãíÉ\');return false;"" class=""navMenu"">ÇáÑÊÈÉ ÇáÚáãíÉ</a></td></tr><tr><td><a href=# onclick=""top.SetLocation(\'\',\'\',\'MemberQualificationList.aspx?t=\'+(new Date()).toLocaleTimeString().replace(\':\',\'\'));top.SetTitle(\'ãÄåá ÇßÇÏíãí\');return false;"" class=""navMenu"">ãÄåá ÇßÇÏíãí</a></td></tr><tr><td><a href=""#"" onclick=""{0}"" class=""navMenu"">ÊÍãíá ÇáÓíÑÉ ÇáÐÇÊíÉ</a></td></tr><tr><td><a href=""#"" onclick=""{1}"" class=""navMenu"" title=""ÌÏæá ÇáãæÇÏ ÇáÊÚáíãíÉ"">ÌÏæá ÇáãæÇÏ ÇáÊÚáíãíÉ</a></td></tr><tr><td><a href=""#"" onclick=""window.open(\'loadEduGate.htm\'); return false;"" class=""navMenu"">ÇáÈæÇÈÉ ÇáÅáßÊÑæäíÉ</a></td></tr><tr><td><a href=# onclick=""top.SetLocation(\'\',\'\',\'MarksMainPage.aspx\');top.SetTitle(\'äÙÇã ÇáÚáÇãÇÊ ÇáÑÓãí áÃÚÖÇÁ ÇáåíÆÇÊ ÇáÊÏÑíÓíÉ ÈÌÇãÚÉ ÇáÈÊÑÇ\');return false;"" class=""navMenu"">äÙÇã ÇÏÎÇá ÇáÚáÇãÇÊ</a></td></tr></table>";
Then one must show it:
lblScript.Text = @"<script type='text/javascript'>document.getElementById('navContent').innerHTML='" + string.Format(memberMenu, @"top.SetLocation(\'\',\'\',\'ListOfMemberCVs.aspx?mid=" + (new FacultyMembers()).GetMemberByUserName(sUserName + "@uop.edu.jo").Rows[0]["membersID"].ToString() + @"&t=\'+(new Date()).toLocaleTimeString().replace(\':\',\'\'));top.SetTitle(\'ÇáÓíÑÉ ÇáÐÇÊíÉ\');return false;", @"top.SetLocation(\'\',\'\',\'../Courseslist/Default.aspx?d=" + ReserveTicketForUser(sUserName, pwd, userType + "," + pwd) + "&mid=" + (new FacultyMembers()).GetMemberByUserName(sUserName + "@uop.edu.jo").Rows[0]["membersID"].ToString() + @"&t=\'+(new Date()).toLocaleTimeString().replace(\':\',\'\'));top.SetTitle(\'My Courses\');return false;") + @"';</script>";
All I wanted to do was to show a link that only the developers could see so we can test a critical system we are migrating to live, this leaves me no opportunity to do so. Some stuff I can put down to bad design decisions, but this I can't explain away.
|
|
|
|
|
In any application I scream a little every time I see a hard coded menu. FFS, it is as easy to parametrise it as it is to hard code and the latter is more extensible. If I caught one of my trained simians doing that it'd be bull-whip time.
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
You'd have a fit with our codebase, nothing (I and mean nothing) is well implemented. I'd call "Job Security" but the bloke who wrote the worst of it left. To add piquancy to the proceedings, I'm struggling to convince the powers that be that doing things properly will be quicker than doing things "quickly" as per the OP. Oh well, I can always resign.
|
|
|
|
|
The approach has to be to give them a route to a better application. "Throw it all away" will not work.
Tell the PHB's that any bug fix will take 5x what would be expected because of the shyte code, but only 4x to reimplement. Stick to this.
All new work, for a given value of 'new', should be done with the new approach and the legacy code updated as and when it needs to change.
If possible, black-box the legacy stuff so that you don't have to go in there too often.
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
Yes, they don't have to know that in the end nothing of the old code will remain and that you gradually threw everything away. Hopefully the old application is not so twisted and dependent that every change triggers a chain reaction of subsequent changes. Then you have little chance to do it step by step.
"Dark the dark side is. Very dark..." - Yoda
--- "Shut up, Yoda, and just make yourself another toast." - Obi Wan Kenobi
|
|
|
|
|
Yes, that would be a good approach, but they've agreed to a re-write (on the grounds our current site really doesn't play well will googlebots) but they want the new system to be as patchy as the first. Naturally, there is some politics going on which is behind all this.
|
|
|
|
|
Same here. I have written applications that have been online for months without any problems and they whine about the time it took to get them to work that well. The old application fell apart every day and was almost unmaintainable, but this time and effort somehow does not count.
"Dark the dark side is. Very dark..." - Yoda
--- "Shut up, Yoda, and just make yourself another toast." - Obi Wan Kenobi
|
|
|
|
|
Ran across this little gem while cleaning some old (but still in active development ) VB6 code today:
If GV_GracefullyExiting Then
End
End
End
End If
* Names and dates removed to protect the ???
Was it really that hard to track down why the application wouldn't die that it needed to be ended three times? I mean, a double-tap is standard zombie killing procedure, but thrice?
|
|
|
|
|
Yeah, and those other two End statements should be commented! Like so:
If GV_GracefullyExiting Then
End
End
End
End
End
End
End
End If
|
|
|
|
|
If GV_GracefullyExiting Then
While True
End
End While
End If It is VB after all - the Language That Would Not Die...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
|
I wish I could do more than 5
|
|
|
|
|
Yet Another VB Horror!
The following is an error-handling block from some old code I'm having to maintain (for my sins)..
errorPAT:
If retryCount < 1000 Then
ElseIf Err.Number = errOdbcCallFailed Then
If InStr(odbcErrorMess(Err), "insert duplicate") > 0 Then
retryCount = retryCount + 1
Resume tryAgain
ElseIf InStr(odbcErrorMess(Err), "unique constraint") > 0 And InStr(odbcErrorMess(Err), "violated") > 0 Then
retryCount = retryCount + 1
Resume tryAgain
ElseIf InStr(odbcErrorMess(Err), "Duplicate key value specified") > 0 Then
retryCount = retryCount + 1
Resume tryAgain
Else
message "Error " & Format(Err, "######") & " " & odbcErrorMess(Err), "P_ArchiveTag"
Exit Sub
End If
ElseIf Err.Number = errDuplicateValues Then
retryCount = retryCount + 1
Resume tryAgain
End If
message "Error " & Format(Err, "######") & " " & Error, "P_ArchiveTag"
End Sub
I think there's ample horrors for a short chunk of code...
|
|
|
|
|
It's 8am here. Remind me to never again visit this forum before breakfast. I can see this ruining my whole day (and no, I'm not going to sea, but that's another story.)
:vomit:
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
Yes, like the unique constraint in there, I feel "violated"
|
|
|
|
|
There a very aptly named method/function called 'odbcErrorMess', which neatly sums the whole code block you pasted.
Take-away: never shorten your method/function names
'As programmers go, I'm fairly social. Which still means I'm a borderline sociopath by normal standards.' Jeff Atwood
|
|
|
|
|
Julien Villers wrote: Take-away: never shorten your method/function names
I don't know, in this case I'd say the variable name is spot on .
Must be the only example in the code of a well named variable. I have such treasures as Function names:
Function H_WriteRecord1()
Function H_WriteRecord2()
Function H_WriteRecord3()
Note - those are the declarations as they appear. No return type given, all state passed in via global or module-level variables, and nothing to indicate what gets written, what the difference between the three variants is. I suspect "that nearly does what I want, I'll copy and paste it".
I also like the "batchHeader" boolean that sometimes outputs a header when true, otherwise when false. I still can't work out the logic governing when the two forms are used.
I suspect the originator may be a closet worshipper of The FSM[^]. I just wished he hadn't felt the need to spread noodly appendages through the code I'm now tasked with maintaining.
|
|
|
|
|
I was assigned to do some changes on built page and I found this.....
protected void btnEditClick(object sender, EventArgs e)
{
for (int i = 0; i < gvContactInfo.Rows.Count; i++)
{
var row = gvContactInfo.Rows[i].Cells[8];
ImageButton button = row.FindControl("modifyLink") as ImageButton;
if (button.GetHashCode() == SenderButton.GetHashCode())
{
ContactInfoView contactInfoView = row.FindControl("ctlContactInfoView") as ContactInfoView;
ctlNewContactInfo.ContactInfo = contactInfoView.ContactInfo;
}
}
}
|
|
|
|
|
Why? Why?
Why check an already boolean result?
Noticed this redundancy in many parts of an ill written app.
If myControl.Visible = True Then
Else
End If
I don't know why, it's just plain turn off to see this redundancy!
-
Just that something can be done, doesn't mean it should be done. Respect developers and their efforts!
Jk
|
|
|
|
|
Unfortunately this is the biggest issue I have about vb. It's too easy to be deep in thought and literally code what you are thinking and make the code more annoying to read. i.e. If control x visible property is true then do this and this and this. I usually pick it up after I have written it and clean it up afterwards but sometimes I've come across code a few months later and go whoops.
Hopefully the compiler is smart enough to fix the extra redundancy I've added so it doesn't effect performance.
|
|
|
|
|
I don
Anyway, to be really sure the control is visible you should obviously write
<pre>If (myControl.Visible = True) = True Then...
> so it doesn't effect performance
You mean "affect" (I hope)
|
|
|
|