Developing Snow Fighters

February 16, 2011 at 10:02 pm | Posted in Java | 2 Comments

I’ve had a lot of fun in the last few weeks developing code as part of the ACM Queue 2011 ICPC Challenge also known as the Icy Projectile Challenge. There are a lot of ideas that I never had time to investigate, but I thought I’d blog about the ideas I did investigate. Continue Reading Developing Snow Fighters…

Eclipse Helios Mostly Works

July 30, 2010 at 5:00 pm | Posted in Eclipse | Leave a comment

For development at work, I downloaded and started using Eclipse Helios packaged for J2EE development, wanting to see what I could stumble upon as new or different, and whether I could recommend it to the rest of my team yet without having to describe a whole lot of changes to our practices.

We use a multi-module maven project, using mvn eclipse:eclipse to generate our eclipse projects, and that continued to work just fine, with the projects seeming to be imported without issue.

I noticed that Tomcat 7 is now listed in the set of servers that can be configured, and indeed the WTP 3.2.0 New and Noteworthy lists that in it’s “Servers” section. Handy, but as we’re hosting our own application, we do not need to test against Tomcat 7 yet.

I next noticed that the view of web projects added to the server included a couple of jars. Strange. I still haven’t figured out why a small number of the many included jars get shown in that view.

The first thing I tried to investigate showed that specifying what gets deployed as part of your web application has been changed too. That’s shown in the Java EE section of WTP’s New and Noteworthy.

The applications deployed and ran ok, though a number of times I’ve tried starting tomcat only to have it complain that one of the web applications can’t find hibernate classes, and looking in the deployed directory, the jar is indeed missing.

The next thing I noticed is that a whole lot of classes now show warnings. Apparently I should now change from using @SuppressWarnings(“unchecked”) to the new and more accurate @SuppressWarnings(“rawtypes”) or according to the JDT New and Noteworthy, set the suppressRawWhenUnchecked=true system property when starting eclipse.

Another JDT change highlighted that our method of starting up one of our application included an unused object allocation. That actually highlighted that we were starting threads from within a constructor… something that is rife with difficulties, and to be discouraged.

While investigating what various people on StackOverflow recommend for eclipse.ini options I discovered the details of Oracle’s changing the executable and libraries’ organisation meta-data, and how eclipse has been using those to identify Sun’s JVM and apply Sun’s -XX:MaxPermSize setting. Oracle have changed the organisation back again for build 7 of Java 6 update 21.

I have not yet started using Helios for personal projects, since for the last little while I’ve been trying my hand at creating an Android application, implementing a nice looking Tree Mapping View showing space used by a various tables and indexes of a PostgreSQL database. The page detailing how to set up the eclipse plugins for Android development still says: “There are known issues with the ADT plugin running with Eclipse 3.6. Please stay on 3.5 until further notice.”

So far this sounds like a lack of any compelling reasons to upgrade.

However…

Using the market to install the SVN plugins we use was a much nicer experience than in previous versions, and being able to find out about other plugins from within eclipse is great.

I’m also going to start using package name abbreviations, so that all our packages of the format:

nz.co.mycompany.myproduct.subcomponentA.internalpackage1

can be nicely and succinctly shown as

{A}.internalpackage1

Something I usually do with a new eclipse installation is tune the startup parameters, editing the eclipse.ini file to show me the workspace location. This is because I often work with multiple workspaces, one showing the current production code for investigating symptoms and behaviour of the production system, and one showing later code with a number of development changes. Eclipse 3.6 has a new preferences option that lets you specify a workspace name to show in the title, which works much better as you do not need to restart eclipse for it to take affect, you can use a short code for your workspace, and it appears first in the title, before the perspective and application name.

Lastly I’m looking forward to experimenting with all the new options for controlling the formatter. I believe I can finally now get it set up to alter the code formatting to my liking more consistently.

Towards Maintainability

June 19, 2009 at 12:58 am | Posted in Eclipse, Java | Leave a comment
Tags: , ,

My friend Bevan has linked to the tools he referenced in his “Towards Maintainability” talk at the Wellington .NET users group recently.

I thought I’d add the equivalents from the perspective of an Eclipse-using Java developer…

Definr.com
Definr.com isn’t specific to a single programming language.
I simply type things into Google Chrome’s Omnibar.
FxCop & Gendarme
FindBugs
PMD
Visual Studio Class Diagrams
Perhaps AgileJ though I do not use it.
Snippets
Snippets in Eclipse
Creating extensions to snippets
StyleCop
Checkstyle
NAnt
Ant
Maven 2
NUnit
junit
TestDriven.Net
junit is integrated into all IDEs
Sandcastle
Perhaps Doxia?
TeamCity
TeamCity supports java
CruiseControl
Continuum
Hudson
Gump
ReSharper
Mylyn is probably the closest productivity adding, IDE-changing example.

Eclipse Galileo Improvements to Java Developer Tools

June 19, 2009 at 12:23 am | Posted in Eclipse, Java | 2 Comments
Tags: , , ,

Here are some improvements to JDT Project in Galileo that I personally find useful:

  1. Support for {@inheritDoc} in the javadoc popups.
    • This is encourages its use, which in turn encourages documenting why a method has been overridden, or what’s so special about this particular implementation, without having to repeat the purpose of the method itself.
  2. Warnings when a method overrides a synchronized method, but isn’t synchronized itself.
    • It’s hard enough as it is to ensure you get the intended multi-threaded behaviour. This change can help prevent an error that while not very common, can be very hard to spot.
  3. When auto-reformatting an entire class, I can keep the line breaks that I’ve added.
    • This caters for where the formatting rules are too general, and are not aware that I’d find some things much clearer if split into multiple lines in very specific places.
  4. Constructor completion has been made more useful, by offering more appropriate suggestions.
    • I also often save myself some typing by writing the right hand side of the assignment, then using a quick assist to assign the result to a new variable.
  5. By holding down Ctrl, and hovering on a method, I can chose whether to jump to the declaration, or the implementation.
    • I still find this method of navigation difficult though, preferring to keep my hands on the keyboard, navigating to the method call, pressing Ctrl-T, and choosing which implementing or declaring class I wish to view. (That’s not a new feature.)
    • What I’d like is a companion for F3’s mapping of “Go To Declaration” that with a single key press I can “Go To Implementation”. However I can’t find that command in the key binding preferences page.

Best Practices

August 23, 2008 at 3:24 pm | Posted in Uncategorized | Leave a comment

My friend Bevan points out a post on NUnit Best Practices by Scott White, and asks whether we agree with them.

Most of my coding these days is in java, so some of Scott’s best practices need altering to my situation, e.g. junit.jar instead of nunit.framework.dll.

For reference, I disagree to varying extents with #1, #2, #3, and #5, and agree with #4, #6, and #7.

However I believe that best practices are often relative to the situation you find yourself in. That situation includes which IDE you are using, and how best to use it, how large your team is, how complex your application is, etc.

I also think that it is an excellent idea to consider which practices consciously or unconsciously drive your coding practice, and whether any of them could be improved. Scott himself says that best practices change over time, and his blog seems to have a long running theme of identifying some of these changes. I commend him for identifying and documenting what he does, providing advice for others to consider, and asking for feedback.

Here are my reasons for disagreeing with some of his NUnit best practices, from my junit in eclipse standpoint:

#1

I primarily disagree since all too often the tests are not distributed with the code being tested. When dealing with some-one else’s code, I don’t have their test cases, so if I have problems with their code, I can’t simply find out whether their test cases still work in my environment, nor whether I’m using parts of their code which are not covered by their tests.

Secondly, I disagree with “don’t be lazy”. We should all be striving to have our best practices also be the easiest things to do.

#2 & #3

These are things that should be integrated into your IDE and dependency management tools. They appear to be workarounds for poor visual studio defaults when you wish to use NUnit to test your code.

#5

I prefer the idea of starting by writing test cases in a style that documents what you want to achieve. That then drives what methods you need, and perhaps how they should be collected into various interfaces. I refer to this as an idea since I’m not particularly disciplined in developing in this way.

Overall though, I’d say that I agree with Scott in that solid unit testing using a tool like NUnit is best practice.

Mathematics of Boxy Numbers

June 22, 2008 at 3:48 pm | Posted in Uncategorized | Leave a comment

I’ve found some interesting mathematical concepts through researching my ideas presented in my previous blog posts on a scheme for representing numbers using Basic Primes, and drawing that representation as Boxy Numbers.

There is a function named pi, (written as the greek symbol), but pi isn’t used in reference to circles’ diameters and circumferences, but is instead (as far as I can tell) P. I. standing for prime index. pi(x) is equal to the number of primes equal to or less than x.

By altering my representation slightly so that the number one is represented as a single box:

    

So that two is the first prime, so two is a box with the representation of one inside it (which is how I previously drew three).

Then the representation of any number n is drawn by producing n‘s prime factors, f0 to fk and each factor fi is drawn as a box with the representation of pi(fi) inside it.

To make the representation slightly more aesthetic, you can fill in all the gaps with the representation of one. This is because everything is multiplied, and you can of course multiply by one as many times as you like without altering the product. Multiplication is also commutative, so the boxes may be rearranged to give a pleasant looking number, so long as the number of boxes within any box stays the same.

Multiplication is simply a case of drawing both sets of boxes for the numbers being multiplied.

Division and rational numbers are probably best drawn with a numerator over a divisor separated by a line. Common factors are easily identified and removed.

By contrast, addition and subtraction are intensely difficult.

Here’s a walk-through of representing your birthday as a bunch of boxes:

You could draw the number for the day, month and year individually, but you’ll probably end up with more a more interesting drawing if you start with one large number n = YYYYMMDD. So for my birthday, 8th September 1972, n=19720908

The first step is to produce the prime factors. There are lots of ways of doing this. The easiest way if you are reading this online is to use an online tool. The one from Maths Is Fun says my prime factors are 6763 x 3 x 3 x 3 x 3 x 3 x 3 x 2 x 2.

So I need nine boxes, containing the representation of pi of each factor.

Though boxes can be arranged in any way you like, in order to demonstrate the technique I’ll stay consistent, showing these vertically, as otherwise by the end of the post I’ll be running out of room. Web pages have a fixed width, but can be infinitely long:

pi(6763)
pi(3)
pi(3)
pi(3)
pi(3)
pi(3)
pi(3)
pi(2)
pi(2)

There’s an online calculator of pi(n) too here.

It reports that there are:

871 primes less than or equal to 6763

2 primes less than or equal to 3

1 prime less than or equal to 2

So our boxes need to be:

871
2
2
2
2
2
2
1
1

We repeat the process for each of these numbers, drawing a box for each prime factor, and writing pi(factor) in each box.

The prime factors of 871 are 67 x 13, so we need two boxes.

2 is prime, so each of the 2s need a single box.

1 has been defined as a box with nothing in it.

pi(67)
pi(13)

pi(2)

pi(2)

pi(2)

pi(2)

pi(2)

pi(2)

    

    

pi(67) = 19

pi(13) = 6

pi(2) we’ve previously seen = 1

So our boxes need to be:

19
6

1

1

1

1

1

1

    

    

Producing prime factors again, 19 is prime, so a single box is needed. 6s prime factors are 3 x 2, so two boxes needed

We’ll replace 1s as before.

So we’ve got:

pi(19)

pi(3)
pi(2)

    

    

    

    

    

    

    

    

Evaluating the pi functions gives:

8

2
1

    

    

    

    

    

    

    

    

Factorising gives:

pi(2)
pi(2)
pi(2)

pi(2)

    

    

    

    

    

    

    

    

    

Evaluating the pi functions gives:

1
1
1

1

    

    

    

    

    

    

    

    

    

Replacing the last 1s with their representation of an empty box gives the final representation:

    

    

    

    

    

    

    

    

    

    

    

    

    

Rearranging this into a pleasing arrangement gives

    

    

    

    

    
    

    

    

    

    

    

    
    

    

    
    

 

Eclipse Ganymede Features

June 8, 2008 at 12:55 am | Posted in Eclipse, Java | 3 Comments
Tags: , ,

The Eclipse Ganymede release is only a few weeks away. As a long time eclipse user, inquisitive, early adopter, I’ve been trying the milestone and release candidates of the java developer tools components. (Ganymede is a coordinated release of an enormous number of eclipse projects. Several packages are available here.)

The list of new features is no longer as easy to find, since it was linked to from the download page for the milestone releases, and since the releases are now release candidates, there are no new features.

These will no doubt be combined into a single what’s new page for the final release, but until then, the lists for each milestone release are well worth a read: M1 M2 M3 M4 M5 M6 M7

Update: As expected, the release of 3.4 is accompanied by a new New and Noteworthy page. What’s also worth reviewing is the feature comparison page for the various Ganymede packages.

My personal favourite dozen new features:

  1. System Proxy Settings – One less place to change those settings when I plug the laptop in somewhere new.
  2. Default console and file encoding – I develop on Windows for Linux.
  3. Shearing – I love the pun.
  4. The improved error log view, and the Plug-in registry view enhancements – these will help when trying out misbehaving plug-ins.
  5. Line support in overview ruler – much faster navigation.
  6. Runnable JAR export wizard – no more searching for and installing third party plug-ins to do this simple thing.
  7. Different highlighting for read and write occurrences of the selected or searched for element – this is fantastic.
  8. Direct interaction with text hovers – less hand movement is good. Being able to click through to other javadocs is fantastic.
  9. Breadcrumb navigation – this is a quite good compromise between ease of use and screen real estate.
  10. Support for external class folders – I haven’t used this yet, but can think of some past experiences where it would have been useful.
  11. Java compiler on multi-CPU machines – parallelisation is how we go faster these days.
  12. Quick Assist becomes even more helpful.

Eclipse’s quick assist feature saves a huge amount of work. There’s no need to go looking through menus and dialogs to find the right place to activate the thing you want to do right now, you simply hit Ctrl-1 and what you want to do is invariably in the short list that immediately pops up. The “what’s new” pages list these additional assists and fixes:

M1
-    Helps with regular expressions in find/replace
-    Helps correct spelling in CVS commits
M2
-    PDE Quickfix for Java file issues
-    Add @throws or @exception javadoc tag
-    Select a missing method error in the Problems view and Quick Fix
-    Create getter and setters for fields (encapsulate fields)
-    Extract method on expressions
-    Helps with the new SWT Templates
-    Helps with user created templates
M3
-    Code completion helps with casts
-    Complete static members of not yet imported types
M4
-    Ensure source entries found in build.properties are properly accounted for in the plug-in manifest
-    Diagnosis (and removal quick fix) of redundant superinterfaces
-    Improved key binding support
-    Convert to StringBuffer
M5
-    Improved cursor jumping
M6
-    New Javadoc tags to annotate (PDE) API with explicit restrictions
-    Quick fix provided for missing or incorrect @since tags
-    The Java problem hover now offers all available quick fixes
-    Use MessageFormat for string concatenation
-    Extract local variable (without replacing all occurrences)
-    only show templates applicable at the current location
M7
-    Remove invalid use of API Javadoc tags
-    Inserting parameter name also shows guessed arguments
-    Shows gory details of improved text search

Updating Internet Explorer RSS Feeds

May 18, 2008 at 11:12 pm | Posted in Uncategorized | Leave a comment

I tried out RikReader recently, which is one of the class of feed readers which use Internet Explorer’s (and Vista’s) list of RSS feeds. It has its pro’s and con’s, but the lack of the ability to refresh all feeds was initially a surprise.

It doesn’t need that feature though, since using IE’s feeds, it also uses IE’s feed updating mechanism. I don’t really like IE’s feed updating mechanism, since it is a background task that keeps using my laptop’s resources when it wants to, rather than when I want it to.

Investigating how it updates, I discovered that I can disable the background task, and when I want the feeds updated, I can run:

msfeedssync forcesync

I thought I’d blog about it, since there are currently so few mentions (in English) of this.

I created a shortcut to run that on my Quick Launch bar. Can anyone comment on where to find a pre-installed rss icon?

Boxy Numbers

April 16, 2008 at 11:30 pm | Posted in Uncategorized | Leave a comment

My previous post “Basic Primes in Scala” ended with some ideas of how to salvage some use out of the algorithm. I mentioned representing the numbers as concentric circles. Playing around with a text editor, I converted some of the numbers to arrangements of concentric squares.

Continue Reading Boxy Numbers…

Basic Primes in Scala

April 16, 2008 at 12:17 am | Posted in Scala | 3 Comments

I’ve started learning Scala. One way I learn is by reading and experimenting, so I looked for a simple program I could write in the right problem space to make use of language features expressed more succinctly in Scala than in Java.

Continue Reading Basic Primes in Scala…

Next Page »

Create a free website or blog at WordPress.com. | The Pool Theme.
Entries and comments feeds.

Follow

Get every new post delivered to your Inbox.