Explaining Dependency Injection and Inversion of Control

In a normal programming sense, your code generally tells the system what to do and what resources such as databases or authentication system to use. In Inversion of Control reverses that idea and the system instead tells which of your code to run. Hence, inversion of control, IoC for short.

Normally when we code we tend to have dependencies on resources. When coding in an IoC fashion, these dependencies are “injected” into your codde when needed. Hence the name Dependency Injection.
Continue reading

Share Button

Screen time vs Paper Time

Screen time vs Paper Time

I think the above comic sums up my view when I hear parents limiting their kids use of screens.  Personally, setting arbitrary limits to kids creativity isn’t my cup of tea.  Most things on the iPad [that PM-1 will get when he is big enough] have a lot of  apps that promote creative expression so why hamper? Continue reading

Share Button

JET-NG

When I was doing my JPA Anntation Processor, I used JET to do my code generation because it was the only templating engine that I have seen that creates Java code that can return a String. The problem with using JET was the Maven plugin that was is available on central doesn’t have any of its sources and is no longer actively developed (as shown by the lack of source pointed by their POM). Using JET that comes from Eclipse apparently requires the entire Eclipse runtime and their direction with JET2 seems to force more Eclipse dependencies. However, JET in itself is a pretty neat standard so I decided to reduce the chance of having trouble with lack of support I decided to make my own with an associated Maven plugin. This blog post defines the requirements I had for my implementation
Continue reading

Share Button

Microbenchmarking repeated characters in Java

When doing a code generator, I found that I had to do indents which usually involve repeating characters. So I wrote some short code to do it using arrays. Of course this should be tested and Google created a microbenchmarking tool called Caliper to do this. Unfortunately, this tool has practically ended up in the ever big pile known as the Google Graveyard in that it has abandoned supporting people who may use this in Windows that are affected by this bug #215. I have decided to fork and do the deployment myself on my own namespace in central rather than waiting for a release which is who knows when.

Once I got it done I then implemented the benchmark.
Continue reading

Share Button

No iPad for my kid

At least not until he can carry it on their own.  One of the things I notice about kids and their iPads is who carries them around when they are not using them.  Sorry PM-1, I am not your pack mule. Continue reading

Share Button

JPA annotation processing

Previously I had defined how I would design domain objects with JPA. One of the things I had noted was the notion of a table model that encapsulates persistence operations. The table model is pretty much common and although some things can be done by generics, some things such as named queries cannot and require the use of strings. However, a pattern can be followed for the names combines with Java annotation processor be used to create code that would reduce the use of strings for users of the class.

This post discusses how I would build an annotation processor that takes advantage of JPA entity definitions to create support classes that avoid strings in user code.
Continue reading

Share Button

Using JET to create code in Maven

Java Emitter Templates (JET) is a templating system that takes JET template files and converts them into Java source code.  Unlike other templating systems like Velocity, the code it generates does not require additional libraries making its generated code usable without additional libraries when creating annotation processors.

This is a simple introduction to using JET with Maven using the tikal-maven-jet-plugin in Eclipse M2E.
Continue reading

Share Button

Gaming allowance using Khan Academy

Eventually PM-1 will need to learn the value of a dollar. The normal way of doing it is by providing an allowance for the kid, but rather than do chores which I myself find menial to do, I would rather they continue focusing on learning. One of my friends from work, UV, introduced me to a smart use of one of the more popular learning sites I have encountered, Khan Academy, and how he uses it with his children’s allowance.
Continue reading

Share Button

Creating an annotation based code generator in Maven

One of the nicer features added in Java 5 was the support of creating custom annotation processors.  The use of custom annotation processing allows framework developers to set up a model that would generate additional code as part of the build.

This blog post discusses how to create and test an annotation processor in Maven. Continue reading

Share Button

Learning AngularJS

There’s many tutorials that show how to use AngularJS online, the AngularJS home page does a very good start. @blm849, one of the smarter people I know asked me if there was any site to ramp him up. I said the AngularJS home page followed by learning directives.

In this post I will expand on my suggestion and follow on with other things to look at.
Continue reading

Share Button