Tag Archives: java

Apache Wicket [In Action]: A Review and How It Relates to the Java World

Java is a great tool for creating software. It is well designed, modular, has a wide array of platforms that it can run on, performs well, it’s very extendable, and it has a large community with lots of support. However, it’s support for websites and related services is severely lacking. It’s bad enough that frameworks that extend the existing infrastructure have massive pitfalls that you later discover.

For the most part Apache Wicket solves many of the web related issues that J2EE (JSP) has. If you are to follow the prescribed way of doing things, it can actually be quite pleasant. However, there are a few thorny patches with Wicket. I will get to those later.

Wicket In Action like a marriage. During the honeymoon, everything is great. Everyone is happy, and then later discontent grows and things go up and down. However, unlike a marriage, you don’t really get an ending. This is a rather good way to end things, but some of the lesser parts of the book were rather disappointing. One of the big selling points of Wicket is that it is a framework that assumes that the developer has already prototyped the pages in HTML prior to starting with Wicket [The pages are adapted into Wicket-ized and previewable pages]. This upside was enough to ignore the placement of the HTML files, in the class path rather than the web resources section.

I jumped into this book with lots of enthusiasm after reading the introduction. I even bore through some of the non-stated setup issues in the book. The book starts off by creating a project, from scratch, however I went the Maven route (which I discovered is the better way to go). The book mentions maven, but it doesn’t mention how to build your application or to generate a project. I believe that I went the correct way because Maven helped to setup all of the application servers and the folder structures. The book started by having the user to jump in, examine a few code segments, and then to start on a sample (full featured) e-commerces application. The store was oddly pleasant; the goal was to sell cheeses online. The application started from a few sample view pages, it went on to creating a reusable shopping cart, and finally on to a membership mechanism. This is a very straightforward and to-the point way of starting a new framework. It’s already addressing the needs of the majority of its audience.

Another nice thing to point out about the introduction is that it did not try to cover all of the material at once. It would frequently describe what you were doing, but would mention the chapter where the concepts were explained in depth later on. Something that pleased me was that the code listings did not include a listing number. They were place in the correct location of the text. After you’re done with the sample application, you should be quite proud of yourself. This is similar to your first website.

However, the book got a little disappointing when describing the more detailed interworkings of Wicket: sessions, bookmarkable pages, and layering/rendering. The book improves when it gets to the Ajax functionality and a brief mention of dependency injection and Wicket. The book gets a little rough in the Spring through Hibernate sections and then better in the testing section. The book ends in a rather low note on SEO, production configuration, and JMX. If I had known more about JMX, I would have probably had a better opinion of the ending.

Overall I am not sure if I can say that the less than stellar sections of the book were entirely the authors’ or the book’s fault. It quite possibly may be the technology’s fault.  I would strongly recommend the book if you are new to Wicket.

Lastly, here are some direct tips that I had to discover on my own that helped out a lot:

 

The Pitfalls of Testing

For the most part, testing is a great thing that is a surefire way to improve software quality. However, I’ve found that there can be three minor pitfalls when it comes to testing. I’m sure there are more, but these are the ones that I’ve experienced.

When running the tests, your current runtime environment is based off the testing class path. This means that when you are using refactoring, the classes that the test cases are contained within can appear to be valid packages within your application. For example, when recursively searching for a listing of classes by using reflection, the test classes will show up. This is an important thing to note, and to remove the test classes in your cases, when you’re confirming the results of this process. In addition, it is possible to use reflection to see and initiate test cases from the application logic, something that should not be a valid operation in unit testing. For example: If you had a Factory class to initiate only the classes within your JAR file, you could pass in a reference to a test class, and it would initiate it. This would produce undesired behavior.

IDEs consider test cases to be a usage of code. This makes it more difficult to spot dead code in your project. Dead code slows down production time, tends to be non-conforming with the current code base/philosophy, and may be used by an ill-informed developer later.

As of the current JUnit version (4.11), there is no way to disable a test and have a warning created for this state. The only two options for this are to let the unused test case fail intentionally, or to use the ignore annotation. Intentional test case breakages performed by an intentional fail method within the test case, or leaving the functionality broken. Unfinished test cases [which would warrant this situation], should not be left blank, they will show up as a passed test case. Empty test cases should be shown as an error, but are not. This StackOverflow question discusses the Ignore annotation more; however using @Ignore leaves unused test cases, which the developer is responsible for keeping up with. Having a broken test case inflates the failed test case count, and may cause valid test failures to be overlooked.

Review: The Java Virtual Machine Specification: Second Edition (Java 2 Platform)

Despite the age and subtitle. This book is still relevant for the Java 6 and 7 platform. The Java Virtual Machine Specification,by Tim Lindholm and Frank Yellin, is a specification book from a pre-Oracle time. The book goes over how the Java language is structured and designed. This is a great guide for any serious Java developer. The book provides insight on the reasons why things are designed the way they are, Java [assembly like] byte code, the classfile format, and a handy reference for the bytecode [including the op codes].

I read this book for non-professional reasons. It was more of a curiosity to read this book. At times, the book went into more detail than I cared about. Also, I skimmed over the documentation on the bytecode. However, I really did like that it introduced the detailed bytecode documentation and then followed it up with examples of how code is transformed into its related bytecode.

Reading this book should make Java Performance (Hunt) a bit easier to read, understand, and more interesting. That is when I can get to reading the book. At the moment, I have more than 30 [physical and non-physical] books on my reading queue.

Progress on Tech Resolutions of 2013

Earlier this year I made a few resolutions for this year.

So far I have completed the following:

  1. Finished and reviewed “Groovy In Action”
  2. Refresh on networking

Despite this not being much, I have learned many new things about disk storage, and Maven. Also, I’ve created a new GitHub repository for a ogg2mp3 script that I created.

Things left to learn/do:

  1. Finally get around to learning GridGain.   [I would love to see a well published book, or at least a Kindle eBook to get some headway on this] HazelCast would also be interesting, but GridGain has more of what I’m looking for.
  2. Finally understand how network routing works.
  3. Get more experience with DNS, and DNS tools
  4. Master NMap [not just learn the basic uses of it, but to really excel with the tool] This would be similar to the reading up on SSH I did last year.
  5. Get up to conversational level German. [Living outside of German speaking nations makes this incredibly difficult]
  6. Finally develop some strong time management habits.
  7. Learn how to use Python [to the point where you can do some cool stuff with it]
  8. Learn R [rather than haphazardly hack]
  9. Meet/talk with some of the gurus of airfare scheduling/decoding, and the famous Tom Stuker.
  10. Learn how to use GraphViz [This is one of the odd ones here, but it's interesting]
  11. Get better with Erlang and to find/make real world uses.
  12. Learn/Create a GUI in Apache Pivot
  13. Create a web interface with either Stripes and/or Wicket.

 

Interesting finds of the Week [Week of the 20January 2013]

Here is yet another installment of things I found interesting/learned this week.

  • Typically, when you group disks together there are two options for this: RAID and LVM. This only works if you have similarly sized disks. However, if you don’t have then you can group them together by using “JBOD” related services. JBOD = Just a bunch of disks. At the moment, the technology I’m learning is Greyhole. It looks really awesome for small home server setups.
  • Auditing your code base for dead/unused code can make a world of difference to your productivity and size of your executable. I do not have actual figures, but I can only assume that it would make class loading and loading of your executable faster.
  • Obvious statement: Math and comparisons with doubles is extremely aggravating. Two numbers can be displayed the same, but unequal when compared. Google’s Guava collection handles this in DoubleMath. The class was introduced in version 13.
  • Need a list of locale-friendly holidays for your Java application? There’s an open source library for that: JollyDay
  • BoardingArea found that it is to pull your basic marketing profile from Delta. This didn’t work for me, I can only assume that the data end point has been fixed.

 

In Support Of Maven

In the last few days there has been an article completely bashing Maven on hacker news. I found this a little aggravating. Much of the article spent time complaining about how the files are structured, and how much effort it takes to maintain a Maven file. Also, the article complained about the plug-in structure.

To some extent I can agree with the original author. The plug-in system makes Maven a little difficult to learn and get completely right. On the other hand, the plug-in system makes it easy to deliver a single meta-build system that can easily adapt to what you need it to do. Building a Java web app? It has a plug-in to build and package it for you.

My main beef with the article is that it completely ignores why we got Maven in the first place. It builds, packages, and manages your dependencies better than ANT does. Before, you had to manually acquire, and grab your dependencies. If you had ANT or make, then you had to include the declarations for the dependencies in the build file, and put the dependency in your project. This is a pain for those that are using source control, and for setting up new developer machines. However, with Maven, just declare the dependency and the scope in the build file and you’re done. If you’re using an IDE it’ll bring in the references and may be able to pull the Javadoc if it’s available. Additionally, any new upgrades to the dependencies could be added just by changing the version number. Imagine doing that without a Maven like build system. Maven can even go the extra mile and create a redistributable package [this is a little tricky, but you can do it], deploy your new package to a repository, check in your code for you, or even deploy it to a webserver. For example, if you have a web service and don’t have Tomcat7 downloaded, run it with an embedded instance with mvn tomcat7:run . You’re done, Maven grabs Tomcat7, its dependences and tries to deploy your webapp to the new instance of Tomcat7. No installation of the server required.

In closing, Maven is a build tool. Unless you’re making project structure changes you shouldn’t be messing about with the way it builds things.

Massive IntelliJ Sale

Usually I’m not the type to advertise on going sales, especially when it is a ‘limited-time’ type sale. However, IntelliJ is having a 75% off sale. They’re offering the IntelliJ IDE for $50 for a personal license. This is incredible, considering that the IDE is similar to Netbeans and it includes features that were stripped out of Netbeans in previous versions. The sale lasts until 5AM 21 December [Eastern Standard Time].

Really Cool Things I’ve Learned This Week (R, Random Numbers, Java, Hypervisiors, and fan maintenance)

Within the last week I’ve learned a few interesting and strange things:

  • Given the right connectors, R and PostgreSQL can work with each other to produce graphs, and use each other’s functions. I believe that the strongest use forthesetoolsare: to create windowing functions that aren’t already provided in PostgreSQL and to generate charts directly from the database.
    • R can operate within PostgreSQL with the Pl/R module. This means that you can create a graph from an SQL query. In addition, with Pl/R, you can make R functions callable from SQL. For an example on getting Pl/R to work, and generate a graph see this. One example, is that R can provide an aggregate function, that PostGreSQL does not contain: median. Warning: At this time, PostgreSQL 9.1 is the most recent supported DB for Pl/R.
    • R can work with PostgreSQL with the RPostGresSQL driver. This is pretty cool, as that the data it brings in is an ordinary data frame, in-which you can perform any R related function as if it came from any other source. Instructions can be found on it’s project page.
    • This may sound crazy, but the lack of random numbers on Linux may cause WebLogic to double the time needed to start. My own personal test has confirmed this to be the case. This is typically an issue with Linux, /dev/random’s behavior, and WebLogic’s usage of SecureRandom [Java].  Under Linux, SecureRandom uses /dev/random for its default source of random numbers. However, under Linux /dev/random blocks until it can get the next random number, and the numbers are based on activity from system drivers.  Within a VM, the performance of /dev/random is exacerbated by a lack of driver noise. As of the time of writing, the only hypervisor to provide a driver to assist in this issue is KVM; VMware and Xen do not provide a driver. The solutions provided by Go-Integral are: redirect /dev/random to urandom(not advisable), use a hardware key, use a broker, or use the hypervisor driver (if it exists).
      • TL;DR: Using VMs and plan on generating lots of random numbers for SSL and/or crypto? Use a hardware key, entropy broker, or a hypervisor driver if you’re using KVM.
    • Recently, a lower powered box that I own refused to operate. This was due to a fan underperforming, and would let the box get too hot, to the point that the BIOS just halted the machine from running. Instead of replacing a functional fan, I found out that a little machine oil [for sewing machines] can actually fix the issue. Oiling the fan should be in every computer user’s periodic maintenance schedule along with backing up their data, and cleaning out the dust. Due to fan size this is incredibly important on laptops and GPUs.
    • If you need numbering for groups within a PostgreSQL query, you should use the rank function. It is a Windowing function, that will give you the number for that particular group, based on a criteria. See the documentation yourself for a better explanation. 

“Wanted Java Developer” could you be a little more ambiguous?

I have a bone to pick with the industry I associate with. The tech industry struggles to clearly define the expectations of whatever is desired. This is pretty much a universal issue with the industry. There are always hidden requirements. Job listings are no different.

The bone I have to pick is with the titles/job requirements. One of the worst offenders of this is for a Java Software Engineer. Based on the availability of frameworks, and meta-frameworks, asking for a Java engineer is quite ambiguous. This could ask for a graphics developer, API designer, web developer, Computer vision expert [CV in java is possible with native libraries, trust me!], core libraries developer, or even a micro-JVM developer. The amount of variability with the language makes a generic “Java developer” title frustrating.

As a potential candidate, it is incredibly frustrating to see the “Java Developer” title. Some titles ask for experience in Spring, Hibernate, Solr, Lucene, JAI, J2EE, etc. It’s incredibly frustrating to go into an interview, where the listing asked for all of these and then only be grilled on the minute [rarely used] inner workings of Spring RMI. Just the Spring framework alone asks for a lot. Of all of the potential avenues of spring that one could master are: Message queuing, Web services, Roo, Security, Integration, Web flow, MVC, BlazeDS, Batch, Social, and mobile. That’s not even accounting for the frameworks that you can substitute between the pathways for Spring. I’ve worked with a late Spring 2.x and early 3.0, I was not even aware of the new BlazeDS, Batch, social, or even mobile options for the framework. Things change quite quickly.

Besides ranting, what is the purpose of this article? I believe that the Java title should be a bit more specific. If you want a Java developer that knows a lot of frameworks, still label it as a Java developer position. However, don’t expect him or her to know all of the inner workings: that is just silly. If your business involves multimedia display, request a developer that knows the Java 2D and 3D graphics, and maybe the JAI libraries. There is a lot there for practically any task you want to throw at Java, given you know which library to use.

Scientific or mathematical tasks, ask for a Scientific Java Developer. What libraries should they know? Colt, EJML, JAMA, etc.

Writing a Java API? Ask for a Java API Designer. Expect for them to list their favorite APIs, what works, what doesn’t, and why.

Web applications? Ask for a Java Web Developer. Maybe they should have experience with a SOAP framework, MVC framework, Play, GWT, basic Web skills, and maybe even a non-SOAP based webservice library [REST, Hessian/Binary]. Please don’t use the enterprise title unless you need someone who knows EJB, and/or ESB frameworks.

Moreover as an employer, be more specific the first interview/inquiry on what the job is asking for. If an job application asks for the common ORM Hibernate, how much should one know about it before applying for the position? Should they be able to know how to wire up beans to their DB analog? Should they know how write their own dialect for a new data source? With JUnit, should the applicant be expected to transition your current development methodology to TDD? Should they know how to extend the JUnit framework?

At this point, you should be getting the picture. Different tasks demand different skills. Specify what you’re looking for. Find people that can learn new skills and that are interested in the same problems you are. People who have an active interest can learn what is needed to get up to speed. If you go to a butcher and ask for meat, you’re always going to get what you asked for, but not what you were craving.

Addendum: This can apply to an Erlang, C++, Python, and most other developers. The role of Java currently has such a great demand, and such an ambiguous title, making this article a little easier to communicate.

My first attempt at open source: PageRecommender

For personal/private [non-work related] projects, I tend to shy away from creating/working on open source projects. Typically open source projects tend to resemble the same work I do during the day, working and dealing with others. That’s no fun when you just want to build something you need. However, I am trying something new. I’m releasing one of the personal projects into the world of open source. It is the component that is used on this website for making recommendations for projects. [Example: see the bottom of the Financial Strategy Simulator page] A project page that contains more technical information about this project can be found under /a/Projects.

To find this source pull it [using git] from: https://github.com/monksy/PageRecommender

What is this project about? This project is designed to analyze Apache request logs, and attempt to piece together sessions, and then to create an Amazon/Newegg-like statistical recommendation. The desired output is XML representing a parent/child relationship of a page and the next connecting page.  The output comes from standard out. The component is designed to be used as a quiet utility.

What this project isn’t: This project isn’t a completely generic solution that’ll fit your site. It is designed within the context of my current website, and the format of the standard Apache log files. Want to have it look for pages that don’t fall under the /p/{Name} syntax? Change up the Apache log file format? Well this project won’t work for you without modification. Also, there is no such warranty provided by this code. It’s open source, it’s free as in speech but not as in beer.

What could be improved: I realize that this project isn’t perfect. I could have designed it to be slightly easier to read. It could be documented much, much better. However, this is an internal project. Want to improve it? Github should allow you to make such changes. [I’m rather new to Github, so don’t hold me to that statement] The XStream dependency could be removed. But for right now it works.

What do I recommend?

Grab the source! Add more tests, and send me input on how you think it could be improved.

Related Posts Plugin for WordPress, Blogger...
Better Tag Cloud