Code review - general guideline

Draft Disclaimer: Please note that this article is currently in draft form and may undergo revisions before final publication. The content, including information, opinions, and recommendations, is subject to change and may not represent the final version. We appreciate your understanding and patience as we work to refine and improve the quality of this article. Your feedback is valuable in shaping the final release.

Language Mismatch Disclaimer: Please be aware that the language of this article may not match the language settings of your browser or device.
Do you want to read articles in English instead ?

Here

  1. Form validation
  2. Try to move all the calculation to the database level whenever possible
  3. Use pagination when looping through all records from the database
  4. Chunking if we really need to process all records in database (could be million of records) Use model chunking
    Model::chunk(number, function ($models) {})

    // example
    Event::chunk(100, function ($events) {
      foreach ($events as $event) {
         // processs $event
      }
    });
  1. Project import
  • Run a benchmark for 1000 records So that we would know how much we improved
  • List out Models in ProjectEditImport::onRow and build a graph of the dependencies between the model Project |__Workflow |__Contract |__Contractors
  • Build better queries:
    • remove redundant project->save() calls
    • remove redundant ProjectProcess::updateOrCreate calls
  • Use a job, event, notification
    • use a job that will dispatch: ProjectImportStarted, ProjectImportEnded and return 200 status to not block the client.
    • Send a notification when the job end
    • optional: use socket for instant notification
  1. Project Import prepareForValidation
  • use helper method for repetitive actions
  1. Create exception for workflow rules validation
  2. Later we can discuss the need of saving potential in advance, If the is confirmed, need to know the potential appointments then it might a good idea to save the potential appointments in the database.
  • We will use PotentialAppointment (create migration, model, jsonResource)
  • add expired_at field that would store the 10min or whatever the temporary duration
  • Job running every period of time (ie an hour), that would delete every expired PotentialAppointment
  • add scope for scopeAvailable() use expired_at < now().
  • use that scope in every places

Communication:

    1. I am usually up by 9am my timezone and available until 8pm sometimes more (upto midnight). Since I am close to client timezone (1h difference), we can leverage that for communication. I can draft messages (email, slack) during the day and have them scheduled for 8 or 9am UK time once all good.
    1. Introduction email as Team lead on the project (cc on that email) so that I would be their point of contact. We could then sync up in the morning if that's something that could improve their response time. Going forward:
    1. Sprint 0: Taking 16 to 24h preemptive work to fix couple of things we saw on the audits Can do more once client agrees with this. We will prioritize based on their goals outlined on the email.
    1. Start Sprint 1 as continuation of Sprint 0 and client inputs Tech planning on G-Cloud framework, G-Cloud registrars
  • Add tests (smoke, feature)
  • Refactor folder structure/namespace to avoid over contexting (ie AppointmentFinancialTransaction)
  • Use livewire/alpineJS or blade components as replacement to jQuery views This will allow to
    • reduce page load by reducing complexity
    • increase app reliability
    • solid basis to welcome new features Next steps
  • Refactoring
    • model query scope. rewrite to give example
    • authorization: permissions, project role, project briefs with their status, project amendments with their status
      • solution: custom form request + policy
    • no happy path ? treat every scenario from end to end then see how we can combine reuse logic. Strategy pattern can help
  • customizable form validation rules
    • UI to match laravel validation rules.
    • custom validation ? code editor to input functions for
  • is HasOneThrough/HasManyThrough performant for CRUD operations ?
  • tailwind vs bootstrap
  • template to customize for reuse across projects