Colby-CPU-Sim / CPUSim

GNU General Public License v3.0
52 stars 18 forks source link

Where should error checking be done for table cells? #89

Open moirage opened 7 years ago

moirage commented 7 years ago

When error checking the values in table cells after editing, there are 3 places we could do it: (1) within the cell factory, (2) within setOnEditCommit in the Controller, and (3) within handleOKButton in the Dialog containing the table. Currently we do most checking within the cell factory or within the handleOKButton. What error checking should be done where?

Nava2 commented 7 years ago

I had some shower thoughts on this last night. Currently, I've made a lot of the model to utilize the concept of a "validatable" which is just something that can be validated (I know it's not a word.. I just couldn't think of a real word).

Currently, when the "OK" button gets pressed, the DialogButtonController calls a checkValidity() method on all of the controllers it's attached to. This checks that all of the content currently in use is valid (e.g. Micro dialog checks all of the tabs). If an error is thrown, the invalid status isn't written to the machine and it shows the error dialog. This is okay, but I feel like it could be better.

Ideally, we could utilize things like CSS styles and being smarter about "how" we attach an error. Currently, we throw and catch a ValidationException. While this is an OK way to do this, I think what might be better is applying some kind of "path-and-track" method where we can build up a path incrementally as the validations are happening. This way, when we hit a validation error, the "tracker" is told "machine.microinstruction.transferrtoa.buff2a.name" is invalid. This pathing would also let us do things like "highlight" the error if the dialog is open.

This is a much more complicated and involved mechanism than we have currently, but it'd be advantageous from a user interaction perspective.

Nava2 commented 7 years ago

Oops, missed part of the question: for a "column field," I would think checking things like "is it a number?" would be solid at the cell level, but model validations are better at a higher level. I think this is how its done now...