Shorter code is better?

Which one do you prefer: shorter code or more legible code? As for me, legibility of the code always come first. Working in a team will make one realize the importance of code legibility sooner or later. Your code is not for you alone to read. It should be friendly and easy for whoever has to maintain your code as well. It’s not easy to write elegant code but it’s much easier to write legible code.

Some useful use cases for Java Reflection

While most will recommend you not to use Reflection because: Lose ability to refactoring because you hard-code the name of class/method as String. Lower runtime performance, No compile time safety check. However, there’re many cases Reflection can become very useful that it pros might outweight its cons. Or it’s just cool to show colleagues some new cool tips. Easier to implement toString() method for debugging You can use Reflection to loop through an Object’s attribute and print it out instead of using StringBuilder to append it yourself.

Clean code/dirty code

I like to think of myself as a perfectionist. I like going back and forth re- evaluate all the possible options and come up with the cleanest, best, perfect alternative (I can think of) out there. If you are like me and you got to maintain someone else’s bad code, this is gonna be a real nightmare. You just want to scratch everything and start over again. Unfortunately, management people doesn’t think so and you don’t get the luxury of times you need.

How to code like a dick in JS

The goal of this post is to make simple things look complicated. 1. Invert logic Let’s start with something easy. Instead of if (x && y) { ... } // easy Write this instead if (!(!x || !y)) { ... } // good enough 2. Extended unicode chars for variable names Use of extended unicode chars, especially those that are not visible in console like \r, \t, etc… 3. Use = instead of == if (x=true) { .