wasp-lang / wasp

The fastest way to develop full-stack web apps with React & Node.js.
https://wasp-lang.dev
MIT License
12.92k stars 1.15k forks source link

Thoughts - Refactor MainPage and re-organise app #259

Open cursorial opened 3 years ago

cursorial commented 3 years ago

The MainPage file currently has two components defined in it.

These should all be split out into their own components, we can render them from the Thought component. In addition, CSS can be split out to handle each of these, bringing the app structure closer to where we'd like it for styled-components.

We should change the name of MainPage to something else. I was thinking ThoughtPage but this will come awfully close to ThoughtsPage, seems picky but this will cause confusion for someone and I don't wanna be that dev. That being said, naming it something too far removed from ThoughtsPage could be difficult while leaving ThoughtsPage alone. I'm tempted to implement a different naming convention here, potentially something along the lines of ThoughtCreatePage and ThoughtIndexPage to accurately reflect the way we interact with Thought data on each page. I think it would also make a lot of sense to start breaking up the structure into directories at this point.

See proposed file structure here: ext/

The main.wasp file will need to be updated in order to match these new directories.

Martinsos commented 3 years ago

Sounds good @cursorial , I like the general idea behind this, you are driving Thoughts to became a really nice project :)! And sorry for slow response, I was on vacation and days just flew by!

MainPage component -> I agree, we can remove this one.

Splitting Thought component into smaller components -> certainly, let's do that.

Naming (ThoughtPage, ThoughtsPage) -> those are very good arguments and I agree with the train of thought. I like the final proposal of ThoughtCreatePage and ThoughtIndexPage. I am considering some small changes, specificaly ThoughtEditorPage and ThoughtListPage, but that is very similar and I am ok with the naming you proposed if you prefer that.

Regarding proposed file structure, I agree it is time to organize stuff! I am however big fan of organizing files by function/feature, instead of organizing them by type. I tried both in the past and I found the former to be easier to navigate as project grows, it also organically grows with the project. So if following that, it could look like:

ext/

This is certainly not the only way to organize it, we could do it somewhat differently, maybe even mix two approaches in the sense that there exists frontend/backend separation on the top level and then from there it is organized by function. But I somewhat like the idea that frontend/backend are not clearly separated, due to how Wasp is trying to blur the line between the two. From the organization I proposed above I feel least confident with the layout dir, it feels like we are putting all the "view" logic there that is general, so maybe it could have a better name. Maybe it should be frontend or view or client or frontend/layout. Not sure thought, I am thinking that will evolve as project grows and will become clearer.

What do you think about this?

cursorial commented 3 years ago

Really great feedback and I'm more than happy to use the naming conventions you suggested and the file structure, I like yours a lot more than mine. Will get to work on this tomorrow.

Martinsos commented 3 years ago

Really great feedback and I'm more than happy to use the naming conventions you suggested and the file structure, I like yours a lot more than mine. Will get to work on this tomorrow.

Yay the power of iterating together :D! Great, and pls feel free to additionally improve the file structure I proposed, be it naming or additional structure, if you think it helps.