Jacky Luk wrote:Where should be the best place to make a try catch block?
IMO: As little as possible; and not at all if you can get away with it.
Maybe more specifically: if you have a bunch code that, for example, reads a file, put ALL the code inside
one try...
catch (or try-with-resources) block - ie, don't put a
try...
catch around every record you read. And don't put it in a TC block
at all if your program can't recover from an
IOException.
And should I limit the number of active transactions in a sales addition screen for example?
No idea, but the general rule is that transactions should be as small as makes sense for the business rules.
to prevent "abuses" and make the software unstable?
(If he/she needs to add 100000 records, he/she has to do it twice)
Who has to add 100,000 records? I imagine if it was done by hand, it would take
months...
Is such control reasonable? But I doubt it....
Absolutely no idea because you've given us nothing to work with. All I can say is that "such control" is
probably available.
Winston