FAC-Sixteen / groundworks-client

Groundworks Tech for Better Client Project
0 stars 2 forks source link

Groundworks Code Review 15/06 #72

Open martingaston opened 5 years ago

martingaston commented 5 years ago

Morning all! Congratulations on getting so much done so far :tada: This looks like a really meaty project with plenty of action, so I'm sure you're all mega excited to get stuck into the second week of your build sprint.

I've tried to separate out my feedback into sections, and some of my comments are opinionated which means you shouldn't feel bad at all if you disagree. Go your own way! Have those opinions! This is your project :tada: But I thought it might be useful to throw in some more conceptual discussion - maybe as something to refer back to down the line :+1: My intention is absolutely not to try and overwhelm you or suggest that everything here should even be considered to be actioned for your current sprint.

Don't forget to support each other and make time for pairing, and I'll be around for some remote pairing if you're interested throughout the week.

ALSO don't forget that you're doing great :+1:

General

Project Management

Client

Directory Structure/Repo

React

    <div class="FoundersComponent">
      <h2 class="FoundersComponent--header">From the Founders</h2>
      <div class="FoundersComponent--container">

CSS

Console.logging

I'd say some of these comments can come be tidied up, and I'd take a look at L19 of ClientSignupForm.js as well - you never know who is going to stumble upon these things.

Duplication

/routes

Most of your routes here seem to be wrapping other components in a <div> - might you consider just throwing the components directly to the routes and help trim your codebase down?

LoginPortal/LoginPortal.js

<h2 className="form--el form--input__title">Password</h2>
        <input
          className="form--el input"
          type="text"
          onChange={e => setPassword({ password: e.target.value })}
/>

RegisterPortal/RegisterPortal.js

<h2 className="form--el form--input__title">Password</h2>
        <input
          className="form--el input"
          type="text"
          onChange={e => setPassword({ password: e.target.value })}
/>

This isn't such a big deal when you're working across only a few files, but what happens when you've got to change one of these? You've encapsulated LoginPortal and RegisterPortal into the same directory and they have many of the same patterns - do you have a modular Portal component screaming to break out?

Then you can start thinking even more abstract - do all your, say, Buttons, inevitably share the same code? Is there a Button component you can make? A really nice article is 'Thinking in React' - this has the benefit of making testing those individual components much easier, and then you can build your pages by composing those smaller functions together.

I suppose a question I could ask is: what is React actually bringing to your app? Could this all (theoretically - I am in no way suggesting a pivot) have been done by Express & Handlebars templates on the backend? It might be useful for your own understanding to maybe spend a couple of minutes noodling on what the pros and cons of both options would have been.

"We wanted to do React because React is cool" is a fine answer here, mind, and that's exactly what we did for our final project as well. Because React IS cool. BUT STILL. Something to think about!

What I do like here is a line coined by Sandi Metz - duplication is cheaper than the wrong abstraction, and I would 100% of the time rather see a bunch of duplicated code than an unnatural abstraction. But maybe you are at the point where it might be prudent to start considering where you can abstract? This might help you significantly cut down on your workload, and help you design/optimise faster. Plus, when you're getting into a groove, you'll find you're probably deleting code left and right and, boy, what's more satisfying than deleting a whole bunch of code? NOTHING.

API Calls

components/clientSignupForm.js

Your API calls are coupled tightly to Axios and its API. What if you want to ditch Axios? What if your own API changes? You've probably got to go through all of your components, scattered over the place, and update everything file by file. Your component is bound to this implementation. It's probably also hard to work on this in a group, because you've got to make many changes to one file, or (this always feels worse to me) you've got to make one change to many files.

One thing you could do is extract all your API logic away from your components - let's say you make an GroundWorksAPI function. You could import this into your files that need to make API calls, and your function names can now be more tailored to what you're trying to achieve - so you could have GroundWorksAPI.registerClient() or GroundWorksAPI.getClientJob() and the like.

This also creates some nice seams and a common language in your project, so when you're pairing, one group can work on the presentational components (which don't need to worry about the business logic) and the other can plumb in all the API calls (which don't give a toot about how to actually render that information).

Server

Where does this live?

Is this going up on Heroku? I can't see a procfile. Do you have a working deployment already? I only say this because someone (me) has only narrowly dodged a few hairy deadlines from time to time (literally every time I ever deploy anything) because they (me) don't estimate well on how long it actually takes to get these kind of things up and running.

If you've already smashed this, great.

Tight Coupling

controllers/clientControllers.js

Sanitising Data / Validating

Concurrently devStart relies on another repo

misterrodger commented 5 years ago

Thank you, Martin! :fireworks: Yes, it is an exciting project for us and we are looking forward to next week. Thank you for your comments which are super helpful! Briefly:

Client

:question: :question: :question: Given that we have about 3-4 days next week to complete building the MVP, which still needs authentication/sessions and the main dashboard/jobs matching page (a simple, single match at a time, so not massively complicated), would you suggest any particular CSS method above over the others? I'm happy to spend time learning over the weekend if it would be helpful, but also mindful that time is running short now.

Server

Yes, server is on Heroku and Client is on Netlify currently. Front end with Webpack on Heroku as well was the original plan, but deployment seemed to be taking a lot of time to iron out the kinks, so Ryan suggested Netlify for that part and it was working last time we checked. However we have added a lot to the project since the initial deployment, so we will check again on Monday that it is still working.

Will look into the Adapter pattern as you suggest, thank you.

Thanks again, brilliant and lots for us to work on! Cheers! :champagne:

martingaston commented 5 years ago

CSS: To be honest we have pushed this to the side a bit, so as you say it is just bits of CSS floating around. Honestly we have had a bit of "analysis paralysis" and ended up doing nothing...trying to decide between Sass, CSS-in-JS, or Styled Components...

I get that, Analysis Paralysis will be the subtitle of my biography 😂

I think you're absolutely right to bring up time - that's always, every time, going to be what gets you. I think Styled Components is neato, has super good documentation and is a logical fit for the structure you've already got in place, and at a complete gut feeling it might be easier to pick up compared to SASS as you're already rockin' React syntax and concepts. BUT... it also has downsides, like you say it's going to take some time to spin up and incorporate it, and refactoring it across your entire codebase will take big time.

Advantages of SASS are that it's more established, your current CSS will probably more easily get batched over to it, and it's probably more straightforward to refactor your current CSS into SCSS as you already have a neat Webpack script (also, I forgot to say, you wrote your own Webpack script? Daaaaaaaaaaaaaaang that's neat 😎)

Is it worth pulling yourselves off other user stories to work on that? What are the risks of implementing (my usual two biggies are: 1) it takes longer to skill up on tool [x] than I was anticipating, and 2) I accidentally break something along the way)

On the other side - if the solution you've got now is working... then it's working! There's a lot to be said for not potentially breaking something that's not broken

It's all about the trade-offs. There might be a 'meet in the middle' solution where you scope out testing implementing Styled Components in something you build this week (say, a button or something) and see what it's like. If you're not getting anywhere other than capital F Frustrated after a couple of hours... consider it a spike and go back. Or if you all take to it and think it's the answer to all of your CSS problems you can start rolling it out on more components.

Feel free to reach out with any other Q's 👍