|
Rob Grainger wrote: What could go wrong?
Let me count the ways...
|
|
|
|
|
Yep, that's dire. We've some godawful excrement here, but not that particular flavour.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
A database I access where I am has a bunch of DONOTUSEblahblahblah tables. 
|
|
|
|
|
Quote: Did you string the coder up by his thumbs? Only the First Time ...and then again on the First Time 2.
- I would love to change the world, but they won’t give me the source code.
|
|
|
|
|
They should be strung up by their index fingers.
I have a feeling they peck-type 
|
|
|
|
|
I wish there was a second first time for a lot of things in life...
It's an OO world.
public class SanderRossel : Lazy<Person>
{
public void DoWork()
{
throw new NotSupportedException();
}
}
|
|
|
|
|
public static class Extensions
{
public static void SetProperty(this object domainEntity, string propertyName, object value)
{
var t = domainEntity.GetType();
var p = t.GetProperty(propertyName, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic);
p.SetValue(domainEntity, value);
}
public static void SetProperty<T, TProp>(this T domainEntity, Expression<Func<T, TProp>> getP, TProp value)
{
var e = (MemberExpression)getP.Body;
SetProperty(domainEntity, e.Member.Name, value);
}
}
This piece of code has a fantastic history that is not obvious...
Why is that you might ask?
Well.. the single architect of our application decided that we were going to use Domain Driven Design (DDD). He also decided that all domain object property will have private setters. This being, as you can imagine, inconvenient, we got large use of this method (which he also wrote) to set private properties whenever needed!
Brilliant! Let's use private property for safety! And let's use this method to ignore private! Genius!
|
|
|
|
|
At least, static properties are still safe.
|
|
|
|
|
Not only that - because you have to refer to the property by name you also break compile time type-checking.
|
|
|
|
|
I guess that's where the second overload comes in:
codeReview.SetProperty(review => review.Status, Status.WhatTheElephant);
It's not fast, pretty, or even remotely sensible, but at least it's strongly typed and the property name is checked by the compiler.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Yeah - Ironically the non type safe overload shouldn't be public 
|
|
|
|
|
I created this second overload 2 days ago!!
|
|
|
|
|
well, you can't use this line of code outside of review.GetType() class... Status is private 
|
|
|
|
|
Dagnabit, I keep hitting upvote, but it only registered once.
That's right up there with the "Singleton<t>" articles that get posted here that require the target class to have a private constructor and then use Reflection to get it.
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
That's just as bad, indeed!!!
|
|
|
|
|
What do you get when you cross a joke with a rhetorical question?
|
|
|
|
|
It remind me when I wrote
static bool Is<T>(this T obj);
with reflection...
Then a friend of mind said : WTF have you written that ? instead of "obj is T".
The worse of it is that I had no idea why I did something so stupid... wanted to blame somebody else, but the source control history pointed at me. 
|
|
|
|
|
Did you mean static bool Is<T>(this object obj); ?
Because T obj is... always... T as far as I can tell!
Good one anyway!
|
|
|
|
|
yes it was this object good point 
|
|
|
|
|
I can imagine a use for something like this when implementing Undo/Redo.
|
|
|
|
|
I loved DOS, after having to load 6 floppy disks for a program; DOS was the most amazing thing ever.
Then Windows 3.11 came along; not only did I get a windowed experience, but also a networked one as well.
Then Windows 95; glorious improvements in graphics. I remember I just had to have it because it was futuristic.
It wasn't until College that I fell in love with Windows 98 for the compatibility of everything new.
In my 3rd year of college Windows XP came out. Before this point the average person didn't really have a computer, and I considered XP to be a joke. Most to the same way I saw Windows Millennium Edition and including Vista on top of that.
At the time vista came out I was forced to upgrade to Windows XP, then did so without ever updating the thing, and gave up on trying to control the IRQ's.
While using windows 7, my first reaction was to hate windows 8.
That's when I noticed a pattern that the only reason I didn't like something was my resistance to change.
I also consider the only reason XP did so well was the lack of devices in the common home.
Now I fear that every reason to love Windows 8 will never be known and the quick response of people will kill off a technology that has barely come to light.
|
|
|
|
|
Wrong forum. How about putting it on your blog?
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
Which forum should I use?
|
|
|
|
|
This one[^]
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
It was Microsoft that advertised that I should be engaged with this website. As you are well respected by the public, and because it is in public view; what is wrong with opinions you don't like?
|
|
|
|