Click here to Skip to main content
15,887,746 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: WPF ValidationErrors Pin
Brisingr Aerowing29-May-15 5:11
professionalBrisingr Aerowing29-May-15 5:11 
JokeMessage Closed Pin
29-May-15 5:14
User 113800029-May-15 5:14 
GeneralRe: WPF ValidationErrors Pin
Bernhard Hiller29-May-15 5:35
Bernhard Hiller29-May-15 5:35 
GeneralRe: WPF ValidationErrors Pin
Eddy Vluggen29-May-15 5:46
professionalEddy Vluggen29-May-15 5:46 
GeneralRe: WPF ValidationErrors Pin
Brisingr Aerowing29-May-15 6:00
professionalBrisingr Aerowing29-May-15 6:00 
GeneralRe: WPF ValidationErrors Pin
Eddy Vluggen29-May-15 5:43
professionalEddy Vluggen29-May-15 5:43 
GeneralRe: WPF ValidationErrors Pin
Richard Deeming29-May-15 6:08
mveRichard Deeming29-May-15 6:08 
GeneralRe: WPF ValidationErrors Pin
Bernhard Hiller31-May-15 23:49
Bernhard Hiller31-May-15 23:49 
That's a good point. Their reason is totally valid. But their solution is NOT.
When an error has to be replaced by a different error, the system is in an invalid state when only one of the two steps of adding the new error and removing the old error has been completed. Two errors on the field are as wrong as no error on it. It's similar to transferring money from one bank account to another bank account: do not create or loose money by omitting one step. A solution could be a transaction.
But I think the simplest solution here is similar to a PropertyChanged event. Get rid of the Added/Removed enum, and take two error properties: OldError and NewError.
When you leave the valid state, NewError contains the error which is now communicated with Added, and OldError is null.
When an error gets replaced by a different error, NewError contains the freshly incurred error (now with Added), and OldError the previously encountered error (now with Removed).
When you return to a valid state, NewError is null, and OldError the previously encountered error (now with Removed).
That's a better solution, isn't it?
GeneralRe: WPF ValidationErrors Pin
Richard Deeming1-Jun-15 1:50
mveRichard Deeming1-Jun-15 1:50 
GeneralCode Puzzle Pin
Sascha Lefèvre13-May-15 15:24
professionalSascha Lefèvre13-May-15 15:24 
GeneralRe: Code Puzzle Pin
PIEBALDconsult13-May-15 15:32
mvePIEBALDconsult13-May-15 15:32 
GeneralRe: Code Puzzle Pin
Brisingr Aerowing13-May-15 15:33
professionalBrisingr Aerowing13-May-15 15:33 
GeneralRe: Code Puzzle Pin
Sascha Lefèvre15-May-15 4:26
professionalSascha Lefèvre15-May-15 4:26 
GeneralRe: Code Puzzle Pin
Brisingr Aerowing13-May-15 15:33
professionalBrisingr Aerowing13-May-15 15:33 
GeneralRe: Code Puzzle Pin
Suvabrata Roy13-May-15 21:28
professionalSuvabrata Roy13-May-15 21:28 
GeneralRe: Code Puzzle Pin
Agent__00713-May-15 21:54
professionalAgent__00713-May-15 21:54 
GeneralRe: Code Puzzle Pin
Richard Deeming14-May-15 1:19
mveRichard Deeming14-May-15 1:19 
GeneralRe: Code Puzzle Pin
Agent__00714-May-15 1:46
professionalAgent__00714-May-15 1:46 
GeneralRe: Code Puzzle Pin
Smart K813-May-15 23:26
professionalSmart K813-May-15 23:26 
GeneralRe: Code Puzzle Pin
Power Puff Boy15-May-15 2:04
Power Puff Boy15-May-15 2:04 
GeneralRe: Code Puzzle Pin
Freak3015-May-15 2:11
Freak3015-May-15 2:11 
GeneralRe: Code Puzzle Pin
Richard Deeming15-May-15 3:59
mveRichard Deeming15-May-15 3:59 
GeneralRe: Code Puzzle Pin
Brisingr Aerowing15-May-15 4:02
professionalBrisingr Aerowing15-May-15 4:02 
GeneralRe: Code Puzzle Pin
Sascha Lefèvre15-May-15 4:12
professionalSascha Lefèvre15-May-15 4:12 
GeneralSOLUTION Pin
Sascha Lefèvre15-May-15 4:22
professionalSascha Lefèvre15-May-15 4:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.