Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uppercase data structures #4

Open
martoio opened this issue Nov 25, 2019 · 1 comment
Open

Uppercase data structures #4

martoio opened this issue Nov 25, 2019 · 1 comment

Comments

@martoio
Copy link
Collaborator

martoio commented Nov 25, 2019

Capitalize your data structure classes:

const item = function(img, alt, name, price) {

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
Copy link
Collaborator Author

martoio commented Nov 25, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant