Stellar-Junior-Dev / cocktailMasters-cosmin

0 stars 0 forks source link

[Code review] Move Search and Hamburger menu component into two separate functions. #15

Open emilianraduu opened 1 year ago

emilianraduu commented 1 year ago

Minimise the renderSection function to be modular like the "detailsPage" javascript file. In order to do that please make the function as small as possible by moving the Search and Hamburger menu login into separate functions. The functions should also be minimal in size and, if its the case, call other functions that render small parts of their children. Also, please name the css classes accordingly so they can be easily identified (no "TEST" classes, no "divElement" js names. make them explicit).

emilianraduu commented 1 year ago

Guide

In order to make the code clearer, the following logic should be kept in mind:

  1. Every line of code that represents or changes a HTML element should be kept near each other in order to make the code readable

Image

  1. Instead of writing multiple appends on multiple lines on the same element, please write a function that receives the HTML element and an array of elements and appends them using iteration over the array.

Image

emilianraduu commented 1 year ago

Image

Also, you shouldn't select multiple times the same element. It's wasteful and we should only select it once and reuse it. In the screenshot above it says that the body was selected 4 times and in the one below the body element is selected twice in the same function without a specific reason.

Image