Friday, December 24, 2010

JPA + Hibernate: optimizing queries on a many-to-many relationship

Following up a discussion (in Russian) on a developers' forum on advanced querying against many-to-many mapping in JPA I have compiled all my findings in this post. I intentionally leave all object and database names close to the original maybe with minor changes.

Friday, December 17, 2010

Splitting the blog in two

Finally this is the time to sort out the mess of English and Russian posts in the same blog. I feel much easier when writing about IT and related technologies in English. So I will split the blog and go on posting in English here. All posts in Russian are moving to yegodm-ru.blogspot.com.

Wednesday, February 3, 2010

Idea of a litmus test for the company that hires you

I suspect this might be a good question to raise on an interview with any potential employer in software engineering industry: "With regard to the engineering you do when creating your product(s), if you were a car manufacturer what kind of car make would you match your whole production line with - AvtoVAZ, Toyota, Ferrari?". The list, of course, can vary to contain names known to the other party but the idea would still be the same.

I see no other way to quickly reveal how significant and relevant the tools and technologies employed by the company are. Sometimes they might tell you they use Perforce but then it appears they don't use branches and store compiled binaries in it for some wierd reason. Sometimes they claim to use Continuous Integration system but then you find out they don't write unit-tests so it makes using of CI close to sheer nonsense. Or, even worse, they do write unit-tests but without assertions. Some mention they are Agile but meaning by that things are in total mess and uncontrolled. Think for some time and I bet you will be able to find your own examples of such lies.

It is just a rough guess, yet I hope it is on the right track.

Tuesday, February 2, 2010

Servlets vs Messaging

Being kind of not a big fan of Web development I wonder what is so special about Servlets that requires a separate API to use them?

Integer.valueOf(): a few facts

Integer.valueOf(int x) added since Java 1.5 has one interesting feature - it resolves all incoming int values through a cache so to minimize the number of java.lang.Integer instances in application by re-using the cached values. This cache is also configurable with a system property java.lang.Integer.IntegerCache.high which is used to define the upper bound to populate the cache to. The minimum value is hard-coded and it is -128.

Surprisingly the upper bound for java.lang.Long, where a similar cache also exist, is hard-coded to 127 and is not at all configurable.

Thursday, January 28, 2010

SonyEricsson G900 disappoints me

It is the second time my phone requires service attention. And the problem is exactly the same as it was the first time - the screen either suddenly goes dim and all colors become dark or it fails to light up at all when the phone is waking up from the standby mode. Often prior to unexpectedly dimming the screen the phone starts reacting on navigation commands in a sluggish manner and usually smooth transition effects when switching panels now become staggering.

It was just this summer when this has been fixed by replacing the TFT matrix. I can hardly imagine how cheap these TFTs should be to exhibit faulty behavior that frequently. Seems like the MTBF is approximately 6 months.

Looking around for a better options I can hardly think of any good alternative amongst the plenty of all these smart-phones, communicators, etc. They just don't look reliable. Indeed, with the current manufacturing rates we will very soon be buried under a large pile of such cheap sh*t. What a nice prospect!

These little things cannot even replace firewood if it gets much colder one day. A Darwin award is awaiting for you, people! Keep going.

My list of features missing in Java

It is a very common question on interviews about what features you consider missing and would like to add to Java. Here is my list:
  • C#-style properties accessible as such via reflection;
  • C#-style yield keyword;
  • C#-style as keyword;
  • Get rid of java.util.Date hell - will require changes in java.sql as well;
  • Function objects, specifically for bulk processing on collections; implies C#-style delegates;
  • modularity, e.g. OSGi-like bundling - no jar-hell;
  • Annotation-based configuration for JavaBeans, again, like it is done in .NET System.ComponentModel; extensive support in Swing;
  • Something similar to org.springframework.util.Assert class for common runtime checks;
  • Human-oriented Generics;
  • Byte-code emitter API;
  • Unified interfaces and compiler support for events like in .NET, free of known problems;
  • One more feature would be nice to have - a user-defined context reference in java.lang.Class object. This would let keep all class-related extensions, e.g. persisters, serializers, validators, type descriptors, etc, acessible by simple navigation as opposed to keeping multiple mappings.
  • Extremely useful feature - C#-style verbatim string literals (@"...") = multiline strings in Scala ("""...""");
UPD: I think I'd better provide some explanations why I deem these features to be missing.:-)

Thursday, January 21, 2010

IBM eXtreme Scale vs ORMs

Ah, that's a solution I have also been thinking over for quite long time. Distributed object caching - that's the next generation platform for most applications. I am sure this is one of the most interesting areas to work in. Shall I seek for opportunities with IBM, maybe? :)

Thursday, January 14, 2010

Thoughts on validation

Would I miss anything if I guess that a validation rule applied to a single entity can be either of the two:
  1. An extention to a standard general-purpose type like int, double, String, etc that constrains the domain of possible values to the actual business domain. When I declare a String property as not null and having at most 16 characters, I actually give a hint to the framework to force the corresponding restriction on assigned values. Alternatively I could probably declare a new type like NonNullString16 and use it instead. Possibly a good example is the price of some asset that should never be less than zero. This requirement can be captured by NonNegativeDecimal type or even more specialized AssetPrice type. However, building a custom type for every particular situation seems rather irrational and hardly doable in most cases dut to a number of technical problems.
  2. A complex check on several properties correlated by some law. Examples:
    for an employee the graduation date cannot precede the date of birth, for a market quote bid price cannot be higher than offer price, the number of idle resources cannot exceed the overall pool size, etc.
There is also sort of mess in SQL where #1 maps to NOT NULL constraint and size restriction on the column data type, and #2 is reflected by a CHECK constraint. Or is it a mess at all?

From Java constructors to domain-driven design concepts

Interestingly, a constructor in Java can be thought of as a callback method which is to be invoked upon instance allocation.