- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Thanks for the advice, but the proper way to accomplish this in .Net would be to deploy a publisher policy assembly to the GAC along with the updated rule validator. This publisher policy assembly would contain redirection rules to tell the class loader that version 1.1.2.3 can safely be replaced by version 1.2.1.4. This way, we can still have hotswappability, without the risk of breaking the running code when updating to NotNullRule 1.4 which is not backwards compatible.
As for the public key token, I wouldn't risk removing it, otherwise a malicious user who has access to the configuration file and the executable files may be able to inject a FileNotFoundRule into the validation rules, thus turning any perfectly valid occurrences of "FileNotFound" into rejected data.
Admin
Actually some time ago I had in my mind a "Validation Framework". In fact I implemented it using annotations I would put on my model classes like @NotNull or @MaxLength(5) above a String. But a few days after it was done I discovered that I had just been busy reinventing the wheel, because there was already something similar, which is called Oval (http://oval.sourceforge.net/) and is related to "AOP" (aspect oriented programming)...
Funny thing is that I never used my "framework" or Oval in any application i've worked on since then, wonder why...
Admin
No. Native speakers of any language do not make errors in that language. It's not possible.
Admin
I'm sorry, but you're all wrong. Here is the corrected text:
Admin
Admin
This is not a WTF.
Admin
Yeah, i dont feel that this is a candidate for a WTF wrt to architecture atleast.. being slightly less efficient, doesnt automatically make it a WTF. anyways.. how is this for a better implementation :)
Havent checked the code for syntax errors, but you get the picture.. isnt this better? or do i need to visit the "Architects Anonymous" too?
Admin
Admin
It isn't a WTF - it's another hamcrest.
http://code.google.com/p/hamcrest/
Admin
Ok, I agree with you here, if its used as part of a given design pattern (E.g. Chain of Responsibility) then I really don't see a problem. If this is part of a parser where you are adding given validation rules then it seems like an acceptable design.
Admin
I don't see a WTF either. Sometimes, there is more to a rule definition than just checking a value once. Especially field states for mandatory, optional, forbidden, readonly and hidden fields are information you need more often.
So if you have a collection of rules regarding a certain field, these rules can be interpreted by a GUI to display different field colours, block input etc. The execution of the rule could be timed by a keystroke or an independent timer which just processes abstract rule collections for a field, and the rule set created by adding lots of rules could be recycled for different purposes (DB import, GUI, JUnit tests etc.)
Additionally, you have on code segment creating rule definitions, even if these rules are executed in different places. You have not a undefined cloud of business decisions strewn out through numerous classes.
Calling an architect is a good idea, but one should know what architecture is for in the first place.
Admin
I have been going through some relatively old code of mine while pair programming with other guys and sometimes it has been awkward to just seat there looking at some of my wtfs and trying to figure out what I was thinking, and come up with some kind of reasonable explanation for it. If you find it by yourself you just laugh at it and whatever but then seating there, realizing this can probably go to codesod and thinking that they probably are thinking the same thing, well that is just priceless.
Admin
The one time this kind of thing could be necessary is if you are creating a chain of validators; your base class of validator would simply be class ValidateBase { public abstract boolean isValid(String text){} }
or some such. You would then have classes such as ValidateNumerical ValidateNotEmpty ValidateNotContainingStarTrekTrivia
You then create an array of instances of validators and run each value through the chain.
Theoretically, ValidateNotNull could be one such validator.
Admin
TRWTF is that I'd bet a lunch that addRule() actually checks the rule when it's called.
It takes a new Rule object, it doesn't return anything, and he doesn't pass it a pointer to a list that the new Rule should be added to - so what happens to the Rule you created?
I'm betting that it just checks the rule and then chucks it into the bitbucket.
The alternatives are even worse: a static list of rules which addRule() updates a global list of rules which addRule() updates an XML file of rules that addRule() updates a relational database of rules that addRule() updates a flat file which addRule() appends the serialized Rule object ...I think I'll stop coming up with these ideas now.
I hope it just checks the rule.