Lessons learned from working on Terawhere
The month before Ramadan, starting on 1st May 2017, msociety decided to make a car-sharing/carpooling app that we affectionately called, Terawhere. It was a play on the word Terawih, a nightly prayer Muslims perform during Ramadan. I had the opportunity of working on the backend API for the app. It was a great learning experience working in a proper team for the first time.
Throughout building the app, I’ve been noting down little learning points to improve myself as a developer. Since my intention for working on Terawhere was mainly for learning Laravel, I’ve been slowly adding these as I worked on the project to learn from my mistakes. Some may be quite specific to Laravel or backend stuff, others more general. May these be of some benefit to those reading.
Use resource controllers as much as possible.
Makes it easier for team members to pick up on a project. Making a new resource for every little thing makes it more verbose
Use migrations properly.
Especially on production. Looks messy with the many files, but works smoothly. Initially I had trouble grasping the idea of using migrations, but after much tinkering, it’s actually quite intuitive.
Use the Carbon library for EVERYTHING datetime-related.
It’s just awesome. It extends on PHP’s default datetime library. Makes handling datetime objects a breeze.
Write unit tests early on to check for problems EARLY on.
Becomes a PITA to do it when most of the code is up and running already. Makes it easier to test endpoints after making any changes.
Conventions exists for a reason.
Generations of programmers have found that this is the best way to do things. DO IT. And it’s easier to work in teams with conventions. Read up more on PSR1–2 etc. Very useful. Still learning.
Sentry.io is awesome.
Seriously, use it.
Don’t use Laravel’s soft deletes for objects that will have multiple ‘states’.
Use status, and then filter out when retrieving said object. (Offer objects in this case). This becomes a problem when trying to retrieve all objects for the sake of analytics. Some methods use withTrashed() and others don’t. Becomes very messy.
Learn GraphQL
My next objective would be to learn to make APIs using GraphQL. There are already several Laravel packages to implement GraphQL. It’s simply a better way to make APIs for native mobile frontend developers. Read more about GraphQL here.
Conclusion
Reading back what I wrote here a month ago, makes me think that most of these were “DUH” learning points. But that’s the point, as a rookie developer, I’m here to grow and learn from my past mistakes. I will inevitably make more mistakes in the future, but hopefully I’ll be a better developer from it.