Why never change the notifier in receiving a change event

I think she means that if you don’t really think about your code then you can introduce an infinite loop.

Most people when when they create the table would probably make columns 1, 2 editable and make column 3 uneditable since column 3 is just the difference between the two columns.

So when they write the TableModelListener they will check for the UPDATE event but forget to check to see which column is updated because they think the table won’t allow them to update column 3.

They forget that when the TableModelListener updates column 3 another UPDATE event will be generated thus causing the infinite loop. Of course, proper coding, like in your example, will prevent the loop.

In general, it should not cause an exception.

The second point is about business rules. The business rules should be defined on one place, in this case the model. The data itself and the updating of the data should be done in a single place.

Leave a Comment