elegant-design

Tips on creating clean, elegant code

Writing clean, elegant code is what makes coding a pleasure for me. I'm always looking for more ways to do so. Here are some of my strategies/tactics: Keep large code blocks in smaller chunks of routines/methods/classes Be sure every routine has one point of exit. Exit loops with logic at the top of the loop, not with breaks or some ty...

Elegant design of simulating a read-only object

Hi, I am currently developing an GUI to an embedded system. (I am using GUI to descripe my app opposed to interface to avoid confusion with the progamatic meaning) Context I have created a class which simulates the embedded system. I do all my communications through a Connection class I have designed which can communicate via TCP/Seria...

Does Hibernate auto-rollback programmatic transactions when unhandled exception occurs?

When working with programmatic transactions in Hibernate, is it necessary to explicitly call rollback if an exception occurs, or will the framework take care of calling rollback if there is an unhandled exception? The code below seems like the safe approach (albeit ugly code) to ensure rollback, but i'm wondering if there is a more elega...

Elegant Python?

I am trying to teach myself Python, and I have realized that the only way I really learn stuff is by reading the actual programs. Tutorials/manuals just cause me to feel deeply confused. It's just my learning style, and I'm like that with everything I've studied (including natural languages -- I've managed to teach myself three of them...