Suppose I have Three Components first one is Photographer,Second one is Camera and Finally last one is Photo. Now how can we tell the model, view controller from these.
Loading
Suppose I have Three Components first one is Photographer,Second one is Camera and Finally last one is Photo. Now how can we tell the model, view controller from these.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Deepak RawatRank #646 · 3.7K reputationPosted Jun 27, 2023, 6:49 AM EDT
Sure! Let's use a real scenario of a blog application to illustrate the Model-View-Controller (MVC) architecture.
Post: Represents a blog post, with properties like title, content, author, and date.User: Represents a user of the blog, with properties like username, email, and password.Comment: Represents a comment on a blog post, with properties like content, author, and date.The Model classes would also contain methods for performing operations related to the data, such as saving a new post, retrieving a list of posts, updating user information, etc.
HomePage: Displays a list of recent blog posts.PostPage: Displays a single blog post along with its comments.UserRegistrationPage: Displays a form for users to register an account.CommentForm: Displays a form for users to add comments on a blog post.The View components are typically implemented using HTML, CSS, and a templating engine like Razor in ASP.NET.
PostController: Handles operations related to blog posts, such as creating a new post, retrieving a post by ID, and handling comments on a post.UserController: Manages user-related operations, such as user registration, login, and updating user information.The Controller classes receive requests from the View, interact with the Model to perform the necessary operations, and then pass the updated data back to the View for presentation.
Here's an example of how the flow could work in this scenario:
PostController.PostControllerinteracts with thePostModel to retrieve the list of posts.PostControllerpasses the list of posts back to the homepage (View).PostController.PostControllerinteracts with thePostModel to retrieve the requested post and its associated comments.PostControllerpasses the post and comments back to the post page (View).This is just a basic overview of how the Model, View, and Controller can be categorized in an MVC architecture. In a real application, there would be more complexities and interactions between these components, but this example should give you a general idea of how they work together to create a structured and maintainable application.
Rajeev KumarRank #1,334 · 1.3K reputationPosted Jun 27, 2023, 6:59 AM EDT
I am asking about this- Suppose I have Three Components first one is Photographer,Second one is Camera and Finally last one is Photo. Now how can we tell the model, view controller from these.
Amit MohantyRank #112 · 20K reputationPosted Jun 27, 2023, 7:43 AM EDT
Model: Photo (data and business logic)
View: Photographer (UI, interaction with the user)
Controller: Camera (mediates between the View and the Model)