Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

I'd seriously recommend looking into viewmodels. How the data is presented in the database isn't always how you'd want it presented in the UI.

A common example is prices - where it might be stored as an int or decimal in the DB. However, in the UI, you'd maybe want the currency symbol and digit grouping so:

$1,999 rather than 1999.

Adding this logic to the UI or model makes no sense - and with a viewmodel, the UI & model can be kept clean: the UI just serves up the data, the viewmodel only contains the data and logic required, and the model stores the initial representation of the data.

This pageThis page describes its use in ASP.NET MVC, but the general principles are sound.

I'd seriously recommend looking into viewmodels. How the data is presented in the database isn't always how you'd want it presented in the UI.

A common example is prices - where it might be stored as an int or decimal in the DB. However, in the UI, you'd maybe want the currency symbol and digit grouping so:

$1,999 rather than 1999.

Adding this logic to the UI or model makes no sense - and with a viewmodel, the UI & model can be kept clean: the UI just serves up the data, the viewmodel only contains the data and logic required, and the model stores the initial representation of the data.

This page describes its use in ASP.NET MVC, but the general principles are sound.

I'd seriously recommend looking into viewmodels. How the data is presented in the database isn't always how you'd want it presented in the UI.

A common example is prices - where it might be stored as an int or decimal in the DB. However, in the UI, you'd maybe want the currency symbol and digit grouping so:

$1,999 rather than 1999.

Adding this logic to the UI or model makes no sense - and with a viewmodel, the UI & model can be kept clean: the UI just serves up the data, the viewmodel only contains the data and logic required, and the model stores the initial representation of the data.

This page describes its use in ASP.NET MVC, but the general principles are sound.

added 58 characters in body
Source Link
Robbie Dee
  • 9.8k
  • 2
  • 26
  • 54

I'd seriously recommend looking into viewmodelviewmodels. How the data is presented in the database isn't always how you'd want it presented in the UI.

A common example is prices - where it might be stored as an int or decimal in the DB. However, in the UI, you'd maybe want the currency symbol and digit grouping so:

$1,999 rather than 1999.

Adding this logic to the UI or model makes no sense - and with a view modelviewmodel, the UI & model can be kept clean: the UI just serves up the data, the viewmodel only contains the data and logic required, and the model stores the initial representation of the data.

This page describes its use in ASP.NET MVC, but the general principles are sound.

I'd seriously recommend looking into viewmodel. How the data is presented in the database isn't always how you'd want it presented in the UI.

A common example is prices - where it might be stored as an int or decimal in the DB. However, in the UI, you'd maybe want the currency symbol and digit grouping so:

$1,999 rather than 1999.

Adding this logic to the UI or model makes no sense - and with a view model, the UI & model can be kept clean: the UI just serves up the data and the model stores the initial representation of the data.

This page describes its use in ASP.NET MVC, but the general principles are sound.

I'd seriously recommend looking into viewmodels. How the data is presented in the database isn't always how you'd want it presented in the UI.

A common example is prices - where it might be stored as an int or decimal in the DB. However, in the UI, you'd maybe want the currency symbol and digit grouping so:

$1,999 rather than 1999.

Adding this logic to the UI or model makes no sense - and with a viewmodel, the UI & model can be kept clean: the UI just serves up the data, the viewmodel only contains the data and logic required, and the model stores the initial representation of the data.

This page describes its use in ASP.NET MVC, but the general principles are sound.

Source Link
Robbie Dee
  • 9.8k
  • 2
  • 26
  • 54

I'd seriously recommend looking into viewmodel. How the data is presented in the database isn't always how you'd want it presented in the UI.

A common example is prices - where it might be stored as an int or decimal in the DB. However, in the UI, you'd maybe want the currency symbol and digit grouping so:

$1,999 rather than 1999.

Adding this logic to the UI or model makes no sense - and with a view model, the UI & model can be kept clean: the UI just serves up the data and the model stores the initial representation of the data.

This page describes its use in ASP.NET MVC, but the general principles are sound.