Results 1 to 2 of 2
  1. #1
    AWJustAGuy is offline Member
    Join Date
    Apr 2012
    Rep Power

    Default Multiple Models in an MVC? How should I make them?

    I'm wondering the correct way to deal with an Array of models. My models are basically accounts, with a name, id, and balance. I need to make as many of them as are in a file that I have.

    What I originally did was just create a (Model[] models) in my controller and did the file input in the controller, just directly creating all the models there and then sending them around to the various view and other functions. This sticks-and-glue method worked, and I completed the program, but now I'm trying to re-use it with expanded functions and my little card castle of hope has crashed down and I need to redo the structure.

    Do I create an AddAccount method in the model class to read in one line from a file? How do I keep all my models together? I am so confused about this that I can't even really ask a proper question about it.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Rep Power

    Default Re: Multiple Models in an MVC? How should I make them?

    I think you may have confused your terminology somewhere.
    Your code has a model.
    It may have many parts, and there may be many instances of those parts (eg your Accounts), but it just a model.

    Having a class called 'Model' seems wrong. If it's an account, then it should be called Account.

    In any case, your model should not care particularly where the data for it comes from.
    That's part of the Controllers job.
    Part of the Controller will be for reading in your model and manipulating it.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. List models awesome usage -.-''
    By claudiocarcaci in forum AWT / Swing
    Replies: 4
    Last Post: 12-22-2011, 09:40 PM
  2. implement mobility models with jist/swans
    By yran in forum Networking
    Replies: 1
    Last Post: 04-04-2010, 05:48 PM
  3. Replies: 2
    Last Post: 01-27-2010, 09:28 AM
  4. Make multiple JTextFields focus at the same time.
    By toymachiner62 in forum AWT / Swing
    Replies: 6
    Last Post: 10-09-2009, 03:59 AM
  5. Testing EMF models.
    By manik_jforum in forum Eclipse
    Replies: 0
    Last Post: 12-10-2008, 09:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts