God x jQuery Mobile class

Asked

Viewed 56 times

2

I have always been interested in studying methodologies in relation to programming and I have heard many professors mainly in the universities speaking badly of the famous Gods classes, who do everything within it. And now I have a question that I find interesting. Reading some articles about jQuery Mobile (knowing that an html page is not a class) that is very encouraged to create all your screens separated by divs what depended can leave your file immense and worse if we put our js together. It would no longer be right to split jQuery Mobile screens by html pages?

1 answer

1

The problem with the analogy

The analogy between a class with a screen that uses HTML structure cannot be made from 1 to 1.

By dividing responsibilities between classes and methods you have a overhead processing and memory, but it is much smaller compared to having two pages in different files.

In addition, the idea of dividing responsibilities involves logical issues, coupling, maintenance and reuse.

In the case of an HTML structure as proposed by jQuery Mobile, although it is bad to work on a large file, there is effectively a mix between the various sections.

Javascript could, yes, end up mixing some things, but at this point it is worth the programmer’s competence to know how to create specific snippets for each screen.

Note that even with splitting Htmls into multiple files, it would still be possible to add the same script on all screens and there is confusion. In fact, this is a very common practice.

Depends on the context

The complexity of an application and its respective optimization make it an absolutely "better" way to join or share responsibilities.

To avoid complexity of development and maintenance the best would be to split into several Htmls. This would avoid unnecessary conflicts during the merges and simplifies developer life in many ways. It also occupies less memory on the device. Seems to be better for apps that have plenty of content.

Already having an HTML can improve the user experience as browsing between pages will be instantaneous. Of course this can have a negative effect if the user wants to see only one page. This seems to be the best solution for relatively small applications where overall simplicity speaks louder.

Considerations

jQuery Mobile allows different and mixed approaches.

In the documentation on pages, there is information on how to do single page template (one page per HTML) and multi-page template (multiple pages in an HTML).

It also says that using these structures are conventions, not an obligation. There is even a topic entitled Prefetching pages which explains how to pre-load multiple pages when using single page templates.

A more advantageous mixed solution would be to have multiple Htmls, but group related screens in each.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.