Is it better to have one large object in JavaScript or many smaller ones?

后端 未结 5 857
你的背包
你的背包 2020-12-29 09:15

I\'m writing a JS lib that reads chess games to turn them into re playable games, in one single web page there can be many games (one in its own div), what I\'m wondering is

5条回答
  •  失恋的感觉
    2020-12-29 09:37

    I think this question is much more about software design than performance. But I'm glad youare addressing it now, avoiding refactoring later.

    I think you should think each game as an instance (div) of a ChessGame object. This will facilitate much of the rest of development, as making custom libs and functions to deal with game, also you will have the possibility of threading each game (google for "web workers"), increasing the overall performance.

提交回复
热议问题