🧡 Kent Beck's "First make the change easy, then make the easy change" applies here. There's no single best way of organizing a codebase. Rails gives you initial structure, which is a good start, but it shouldn't end with the 3 directories in "app/" (1/9)
When it comes to default directories I don't recommend putting non-AR classes under app/models simply because it is the convention that AR models go there. Mixing them up with other types of classes makes things more difficult (2/9)
When it comes to lib/ it's a good place for files that provide abstract or shared functionality that you can then leverage in concrete implementations under app/*. Remember these files are not reloaded in development by default but you can change that in the config (3/9)
When it comes to app/** - this can be dictated by your domain. You can start with a separation between app/commands (objects that have side-effects) and app/queries (objects that just return data). Over time you discover more concrete ways of organization (4/9)
ie you may end up with app/lessons/{commands,queries} as the edu platform you're building clearly has a distinct "Lessons domain" that can live in its own directory. The trick? Goes back to the beginning of this thread - make the easy change, assuming it's easy to do so πŸ™‚ (5/9)
Being able to move things around, rename classes, modules etc. can be simple when your codebase is consistent. If you have a crappy piece of code but it's consistently crappy, it is actually easier to make it better then when you have inconsistent crappyness (🀣) (6/9)
What it means is that if you made a design choice - stick to it everywhere until you decide to change it. This will help πŸ’― That's of course not everything (I wish it was haha). Another big factor is the level of coupling that you have across your codebase (7/9)
That's why you need to be very cautious about things like constants and bi-directional coupling. Quite often you may realize that coupling could only go in one direction. Maybe Teacher needs to know about Lesson but Lesson doesn't really need to know about Teacher. (8/9)
With consistency and low coupling, it's easier to move things around and re-organize your codebase and that's really the only reasonable way. You can't come up with a great organization structure upfront because you don't know what you don't know.

(9/9) The end πŸ™‚

β€’ β€’ β€’

Missing some Tweet in this thread? You can try to force a refresh
γ€€

Keep Current with πŸ’™ Peter Solnica πŸ’›

πŸ’™ Peter Solnica πŸ’› Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @solnic29a

Feb 5
🧡This should stop. Such practices are not inclusive unfortunately. Believe it or not but for some folks any form of a "test/quiz" can be triggering. My brain shuts down when somebody tells me to do a test in front of them. This is what trauma does to people.
In my case that's quite simple. As a kid with undiagnosed ADHD I've had a lot of traumatic experiences during school and studies. Because it was hard for me to focus in classes with lots of children, I had trouble when ie solving math problems on a whiteboard.
As a result, I would experience all sorts of criticisms from teachers and/or being laughed at by other kids because I was making "stupid mistakes" and I would constantly hear that "I should try harder" or it would be assumed that "I didn't care to prepare for the class".
Read 6 tweets
Jan 3
🧡Good point/question. This is definitely one of the hardest problems to solve but I say that AR's way is not the best way. First of all if you separate reading from writing, you already reduce complexity. That's a win right there.
Secondly, dealing with associated data when making changes can be handled much better if you have dedicated data transformations in place. This is because the input is *often* incompatible with what is actually persisted. This is *a huge* source of complexity in many apps.
Now when it comes to reading - if you look at your *domain data* you will quickly realize that quite often *you don't need associations* the way they are established in your db. You will discover that there are *simpler* ways of representing your domain data.
Read 6 tweets
Feb 1, 2021
A couple of years ago I promised myself that one day I'll be strong enough to be able to talk about my mental health openly. I've made this my goal. I think this is the day, so here's how I ended up diagnosed with ADHD at the age of 37 - a thread...
In 2017 I reached my rock-bottom. I got back home from Philippines, where I failed to deliver my conference talk due to being a mental train-wreck (for which I'm terribly sorry!). I started having suicidal idealizations and I realized it's time to get help.
It's not that I wanted to end myself, but I would see myself dying in all sorts of ways every-single-day. These are called intrusive thoughts and the ones I had were probably one of the worst ones you can experience.
Read 25 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(