Hacker News new | ask | show | jobs
by bad_user 5632 days ago

     this method must be called in the context of a 
     READ-COMMITTED transaction
I get what you're saying, but I like conventions and clear APIs with proper encapsulation.

Here's a sample from Python/Django ...

      @transaction.commit_on_success
      def do_stuff_with_the_db():
           db.execute("insert into tmp values (1)")
           raise Exception
Or if you need to supply the DB queries yourself, you can implement your own context-manager than use it with a with block ...

     with stuff.inside_transaction() as obj:
          obj.execute("query")
No need to extend a class that represents a transaction or some other shit like that.

       having the language assist in simply not breaking it at all
You know that's an utopian goal. What I dislike most about languages that try to detect too much shit for me is that it gives me a false sense of security. And the worst offender is Java: not only is its type-system too weak, because it is manifest-typed you get the false impression that it guarantees stuff for you, when it doesn't.