Wednesday, December 16, 2009

Automounting USB drives - Sheevaplug

Found some resources that might help.

Will post the results when i have tried it.

http://ubuntuforums.org/showthread.php?t=724227&page=2

http://ubuntuforums.org/showthread.php?t=168221&highlight=automount+devices

Thursday, November 26, 2009

Saturday, September 12, 2009

XML-RPC in Lisp

Here is how to get a xml-rpc client working in SBCL.

You will need to install s-xml,s-xml-rpc using asdf

[sourcecode lang='bash']
(require 'asdf)
(require 'asdf-install)
(asdf-install:install 's-xml)
(asdf-install:install 's-xml-rpc)
[/sourcecode]

Next to use the libraries you will use the following commands.

[sourcecode lang='bash']
(require 'asdf)
(asdf:oos 'asdf:load-op 's-xml)
(asdf:oos 'asdf:load-op 's-xml-rpc)
(use-package :s-xml-rpc)
;(use-package :commuse-lisp-user)

(xml-rpc-call
(encode-xml-rpc-call "math.SumAndDifference" 5 2)
:host "www.cookcomputing.com"
:url "/xmlrpcsamples/math.rem")
[/sourcecode]
Links

cookcomputing rpc page

XML-RPC in Lisp

XML-RPC project page

Thursday, September 10, 2009

What are Immutable Object

I think every programmer should seriously try to understand what immutable objects/persistent data structures are about and how they can simplify and solve certain problems especially when they have to deal with threading/concurrency since they are inherently thread safe.

This is probably the simplest definition that I found.

immutable
adj. 1. (of an object) Having components that cannot be modified once the object has been created. 2. (of a class) An immutable class is a class all of whose objects are immutable. [annotate]
So what does that mean in code ?

It means that when you do something like

A=(1 2 3) ; where (1 2 3) is an imutable list of integers 1, 2 and 3

We can't say swap the element 2 for a 4 because it is imutable. Some languages allow you to replace the list like

A=(4 5 6), In Erlang you can't once it is assigned you can't change it.

Links:

Java theory and practice - To mutate or not to mutate

Immutable object

Tuesday, September 8, 2009

Using JMeter to look at data transmitted

JMeter beside looking at how your website performs, you can also use the data to look at how much data is actually sent to the browser and the effects of caching.

Many web projects use some javascript/Ajax library for doing UI, and these javascript files usually come in a debug or minified version. And the javascript files are big for example we were using ExtJS 2.2 and the debug version is almost a meg big, the minified version of about 527kb, but there might exists other javascript files that your webpages may call and it is probably quite a pain to look for each file and count the size.

In my case we wanted to see how much data is actually sent over with each call to a web page, and how web browser caching during subsequent calls to other webpages affects the data transmitted. Using JMeter allows you to see how much data is transmitted with each call including what files are being transmitted with each call and their sizes.

Friday, August 7, 2009

Implementing INotifyPropertyChanged

http://msdn.microsoft.com/en-us/library/ms229614.aspx

Thursday, August 6, 2009

WPF displaying images in ListBox

http://www.codeproject.com/KB/WPF/CustomListBoxLayoutInWPF.aspx

Wednesday, July 15, 2009

Wednesday, June 24, 2009

Tesing using Selenium and ExtJS

Selenium is probably one of the more popular web testing software out now. I have been trying to use selenium to generate some functional test for my project. Below are some of my notes/tips for using Selenium and Ext JS together. Selenium IDE was used in Firefox to generate the tests. Integration with the build server will come later.

UI Elements that don't work too well

  • Right Clicks don't seem to be captured in Selenium so if you use them, you probably got to try another way of testing.

  • Date pickers, don't seemed to work well too, i use the type command to input values into date pickers and time pickers in forms.


Asserting.

  • For textfield use verifyValue, the Target being the id of the element and the Value is the text you want to check against. Using assertText dosen't seemed to work for me.

  • You can right click on the web page and it will show a context menu allowing you to add assertions/verifications easily instead of trying to use firebug or some other tool to find the id or xpath value.


Speed
If you are using iframes in your pages, you might want to slow down your tests instead of putting it on the fast mode. This ensures that your iframes have time to load completely and that Selenium can find the link to whatever that you are clicking next.

Monday, June 1, 2009

SLIME, SBCL and Windows

I was having lots of problems setting up SBCL 1.0.22 and the latest SLIME CVS in Emacs 22.3.1. I had lots of help from the SLIME mailing list and this is my final .emacs files.

I am assuming that you have installed/unzip everything into a directory called c:\lisp on your system. WIth SLIME in c:\lisp\slime and SBCL in c:\lisp\sbcl.

(add-to-list 'load-path "C:/lisp/slime");Your slime directory
(setq inferior-lisp-program "sbcl -core c:/list/sbcl/sbcl.core"); your lisp system
(require 'slime)
(eval-after-load "slime" (slime-setup '(slime-repl))) ;This is different from the documentation

Sunday, May 24, 2009

Lessons from Robert Martin Keynote (What killed Smalltalk could kill Ruby too)

Robert Martin gave the keynote at this years Rails Conf. Beside learning about some programming history and other interesting bits of knowledge , there are a few lessons that most developers can take away from the talk.

1. Clean Code has zero WTF/min

Most interesting  way of measuring if the code is clean. All programmer should take note of this. Even when i read my own code after some time, I tend to think "WTF, what made me write that crap".

Peer review and refactoring helps in this aspect but many development teams don't do it. It takes quite a lot to make programmer's write tests when we are always faced with deadlines.

One reason is that during school,  TDD isn't really emphasized when doing software projects. Perhaps, universities and polytechnic should start teaching people what are good practices, things like Design pattern's, TDD, source control and so on. Grade projects not only on the functional and design aspects but also on the practices aspect. See if they write tests and see if their tests are maintained still work when the project is done.

2. Rules/Laws of TDD
The laws


  1. You may not write production code until you have written a *failing* unit test.



  2. You may not write more of a unit test than is sufficient to fail, and not compiling is failing.



  3. You may not write more production code than is sufficient to pass the current failing test.



3. Professionalism
Robert also talks about what being professional means. Simple to say it means not bowing down to fear and not taking corners when the going gets tough.

[youtube=http://www.youtube.com/watch?v=YX3iRjKj7C0&hl=en&fs=1]

Links

RSpec
Ward Cunningham on Wikipedia
Ward Cunningham on Twitter
Robert Martin's Page at Object Mentor
Robert Martin Page at Wikipedia
Rules of TDD

Thursday, May 21, 2009

Wednesday, May 20, 2009

Using Ruby and ERB for code generation

In my current project (using Java, Spring MVC and ExtJS), we have a lot of modules for data entry and since there were similarities in all the modules (and the fact is we had like 20 of these to code) we decided to take a closer look at code generation.

But what tool to use? Stumble upon ruby in the book Code Generation in Action and found a chapter on code templates and the example uses Ruby and ERBs. I thought wasn't ERB's used in Rails like JSP's? I thought i needed to write web programs in order to generate the code. But boy was i wrong, we could actually use ERBs from any Ruby programs.

Sample of the ruby file - test.rb

[sourcecode language='ruby']
require 'erb'

erb=ERB.new(File.open("test.erb").read());
name='Stephen';
code=erb.result(binding);
print code;
[/sourcecode]

Sample of the ERB file - test.erb

[sourcecode language='ruby']
public class <%=name%>{
}
[/sourcecode]

What's happening here, the name variable that you defined in test.rb is passed to the erb file when erb.result(binding) is execute and it returns the results of the erb file. You can pass in arrays, hashes from the code to the erb file easily just by calling the erb.result(binding) method.

Our experience - Great ! We wrote generators to generate our javascript menus, spring MVC views (which are in ExtJS) to Spring Controller to Hibernate DAOs. It does save us sometime in do repertitive work.

If your project has lots of similar components that you need to code. Why not take a look at code templating using Ruby and ERB.

Monday, May 18, 2009

Decoding URI/URL strings

In one of my last post, I talking about Finding the Url paramters from a URL using javascript.

But there is a problem with the code, what if the url has some HTML encoding inside like %20 (which represents a space) or some other special html encoding.

You will need to use decodeURI function in javascript. The function will decode html special charecters to their correct form so things like Hello%20World will become Hello World.

[source lang='jscript']
function gup( name )
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return "";
else
return decodeURI(results[1]);
}
[/source]

Thursday, May 14, 2009

Creating directories with date using batch files in XP

This is how you create directories with todays date using a batch file for xp/win server command prompt. Useful when you are doing backups

[sourcecode language='shell']
for /F "tokens=2-4 delims=/- " %%A in ('date/T') do set var=%%A%%B%%C
md %var%
cd R:\MACHINE PROGRAMS\%var%\
[/sourcecode]

Copy and paste the code directly, any space where it's not suppose to be can cause the script to break (like a space between the = and %%A%%B%%C.
To use the date just use the variable %var%.

Tuesday, May 12, 2009

Daily Cycle for Developers

Why have a daily cycle? It like a checklist that get you off to a start when you reach work. Much like before the airplane files, they have to go through a checklist to make sure everything is checked ok. LIke going to work before you start coding, probably you should ensure that your environment is ready for you to begin work.

This is my daily cycle when I go to work.

8:00am Start up all my pcs

8:15am
Ensure my development servers are working

Update code from SVN and try to build
Make sure none of the code breaks in my environment, even though we have a build server.

Look at the bug db to see if there are any new bugs

Plan what to do today from the backlog/sprint list/bug list

8:35am
Have some breakfast before the stand up meeting
Can't work on an empty stomach
Do some work

9:30am
Daily Stand up meeting

5:00pm
Ensure source code control backup script backs up correctly.
Make sure the code is safely backedup from the svn server.

Thursday, April 23, 2009

Finding Url Parameters using Javascript

Sometimes you want to get the parameters of a url ? In jsp, you can use something like
[source lang="jscript"]

var name='<%=request.getParameter("name") %>';

if(name==='null'){
name='';
}
[/source]
Now I found a much better way using Javascript at this web site . The code is below for reference.

[source lang="jscript"]
function gup( name )
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return "";
else
return results[1];
}
[/source]

The website also has other articles with regards to web programming and javascript.

Tuesday, March 31, 2009

Ext JS - Disabling FormPanel submit if validation fails

To disable the FormPanel's submit button if the validation fails (example like allowBlank:false). You will need to set the FormPanel's monitorValid to true and the submit button's formBind to true.

[sourcecode language='jscript']
var form=new Ext.form.FormPanel{
monitorValid:true,
items:[{
name:"testing",
xtype:'textfield',
fieldLabel:'Test',
allowBlank:false, //Must be filled in
value:'' //Set the value so that the validation will trigger
}],
buttons:[{
text:'Submit',
formBind:true //If validation fails disable the button
}
]
}
[/sourcecode]

In some cases you might need to set the value of the textfield or combobox explicitly to empty string. If not the validation will not kick in.
Links

Login Form: Disable 'submit' until username has been input

Thursday, March 26, 2009

Visual VM -

Found an interesting video on how to use Visual VM that comes with JDK 6 update 7 to see what's happening in Glassfish. Looks like an interesting tool to find out whether your app servers are leaking memory.

Java VisualVM User Guide:
http://java.sun.com/javase/6/docs/technotes/guides/visualvm/index.html
VisualVM project page:
https://visualvm.dev.java.net/gettingstarted.html

Sunday, March 15, 2009

Keeping your boss in the loop - Software Projects

When I was serving in the Navy, I had a CO who liked to be informed of everything that is happening on the ship. Cause it's his ship and he should be in the know for what happens around. And on a ship there are many departments like engineering, electronics, navigation and so on, and all these department has to coordinate with people all round, inside the ship as well as departments outside the ship so you can see it's quite hard for him to be on top of everything. If something happens and he is not informed, he is not too pleased especially if the information came from some other source. So the people on the ship developed a habit to always inform the CO of what's happening around the ship, to always keep him "in the loop" so to speak. He will offer his advice and even help to resolve some of the issues.

Now trying to keep up with what's going on in a software project is similarly just as hard as on a ship. There are so many components that make up the project and there are co-ordination between people from QA , procurement and even other project teams that you are interfacing with. The project lead/manager will be the person that management will most likely ask on a regular basis what's happening to the project. They might use things like monthly reports to update management to keep track of the progress, issues and so on.

Now what happens when management gets uncomfortable about the project, most likely management  do some or all of the below

  1. More meetings

  2. From monthly to weekly reports

  3. In extreme cases even bother the developers to give him reports on what they are doing

User Story Estimation Resources

Wednesday, March 4, 2009

Spring DataBinding and PropertyEditors

To bind data from a <form> to a SimpleFormController is easy, just read Spring MVC Step by Step in the Spring distribution and they show you how to do it. But what happens when you need to translate strings that represent dates to Date objects? or translate from JSON string to an Object?


To that you'll need to create a custom PropertyEditor and override initBinder in SimpleFormController, to tell the controller how to handle the data that return from a HttpServletRequest object. By default it does a simple mapping, that is to say it tries to read the keys from HttpServletRequest and tries to find the corresponding setter in the commandClass and sets the value. If it can't it will generate a DataBinding error.


e.g


If the class has a setter named setText and the HttpSerlvetRequest has a parameter with the key "text", the binder will try to set the value of the key into the object specified by the commandClass.


Sample code from overiding initBinder using CustomDateEditor to read dates


protected void initBinder(HttpServletRequest request,
ServletRequestDataBinder binder)throws Exception{
SimpleDateFormat df=new SimpleDateFormat("dd/MM/yyyy");
CustomDateEditor cde=new CustomDateEditor(df,true);
binder.setCustomEditor(Date.class,cde);
super.initBinder(request,binder);
}

I suggest you look at this presentation to get a feel of the workflow for the SimpleFormController. For Spring MVC it is important to know how the flow if the controller is so that you can understand how the various overrides will work.


For custom PropertyEditors you can look at the source for CustomDateEditor to get a feel how to implement. Most of the property editors will inherit from PropertyEditorSupport rather then implementing PropertyEditor staright.


It seems like the few methods that you will need to override are the setAsText and getAsText methods. And in these 2 methods you will need to use setValue and getValue to set the correct object so that the binder can retrive the final object. So a custom PropertyEditor might look something like this:


public class CustomEditor extends PropertyEditorSupport{

public CustomEditor(){}

public void setAsText(String text){

//Do some proccessing then call setValue(); to set the object
setValue(someObject);

}

public String getAsText(){

SomeObject obj=getValue();

//Do something to get the thing as text again

}

}

The only puzzling thing (at least to me) is why does Spring use the ProperyEditor interface for something that could probably be implemented by using a simpler interface consiting of the above 4 methods (setAsText,getAsText,setValue,getValue)? I have no idea it seems that lots of methods in the interface are not  being use and they could probably be served by using a simpler interface.


Links


CustomDateEditor source


Saturday, February 21, 2009

Things you wish your Software Product Manager knows - Requirements

Most product managers/ops managers don't really know much about software developments but they do know management.

A good example is the word requirements. Most of the time the product manager will spend some time crafting out the business requirements/operational requirements in order to get management approval to go ahead with the project. After getting approval the product manager would pass these business requirements to the development team and probably say something like,

Manager : "Here are the requirements now go build me something".

Development team : "Now we need to do some requirement gathering"

Manager : "What do you mean you need to gather more requirements, I took a few months asking all the managers what the requirements are, I already asked all the ground users what the requirements are, don't waste anymore time , now go build me the system. "

and so on....

That's more or less what happened to me, then as my team around asking end users if they heard about my project and what's the aims are, no one seems to know much. So every user meeting we went to we gotta explain what the vsion of the project was and what we think their roles in the project is and how they can contribute.

So what product managers should know that there are many types of requirements, namely business, functional, user and system requirements. And they are all needed in order to build a system. What the product manager wrote to management in order to get the project moving is usually a mixture of Business and User Requirements.

So what are the various requirements that you need?

Business/Operational Requirements - Usually stated in terms of what must be accomplished to achieve value to the business.

User Requirements- Describe what the users are able to do, usually model thru use cases or user stories. Examples would be like - "User would be able to make a reservation:, "User would be able to edit his personal information"

Functional Requirements - What the system needs to do in order to fufill the User Requirements, like we need to have logins tied to the LDAP server, or we need send email notification and so on. Things the developement team might need to build in order to satisfy the use cases.

Monday, February 16, 2009

Tomcat and JRockit

One probelm with Tomcat is that if you deploy and app too many times you will hit a java.lang.OutOfMemoryError: PermGen space sooner or later. This is especially prevalent if you use things like Hibernate, Apache commons logging.

Here's the way that I setup Tomcat to run with JRockit.

open setclasspath.bat in <Tomcat Home>\bin

Put in the follwing lines after the last comment from the top

set JAVA_HOME=<jrockit home>

Just run tomcat using the startup.bat file and go to the status page at http://<ip>:<port>/manager/status you should see a table "Server Information" with a heading JVM Vendor as Bea Systems,Inc .

I tested this with Tomcat 6.0.18 and JRockit 1.6.05_b13

External Links:

Info I found on running JRockit and Tomcat as a windows service.

Some links on the Perm Gen issue.

Crashing Tomcat

Preventing Java’s java.lang.OutOfMemoryError: PermGen space failure

Memory leak - classloader won’t let go

Friday, February 13, 2009

Web frameworks and Ajax

What I wanted to share today are some criteria that you might want to look at when looking at using Ajax components (Extjs, Dojo) and Web Frameworks like Spring, Struts.

How we decide on the Ajax component/framework the first time round?

Simple ... we just looked for the best and sexiest one around ... and we settled on Extjs. Seems to offer all the componets we wanted.

So we tried putting Spring MVC and Extjs to work together.

After starting to program...

After programming for about 2 months, we found somethings that you probably should try with each of the frameworks before you decide.

1. Submitting forms

Find out how the ajax library submits forms, for example Extjs submits forms using the "ajax" way, and expects the reply as a JSON string indicating success or failure, while Spring does it the traditional way that is through GET/POST and you are also able send Java objects and get back Java objects. So when you merge these 2, you need to either make Extjs send as a normal post/make Spring send back spcific JSON strings.

We went for the first approach, so we were unable to get Spring's simple form controller to get back objects so we just use the normal HttpServletRequest object to read the ParameterMap and form objects from the map.

Take note also that not all components can be sent back as a Post response. Things like Grids in Extjs can't be sent back automatically so we had to use hidden fields and set them to the Grids data (in JSON) to send back to the controller.

2. UI Components

Things that looked good in demos,  is sometimes  not too easy to replicate and to decipher, our first approach was to try and modify similar layouts to our needs but then we found out that most of the demo code resides in javascript files and  not embedded that made debugging abit harder for us. And the code was getting messy with comments here and there and debugging was painful.

So we did a bottom up approach where we slowly tried to learn and build the UI and we embedded most of the UI code in the jsp page itself and used firebug extensively to debug. It took a lot more time but hey we understand how things work better.

3. Cross Platform

The main use of such Ajax frameworks over coding your own is most of them cater for cross browser compatibility but its still up to you to fully test your website.

We found Firefox to be more forgiving in terms of certain mistakes where in IE that page won't even be rendered. Things like additional commas when defining array and missing variables are more likely tolerated in Firefox than in IE.  So test at least on IE and on FireFox and on as many browsers you can get, u maybe surprise at the errors that you get.

Thursday, January 29, 2009

java.lang.ClassCastException: [Ljava.lang.String; cannot be cast to java.lang.String When using HttpServletRequest getParameters()

I got the following error when trying to read a HttpServlet.getParameterMap(). Using the following code.

Map map=request.getParameterMap();
if(map.contains(key)){
String value=(String) map.get(key);
}


java.lang.ClassCastException: [Ljava.lang.String; cannot be cast to java.lang.String]

HttpServletRequest.getParameters() according to the javadocs returns an object of Map with the following attributes.

From the Java docs

"""
Returns:

an immutable java.util.Map containing parameter names as keys and parameter values as map values. The keys in the parameter map are of type String. The values in the parameter map are of type String array.
"""

So what it means is that it actually returns a type of Map<String,String[]> instead of Map<String,String>. So the correct defination is map.get(key) returns a String[] not a String. This is because request.getParameter(key) returns a String which is actually the first element of the resulting string array.

Have no idea why the designers design it this way. So to be safe, you can use the following to ensure that you will always use the correct type of map from a HttpServletRequest object.

Map<String,String[]> map=request.getParameterMap();

So read your javadocs carefully when you get weird ClassCastExceptions.

Wednesday, January 28, 2009

Spring and Servlets

http://andykayley.blogspot.com/2008/06/how-to-inject-spring-beans-into.html

Wednesday, January 21, 2009

Answering the Joel Test : 12 Steps to better code

Joel Spolsky in his blog wrote about the Joel Test, in his own words

"highly irresponsible, sloppy test to rate the quality of a software team".

So I have decided to rate my project base on his criteria.

  1. Do you use source control?

  2. Can you make a build in one step?

  3. Do you make daily builds?

  4. Do you have a bug database?

  5. Do you fix bugs before writing new code?

  6. Do you have an up-to-date schedule?

  7. Do you have a spec?

  8. Do programmers have quiet working conditions?

  9. Do you use the best tools money can buy?

  10. Do you have testers?

  11. Do new candidates write code during their interview?

  12. Do you do hallway usability testing?


1. Do you use source control? YES

Yes we do, we use primarily svn.

2. Can you make a build in one step?

Yes at least for our web stuff. We use ivy to manage our internal libraries dependencies and ant to build all the java stuff. The rest of the libraries (namely 3rd party like spring and hibernate) are checked into svn. The reason being these are the libraies most unlikey to change, unlike our own internally developed libraries.

3. Do you make daily builds?

Yes, we use cruisecontrol as our countinous integration server which polls our svn server for code changes and attempts to build them. The only problem is we couldn't get the jabber plugin to work so we rely on cctray for notification.

4. Do you have a bug database?

This is where we got the first NO! Nope we don't have a bug database. So far we have been programming for about a month. But at our current stage we are still trying to figure out what extjs can do for our ui even as we are developing parts of the backend and parts of the thick client version. Although we have bugzilla in our development network but the problem is that none of the developers gotten around to learning it yet. So even if we have bugzilla no one is using, gotta get up to speed learning about bugzilla for the whole team. Might just decide to install Trac as I think it might be easier and it has integration with  svn.

5. Do you fix bugs before writing new code?

I would like to think that all my team members do. But we are currently still trying to learn and evaluate the software/libraies that we are using (some GIS cots and some new libraries).

6. Do you have an up-to-date schedule?

Yes we do, in terms of when to deliver the project and the important milestones. But in terms of estimating how much work we can do and the accuracy of that estimate we are not quite there yet.

So we actually have to try and gauge how much work there is and how much effort is required. We are currently trying to use story points as a guide and using this month (the first official month of coding) to try and see how many story points can we actually complete since we are using a couple of new tools/libraries (extjs and spring mvc). And from there we will know roughly how much work we can do.

7. Do you have a spec?

Joel in his article mainly refers to Functional Specifications. Hmm this part we are also not too good. For the current project what we did is to work through the user workflow (or what we know of the work flow) and the user/operational requirements and try to think off what features are in thhe system based on our interprtation of the user requirements. This is so that at all times we know roughly what we are going to build. And also as we interact with the users we can get them to confirm whether the features are needed or not. The project complexity comes from having to interact with many branches/division in which they have different requirements, feeding it back to the manager commission the project so that he can have the feedback and make the necessary decisions.

And we taken these feaures/operational requirements to try and design a workflow and try to see how the users will interact. Basically we use a big whiteboard and draw out scenarios and simple screen shots to determine how the user will interact.

We then transfer these drawings to paper and file it for reference. What we lack is the transfer of the drawings to words specifications. We have no functional specification templates and probably will adopt Joel's as a starting point to see what needs to be included.

The main problem is that the project is on a rather short timeline and the developers are the ones who are coming out with the design, documenting and code at the same time. With the short timeline we have it's why we work off sheets of paper with drawings and notes and not write formal specifications. We don't really have a program manager (as in Joel's version of it) to help us come out and write the  functional specs.

But what we intend to do is to come out with small working systems like what agile methodologies advocate (Currently we are trying out SCRUM) to continuously get the users feedback to help in designing and specifications.

So will we write specifications? Probably yes as we do need some sort of documentation to drive things like testing and user docs.

8. Do programmers have quiet working conditions?

Yes we all have our own cubicles.

9. Do you use the best tools money can buy?

When i first joined my current company all I had was an internet laptop and a development laptop that has no internet on it. They have strict policies on having the internet on the development network. It was a nice laptop, 17" screen, Core 2 Duo and 2Gb of ram. Unfortunately I was transferred to another project and all they could give me was a 14", Pentium M 2.4 and 2G ram.

I do agree with Joel that we need to give the best money can buy and that means trying to max out the ram (we used WinXP so that means about 3gb to 4gb would be nice) and having real monitors. Why? Imagine on the 14" machine I run Oracle Xe, Tomcat, Netbeans, Eclipse. And to program using a small screen is really a pain, especially when doing javascript. It does gets abit tiring scrolling the screen up and down. I tired to run Workshop for Weblogic 10.3 and immediately my laptop starts to page really badly, I checked the preformance tab and it was using 2.3gb of memory, so I was trying to swap about 300megs. And when you are debugging you need to see the code and watch the varibles a 14" screen quickly runs out of space.

Well my current setup is a quad core xeon, with 3gb and a 19" real monitor. It could be better with another 19" monitor to aid in debugging and reading javadocs or other documentation.

10. Do you have testers?

No, in our setup we don't have a testing group dedicated to just doing testing. Most of the time the developers are the testers. Although we do have a QA group that does security and vulnerability assessments.

11. Do new candidates write code during their interview?

Before I got a job, I went for 3 interviews, two didn't ask me to write code, my current company was one of them. And the one that asked to write code, did more than that, they made me do binary math, made sure I knew what XOR, OR and AND were, draw on a white board how I might implement some things in code. But then of course I chose the company that I had more interest in.

After I was in the company for about 2 years, I attended two interviews with fresh graduates with my project manager, to assess who should join my current project. I did have a dilemma on whether I should just base on paper qualifications and not ask them do any coding just as I have gone thru. One of them was clearly out as he is a Computer Engineering graduate with mainly hardware experience and I was looking for a software kind of guy to do web programming. He has no knowledge of what an app server or even what J2EE is, so i dropped him. The second is a computer science grad from the same university that I come from and he does have some experience but I did not ask him to write code as there were other project managers around me and they were all asking the normal questions like, "Tell me you last project" and so on.

I feel that asking the interviewees to write code is important, it demonstrates at least a certain sense of logical thinking and more than being able to write code, the person should also be familiar with design patterns, general OO concepts. He/she dosen't need to be an expert but should realised such things exists. For someone who dosen't know what encapsulation, inheritance and polymorphisim is, you probably gotta spend more time training him and bringing him up to speed.

When doing the interviewing, I have to think about my team members who are already working on the project. Do they have the time and energy to try and hire someone who has little experience and knowledge, and bring him up to speed with what we are doing? In the book The Mythical Man-Month, the author talks about how adding people to a project actually makes it slower. In , Software Projects Secrets, programmers are always using some new toolkit or new framework or some new component with each new project. For the people who sort of know the job, it is hard enough to learn on the job, imagine someone who don't really know and have to pick up all these knowledge and more! And remember the project moves at the speed of its slowest member.

12. Do you do hallway usability testing?

No, in fact I don't really remember anyone doing it. I do think its a good idea to do some user interface testing using your fellow colleagues.

Final Score

Yes: 6

No: 4

Maybe: 2

Hmm there are 2 maybes in the "Do you fix bugs before writing new code" and "Do you have the best tools money can buy". I can't really gauge the first due to the project starting and we don't really keep tracks of the bugs and the second is because we could have requested for more money to buy another monitor but because we didn't cater the money for the extra monitor so it's mainly due to our own fault.

So according to the score my project got less than 10 and so my project is due for some serious rethinking on how to do things properly.

Thursday, January 15, 2009

Doing a normal form post with Ext Js and FormPanel

Been having lots of problems today. Most of it gotta do with trying to post data using a normal form post in Ext Js and the FormPanel object. The example givien in the documentation is not correct.

Found these 2 posts which explains how to do a normal form post. The next problem I am going to solve is how to get it to interact properly with Spring's MVC SimpleFormController.

http://extjs.com/forum/showthread.php?t=14204

http://www.yui-ext.com/forum/showthread.php?t=23205

Thursday, January 8, 2009

Cheat Sheets UML, Design Patterns

Was searching around for a design pattern cheat sheet because I want to have an easy reference with me instead of trying to look through a book or search the web. Found this guy and on Dzone who did up a great cheat sheet as far as I can tell but the only problem is that he uses a lot of UML which my brain somehow has decided to conveniently forget after I left university, so I looked around for a UML cheat sheet and found these.

Links
Design Pattern Cheat sheet from Jason McDonald
Design Pattern ref card from DZone
UML Cheat Sheet 1
UML Cheat Sheet 2

Saturday, January 3, 2009

DB Unit Testing

DB Unit testing has always been a huge headache for me and i suspect many people out there.

The few main reasons why they are difficult are:

1. Setup code for running tests (like jdbc connections)
2. Cannot assume that runs are in a certain order
3. Maintaining states

Setup code

Most database testing code will probably setup their jdbc connection like this, either you have a singleton that passes a jdbc connection to you unit tests or you will have an abstract subclass that inherit from TestCase and do the setup there and exposing the connection.

public class DBBase extends TestCase {

private Connection c;



public DBBase(String testName) {
super(testName);
}


@Override
protected void setUp() throws Exception {
super.setUp();
Class.forName("org.hsqldb.jdbcDriver" );
c = DriverManager.getConnection("jdbc:hsqldb:hsql://localhost/xdb", "sa", "");
}


public Connection getConnection(){
return c;
}


// TODO add test methods here. The name must begin with 'test'. For example:
// public void testHello() {}


}

What's not good is that if we want to run somewhere else, for example in a build server we might need to potentially change the connection string to ensure that it points to the correct server.

Maintaining States
DB tests involving queries usually does involve knowing what the state of the data in database is in so as to check the results or the query are correct or not.

http://www.dallaway.com/acad/dbunit.html

http://livingtao.blogspot.com/2007/08/unit-testing-with-junit-spring-and.html