|
Ahhh, a Clinton supporter!
|
|
|
|
|
Finally, a language that doesn't put stupid restrictions on me!
|
|
|
|
|
You don't even want to know what you can do with JavaScript.
|
|
|
|
|
What.
The most iffy thing I've done is to recreate IIf for WP7, but man, that's just...
Don't forget to rate my post if it helped!
"He has no enemies, but is intensely disliked by his friends."
"His mother should have thrown him away, and kept the stork."
"There's nothing wrong with you that reincarnation won't cure."
"He loves nature, in spite of what it did to him."
|
|
|
|
|
|
The "intro message" on one of the new Futurama episodes tonight was:
Some ask "What if?"
We ask "Why if?"
|
|
|
|
|
Whenever I hear "what if", I think of The Time Machine ("you're a man haunted by those two most terrible words: what if").
|
|
|
|
|
Too funny. I just watched that on TV over the last weekend. My son was seeing it for the first time and as one proud, highly geeky dad I observed him riveted to the screen as he pondered the concepts of time travel.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
Why Stop.... Carry on Ifs and Iffs ....... But no End If
|
|
|
|
|
and I didn't write it!
Just look at the code the OP posted...
Clickety!
First problem....the post is located in Javascript forum while the code is in vbscript!
"Whether you think you can, or you think you can't--either way, you are right." — Henry Ford
"When I waste my time, I only use the best, Code Project...don't leave home without it." — Slacker007
|
|
|
|
|
Anything which is still vulnerable to SQL injection is definitely deserving of a place in this forum.
|
|
|
|
|
Wow...... I would never hire someone who wrote code like that.
|
|
|
|
|
It starts off, OK (if you ignore the Data Access stuff inside the "Object Model", so it doesn't start OK, but OK is relative in our codebase):
public class FacultyDean
{
}
Nothing too contenious, unless you want to argue about the use of the word Faculty: all faculties have one dean, and all deans belong to 1..* Faculties so it is not necessary. I'd have called it Dean but there it is.
Here comes the complete listing for a subclass of FacultyDean :
public class NullFacultyDean : FacultyDean
{
public NullFacultyDean()
{
ID = -1;
}
}
A whole subclass for an uninitialised dean, what luxury! There is no flag to say that the Dean is null, so I'm not 100% sure what this is doing.
Oh and we have tens of classes like this all over:
public class DeanCollection : List<FacultyDean>
{
}
Again this is the full class, and 99% of them are uneccessary (Hurray! I Can't just remove theem en-masse, I have to check each!). Notice this time we have a DeanCollection rather than FacultyDeanCollection. Nice, consistent naming!
|
|
|
|
|
Keith Barrow wrote: public class DeanCollection : List<FacultyDean>
{
}
This could make sense if you are using reflection. Which I guess you are not.
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
|
|
|
|
|
I doubt the "expert" that wrote this code was capable of self-reflection never mind the kind you mean
I also discovered today that we are passing down UI element objects into what I laughingly call our database layer just so we don't have to pass down paging information. At least this has a nice degree of symmetry about it: the UI has plenty of data access in it
|
|
|
|
|
You can reflect generic classes, though it takes a bit of effort for those of us brought up on .Net 1.1 who learnt how it works before generics existed.
There is a reason to do something similar to this: for UI classes, the VS designer can't get its tiny mind around generic control classes, so if you want to be able to drag-drop controls onto the form, you have to make a non-generic subclass. Thus I have this class in a real system:
public class PlotIconPicker : PickerBase<PlotIcon>
{
}
I haven't come across a reason to do it with things that don't live in the designer, though.
|
|
|
|
|
Is this a WPF app by any chance, and are there DataTemplates involved? This type of trick is a common hack to get around the apparent inability to apply a DataTemplate to a generic item (there are other ways, but this is the lazy-hack way to do it).
|
|
|
|
|
Just a basic ASP.NET effort!
|
|
|
|
|
Maybe they did that instead of this:
using DeanCollection = List<FacultyDean>;
It makes a certain sort of sense. You can then later change what DeanCollection is (e.g., to SortedList) without changing code that makes use of that type. Also makes adding functionality easier.
Not that I think that's what they were doing.
|
|
|
|
|
Keith Barrow wrote: public class DeanCollection : List<FacultyDean>
{
}
That's actually not a really strange one. In certain languages you had to define your own lists if you wanted to have them typesafe. Eg; you did have a list of objects, but if you wanted a list of person you had to create your own class. Lots of those programmers who did that in the past took that way of working over in .NET.
Ofcourse with Generic this makes no sense, but those people tend to argue that using the "DeanCollection" abstracts away the "FacultyDean", so that you can always replace it with a different class. I do wonder why you would want that though...
Keith Barrow wrote: public class NullFacultyDean : FacultyDean
{
public NullFacultyDean()
{
ID = -1;
}
}
I have done that in the past also, only then the other way around . I guess they needed something which represents an empty "FacultyDean" and created it this way instead of a more common:
public FacultyDean Empty
{
get {
return new FacultyDean() { ID = -1 };
}
}
Ofcourse this code example also doesn't work out of the box, unless you compare the ID's. A normal equal won't work :P
It's always something with code you inherit I for once got the comments the code was to hard; It had to much inheritance. I could also just have copied the code in all the classes. Much easier to understand! ;x
|
|
|
|
|
JV9999 wrote: I guess they needed something which represents an empty "FacultyDean" and
created it this way instead of a more common
Nope, I checked. It really just means an "uninitialised dean". I do like the idea of a Null Deanthough, just the sort of thing you'd expect at the Unseen University [^]
|
|
|
|
|
I think I didn't wrote it correctly what I wanted to say. I actually meant it might act as a "unsaved"/"new" dean. If you use -1 for unsaved values, having an (static)object which represents could help, but there are far easier solutions for that which are also much more common.
Null should ofcourse be eh... null? (and not some weird nulldeanobject)
|
|
|
|
|
JV9999 wrote: but there are far easier solutions for that which are also much more
common.
Kind of the definition of a coding Horror
|
|
|
|
|
Then let me congratulate you to your uncommonly complete collection of deans
"I just exchanged opinions with my boss. I went in with mine and came out with his." - me, 2011
--- I am endeavoring, Madam, to construct a mnemonic memory circuit using stone knives and bearskins - Mr. Spock 1935 and me 2011
|
|
|
|
|
I submitted this to The Daily WTF and they didn't use it, so here we go.
(PS: I saw it's now in TDWTF Forums. Zecc, I signed up for the forums over a week ago now but it requires admin approval before you can post. Admin appears to be away because I never got approved. I also submitted again to ask them to approve my account so I could use the forums and I got no response. It's not that I just "couldn't be bothered", the whole thing has left me slightly miffed.)
--
A company I work with is replacing a mainframe application with a trendy new version, but it's not complete yet. The old software still published customer data to a website once an hour, and this responsibility had to be handed off to the new system, but "in the old format", until a proper project could be contracted out to make a new website.
It sounded like a nightmare. There was only a production system to work with, all the data had to be extracted in a few CSV formats (incremental and full updates) and transferred over FTP. I was told there was no access to the source code, nobody knew how it worked aside from it being in production for nearly a decade, and the only way to test it would be to click a button that could start a manual import process, quickly check a few screens, and revert the data again with a forced export from the legacy system before anyone could notice anything wrong.
I took it on, for fun.
I started by spending days creating a CSV extract from data in the new system based on the column names that had been provided from the legacy system. Then I compared the data to a previous CSV and found that the old system ignored/munged a whole bunch of those columns and that I had to start from scratch and build a new "purposefully broken extract", just in case the parser on the web-site end (a complete black box at the time) would choke on logically valid data. The one good thing was that the website was supposed to email us with a detailed explanation or where and why any data import failed.
And finally, late one night, we tested it by FTP'd the new data over and clicking the manual import button. And nothing happened. Not even the email.
"It's a disaster!" The format of my data export was assumed incorrect and so bad that the web site couldn't even parse it, so it was thrown back at me. I went over it column by column and could not find any problems. I explained as such, and another developer sent off a complaint to the web hosting company asking if they had messed something up (Why them? "Because it used to work!")
Which is right about the time I noticed the FTP account I had been provided (once switched to PASV mode) had entire access to the web site, which turned out to be a bunch of HTML and PHP scripts, with an ancient MySQL database (username, password, and location) embedded inside. I copied everything to my local machine, cloned the database, and tweaked the script so I could run it locally; but it spewed out a bunch of errors about truncated strings. I determined these were because I was using a way-too-new (anything in the past 5 years) version of MySQL, and had to trawl the internet looking for a binary of the ancient version I wanted to use instead.
And the import worked. When run manually. No problems. The button to do it via the web, was another matter. After looking into it, it had been so many years since the website had been written (let alone maintained), that various PHP APIs had been disabled/deprecated as security risks, and this had likely been upgraded at one stage on the web host. The automatic import processes were ticking along, but the back-end administration buttons which did all kinds of cross-posting would not.
It sounds easy describing that here, but when I first downloaded the site, it took a lot of digging to get there, because the structure was like this:
public_html/form_01.php
public_html/form_01o.php
public_html/form_02.php
public_html/form_02o.php
public_html/publicform.php
public_html/mainform.php
public_html/usermain.php
public_html/admin/form_01.php
public_html/admin/form_01o.php
public_html/admin/form_02.php
public_html/admin/form_02o.php
public_html/admin/publicform.php
public_html/admin/mainform.php
public_html/admin/usermain.php
public_html/www/form_01.php
public_html/www/form_01.bak
public_html/www/form_01o.php
public_html/www/form_02.php
public_html/www/form_02o.php
public_html/www/publicform.php
public_html/www/mainform.php
public_html/www/usermain.php
public_html/www/admin/form_01.php
public_html/www/admin/form_01o.php
public_html/www/admin/form_02.php
public_html/www/admin/form_02o.php
public_html/www/admin/publicform.php
public_html/www/admin/mainform.php
public_html/www/admin/usermain.php
That's right! Your favourite PHP spaghetti! I also later found even more .php files (some active include files with a single/multiple versions, and some more lots of copies) hidden in other subdirectories OUTSIDE the public_html folder.
I could also see that the PHP code was just concatenating a massive INSERT string from all the fields in the CSV without manipulating or sanitising it. Beautiful. But I decided not to touch that, and just change the code on the manual import button to get it working, and it "worked great". Except none of the financial figures showed up properly; some looked like they'd been divided by 100 and had extra numbers tacked onto the end. I pointed this out to the only other person who knew anything about the web site and they told me not to worry as "even the old system does that" and it had always been like this!
I pulled out the PHP code again and had a look, and not being fluent in the language, I had to run to IRC to ask what was happening. Do you see it?
<?=printf("%.2f", $myrow1->x_value);?>
That's right. It was printing dollar amounts, followed by the length of the string. EVERYWHERE.
I bit the bullet and removed the equals sign, tested it, and put the changes out in production myself, and it all worked fine.
Maybe the real WTF is if I was given the proper security in the beginning, I could have saved a few days and pumped the data right into the database instead of going through the PHP side, and also done my own testing in a web browser instead of comparing line-by-line data exports from the old and new systems.
I'm considering rewriting the user-oriented part of the site in ASP .Net as a fun learning project for myself (and getting paid just a little for it once it's done, of course). After all, the standards can't be that high when this was all accepted in the first place...
modified on Thursday, June 23, 2011 9:41 PM
|
|
|
|
|