tags:

views:

76

answers:

5

I am building a webapp to edit some information from a database. The database is being displayed as a table with editing capabilities.

When editing a value, generally I have to validate and do some other tasks, depending on the value that's being edited.

Should I keep a copy as array of objects in memory and use their methods or should I store all the information I need (type of value, id, etc) somewhere in the html table (as attributes or hidden inputs) and get them using several functions?

Which would be best practice? Is it risky to have many objects stored in memory (taking into account memory usage of the browser)?

A: 

Just do whatever is simplest from a programming perspective. I wouldn't worry too much about memory usage for something like this, unless you're absolutely sure that it's causing problems.

You can address the memory usage of your application later, if and when it becomes an issue.

harto
+1  A: 

I think you're describing a MVC, and it is considered best practice. However, the memory model of the view would typically be held on the server for security purposes.

It may not matter in your case (and I may be jumping to conclusions), but I would caution against trusting the client with all of the data and validation. You can modify everything in a page in real time with Firebug, so if that puts your app at risk, consider moving your memory model to the server.

lod3n
+1  A: 

whether you will run into memory troubles on client depends on how much data you will be holding at a time. Consider limiting the information returned to a certain number of records and paging through, you can then limit the amount of data to be held in memory or on the page.

I would expect that holding a information in-memory will give a better user experience than requiring constant calls back to a server, or into the DOM. It is probably easier from a programming perspective also

Steven Adams
+2  A: 

Hi,

storing moderate or large amount of data in memory as objects wont affect the performance with the modern systems. The main factor you should consider is CPU intensive DOM iteration and recurive operations.These takes much of a browser memory.

I preferred to use storing objects in memory rather than HTML hidden fields in many application. It works well and didnt find any performance bottlenecks.

Cheers

Ramesh Vel

Ramesh Vel
A: 

Most database editing tools e.g. PhpPgAdmin and PhpMyAdmin paginate results and only allow editing 1 row at a time. You can extend that to several without much fuss. As mentioned before remember to paginate.

whatnick