IntelliJ vs. Eclipse Projects

A nice table the JetBrains people put out comparing IntelliJ vs. Eclipse projects at: http://www.jetbrains.com/idea/documentation/migration_faq.html

Eclipse IDEA
Workspace Project
Project Module
Project-specific JRE Module JDK
User library Global library
Classpath variable Path variable
Project dependency Module dependency
Library Module library

I actually prefer the Eclipse method of having several “projects” open in a workspace, expecially when it comes to doing checkins on one project-jar, grabbing its build number then plugging that into a war that uses it for Ivy or its Maven setup. Also, doing cascading commits in a distributed repo in Hg is a pain to set up and mantain (and not recommended by Mercurial) — so its not a good solution for Maven projects with multiple modules. Generally, in intelliJ, I find atomic module checkin to be a pain. Anyway.

Regex for Testing A Number Range

Kinda weird, but if you are scanning a file from a build tool for coverage you can do a check by finding your value and using this reg-ex statement:

2[7-9]|[3-9][0-9]|100

This statement will check 27-100.

Regex only does string searching but this works — I can use this in something like the Maven Verification plugin to fail my coverage.

Y2K Dates Out Of Control!

Wow check this out I was digging in a java code base and ran into this date conversion code (added the dateString initialization to illustrate):

String dateString = "04/29/05" ;   // two digit year
 String newDateString = dateString.substring(0, length - 2);
 if (Integer.parseInt(year.substring(2)) > 25) {
      newDateString += "19";
 } else {
     newDateString += "20";
 }
newDateString += dateString.substring(length - 2);
 dateString = newDateString;

LOL.  So if the year is greater than 25, it’s the 1900’s, else its the 2000’s.  :-/

I know that dates suck big time in Java, but this code was result of just bad design.  Across it is all types of date input formats, and no centralized date code and this garbage all over.  Death by 1000 cuts.

There are tons of utilities like Joda Time all over to handle this stuff.  But if they knew the six digit date, they were safe just doing the conversion and formatting it with SimpleDateFormat into a date and then extracting the string!  Even this would have been easier

    DateFormat formatter = new SimpleDateFormat("MM/dd/yy");
    Date date = (Date)formatter.parse(dateString);

Or something to that effect.  I’m pretty sure there are no 1924 records in the database.

Linux Tip: Compression – tar and exclude

A lot of times I have to recursively compress a bunch of files and folders so I can ftp them to my local for perusal.

When I compress, I do this:


tar -cvzf localfolder.tar.gz localfolder

And that gives me a tar file of all the zipped stuff in localfolder.

To decompress it on the command line I do this:

tar -xvzf localfolder.tar.gz

But usually I am doing this in Windows with 7-Zip or Iceows in a GUI.

A little more tricky thing to do is to EXCLUDE something. Let’s say you have a folder tree like below:


/etc/localfolder
--|folder1
--|folder2
--|folder3

But you want to exclude folder2. The trick is to use full pathnames in the exclusion command or the exlclude won’t work:


tar -cvzf localfolder.tar.gz /etc/localfolder --exclude="/etc/localfolder/folder2"
Multiple Exlcudes:
tar -cvzf localfolder.tar.gz /etc/localfolder --exclude="/etc/localfolder/folder1" --exclude="/etc/localfolder/folder2"
With GNU tar, swap the exclude and the source directory:
tar -cvzf localfolder.tar.gz --exclude="/etc/localfolder/folder2" /etc/localfolder

Your IT Culture: Is It Inclusive?”

I work at a place now that was having one of their own highly publicized tech conferences open to developers outside of the company.  There was tech lectures, and food, and coding contests.  Some of it was recruiting, and some of it was jst to be in the “tech game” – creating a company profile in the world.  I think its a good idea.

The FTE developers talked about it and some were volunteering, we received a lot of emails about it, and the managers would mention it often and be respectful asking if we’d like to attend.  All in all, I thought this pretty damn cool and I blew a Saturday morning to take in a few lectures and just make face.

Contrast this.

Another place where I worked on a gig a while back had a tech event much like this, but even HIGHER profile.  The technologies included mobile which is a monstrous topic these days.  Their even had national web ads.

But inside the shop we heard nothing about it.  I heard about the event through another tech group outside the company.  No emails, and management said nothing at the meetings about it to their developers.  Finally, a few days before I mentioned something to a fellow coder and he said “yes me, she, and the manager are going together.”  Knowing the manager I knew he and she weren’t favorites, and I found it curious and sad.  This director said nothing to any of us, in fact, did not seem interested in even discussing it when I mentioned it later that day. Turnout from the company tech staff was low, very low.

Missed opportunites.

Building team coherence, knowledge, and education is the job of the management and company.  We as grunts do our part but we can’t be the cheerleaders — that takes time and skill too.  I found the second company to go out of their way to be non-inclusive.  You could see the effects in both companies of their team policies and the tech events were good vetting tools in the laboratory.

In the “good” company we have a great code base.  Tons of tests, communication, ideas.  Less stress.  Its fun to work at and we are productive as hell.

At the “bad’ company the code base was poor — tons of MVC’s in the UI layer for instance, poor communication, distrust, no test base (means fast checkins and breakage).

This discussion goes all the way up to the top of the type of culture generated by management for a coder to work in.  It does matter, because many skills besides understanding Hash Maps and Event Dispatchers comes into play when writing code.

I highly, highly suggest that a team shares tech knowledge for events in a respectful manner to each other; it really helps build the quality of your code.  And that means cheaper, better code that works and keeps customers.

 

Impact of Implementation Of Ground-Up Architecture

Recently I’ve been working on a project where we have been switching over the datasource code from one code base to another.  The codebase is pretty monstrous and has at least 30 developers checking in on it.

Many things  bothered me about the tasks in this. There was no documentation on it, at all.  So we had to spike out over and over what this new codebase was, and how our old codebase worked.  Also, a lot of baseline integration tests had been removed so if we did changes we could have little confidence as to what we made work corerctly, or broke.

I guess when you have to do this kind of thing there’s no roadmap and its impossible to estimate == even though management presses down on your team for that information.  The re-architecture had no architect oversight, no visibility to the business (like an invisible oil change) but was in reality a strategic move: the change would put our application on a shared code base with other applications, and possibly opening the door for more feature work more quickly because of this.  Maybe the end-game customer wouldn’t not see anything but a better app, but the tech team’s business customers should have known about this major re-work.

Most of the spiking was done by me and a cohort for a few months.  We had object designs and impedances, dead ends, all that good stuff when you wander into the unknown.  It was tough because there was really nothing to be accountable for, until at the end we produced a workable plan to get the job done.

Remember this is a monster codebase.  And the current data system had at least 4 different types of implementation so you couldn’t just “switch” — there was business logic buried into the way we did our datasources.  The system was a sharding system spreading data out across multiple databases based on an encrypted key; and the key could be almost everything and that, too, was tied to rules.

When I sat looking at the entire set of requirements we had gathered the solution stood out — a series of small tiny changes over all the classes over time.  The METHOD to do the work actually was dictating the architecture we’d live with until the conversion was complete.  We would have two data systems up, and slowly switch, class by class, over, until complete.  After looking at what we could do, this would work the best over the whole-hog conversion my colleagues were pushing.

Sounds nice and agile, right?  It is.

But I realize there is a weakness in this approach: during the conversion there is opportunity for abuse of having two db systems in.  And, you can say “well just tell everyone and if it gets abused that’s a communication problem.”  No, not true.  Developers on the team have to drop in features and get them to work — so they may be forced to do one thing or another at that time to make the application work.  It’s called “continuous integration.”  So the weakness is, a small methodological conversion creates more tech debt over time that has to be refactored over time.

This tech debt, though, is very acceptable because the small changes are easier to test and track than a one-time whole conversion.  And if the system gets a bit abuses, when we get to those classes we’ll fix it.

It’s interesting how a good methodology can save the day.

Governance? Really?

I was just at a “DevJam” meeting where a bunch of project manager types discussed, mostly openly, about PMO.   In this came the idea of “governance.”

From what I can tell, and discussing with the manager types, governance is a policy whether in writing or not that meters the relations or procedures of how work gets done.  It may be nothing, like two developers agreeing to pair, or something more like a company mandating developers pair.

Of course discussion always goes around how far down governance should go, maybe even to the point of what type staples to use and sanity.

A few things struck me as a problem: the failure to identify PEOPLE as the important part of the process.  For instance, a great presentation ended with “how do we capture our institutional knowledge and wisdom.”  So mechanisms like blogs, social networking, wikis etc. were discussed.  As I listened it became apparent that the real question was “since people are the wildcards of knowledge and wisdom, how can we remove them because they are the problem”?

Not a single person said:  hire good people.  As a solution.  Not a one.

Another discussion revealed that a big company had just turned “agile” and had chosen TFS as a repository.  Wow.  I asked if the developers were involved — no they weren’t.  Some big company hand shaking got them there.  So now the’ve chosen their process and worse, TFS is a hindrance to going agile it just doesn’t integrate and provide the correct features to do agile well.  I said something to the manager a bout this, nicely, I saw a face tick and their mistake?

Not a single person, not one, had talked to their people.  Not a one.  Who would live with this solution.

Along these lines was a brilliant point-out by a retail manager that “coders cooperate, managers compete.”  And its true, mostly.  At the higher levels competition is more cutthroat; but this happens in development as well.  We tend to cooperate more though because a lot of us have the option of being consultants and removing ourselves from the rat race.  It promotes cooperation.  But I know the problem, at those higher levels.

People.  Hire the right people.

Governance, PMO’s, “rewards” and BS figurehead leadership don’t make great products.

People do.

A Month With Unity, Hmmmm

I started my experiment with going Linux-only (except on my work provided machine) about a month ago.   My new laptop dual boots to Windows 7 and Ubuntu/Unity 11.10;  I’ve been running Ubuntu 11.04 on a home server machine for over 6 months (before that a Gentoo distro) with Unity too, and Linux Mint on an old Compaq notebook.  Being a platform whore, Linux is a good fit for me.  I like Macs but . . I like PC hardware and love being in Linux with all its server type stuff.  Linux on a PC is the best of all worlds for me.

I LOVE Unity.  Its a great interface.  Love it.  The usability things like the trackpad features etc. are much, much better than Windows and the interface is in my opinion equivalent to a Mac.

Of course there’s been some issues, and its hardware related.  Hardware is the reason I didn’t completely go to a Mac years ago (and so you know my career started on System 6 Macs).  It’s this:  Ubuntu’s power management and video driver management is lacking enough to make me think of staying on Windows 7 on my new HP Pavilion notebook.  With my standard battery charged when I start up I get over 4 hours  of time on this i7 quadcore, full 1080p screened up HP.  Starting up Unity, turning down the screen etc. I only get 1.5  hours on the battery.  In percentages, Unity only gives me 37.5% of my battery life; Windows 266% more time than Unity.  this is significant.  Just to get to this I spent 4 hours mucking around with the settings in Unity for my Radeon graphics card.

Having sprung for a better battery this is worry some and not acceptable.  I am trying to think of usability cases — probably, I will work in Ubuntu when plugged in, but, in Windows 7 if I am without an outlet i.e. on a patio at a coffee shop.  So I’ll wait and see.

Also my last platform-specific app is FL Studio.  I would really like it to run better on Ubuntu (in Wine) but it’s OK at best.  So, will work with that too.

Hmmmm.  I  REALLY REALLY want a good Unity machine, sooooo close.

 

Adding an Ubuntu Unity Menu Link for IntelliJ

It’s pretty simple to add a menu launcher link for anything in Ubuntu.

Just make a file with a “.desktop” extension and then edit the file so that it has the pathing for the image file (48 px seems to be the size to choose) and the executable.  Here’s my intellij.desktop file contents:

#!/usr/bin/env xdg-open
[DesktopEntry]
Version=1.0
Terminal=false
StartupNotify=true
Icon=/home/bil/apps/intellij10/bin/idea_CE48.pngName=IntelliJ 10Exec=env UBUNTU_MENUPROXY=0 /home/bil/apps/intellij10/bin/idea.sh

Note the Icon line is a single line but doesn’t fit in this blog format.

I like to keep the file in the directory with the application folder, same level.

Now just drag the file to the Unity bar, and there you go.

My Linux Experiment: Month 1

OK so I decided to set my Linux OS experiment in motion.   I researched notebooks and settled on an HP Pavilion and it will have Unix installed as the primary OS.

I’m a developer.  And I do not know anyone who uses Linux as their workstation OS.   But I’m going to try it.

Decision

I do really like the Macs, but I got a more loaded machine from HP for $1100 compared to the $2100 tag on Apple’s current top of the line 15-incher.   Lenovo put themselves out of the running because they continually put that stupid textured trackpad on their Thinkpads; they annoy my fingers after an hour of use.  I hate it.  It’s too bad because except for that, I probably would have ordered the Thinkpad its one of the few machines I think is aesthetically more cool than a Mac.  I prefer the functional look of the Lenovo to the HP but usability is of course a factor – I have to be able to use it without physical discomfort.

Now while I have a bit of regret about not buying another Mac (I am typing on one now) there were a few things that put me off about them; I think its the locked in attitude (like adding your own ram is more difficult due to proprietary screws; ever update a JDK on a Mac??  ouch) and the much extra cost to hook up two monitors (this machine will funtion at home as a dev workstation).   Also, there’s a “exclusive” design/you aren’t cool thing with a lot of Mac owners, compounded by the fact that their Foxconn manufacturer in China has its workers sign a non-suicide pact.

HP struck a nice balance with the features and cost and gave some good service years back as well.  I’m NOT their whipping boy, they just happened to put together what I would like.  Other runners up were Alienware (a little over the top looking, heavy and power hungry) and Asus (I just didn’t like the form factor — but I do own a netbook its rock solid).

Now The Linux

I’ve been trying two different distributions:  Ubuntu 11 for about 2-3 months, and recently Mint 11.   I am still deciding.

Mint is a lot like Windows.   It is very very user friendly.   But I am not sure I enjoy the look of it so much and, being a power user, fell a little bit farther back from the OS than I’d ike.   it is however Ubuntu underneath (support is a question for me before I commit as well).  I’ll leave it on my old Compaq for now.

Right now I am leaning towards Ubuntu 11.  I like the top-side menu bar, the launcher, and feel close to what’s underneath.  Everything I use works on it.

One thing:  Linux cannot run Netflix because it does not support DRM.  this is SO annoying; I tried VMWare is a Chrome OS image but Chrome OS is so annoying I won’t do it.  So I may either be dropping Netflix or making a Windows image.

————

So that’s it, we’ll see.  My main apps:  browsers, Eclipse, Sublime Text, Tomcat etc. all run on Linux easy.   Libre office will be an adventure, but so is “Page.”

My plan is to test it for 9 months to 1 year, and if it works, great, if not, switch back to Mac or Windows.

Why am I doing this?  Because Windows pissed me off, Macs are too expensive for what they deliver and I like to work in a terminal.  So there.