After extensive observation of software development, my friend Tomas got a very interesting interpretation of Albert Einstein’s mass–energy equivalence:
E = mc2
Interpretation:
Enterprise = lots of middle class
After extensive observation of software development, my friend Tomas got a very interesting interpretation of Albert Einstein’s mass–energy equivalence:
E = mc2
Interpretation:
Enterprise = lots of middle class
Posted in Personal, Software development | Tagged humour, joke, programming | Leave a Comment »
“It’s what I call ‘mental masturbation’, when you engage is some pointless intellectual exercise that has no possible meaning.” – Linus Torvalds
Currently I have some idle time at my job (waiting for a new project), so I thought I don’t want to get too rusty. Programmer has to program… I have found Project Euler, a site dedicated to math/programming problems by Colin Hughes (aka Euler).
So if you want to exercise your head (and fingers) look no more: http://projecteuler.net
To make things more interesting, I’m solving some of the problems in C++, not my first programming language :)
So far I have 17 solutions under my belt, some of which use brute force so I might get back to them some time.
Happy hacking :)
Posted in Personal, Programming | Tagged algorithms, mathematical problems, programming, puzle | 3 Comments »
Update after some comments: this post is not a discussion whether to use Singleton or not. It’s not a discussion on why Singleton might be an anti-pattern. It’s just an example on an alternative implementation of Singleton in Java. Just that.
There are two classic ways to implement Singleton pattern in Java: public final instance field or static factory method to create/get instance.
However there is one more, probably the best way to do it if you are using Java >= 1.5. You can use Enum – this way you get Singleton functionality easily and don’t have to think about serialization as you get it for free:
package electro;
public enum YourSingleton {
INSTANCE;
public void doStuff(String stuff) {
System.out.println("Doing " + stuff);
}
}
Now you can use it and be completely sure it’s Singleton:
YourSingleton.INSTANCE.doStuff("some stuff");
Thanks to Joshua Bloch and his great book “Effective Java Second Edition“.
Posted in Java, Software development | Tagged enum, Java, pattern, serialization, singleton | 23 Comments »