In a web application, is it ok to group multiple pages in one view class or one class per page?

If you are building a web application, and you have a user management component, is it recommended to do:

class UserAdminView extends View {

}

or

class UserAdminUpdateView extends View {

}

What about controllers? Thoughts?

0

It will depend on which web-development design pattern your team is set to go/follow.

For example: in MVC design patter, each view it is recommended to have a dedicated view-model. While your models are the constructs that serve as a data containers, it is not recommend expose them directly as view-models. Thus, depending on view requirement, a custom view-model is build from a single or multiple models.

Important productivity tip: for a convention-based object-object mapper always try to look fr tools like AutoMapper. It will save tons of time during the development.

If you want to do it MVC style, I personally most of the time have different views for different actions. In some cases, when the content for show / edit / save / list or whatever I had there was very similar I used only one view. But rarely.

As for the Controller, there should be one controller with different methods for the different actions.

As for Model. I consider models kind of redundant. I use them only to validate forms and only because they integrate with the framework.

Business logic should be outside the MVC framework, which I consider only a delivery mechanism to the application.

PS: I know many web developers will not agree with my last statement. Don’t flame, think. Thanks.

4

I think that the first approach “class UserAdminView extends View” is better. UpdateView fits better as an method of class a than an actual class.

If you want UserAdminUpdateView to be inheriting from a class than the superclass should be an UserAdmin class not a view class.

Taking a look at a popular MVC framework such as Codeigniter for PHP or even the structure of Play Framework (java) should help.

For example in both cases the idea of a view is that it seperates the coding from the templating (gui). Creating an individual view as its own class confuses this as a front end developer shouldn’t be using code. It would be more beneficial to create a view class which effectively allows you to load HTML based templates and pass your data to them. For example:

class userAdmin extends Controller {

  public void view() {
    data = userAdminModel->getView();
    view_html->('header');
    view_html->('userAdmin.view',data);
    view_html->('footer');
  }

  public void updateView() {
    success = userAdminModel->updateView(...);
    view_html->('header');
    view_html->('userAdmin.updateView',success);
    view_html->('footer');
  }
}

The controller invokes the method based on the users action. This method performs any business logic requesting any persistent data from the database using the model. The data is then passed into the view which is effectively a templating engine which has rudimentary scripting to iterate through such data.

The brilliance of the MVC model is that a developer can create the logic that passes the expected data to the view. A HTML/CSS developer (for example) with limited coding skills can then create the front end which uses variables passed in without any concern over how the data is generated and has been manipulated.

The model allows you to access the data within the controller in a standardised way without worrying how that data is stored.

I would suggest googling MVC for a more indepth look.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật