Skip to content
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

Clean up code #34

Open
2 of 8 tasks
hyperrealgopher opened this issue Mar 8, 2020 · 5 comments · Fixed by #80 or #98
Open
2 of 8 tasks

Clean up code #34

hyperrealgopher opened this issue Mar 8, 2020 · 5 comments · Fixed by #80 or #98

Comments

@hyperrealgopher
Copy link
Collaborator

hyperrealgopher commented Mar 8, 2020

  • Safety
  • Put each mode's event handler in their own module
  • Clean comments, including moving TODOs and FIXMEs to issues and their details
  • Document
  • Modularize better so more stuff is moved out of UI
  • Modularize better; put thing in their own modules appropriately and submodules etc
  • Better imports
  • Better exporting+module documentation (specifically import certain things!)
@hyperrealgopher hyperrealgopher added this to the v0.1.0 milestone Mar 8, 2020
@hyperrealgopher hyperrealgopher modified the milestones: v0.1.0, v1.0.0 Apr 10, 2020
@hyperrealgopher
Copy link
Collaborator Author

A lot of stuff could make better use of higher order functions. Something which comes to mind are stuff like progress module and the stuff like searchGet and gopherGet, etc.

@hyperrealgopher
Copy link
Collaborator Author

The history items in progress.hs should go in their own module. They're currently in there because of a circular import problem.

@hyperrealgopher hyperrealgopher modified the milestones: v1.0.0, v0.2.0 Apr 24, 2020
@hyperrealgopher
Copy link
Collaborator Author

hyperrealgopher commented Apr 24, 2020

Some of @Garmelon's suggestions:

  • Explicit exports.
    module Bla (foo, bar) where. This way:

    • you can control what is exported and in which order (useful for documentation)
    • you can easily add haddock headings in order to organize your documentation better
    • the compiler can warn you of unused code/functions (functions that are never used and never exported)
  • Switch to using Data.Text instead of String
    If only to learn about how it works. Data.Text usually has better performance than String's linked-list-of-characters approach. It also has a few common string manipulation functions that String is kinda missing. Some people argue for Text to replace String entirely.

  • Rename GopherClient to Gopher
    Use the module only to model the gopher protocol side of things. Leave out functions that don't use that protocol representation (such as gopherGet; NOTE: I'm guessing I should have a Network.hs). As a rule of thumb: No IO required. Also make sure there are no partial functions (different than partially applied) and you don't use error or undefined anywhere (don't use them in other modules either, if at all possible).
    Programming is pretty much all about manipulating data. Having a good representation for the data helps a lot. I'd say this becomes even more obvious in Haskell, since here you have better ways to represent your data out-of-the-box than in languages like Java or Python. When in doubt, roll your own types instead of using Either (Either already treats its left and right arguments differently due to its various instances. Left is usually used to hold some sort of error, while Right is used to hold a successful result).

  • Separate the UI into different widgets that only need to know their own state.
    This is where I'd need to know more about the UI and its different interactions: Try to separate the UI into different widgets that only need to know their own state. They should not need to know any sort of global state (GBS) nor rely on a common resource name type. You can use the way brick widgets are structured and structure your own widgets after those.

  • Design an application state and application using the widgets from the previous step. This application module should use the widgets, not the other way around. Try to keep features general and loosely coupled. Extract things into modules wherever it makes sense.
    A single client feature (like the history) does not necessarily need to be confined to a single module. For example, I could imagine one module that lets you store a history of states of any type, and a history widget that can display some of the data types from the history module.

@hyperrealgopher hyperrealgopher modified the milestones: v0.2.0, v0.1.0 Apr 24, 2020
@hyperrealgopher hyperrealgopher pinned this issue Apr 24, 2020
@hyperrealgopher hyperrealgopher linked a pull request Apr 24, 2020 that will close this issue
@hyperrealgopher
Copy link
Collaborator Author

Maybe even start UI/Modes/*.hs?

@hyperrealgopher hyperrealgopher modified the milestones: v0.1.0, v0.2.0, v0.3.0, v0.4.0 May 3, 2020
@hyperrealgopher hyperrealgopher modified the milestones: v0.5.0, v0.4.0: Cleaning May 17, 2020
@hyperrealgopher
Copy link
Collaborator Author

you're supposed to keep widgets in app state and manipulate things from there! that's much more efficient than rebuilding every dang time

@hyperrealgopher hyperrealgopher linked a pull request May 23, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant