|
Someone once told me that "if" is the biggest word in the dictionary.
-----------------------------
Just along for the ride.
-----------------------------
|
|
|
|
|
If it depends on your definition of if is, then you are screwed.
Psychosis at 10
Film at 11
|
|
|
|
|
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
|
|
|
|