convert of the object (image) to another object (B

2019-08-01 10:12发布

问题:

Conversions can be done in the first layer ( UI ) ?

回答1:

For these kind of operations I personally create a Utils class/namespace under project namespace (myProjectNamespace.Utils). A ststic class with public static members for conversions, formatting, calculations...

Put this class in BLL (Business Logic Layer) most of the time but sometimes you need different Utils for different layers.



回答2:

Assuming an image is an input - inputs usually come into a system through:

  • The frontend interface / UI.
  • A backend interface (service).
  • An API call.

If the input is specific to - say the UI - then that would suggest it was a UI specific thing and should sit there.

The same rule / principle applies for the other input 'channels'.

if the API being called is in the BL then that's where it might sit.

Where Yousefvand is coming from (and which I agree with) is that if more than one component is using it then it's probably be a good candidate for putting in some osrt of reusable library.

So...

Conversions can be done in the first layer ( UI ) ?

Yes if the what you're converting is specific to the UI / UI technology being used; otherwise you could but probably shouldn't - in this case you'd probably be better implementing your converter in a utility.