• Saturday, January 30th, 2010

There is this project I worked on back in school with a classmate. Its a database of drugs. There is really nothing very spectacular about it, but the java programmers will immediately see how it was created….JAVADOCS.

The way drugs are arranged, it follows a form that can be easily represented by java classes. And that was what we did, after writing the classes, putting in Javadoc comments, we just created the docs, and what we have is t

his http://javabuoy.net/drugs/

This is far from a complete job, we have to kinda give up on the idea because both of us started pursuing other fields. But we are kinda coming together again to make this a complete project, with search capabilities and a complete drugs database.

There is nothing wrong with the current lists we, Just that none of them provide it the way we are doing, or better still none of them is taking the Hierarchical approach we are taking.

WIll keep you posted as we go on.

• Tuesday, December 22nd, 2009

I actually prefer using Spring and Hibernate. I call it Hibernating in Spring. I have never used JSF, I don’t use JPA, entities are a foreign word(may be alien is better) etc etc. So my knowledge of JavaEE was basically as much as will aid me in Hibernating in Spring.

From JavaEE 5, I decided to read the JavaEE tutorial, I was actually reading it when JavaEE 6 was realeased with Netbeans 6.8. I downloaded both and also downloaded the Java EE Toturial, Volume 1. I read this too. After then I asked myself, what’s wrong with JavaEE?

I mean what’s wrong like why do we need frameworks like struts, wicket, spring, etc etc. The JavaEE stack I believe is matured enough to handle all your needs. I really don’t know how JavaEE was before 5, but since 5, and now 6…..JavaEE is the bomb.

Now we have Facelets – I wonder what can be better than that. JPA, Transactions etc etc. Just for the fact that I hate XML and that the compiler can take care of annotation errors, JavaEE 6 wins. Plus the fact that Netbeans 6.8 has what we can call native support for JavaEE 6. I need someone to convince me that I still need to Hibernate in Spring.

Merry XMas to you all.

• Friday, December 11th, 2009

Following my previous post, I have a new addition to the library. This time its a Date utility. Here is the code

package com.trinisoft.mlib.util;

/**
*
* @author trinisoftinc
*/

public class Date extends java.util.Date {
public boolean isAfter(java.util.Date date) {
if(this.getTime() > date.getTime()) {
return true;
}
return false;
}

public boolean isBefore(java.util.Date date) {
if(this.getTime() < date.getTime()) {
return true;
}
return false;
}

public Date afterSeconds(int secs) {
Date newDate = this;
newDate.setTime(this.getTime() + (secs * 1000));
return newDate;
}

public Date afterMinutes(int mins) {
Date newDate = this;
newDate.setTime(this.getTime() + (mins * 60 * 1000));
return newDate;
}

public Date afterHours(int hours) {
Date newDate = this;
newDate.setTime(this.getTime() + (hours * 60 * 60 * 1000));
return newDate;
}

public Date afterDays(int days) {
Date newDate = this;
newDate.setTime(this.getTime() + (days * 24 * 60 * 60 * 1000));
return newDate;
}

public Date afterWeeks(int weeks) {
Date newDate = this;
newDate.setTime(this.getTime() + (weeks * 7 * 24 * 60 * 60 * 1000));
return newDate;
}
}

Now in your code, say you have a date object, you can do this

dateObject.isBefore(anotherDate);
Date newDate = dateObject.afterHours(24);
........

You can try it out. I also will appreciate suggestions.

• Friday, November 20th, 2009

I have this problem with my iPhone, Whenever I run the battery down to less than 20%, the phone won’t charge again when I plug it in my MAC. But if I plug it in windows it will charge, if and only of the windows box is not been used. If the windows PC is in use, then no charging for iPhone. Of recent, the iPhone started behaving very funny too. Sometimes, the MAC will charge it sometimes it won’t. So I decided to look for reasons why.

First I note that when the battery is below 20%, before you plug it in, shut it down first, then plug it in and everything will be fine. Next, The iPhone will charge if iTunes is not running before you plug it in. If iTunes is running, then you have to close iTunes and open it again, and iPhone is charging. Next I also noticed that most of the electric chargers that ship with the iPhone will not work for you once you jailbreak the iPhone.

The iPhone is a great product, but when people complain about the battery, I think it goes beyond the mere fact that it runs down quickly, the battery of the iPhone is generally shitty, You will be surprised at the vast amount of people who have posted online about this(google is your friend) and yet, apple seems to not want to do anything about it! Although this problem of not charging seems to be experienced by mostly people who jailbroke their iPhones.

Anyway, after about 4hours, today I now know exactly the voodoos I have to invoke to make the iPhone charge anytime anyday anywhere…..I pity the less tech savvy people who use jail broken iPhones.

Category: Uncategorized  | One Comment
• Monday, November 16th, 2009

This is my experience with the JavaME EA for MAC OS. I am using 10.5.8(Leopard).

At first it was a God sent that we now have a tool from sun. Using Netbeans and mpp-sdk kinda sucks, but it was all I have got. After the download, which went without incidents, I ran the EA for the first time and it blew all the whistles and knock all the bells. I immediately opened a sample app and run it, It ran well without incidents. Then out of the blue, I got the first error.

When trying to run ANY application, it will return with an exception/error message that it can not connect to device 0, or any of the devices I used at that. I googled and all the responses were not helping me at all. At last I did the unthinkable, guess what that is? I restarted my MAC. I have not done that in a looooooong while so it took some time before the system actually finished the restarting process and voila, my EA was back online. But not for long!

Next, EA takes it upon itself to just DIE for no reason. I run an app, and the next thing is the EA has stopped working un-expectedly. I also tried googling, but no result. So I started fooling around. I went to tools and refresh the SDK under platforms and voila again, EA stops dying. But again, that was not all.

Next I noticed that after running an app for about 6 to 10 times, EA will stop working saying it has run of memory. I tried to close all applications while running EA but, duh! after about 6 to 10, sometimes 15 runs, it will stop working with the same out of memory error. The annoying thing is, it won’t even quit. I will have to use force quit(windows version of CTRL + ALT + DEL).

I am yet to solve this problem, and I don’t think I will ever solve it until the next version comes out. Looking back however to the days of mpp-sdk and Netbeans, I think I still prefer the EA, At least I can do Bluetooth without having to buy some licence from some people.

All in all, I give Sun +1 on this. It is really something all MAC developers have been asking for since time immemorial. All that remains is perfection. And if I remember correctly, in software, attaining perfection is an eternal process. No software is perfect until it is dead.

One thing I will give kudos to the EA guys for again is that, all projects created on Netbeans also works perfectly on EA, be it from windows or linux. +1 to you guys again on that.

Finally, EA is a good product. If you are a MAC J2ME developer, you will enjoy this IDE.

ciao

• Friday, August 28th, 2009

J2EE Myths.

I have met a number of java developers who don’t do J2EE. So many of them have so many reasons why they don’t do it. This post is a view at some of these reasons. I call them myths because most of them are actually not true, or not entirely a correct view.

1.J2EE is hard: This is one of the most popular of these myths. The question is J2EE is hard; compared to what? We quickly forget that programming is anything but easy. I started writing Java in 2002/2003. Then I have a number of friends, most of us were VB experts(or addicts depending on who is doing the evaluation). When I deflected and I started learning Java, most of my friends have this same view of J2EE today to Java then. Java is HARD. But today, these guys are .NET/C# Experts, Some have even successfully picked up Functional Languages like erlang. So the thing is, nothing is hard, or difficult. It is our capabilities to handle them that are shallow. The first time I picked up scala, I wrote this post  Scala after one week. Today I know better. So J2EE is not hard. It’s the programmer’s capability to handle it that is not top notch. There are several J2EE projects flying around, the guys that built them are neither aliens, nor programmers on steroids.
2.J2EE is not necessary: This is another myth popular among most especially non-java programmers. Never say something is not necessary until you try it out. J2EE was built to solve a particular problem(I will get to that soon), so unless you say that problem no longer exists, then I can agree with you that J2EE is not necessary.
3.J2EE is too verbose: And so is java. The verbosity of java is not news anymore. I laugh when I see guys compare writing the famous “Hello World” in java to some other languages. The truth is J2EE was not designed to write programs like “Hello World”. It was designed for building multi-tier applications. If what you want to write is “Hello World”, nobody forces you to use J2EE. Some other languages are more suited for that. But to build scalable n-tier applications, then you need J2EE.
4.J2EE is an overkill: Compared to what? Again this is the question I normally ask. Some will say compared to php. It’s pathetic because comparing J2EE to PHP is the best example of Apples and Oranges. I once had a project in PHP (I am almost through converting it to J2EE). After a while, I have to discontinue the project in order to keep my sanity. You can call me a bad PHP programmer, but the truth is in design, PHP was designed so that you can easily write un-maintainable code. It requires extra effort on the part of the developer to write maintainable code. J2EE on the other hand was designed so that it is difficult for you as a programmer to write un-maintainable code. It requires extra effort on the part of the developers to write un-maintainable code. This extra is not an overkill. I write PHP from time to time when all I need is to put together some piece code. But I am sure a very very low percentage of php programmers can be able to build something on the scale of facebook and yahoo using php without running into maintenance issues.
5.J2EE is slow: Your J2EE servers were designed to run on multicore, high end CPUs and not your low end systems. Trying to run Glassfish, for example on a P3 512Mb RAM is suicide. Because what the servers handle are not trivial, so the hardware requirements for them can also not be trivial. For the fact that they can run on low end systems did not mean they should be run on low end systems. If M$ had allowed Vista to run on a P3 512Mb RAM System, imagine what a world this would be!

There are several other reasons people give for not venturing into J2EE, the only valid reason I have gotten over time is I DONT NEED IT NOW. That was the same reason I gave several times over until the need arises. For everyday web-applications, I believe php will just get you by, but you will need J2EE if you are particular about scalability, security, inter-operability, maintainability, and all the other goodies that J2EE have to offer.

• Monday, August 17th, 2009

During my years of programming, I have met so many programmers with different ways of doing things, for example some believe in documentation, some don’t. This is however one of the many little things that programmers do differently. Some of these little things degenerate into big flame wars.

One of these concepts is what I call the DIE concept. Some programmers believe your program should run as long as possible, other believe the program should die as soon as possible before corrupting other data. I am going to explain the DIE paradigm, because….well I want to write something.

Die Early: We believe your programs should die as early as something bad happens. This concept flows down to compiled languages. If a dot, a jot of your incantation is wrong, the code won’t even compile! This I believe is the way things should work. Never allow your exceptions to be swallowed up. PHP is the only culprit that came to mind here. I believe errors and warnings are/should be a core part of programming. When a language turns off errors and warning by default, then I have a problem. There are several/countless hours wasted by programmers debugging php code that wont have been spent if the language just spit out some errors. I give kudos to java in this case. When something goes wrong, just blow up, or at least log a COMPLETE STACK TRACE of what happened and also TELL SOMEONE THAT SOMETHING BAD HAPPENED.

Die Fast: If you are going to die, please just do so. It makes no sense trying to do house cleaning while you are dying, you won’t need it anyway. The longer it takes an application to die, the more prone the whole system is to a complete disaster. When a part of the system experiences big enough turbulence to make it die, let it just die, or make it stop recieving input from other parts of the system, and it should never send out any message except for the next rule.

Die Loudly: When a module/application is dying, let it do so as loudly as possible. Print all the stack trace, or log it. If there are other modules sending message to it or reading message from it, let them know that the module is dead and can no longer recieve data. So many times, it is bad to let these guys find out for themselves that there server or client is dead. Let is be as loud as it can be. In a scenario where you have monitors and/or supervisors, they should make sure that all applications that require this dead module are paused at least. The best is to KILL THEM TOO.

This is how I have learnt to program, and sincerely, it’s always worked for me. I could have named this post “I love Exceptions”. They are a part of the application development process as well as a way to know what is happening to your application even at runtime.


• Friday, August 14th, 2009

I have course to meet some java newbies over the past week. And one thing 90% of them have in common is that they all had exposure to some other languages. PHP and Python in the majority. Another thing is that most are confused on the java naming convention. One of them even think naming conventions add to the terseness of the language. This post is to clear some of those misconceptions.

The reason for a convention, is so that everyone will be on the same page. Naming conventions in java allows developers to work together without much problem. When you use the convention properly, merely looking at your code, I know which is a class, which is a method, which is an object or variable, which is a constant. In fact if you follow some general programming naming conventions, I can know which class declares what object, what type a variable is and so on. I will highlight these naming conventions here and how I think they should be used.

  1. Classes: All classes should start with a capital letter. If your class’ name comprise more than one word, subsequent words should also start with capital letter. Every other character should be small letters. If your class has an abbreviation (e.g SQL, URL etc), they should be ALL CAPS no matter where they appear. Examples of good class names are TextDirectionChanger, InvalidOption, Controller, URLManager, NewSQLConnector
  2. Variables and Objects: All variables and objects should start with small letter. If your variable or object has more than one word, what do you do? yes, you capitalize subsequent words just like we did for classes. So valid objects or variables will be something like counter, classIntegrator, messageObject. But good programming practice should make us want to different between objects and normal variables of inbuilt classes. So this is what I normally do, when declaring variables, I use any name, but when declaring objects, I do something like this InvalidOption invalidOption, JOptionPane jOptionPane, etc. Also I put the name of the built-in type as part of the variable name when it is appropriate, e.g int intID, String strName, Double dblPrice. This later part are my own conventions, different programmers have different ways of doing this sort of things.
  3. Methods: Your methods take the same format as your objects/variables. The only difference is that methods have parameters list. Even if your method don’t have any parameters, you MUST put an opening and close parenthesis. One example that comes to mind is this getContentPane(), although this method returns an Object, it still follows normal method naming convention and although the method take no arguments, we still put the argument list delimiter ().
  4. Constants: All Constants should be ALL UPPER CASE. examples are EXIT_ON_CLOSE, HIDE_ON_CLOSE, etc. From those examples, you will see that the rule are a little different for constants. If your constant name has more than one word, separate the words with an UNDERSCORE.

There are other conventions, like proper use of interfaces, proper naming of methods, documentations etc. These are usually left to the programmers discretion. It is however good practice to follow popular conventions.

• Monday, August 10th, 2009

I remember the first time we met. It was like you were made for me. I was in love with your friend, hi5, and the relationship was not strained. But you came along and I saw what I have been missing. You were smarter, and knows how to satisfy me more. I tried to make your friend see reasons why she should start getting smart, like you, tried to make her see that her ways were old, we are not in the 90’s anymore. At least she should change her clothes, and maybe her scent. But she was too rigid, she wouldn’t listen.

So like they say in my country, and I think in every other civilized world, “its bros before hos”. My bros(friends) pressured me and I finally left her for you, and since then, the relationship has been sweet, flowers and paradise, until recently.

You have a sister called called twitter, and although I didn’t see anything wrong with you, you always think she is more beautiful than you do. When you decided to have your first plastic surgery, you told me about it, said it’s nothing serious and I went through it with you. And truthfully, it was a success, I loved you more after than before. Maybe you thought it was cool, so you decided to have other surgeries without consulting me. And yes you did have other surgeries, you’ve definitely been there done that: face lift, tummy tuck, breast enlargement, and some other ones that are too sexually explicit to mention. Funny enough, all my friends, or at least a higher percentage thought you were doing well with these surgeries, but for me, you were beginning to look like crap. The more you want to look like your sister, twitter, the more bogus you become. The more bogus you become, the less I found you interesting. It’s true that your sister, twitter is beautiful, I have seen her and wow, she is really beautiful, but her beauty is not in her voluminosity, its rather in her simplicity.

I guess she learnt a lot from your distant cousins, google and youtube. She knew she must be simple and easy to understand, if she is to attract men like me. She knew with time, other people will come to love her simplicity, just like they love your cousins. She knew what simplicity could make her achieve, and she makes herself easily understandable. That is what you were, that is the facebook I loved. But this facebook I am seeing now, to quote a popular Nigerian musician “….is not the girl I used to know, she’s a shadow of herself.”.

The most interesting thing is, my friends who pushed me away from hi5, all seems not to see that you have changed. They all seem to love the new you, and I am like an island. The only few that ventured to even visit your sister with me, got glued and understood me better, but the higher percentage won’t even stop to catch a breadth while all they do is sing your love songs.

And just like your friend hi5, you seem not to miss me. Not immediately I left her anyway. And right now, you seem not to miss me too. I disappear sometimes for a whole week, and when I come back, nothing seems to have changed. Its still the same old you, changing your looks faster than Michael Jackson, and the same old friends singing your boring love songs. Now to me you seems like a movie playing at 1-frame per day. I could be gone for a week and still not miss anything.

Anyway, I don’t want to cheat on you, so I am writing you this letter. This song says it all.

Dear facebook
How I hate to write
Dear facebook
I must let you know tonight
That my love for you has died away
Like grass upon the lawn
And tonight I wed another, twitter.

• Thursday, August 06th, 2009

If there is one trait common to all developers that I have met, it is their love for art. Topmost is the love for music, good music. Ranging from pop to rock to r&b, most programmers love music. The question is when shall we have an IDE that integrates playing music files by default? at least mp3. I was really hoping netbeans will be the first to take this initiative, but till date no one is talking about it. If you really support me on this, lets make a lot of noise about it. Lets twitter it, blog about it, post questions about it, and maybe someone will just listen and give us native support for playing music in Netbeans. I know you can write a plugin, but I think I prefer if it comes bundled with the IDE itself. I have a few things I will love to see.

1. Support for Streaming from sites like last.fm

2. Support for downloading and playing podcasts

3. Support for playing popular(ogg) and less popular(wma) file formats. :) lol, at least you get the picture.

4. Support for online radio. and more

I have just tweeted about this, you can join me by retweeting, or simply make your own tweet. Maybe in 6.8 or 6.9, our wish shall be granted.