Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9045567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:22:19+00:00 2026-06-16T11:22:19+00:00

In the Model View Controller pattern where should data transformation occur? I have a

  • 0

In the Model View Controller pattern where should data transformation occur?

I have a Model that stores very specific mathematical data. I need to convert that data for a physics simulator(that only accepts data in a certain format) and I’m wondering where the code for that should sit? In general where do you place code that transforms one Model into another type of Model?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T11:22:21+00:00Added an answer on June 16, 2026 at 11:22 am

    Personally, I like to put this code in the constructor of the derived type of model. In this way, the code that does the conversion is in the class that needs to use it. I find this way of organizing the code makes it easier to understand, test and maintain.

    Using your example, say you have a class as follows (you did not mention what language you were using, so I’ll give the code below in C#, but it is very similar in java):

    public class MathematicalData
    {
         //members of class
    }
    

    Let’s say you need to take the members of an instance of MathematicalData and transform them into another class named PhysicsSimulator. I would require the constructor to PhysicsSimulator to take an instance of MathematicalData as an input parameter, and then populate the members of PhysicsSimulator in this contructor:

    public class PhysicsSimulator
    {
        //constructor
        public PhysicsSimulator(MathematicalData input)
        {
            //put code here to use the members of input to populate members of this instance of PhysicsSimulator
        }
    }
    

    If the only way you want to create an instace of PhysicsSimulator is by using an instance of MathematicalData, then I would not create a default constructor for PhysicsSimulator. In this way, the only way to create a PhysicsSimulator would be to pass in a MathematicalData instance.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Java project that I'm trying to implement with a model-view-controller design.
According to the Model-View-Controller pattern, applied heavily in Cocoa Touch, UIViewControllers should always handle
I have a C++ application designed according to a classic Model-View-Controller pattern . The
I often see very different implementations of the Model View Controller Pattern, and completely
I'm building an application using the Supervising Controller pattern (Model View Presenter) and I
I have a model, view and controller not interacting correctly, and I do not
I am trying to use the Model-View-Controller pattern in a small application. The model
I'm looking for patterns and principles for using with WPF and NHibernate in model-view-controller
What's the pros and cons of using a Model-View-Controller model in building your application?
Is it just me or is MVC really Model-View/Controller-View View-Model/Controller-Model with two distinct controllers?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.