-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
global.R, server.R, and ui.R need to be refactored for correctness and readability #1
Comments
This is just an example of what can be improved in server. |
The mainPanel is now broken up into visualizer and simulator ui objects. Height and width arguments are removed from the various image and plot outputs to simplify the ui code, and to transfer responsibility of the sizing of elements to CSS. Data assimilation UI inputs are now defined in UI. Helpers added to more elements. Compartment-influencing parameters are now defined in UI. More ui elements are defined in the UI file rather than server; the whitespace and arguments are cleaned up, and some objects are rearranged for clarity and intention. The quotation marks in the ramp object in global.R are now double quotes, per R-programming conventions (single quotes are valid, but unpopular). Concatenated the "appCSS" object; there were three different CSS rules assigned one after the other to the same object, but only the latest would be used. An "acceptedFileTypes" global variable is introduced to be used anywhere a data upload is used in the UI or server. The "updateNumericInputs" function is borrowed from episim to simplify how default input widget values are defined and set. Commentary changes and whitespace changes. Objects related to the non-spatial application mode are removed from server.R, e.g. input validators. Observable for the go button is made into a single line. Terra output image code is cleaned up. Commented on the Level1Country reactive value to ensure that I inspect this spaghetti code closer. Much unnecessary commentary is removed. UI input widget outputs are removed in most cases, and defined in the UI file (as they should've been from the start; fix #1). Input widgets for uploaded observed-data assimilation are defined programmatically. Recommended aggregation factor reactive introduced to simplify other code. "Main" functionality triggered when go button is clicked is cleaned up and improved for readability and correctness. "include/authors.md" added to simplify some UI code. There's no reason for it to be defined in the UI file, really. "misc/epiparms.xlsx" updated to ensure column names are input widget ids to permit updatedNumericInputs to work correctly.
To justify this issue being an example I am labelling it duplicate of the less specific #32 which represents the needed work to refactor the entire application architecture and implementation. |
lambdaValue
lambdaValue
lambdaValue
I removed the duplicate label and renamed the issue to make it clearer that this issue was originally opened to track the refactoring of the server and UI code. At the time I opened this issue I was unaware that the contents of the R/ sub-folder would need to be refactored as well, so this issue tracks a separate but linked refactoring. The server code will take advantage of the functionality provided by the functions defined in one or more files in the R/ sub-folder, so this issue is related to the refactoring occurring in #32 in that way and they will be closed at the same time when the unstable branch is merged in to main. |
As of todayBefore
After
|
GlobalGlobal needed to be cleaned up, so that the libraries that were loaded were only those that are actually used in the application and all of its dependencies. Files below the R/ folder, of course, should not be responsible for loading their own dependencies; it is difficult to track and maintain the files when that is done. It makes it difficult to study too. The meat and potatoes of the application---its foundational SVEIRD simulation feature---is now documented and refactored in the package spatialEpisim.foundation. This will be hosted in a drat repository, and can then be installed quite easily by users (similarly to ExcerptLines 1 to 42 in f5a7913
|
UIThe user interface, of course, was messy and has been rewritten. Things which were in server.R and didn't need to be, either because they could be refactored to not need to be, or just didn't belong there at all in any case, were moved to UI were they belonged. |
ServerSee the previous comment. Code which was written by chat bots, or which didn't perform the documented action have been rewritten for clarity and maintainability. |
The server and UI code is chaotic and not written in a clear style using the syntax of R to its fullest. The server and UI code needs to be refactored so that it is more maintainable after I leave the project.
spatialEpisim/server.R
Lines 846 to 865 in df70041
If the names of the countries are added as a new column to the epiparms data file, these lines can be simplified to the following pipeline.
The text was updated successfully, but these errors were encountered: