Results 1 to 2 of 2
- 04-29-2012, 10:47 PM #1
Member
- Join Date
- Apr 2012
- Posts
- 12
- Rep Power
- 0
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.
- 04-30-2012, 12:12 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 13,541
- Rep Power
- 27
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
-
List models awesome usage -.-''
By claudiocarcaci in forum AWT / SwingReplies: 4Last Post: 12-22-2011, 09:40 PM -
implement mobility models with jist/swans
By yran in forum NetworkingReplies: 1Last Post: 04-04-2010, 05:48 PM -
Java Swing Tables ( JTable Models ) to connect to Database using Table Models
By javaprogrammerishere in forum AWT / SwingReplies: 2Last Post: 01-27-2010, 09:28 AM -
Make multiple JTextFields focus at the same time.
By toymachiner62 in forum AWT / SwingReplies: 6Last Post: 10-09-2009, 03:59 AM -
Testing EMF models.
By manik_jforum in forum EclipseReplies: 0Last Post: 12-10-2008, 09:59 AM
Bookmarks