Posts Tagged Java
Java Surgery: how to swap(int, int) and have it work… sort of
Posted by dreamreal in Java, Rocket Surgery on 9 April, 2010
So it’s a known fact that Java passes references by value. That means that if I pass an Object of some kind into a method, I can change the values in the object, but not the object reference itself. Likewise, if I pass an int into a method, I can change the value of that [...]
Tools should just go ahead and move to OpenJDK7.
This isn’t particularly thought-through or anything, but … I caught myself thinking this morning that communities like Scala, Groovy, Jython, JRuby, maybe even Maven should go ahead and migrate to OpenJDK7 just to push the JDK7 people along. It’d create momentum around features that people used, and force the development team to trim out the [...]
Java Surgery: Timing Method Calls
Posted by dreamreal in Java, Rocket Surgery on 8 April, 2010
My data stores benchmark gives out timings in terms of nanoseconds, by making a list of response times and then applying statistical methods to get data out of the list. However, one part of that comes up every now and then: how do you measure the time it takes to issue a call? After all, [...]
Java Surgery: Spring Injection of Other Beans’ Properties
Posted by dreamreal in Java, Rocket Surgery on 7 April, 2010
Today, someone wanted to inject not a bean, but a bean’s referenced property into another bean. Put more succintly: He had a bean A, with a property B, and didn’t want to inject A into bean C, but wanted to inject the result of A.getB(). Easy.
Java Surgery: Initializing arrays of arrays
Posted by dreamreal in Java, Rocket Surgery on 5 April, 2010
From IRC, from whence many “interesting” questions come: “If I have a 4 dimensional integer array in Java, is there a way to initialise every element in it to a particular value?” Well. First off, you don’t have a four-dimensional array. You have a one-dimensional array of one dimensional arrays of one dimensional arrays of [...]
LeafChat 2: excellent IRC client, but it’s still only a start
I tried out LeafChat 2 this morning. It’s an IRC client that happens to be written in Java. It’s actually very well done, although command shortcuts are missing; you can write some of them yourself, but the scripting API is still slightly too limited to make this worthwhile. It has a number of customizations; thank [...]
Java’s more relevant than you think.
Posted by dreamreal in Programming on 5 April, 2010
People say that java’s irrelevant now, but let’s be real: the ‘cool languages’ are keeping the parts of Java that run well and mixing it with impenetrable syntax. Java’s not only relevant, but important.
Rocket Surgery: What is Inversion of Control?
Posted by dreamreal in Java, Rocket Surgery on 1 April, 2010
From IRC: “What’s Inversion of Control?” First off: Oh, my. Here’s a quick summary: traditionally, Java resources acquired whatever resources they need, when they need them. So if your DAO needed a JDBC connection, it would create one, which meant the more DAOs you created, for whatever reason, the more JDBC connections you used. It [...]
Darn location-oriented datastorage systems.
I’ve been working with Spring’s Pet Clinic application lately, and one of the things that frustrates me about it is that it uses a database script to seed data. I thought of having a signal in the database itself, where the flow would be something like this: Look for a table whose purpose is to [...]
Java Surgery: heap size of objects
Posted by dreamreal in Java, Rocket Surgery on 24 March, 2010
A reader asked if I thought that an array of 1000 bytes and an array of 1000 ints would take the same size on the heap. My answer: I don’t know that it would, but it could. I’d like you to follow along with my logic, if you would, and if anyone has a way to measure, I’d love to know about it.