webwizard99 / salt-store-backend

Back end for salt store project, produced as part of Codecademy Premium program
0 stars 1 forks source link

Uppercase data structures #4

Open martoio opened 4 years ago

martoio commented 4 years ago

Capitalize your data structure classes: https://github.com/webwizard99/salt-store-backend/blob/dc880294543b5bbce10963657e84ac953de71e56/utilities/storeitems.js#L4

It makes it clear later on when you do new Item() that Item is some custom Data Type that you've defined.

Also, try to use ES6 classes!

class Item {
    constructor(options){
        this.img = options.img;
        this.name = options.name;
        this.price = options.price;
    }

    // methods that have to deal with a particular item can go here!
}
martoio commented 4 years ago

Also, if you have more than 2 or 3 arguments for a function, then you should use an object or some kind of data type to represent those arguments. There's no chance you can remember the order every time and it saves you the pain of having to deal with long parameter lists.