samedi 26 septembre 2020

Is it inadvisable to instantiate data to process it?

Been running in circles on this so I thought I’d put it out there. I’m new to programming and have been learning JavaScript.

I’m trying to apply the Object Oriented perspective to my design, which involves a large collection of dynamically created objects. These objects need to be stored in a database, and accessed regularly. It feels weird to get a bunch (say 20) of items from the database and immediately pass them into a constructor to gain access to their functionality, does it feel weird because it’s a strange thing to be doing? Basically each object needs to be its own instance because it’s properties are unique, but it is of a “class” which serves a similar purpose.

I’m not sure if that made any sense, if not, I apologize. Basically.. is it weird to be instantiating a ton of data you get from a database? Should my class be broader? Will delete if this question sucks.

P.S. I know this may sound wooey but one of the hard things to get a handle on when you don’t know what you’re doing is the stuff which seems assumed to those accustomed. Even a “it depends” answer would be quite helpful.

Aucun commentaire:

Enregistrer un commentaire