Skip to main content

Dive into Java

Recently a friend of mine asked me to help him develop a small web application to be run on a tomcat server. So that would mean I have to develop the application using Java, which I have not used ever since my student days. But because the requirements were pretty small, I took up the challenge just for the opportunity to learn something new.

The system was meant to capture the answers of a questionnaire and calculate the score they got. Then display back the past scores. It's pretty small involving just CRUD and a small amount of business logic to calculate the scores. Could probably be done in a bit over an hour if using tools I'm already familiar with like CakePHP or Django. But with Java, it was a completely different story.

My experience with CakePHP when developing MyMeeting made me quite reluctant to ever not use a framework ever again. Unless it's just a small trial program to understand a new language, it's better to use a framework. In the framework usually there is already quite a lot of thought put into how things should be organised and what's the best way to achieve our goals. So you get the benefit of quite a lot of wisdom without having to go through acquiring it. So that was the first thing I did. I googled for a 'java framework' and BOOM. Despair. There was tons of them. So many I had no idea what to choose. So I started to search for reviews and comparisons. You basically can't read about Java framework without struts being mentioned. Tapestry was pretty popular too. But they all seemed to have quite a high learning curve and you read a lot about the DREAD of configuring xml files and all. Finally I tumbled on wicket. Reading reviews and presentations about it got me pretty excited. And when I started developing I realised this framework is just for the UI. It made it pretty easy to do quite ajaxy stuff, but there's nothing about database connection and stuff. And there was no tutorial on how to get CRUD even. So after more googling I finally found Databinder. It is basically using Wicket as UI framework and either Hibernate, ActiveObjects or Cayenne for the database abstraction and interaction. Alhamdullillah. With plenty of examples to copy and paste from (hey, I didn't have a lot of time okeh.. :P) , I was finally able to get simple CRUD working.

Of course by then I met with a lot of the things which made programming in Java a pain. The dependencies, all the declaration, putting in setters and getters for almost every variable. UGH!!!! But in the examples they showed how to set up your project to easily work in Eclipse. And I followed it. And now I understand why Java developers swear by their Eclipse IDE. It's way freaking cool. I mean want to put in all the setters and getters for every variable even though you've got around 50 of them? Forget about typing it, how about just right clicking on the file and choose 'source->generate getters and setters' and it will all be done for you. How cool is that? What's it? You just copied from one file to another a bunch of lines which declared types you've got to import? No problem. Eclipse will automatically copy the imports too if it's already resolved. It's way seriously cool. If only it had vim keybinding.. :P

Anyhow. That took most of my weekends recently but it was very well worth it. I'm not 100% comfortable with it yet, but at least now I can do dev in Java. And if someone was to read my resume and ask me do I know Java I won't have to answer 'Well.. I did a few assignments with it when I was a student'... :P So now the only languages I'd really really like to have a serious go at it is ruby (probably with Rails) and Lisp. Maybe the opportunity would present itself in the future. In the mean time, I still got to polish my Java-fu.

Comments

Popular posts from this blog

haproxy on Centos 7 with SELinux

Setting up haproxy and varnish with reference to the configuration from these sites: http://sharadchhetri.com/2014/12/20/how-to-install-varnish-4-version-on-centos-7-rhel-7/ https://www.upcloud.com/support/haproxy-load-balancer-centos/ And finally can access plone on the server. But when I check the haproxy status, only client1 can be accessed. All other clients were down with general socket error, permission denied. Googling a bit I finally found out it was due to SELinux. Refer to this page: http://stackoverflow.com/questions/26420729/haproxy-health-check-permission-denied With the solution from that page, I installed policycoreutils-python and tried to run the command given: semanage port --add --type http_port_t --proto tcp 8081 But that command failed with the error that the port was already defined. When I looked it up using: semanage port -l | grep 8081 It belonged to some other type (transproxy_port_t). When I tried to delete the type using: semanage port -d -t transpro…

Installing Centos 7 on HP G7 Server

When I first initially tried it, the installer cannot detect any local hard disk to install to. After much googling found out that it was because a certain driver for the Smart Array Controller is no longer available on Centos 7. To allow for use of the new driver on old hardware, you need to enable the option. Once the DVD has booted and on the first menu screen, highlight the first option and then press tab which would bring you to a command line where you can add additional parameters to boot. Add the following parameters: hpsa.hpsa_allow_any=1 hpsa.hpsa_simple_mode=1 And then press enter to boot. You should now be able to install as you wish. After installation, on the first boot, make sure at the menu, press 'e' to edit the parameters and add them again. Then once booted, go to /boot/grub2/grub.cfg to permanently add the parameters to the menu. Refer to http://serverfault.com/questions/611182/centos-7-x64-and-hp-proliant-dl360-g5-scsi-controller-compatibility and it&#…

Me and my sleep apnea

I have been suffering from sleep apnea for quite a few years already. It started to show when I was still with OSCC some 6 years back when I would sometimes "accidentally" sleep at my cubicle. Early on I just dismissed it as because I was growing fat (we ate a lot at OSCC.. :P and I barely went anywhere except my cubicle) and also because of babies. Oh babies.. those cute little things that keeps you awake at night so that they can be so cute and charming when your friends and relatives come over the next day. So it was dismissed. Later on I got more and more used to sleeping at work, started associating it with my lack of motivation and sometimes feeling of downright depression. And I kept growing fatter and fatter, which I assumed was the reason why I was getting more and more tired.

But then around 2 years ago a friend of mine suggested maybe I've got sleep apnea. And a few other people suggested I go to a sleep clinic and all that. Put it off for quite a while. Until…