Php – Laravel Algorithm for taxi app

algorithmsbackendlaravelPHP

I am trying to write a backend for a taxi service (university assignment) and I am stuck on the algorithm.

whenever a new client posts a request, all the taxi drivers nearby get an email notification and, for five minutes, I have to collect the positive answers (the ones who are willing to give a lift).

After five minutes, I have to match the customer with the best taxi driver who answered, based upon feedback and distance.

I have set up everything in Laravel 5.1, but don't know how to implement the "pool" of answers from drivers. Should I use a temporary MySQL table or opt for a temp file storage? Or design a different way of tackling with it?

Best Answer

Using the database has a bunch of benefits. Some of these benefits don't apply to a school project, but I'll list them anyhow.

  1. If a driver is notified about two fares, make sure the driver isn't assigned both.
  2. The state of the system is represented in fewer places.
  3. Storing business rules makes changing business rules without a recompile more feasible. This isn't necessarily a win (it can encourage cowboy coding), but in the case of a project which will never have a version 2, that's moot.
  4. A database schema is easier to create/adapt than a file system, which requires a file names and serialization.
  5. Inspecting the current state of your system is easier with a database. Creating sophisticated queries (e.g., for debugging or to assist a help desk) is easier if the data is in the database.
  6. A database will scale up more easily.

The main benefit of using a file system is that it may have a slightly lower start-up cost. This lower cost introduces a bunch of problems (which a database is designed to solve), but such problems may be unimportant in the case of a school project. Taking on a big chunk of technical debt to save a small amount of time isn't a big deal if you're creating a project that will never be maintained.