Question

I am creating a program using MVC pattern in java... However Im very confused on how to properly perform file input.

For example, should I perform all file input in MAIN? ..I tried but its getting messy, and Im not sure if there is a "uniform" way of performing file input for MVC pattern. This is for an OOP assignment btw. Thank you.

Was it helpful?

Solution

For a theoretical question, the answer would be theoretical.

MVC means Model View Controller

Model - Model represents the layer that is closely related to data. Say if you want to persist a Employee object, you have a Employee POJO carrying the Employee data.

View - View represents the visualization of the data that model contains.

Controller - Controller acts on both Model and view. It controls the data flow into model object and updates the view whenever data changes. It keeps View and Model separate.

In your case, File Input process - what do you mean by that? A File is send as input and you need to persist the file in your database?

This is not a good use case for showing MVC pattern. yet..for your understanding

View - you can have a File Upload page

Controller - The class that route the control from view to a Java class that performs File Read, and performs business logic on the input file

Model - A class that has database connection setup, and has a method that accepts the final formatted File and store to the database.

More experienced folks, correct me if you feel that way

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top