views:

20

answers:

3

Our UI exposes user input as strings. All of them, including dates and numbers, are coming as strings. The question is: is it better to convert these to the appropriate type (datetime, int, etc) in the UI (and then pass converted var to the BLL methods), or in the BLL itself?

A: 

UI type conversion should be done in the UI layer, not the BL layer. This decouples the UI from the BL.

Ignacio Vazquez-Abrams
A: 

I prefer to do type casting in the UI and have the BLL expect the proper datatype.

Dustin Laine
+1  A: 

Input validation and conversion should be done on the UI layer.

Not only is this so your business layer is dealing with typed data, but also so that you can easily throw UI error messages if they enter the wrong type or if the value is outside your range*.

*Some frameworks have their own validation logic for this sort of thing... ASP.NET being the first I can think of.

R. Bemrose