Open 0xF48 opened 4 years ago
require('./../model/meat');
can be
require('../model/meat');
orderPizzas = new Array()
can be
orderPizzas = []
camelCase
notation for variables is fine, different people do it different ways, as long as you have a a strict and systematic way of doing it.
something to watch out for in the future is the fact that if I use underscore_names
for variables in most of the allether source code and camelCase
for functions and methods and UpperCase
for class names. You don't have to do this if you don't want to however, perfectly fine with me, i don't care either way. In fact, I like the camelCase better because it's easier to type its just a habit that i have formed over a period of time.
Commenting code is fine, you can do so for yourself if you need to. Personally, I don't care if you do it or not.
However i do care very much about clean and organized code and variable names that make sense.
again, a lot of this stuff is minor and will come naturally with time as you familiarize yourself with the language/tools more.
I also like how you use reduce
const meatCal = toSaveMeats.reduce(
(currentCal, meat) => {
return meat.calCount + currentCal;
},
0
);
it's always nice to see handy utility functions used in a good way!
I also appreciate your proper use of array methods like
var amountsDetail = dbDrink.sizes.find((amount) => {
return amount.name === orderDrink.size;
});
I use lodash for a lot of this kind of stuff, you can take a look at it if you wish, it contains many useful toolbelt utility functions.
It's always best to use the right tools for the job and avoiding using any sort of for loops is always great practice.
this is a very minor issue, but something to watch out for in the future.
var obj = new Object()
is the same asvar obj = {}
, it's not a good idea (in my opinion) to writenew Object
because it complicates the readability of the code on my end. you are doingSauce.find({})
which the same asSauce.find(new Object())
which is the same asSauce.find()
it's okay to do it the way you are doing it currently but keep in mind when refactoring code in the future, if there is a shorter/faster/easier way of doing things, do it that way instead and don't reinvent the wheel or write extra abstractions that add extra unnecessary code that others will need to read.
the idea is to keep the code as simple and easy as possible for others and your future self to understand by using all the right tools & features of the language and it's libraries as possible, which will naturally come with time and practice.