Filed under code, java, software on September 3 | 0 comments
This is not the first time I do this and it is on the edge of embarrassing except this time I knew I had tools to get me out: lose the source code to a java application.
I have this application that was done a year ago and I guess that in the rush to get it to production I forgot to import the code in SVN.
A year later we have changed a few things and now I have to change a few lines in the code and add a method to it.
I remembered using a command line tool under Linux to decompile but since I could not remember the name of it I had to search for it. In the first few results of my google search for “java decompiler” came this site:
http://java.decompiler.free.fr/
I tried to install the JD-Eclipse but I don’t see how to use it so I simply downloaded and used the JD-Gui for Linux and it works beautifully. I can see my source code in the .class file in 2 seconds and now I can easily change it. This is so convenient.
Filed under code, java on August 18 | 0 comments
Saw this article from a twit and I am unsure how I can do all these:
http://codemonkeyism.com/generation-java-programming-style/
Interesting and if I do any code with this I will post an other entry to let you know how it went.
Filed under code, java on June 9 | 0 comments
I have to read a bit more on the subject but this article was interesting since it shows how to do in Java what Apple Cacao does with the MVC model. I find this twist to be easier to understand.
http://java.sun.com/developer/technicalArticles/javase/mvc/
Filed under code, java on May 5 | 0 comments
http://odi.ch/prog/design/newbies.php
This explains a few things that should be done differently if you want your application to perform well. Very interesting!
Filed under code on February 9 | 0 comments
When looking at java garbage collection logs you only get logs with a time stamp in seconds from the start of the JVM. After a few days of running the JVM it is difficult to remember when it started and when is the event your are looking at from. I was looking for a quick way to calculate the time. Python has some nice facilities built-in to help with that task. Here is what I do from the command line to figure out the last time it was started:
[bash]$ python
>>> from datetime import datetime
>>> from datetime import timedelta
>>> datetime(2009,2,9,10,48) – timedelta(seconds=159565)
datetime.datetime(2009, 2, 7, 14, 28, 35)
The datetime object is initialized with the date I want. In this case it was February 9, 2009 at 10:48. The timedelta object is initialized with a number of seconds but it could be days or min.
Very quick and convenient.
Filed under code on January 29 | 0 comments
A friend recommended this link and I have to admit that I am learning quite a few things about Python on this single page.
http://www.poromenos.org/tutorials/python/
There are quite a few things that I will need to test to fully understand.
Filed under code, documentation on June 26 | 0 comments
Until I followed a link from a twitter friend I had never heard of this term.
As a small time programmer I am always looking for ways to improve the code that I do and I also look at ways to improve myself as a programmer. Code kata is certainly a generic approach at these goals that is worth reading about.
Not everything they propose I will be able to try right away. It all depends on your environment.
It is more than just practicing at solving specific coding puzzle. It is about learning the tools that you use, communicating with the people that are around you, reading code that others do and try to maintain it, getting code reviews and much more.
I have to sit down and write what I will do to improve my programming ways. What I think easily make sense and that I can do rapidly:
- read about new features in Eclipse
- read about codig algorithm in Java
- learn Python
- I have to ask a programmer at work to review some of my code
If I can get those done in the next month I will see some improvement for sure.
Filed under code on May 30 | 0 comments
This morning, I went to a Borland Seminar about Requirement Based Testing (RBT). I don’t think that we can justify the spending for the tools that Borland propose to achieve this concept but none the less the information was very valuable to me. Sometimes the simplest concept are the most effective.The first thing they said that got my attention is that a requirement that you can’t test is not a valid requirement. You simply need to reword it to be measurable. So the requirement of an application to be fast is not valid but saying that step x can only take y seconds is valid.
The other thing that they repeated over and over was traceability. You need to be able to see the link between your requirements, the test and the results. That is where their tools helps you greatly. Doing all this in a spreadsheet is the poor man solution to it.
I also liked hearing that you need to have the least amount of test case for your requirements. Simplify! If you have more than 5% of your test case on a specific requirement you should look at it again.
Something else that I will mention that I liked was the fact that your tester, developers should be made aware of all the requirements early on and when you make changes to them you have to communicate them effectively. The goal to get everyone on board early on is to avoid the separation of the teams and the “ennemy mentality” that “sometime” happens.
The last funny tidbit for me was the mention that 60% to 70% of work in IT is actually rework. Work that will not get used or you are simply redoing what you (or someone else) has done. So easy to believe without any need for proofs.
Filed under code, java on January 1 | 0 comments
Servlet programming has always been something I was curious about. Starting this project was a bit ackward since there is plenty of documentation but nothing to hold your hand in what I was looking at. Too much struggling convinced me to write down how to do it for a very simple servlet so I could go from there.I used Eclipsei 3.1 as my Java IDE and I use Tomcat 5.5.x as my Servlet Application Server.
- Creating a new project in Eclipse
This should be a basic task that is quite easy. I called my new project HelloWorldServlet (great craetive title). I then created a new class named “HelloWorldServlet”. This opens the HelloWordlServlet.java file in the editor and I entered this source code in it:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorldServlet extends HttpServlet
{
static final long serialVersionUID = 1;
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("");
out.println("");
out.println("Hello World through a servlet!");
out.println("");
out.println("");
}
}
- Importing the servlet librarySomething that took me a little while to figure out is that I needed to add the servlet library from Tomcat to be able to properly compile but to also get the proper dynamic help in the Eclipse IDE. Under my working space directory I have a lib directory where I copy the common libraries that I use. The Tomcat servlet-api.jar was copied over there. You then simply right-click on your project in Eclipse, go to “Build Path” and click on “Add External Archives”. You simply browse to where you have copied servlet-api.jar and you now have the library imported.
- Unknown tidbitAfter adding this external archive it highlighted the fact that I need to have a “static final long serialVersionUID”. This is for the serialization of the object but I am not sure what value, if unique, it should have. I only added it as I was told without looking for too many answers right away.
- Compiled and copiedI compiled (ctrl-b) my servlet and copied it to my Tomcat box. Under the Tomcat default directory there is a webapps directory where you have to install your application. I made a new directory simply called “HelloWorld”. Under that directory I created a “WEB-INF” directory. Under the WEB-INF directory I created a “classes” directory where I copied my .class.
The directory structure currently looks like this:
tomcat
+-->webapps
+-->HelloWorld
+-->WEB-INF
+-->classes
HelloWorldServlet.class
- Application declaration In the WEB-INF directory I had to create a web.xml file containing this: <br>&lt;?xml version=”1.0″ encoding=”ISO-8859-1″?&gt;<br>&lt;!DOCTYPE web-app<br> PUBLIC “-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN”<br> “http://java.sun.com/dtd/web-app_2_3.dtd”&gt;<br>&lt;web-app&gt;<br> &lt;servlet&gt;<br> &lt;servlet-name&gt;HelloWorldServlet&lt;/servlet-name&gt;<br> &lt;servlet-class&gt;HelloWorldServlet&lt;/servlet-class&gt;<br> &lt;/servlet&gt;<br> &lt;servlet-mapping&gt;<br> &lt;servlet-name&gt;HelloWorldServlet&lt;/servlet-name&gt;<br> &lt;url-pattern&gt;/HelloWorldServlet&lt;/url-pattern&gt;<br> &lt;/servlet-mapping&gt;<br>&lt;/web-app&gt;<br>
This file declares my servlet name, class name and URI. Since everything is the same here it is quite simple.
- Calling the applicationThe fun part (when it works) is calling the application and seeing the end result. Since I have already declared in my web.xml that the URI is HelloWordlServlet calling it in my browser was as simple as entering “http://serverName/HelloWordlServlet/”.
- A few more notesBecause I was not perfect on the first try I had to reload my application after each change I made to the class file or to the web.xml. Important to reload otherwise the cached version is what you keep seeing.