A good class structure for cleaning and using input?

Posted by ciscoheat on Stack Overflow See other posts from Stack Overflow or by ciscoheat
Published on 2010-05-23T11:46:38Z Indexed on 2010/05/23 11:50 UTC
Read the original article Hit count: 228

Filed under:
|

I want to be helpful to the users of a system, so I'll clean up the input a bit before testing if it can be used. So I have a flow like this:

  1. Input: aa12345b
  2. Clean input somehow: 12345
  3. Test if clean input is valid
  4. Use input if valid

Now I want to do this in a beautiful OO-fashion (IoC, interfaces, testable, no statics, you know). Any ideas how to organize a class structure for this? Is it good to have a Cleaner and a Parser/Validator class separately, or put them as methods in the data class itself? Thanks for any help or discussion about this, and extra thanks if the answer is in C#!

© Stack Overflow or respective owner

Related posts about c#

Related posts about input-validation