views:

77

answers:

2

Hi Everyone,

I awake this morning to a problem!

In all of my components, I have a set of Business Rules which are used to validate DTOs before any changes are committed to the repository.

I've been trying to figure out the best way to get validation errors back to the UI and I came across the IDataErrorInfo interface. Fantastic!

However, The implementation of this interface would transform my DTO into a POCO and make it a larger object in terms of memory usage. At the moment, all of the user controls are bound to the current DTO objects.

Would transforming my DTOs into POCOs have a performance impact? Or is there a better way to get validation messages back to the UI?

A: 

MVVM. i.e. yours DTOs are wrapped in view models, which are bound to your view.

HTH,
Kent

Kent Boogaart
A: 

I've been trying to figure out the best way to get validation errors back to the UI and I came across the IDataErrorInfo interface. Fantastic!

Absolutely. How comes you do not know what you are doing in the first place? IDataErrorInfo is fully documented - not something you should "coming across" (which sounds accidentally).

The implementation of this interface would transform my DTO into a POCO and make it a larger object in terms of memory usage. At the moment, all of the user controls are bound to the current DTO objects.

A DTO has absolutely no business knowing aboutinternal errors - it should not never ever HAVE internal errors. See, DTO is "Data Transfer Object", not "Business Object". The DTO is what the Business object should generate to send it to the DataAccessLayer, and the reason there should not be validation is taht the Business Object makes sure ONLY VALID OBJECTS CREATE DTO's.

Btw.,

would transform my DTO into a POCO

I have another surprise discovery for you - your DTO already IS A POCO. POCO is "Plain Old CLR Object", and I guess the your DTO are established as .NET classes, so - guess what, surprise, they already ARE POCO.

What you mean (again something to discover) is that it would transform your DTO's into BO's.

Or is there a better way to get validation messages back to the UI?

No, there is not. The best way to send messages up to the UI is by UI defined interfaces, and IDataErrorInfo is that.

Your problem is that you have a hugh confusion about:

  • How to program a multi tiered architecture and build a standard data access layer
  • Dont know anything about the terms you use (see your problem knowing what a DTO actually is, and what POCO is).
  • Thus mix up your responsibilities.

See the answers at http://stackoverflow.com/questions/725348/poco-vs-dto for an explanation of what you actually mix up.

Back o the drawing board. As your lead developer / Architect to give you an introduction into multi tiered architectures and read the .NET documentation.

The DTO should noly deal with DataTransfer issues.

TomTom
All valid points. I've marked this answer as correct based on the point's you've made. Try not to be such an abrasive dickwad next time.
Jason Summers