[server] Improve readability of project description

This commit is contained in:
Joscha 2020-02-11 18:04:07 +00:00
parent 7709fc92a9
commit d5d0fccdaf
3 changed files with 81 additions and 43 deletions

View file

@ -7,7 +7,7 @@ module Forest.Node
NodeId NodeId
, Node(..) , Node(..)
, newNode , newNode
, emptyNode , txtNode
, hasChildren , hasChildren
, mapChildren , mapChildren
, applyId , applyId
@ -66,8 +66,8 @@ newNode flags text children =
pairedChildren = zip (map formatId [0..]) children pairedChildren = zip (map formatId [0..]) children
in Node text edit delete reply act $ Map.fromList pairedChildren in Node text edit delete reply act $ Map.fromList pairedChildren
emptyNode :: String -> T.Text -> Node txtNode :: String -> T.Text -> Node
emptyNode flags text = newNode flags text [] txtNode flags text = newNode flags text []
hasChildren :: Node -> Bool hasChildren :: Node -> Bool
hasChildren = not . Map.null . nodeChildren hasChildren = not . Map.null . nodeChildren

View file

@ -58,4 +58,4 @@ serverApp pingDelay constructor pendingConnection = do
constructor (writeChan chan) $ receivePackets conn constructor (writeChan chan) $ receivePackets conn
_ -> closeWithErrorMessage conn "Invalid packet: Expected a hello packet" _ -> closeWithErrorMessage conn "Invalid packet: Expected a hello packet"
where where
initialNode = emptyNode "" "Loading ..." initialNode = txtNode "" "Loading ..."

View file

@ -24,59 +24,97 @@ constModule node sendNode continue = do
projectDescriptionNode :: Node projectDescriptionNode :: Node
projectDescriptionNode = projectDescriptionNode =
newNode "" "About" newNode "" "About"
[ newNode "" "This project is an experiment in tree-based interaction." [] [ txtNode "" "This project is an experiment in tree-based interaction."
, newNode "" "Motivation" , newNode "" "Motivation"
[ newNode "" "My goals for this project were:" [] [ txtNode "" "My goals for this project were:"
, newNode "" "Interactons between multiple people" , newNode "" "Interactons between multiple people"
[ newNode "" "I wanted to create a project that let multiple people interact with each other in different ways." [] [ txtNode ""
, newNode "" "Examples for interactions include:" [] ( "I wanted to create a project that let multiple people interact with "
, newNode "" "Chatting" [] <> "each other in different ways. Examples for interactions include:\n"
, newNode "" "Collaborative editing" [] <> "* Chatting\n"
, newNode "" "Playing (multiplayer) games" [] <> "* Collaborative editing\n"
, newNode "" "The project should allow for many different kinds of interactions." [] <> "* Playing (multiplayer) games\n"
)
, txtNode "" "The project should allow for many different kinds of interactions."
] ]
, newNode "" "Portability" , newNode "" "Portability"
[ newNode "" "The project should be usable on multiple different platforms." [] [ txtNode ""
, newNode "" "To facilitate this, clients should be easy to create." [] ( "The project should be usable on multiple different platforms. To "
, newNode "" "In particular, I wanted at least one terminal-based and one web-based client." [] <> "facilitate this, clients should be easy to create. In particular, I "
<> "want at least one terminal-based and one web-based client."
)
] ]
, newNode "" "Based on these goals, I made the following design decisions:" [] , txtNode "" "Based on these goals, I made the following design decisions:"
, newNode "" "Text-based" , newNode "" "Text-based"
[ newNode "" "Text is the one medium that works on all platforms." [] [ txtNode ""
, newNode "" "Text is also easy to work with as a programmer." [] ( "Text is a medium that works on all platforms and easy to work with "
, newNode "" "Finally, text still allows for a lot of different interactions." [] <> "as a developer."
, newNode "" "Of all the kinds of media one can produce with a computer, text is easy and quick to create." [] )
, newNode "" "After all, pretty much every computer has a keyboard." [] , txtNode ""
( "But text still allows for a lot of different interactions. Of all "
<> "the kinds of media one can produce with a computer, text is easy "
<> "and quick to create. After all, pretty much every computer has a "
<> "keyboard."
)
] ]
, newNode "" "Tree-based" , newNode "" "Tree-based"
[ newNode "" "While plain text may be easy to work with, it makes interactions cumbersome if limited to basic input and output." [] [ txtNode ""
, newNode "" "To make interactions nicer, the server could send the client a screen's worth of text to display, in effect creating a TUI-like interface." [] ( "While plain text may be easy to work with, it makes interactions "
, newNode "" "The client would then only need to send key presses or mouse clicks to the server." [] <> "cumbersome if limited to basic input and output. To make "
, newNode "" "In my opinion, that approach moves too many decisions on how to interact to the server and imposes unnecessary limits on the client design." [] <> "interactions nicer, the server could send the client a screen's "
, newNode "" "Instead, I went with a plaintext-in-tree-structure approach, which allows for more flexibility in the client design." [] <> "worth of text to display, in effect creating a TUI-like interface. "
, newNode "" "Also, this might make bots easier to write, since they don't have to emulate human input." [] <> "The client would then only need to send key presses or mouse clicks "
<> "to the server."
)
, txtNode ""
( "In my opinion, that approach moves too many decisions on how to "
<> "interact to the server and imposes unnecessary limits on the client "
<> "design. Instead, I went with a plaintext-in-tree-structure "
<> "approach, which allows for more flexibility in the client design. "
<> "Also, this should make bots easier to write, since they don't have "
<> "to emulate human input."
)
] ]
, newNode "" "Simple API" , newNode "" "Simple API"
[ newNode "" "Every client must use the same API to interact with the server." [] [ txtNode ""
, newNode "" "Because clients should be easy to create on different platforms, the API should also be simple." [] ( "Every client must use the same API to interact with the server. "
, newNode "" "One way in which the API is simple is that the server doesn't send direct responses to client commands." [] <> "Because clients should be easy to create on different platforms, "
, newNode "" "Instead, there is only the 'update' packet, which is sent whenever the client should modify its tree structure." [] <> "the API should also be simple."
, newNode "" "In total, there are 5 different client packages and 2 different server packages." [] )
, newNode "" "If at some point the API turns out to be too simple, it has a built-in way of negotiating protocol extensions." [] , txtNode ""
( "One way in which the API is simple is that the server doesn't send "
<> "direct responses to client commands. Instead, there is only the "
<> "'update' packet, which is sent whenever the client should modify "
<> "its tree structure."
)
, txtNode ""
( "In total, there are 5 different client packages and 2 different "
<> "server packages. If at some point the API turns out to be too "
<> "simple, it has a built-in way of negotiating protocol extensions."
)
] ]
, newNode "" "Most logic in server" , newNode "" "Most logic in server"
[ newNode "" "All logic besides the immediate input handling and tree folding happens in the server." [] [ txtNode ""
, newNode "" "This has multiple advantages:" [] ( "All logic besides the immediate input handling and tree folding "
, newNode "" "The API and clients are simpler, clients are easier to write or maintain." [] <> "happens in the server. This has multiple advantages:"
, newNode "" "Updates in logic don't require updates of the client." [] )
, newNode "" "The server-side logic becomes easier to write." [] , txtNode "" "The API and clients are simpler, clients are easier to write or maintain."
, txtNode "" "Updates in logic don't require updates of the client."
, txtNode "" "The server-side logic becomes easier to write."
] ]
, newNode "" "Those design decisions should allow for various different kinds of interactions." [] , txtNode ""
, newNode "" "For example: Linear and threaded chat, collaborative node editing, reading node-based documents (like this one), playing text adventures and more." [] ( "Those design decisions should allow for various different kinds of "
, newNode "" "And of course, which interactions are supported only depends on the server and not on the client." [] <> "interactions, for example linear and threaded chat, collaborative "
<> "node editing, reading node-based documents (like this one), playing "
<> "text adventures and more."
)
, txtNode ""
( "And of course, which interactions are supported only depends on the "
<> "server and not on the client."
)
] ]
, newNode "" "Inspirations" , newNode "" "Inspirations"
[ newNode "" "The tree-based chat model and UI of euphoria (euphoria.io) and instant (instant.leet.nu)" [] [ txtNode "" "The tree-based chat model and UI of euphoria (euphoria.io) and instant (instant.leet.nu)"
, newNode "" "MUDs (which are text based and most of the logic happens server-side)" [] , txtNode "" "MUDs (which are text based and most of the logic happens server-side)"
] ]
] ]