Atomicity from the A in ACID properties for database transactions tells that each transaction conducted on a database is like binary number system, 0 or 1, all or nothing.
Is it possible to achieve the same in programming languages like Java or C# or any other general purpose language? e.g.
public static Ticket GetTicket(string filePath) {
counter++;
Application app = new Application(filePath);
.
.
.
Probably, I am giving a bad example, but I believe this should be enough to give an idea. Now, imagine if the line where I am creating an Application
object throws an exception, then the execution of the application would halt and the state of the static variable counter
will already have been mutated and the state of the system changed. Is there a way to prevent the damage being done by statements executed before an exception is thrown?