Thursday, January 25, 2007

Posting from Flickr


DSC_0121.JPG
Originally uploaded by devilelephant.
Testing the ability to blog my Flickr photos directly.

Flickr

This is a test post from flickr, a fancy photo sharing thing.

Back to Blogger

Moved my blog back to Blogger after experimenting with Typo, the Ruby on Rails blogger, on my own server: http://devilelephant.com.

I'll have to work on getting my view back to what it should be.

Lessons Learned:
  • Managing your own blog software is a big job.
  • Typo is hard to upgrade - at least it was for me
  • The version I was using allowed too many spam messages and talkback links
  • Fun AJAX interface is not worth the spam and maintenance.
  • Kept me from wanting to publish.

Dealing with Crap Code

Who doesn’t? Only those who are lucky enough to work on small dedicated teams.

I think it would be an interesting article to face the fact that crap code and low-level developers are a staple of corporate development. The leaders in our industry whine about this a lot but it is a fact of life and it won’t improve due to economic forces. As long as a corporation can pick up a six-pack of developers from Walmart that will work for 50% of what a talented and experienced developer would work for there will be crap code. It doesn’t matter that statistics show the project will take 10x as long or that maintenance costs will be through the roof. I’ve yet to meet a corporation where those concerns matter to anybody above IT manager (if that). Long term maintenance is usually not a planning concern and is part of some other department's budget anyway.

A sad truth is that the majority of crap code performs similar to quality code so many times it is hard to argue for a decent refactoring. I’d be interested in figuring out how to use existing frameworks to better localize the crap code to small crap islands (crapplets?). Early n-tier development did this by letting the so-called junior developers do the 5000-line-per-JSP programming while the experienced developers worked on the server. This was great until people started expecting more usable web interfaces. Now the UI might have as much JavaScript and AJAX magic as the business side of the application.

I have yet to see a software process or framework that tackles this issue realistically. They have “roles” but they don’t specify degrees of capability. When 80% of your team thinks threading concerns are when your clothes start to wear out how do you best place them within a project?

I think it would be fascinating to see a software framework that specifically breaks apart concerns so that you can use your A, B, C, and D developers to the best of their abilities while minimizing the impact of the crap code that the less capable will crank out.

I don’t want to hear any feedback about how you should just get rid of the junior programmers. They have families, they have to eat, and realistically, if downsized, the more expensive developers will get the boot first. Our industry has to figure out how to best utilize the majority of its C and D-level developers. We can’t make them all project-managers.

Commenting fields/methods

Less comments but more content.

Along with methods, if a field has to be commented, I’ve found it is usually because it is misnamed.

// Counter that keeps track of login attempts private int counter;

Would be better expressed as: private int loginAttemptCounter;

It is funny how this simple DRY concept can keep you on the high road of development. Also important is spell-checking and grammar. While a comment shouldn’t be an English thesis paper it should be professionally written. If English is not your strong point have a buddy on the team review your code for errors. Even the best authors lean heavily on editors (the human proof-reading kind not the text-editing kind).

EZ Project Management

No matter what the chosen process is or how tasks are broken up, every major project I’ve been on has been time blocked:

  1. Management decides the new system should be finished by date X.
  2. The analysts and project manager divide the amount of tasks by the number of iterations available before date X.
  3. For each iteration-task-set you divide it evenly amongst your available developers.
  4. You ask your developers for an estimation on their tasks for each iteration.
  5. They respond by taking the number of assigned tasks, divided by the hours available in the iteration.
  6. Some magic happens (scope reduction, overtime, bring in experts to clean up, implement tasks with TODO: statements)
  7. The project finishes on date X.

I’ve developed this project management process on a single MS excel sheet. I’m making it available for a cost of $1000 per seat with an annual $10K maintenance charge. Of course I can offer consulting services to customize it to your corporation at a $300/hour bill rate. Do you like curly fonts?

Corporate Code Smells

Mostly venting here, how many of these have you seen?

Corporate Code smells:
  1. WSAD - There is a reason it isn’t called WHAPPY
  2. Only javadoc is the eclipse message telling you how to change your default javadoc templates
  3. No interfaces at all or an interface for every class
  4. junit.jar exists in the lib directory but no tests to be found
    • I got this unit test that calls the production database
  5. optimized imports? code formatting? we don’t have time in the project plan for that
  6. Sure we use Spring, but we wrap it with our own classes so we can switch it out later
    • We’ve cached the bean instance returned by Spring to speed things up
  7. We added hibernate because we knew we were going to hit the database
  8. Synchronization? Threads? the container takes care of that
  9. Guys, look at this framework I cranked out last night!
  10. With annotations I was able to expose all my classes as web services, you know, for reuse!

Notes on getting Ruby on Rails working on my Powerbook 15

Used darwin ports to install ruby and rb-rubygems

I’m using z-shell so I needed to edit the

'~/Library/init/zsh/environment'

file to make sure that

'/opt/local/bin'

was the first folder on my path. Then I simply did a

gem install rake
gem install rails

This sounds simple but it only took 5 hours of digging to get right!

Come on Apple. If you are going to include Ruby then make sure you install it correctly.

Some kids just got to touch that hot stove

One of my project’s biggest challenges right now is working around the limitations of a validation “framework”, which is both too restrictive and configuration-heavy. It’s almost always a mistake to attempt to write any kind of “framework” in-house but maybe it is good for this client to get a few of these mistakes under their belts. Some lessons have to be learned the hard way no matter how many books, articles, blogs are written on software development anti-patterns.

The Dumbening

But then I started to notice something about the Java projects I was involved in: weak teams and weak programmers will go to great lengths to do the wrong thing

Glenn Vanderburg
No Fluff Just Stuff - 2006 Anthology
Buried Treasure Chapter

Has the pragmatic press put out a bad book yet?

I like this quote. It reflects a lot of my experience with teams lately. I’d put a different twist on it.

Here the author was talking about if the “weakest programmers” on the team could be trusted with more powerful language features. An argument may go along the lines of “we need static typing to protect developers from themselves…”.

A trend I’ve seen in large corporate development is to invest more in smart tools than smart developers. The problem is that smart tools keep developers dumb.

I’ve been on teams with very green developers and have had two experiences:

Simple Tools: Sophisticated Development

The first is that we set up an ant build that has simple targets. Basically, made it easy for the developer to use whatever IDE they wanted. I just gave them the golden rule that the ant build was king. I also set it up so that server processes kicked off in a console window. Taught them how to use the unix “tail” command on the network servers.

It turned out that even the weakest developers felt very comfortable with this setup. If something didn’t build they could figure out quickly if it was a code issue, a missing library, or something else. I saw them grow very comfortable with the command line and with Java development in general. In short trusting the developers made them smarter and made the team stronger. I’d see signs of this when the developers would be able to solve complicated problems independently. Because they felt close to the metal they felt comfortable trying to dig out and solve issues themselves. Try a little AOP? Sure.

The funny thing is that the code was also better. Smaller classes, less code doing more, better javadoc. Pretty much everything that would make a team leader proud.

Smart Tools

The second experience I’ve had is with a company that felt that tools were the solution. Builds, deploys, servers, were all launched from within an IDE. A right-click generated a web-service, or EJB, or JavaBean. Separate teams were responsible for configuration and deployment and each had their own tools. One example was a tool that would try to inspect the .project file from an Eclipse project setup and use that to generate a build script to be used only by the deployment team. Want to take a guess at how much productivity that sucked away? Here is a hint: The solution was to have the development team check in all generated artifacts so the deploy team’s tool would be easier to use.

The tools were smart but kept the developers from knowing what was going on behind the scenes. These developers would be able to crank out 100’s of lines of code but would stumble at the basics. They’d be asking why their workstation has red flags while mine didn’t. They’d be lost as to why a deploy didn’t work. Javadoc would be limited to the crap the IDE spewed out. 100s of TODO statements littered the production code.

In short, smart tools made for dumb programmers.

Why is this? One theory I have is that programmers want to program - not draw pictures or use someone else’s software. If we wanted fancy tools we would be word processors, graphic artists, CAD professionals, etc.

If fancy tools were the solution to good software development then industry would have solved the issue long ago. Yes, I love my IDEs. I love code completion when I can get it. Even debuggers, which I feel is the ultimate “smart tool that keeps programmers dumb” come in useful. I’m just saying that the focus should be on what the developers feel would make them most productive.

Invest in people first, not tools

It is rare to find the developer who does not have potential. Most want to do the best job they can. Most want to learn new things and be considered competent by the team. At the same time, a company that treats its developers like a disposable and replaceable commodity will get developers who live up to that perception. The U.S. military can take 18-year-olds and train them to use million dollar equipment with confidence. That institution knows that setting the bar high will create a team that works well together and as individuals.

The Dumbening

As always The Simposon’s has a relevant episode. In this one Lisa lives down to her expectations when she thinks she has a Simpson-gene that dooms her to slowly become an idiot.

ze environment is ze file to configure ze shell

Bad french aside, here are my notes for configuring the z-shell to find the Darwin Ports version of programs first.

~/Library/init/zsh

This path points to where the “environment” is set.

Edit this file and make sure that your /opt/local/bin folder comes first

prependPath PATH /usr/local/sbin
prependPath PATH /usr/local/bin
prependPath PATH ~/bin/powerpc-apple-darwin
prependPath PATH ~/bin
prependPath PATH /opt/local/bin

appendPath PATH /usr/local/mysql/bin
appendPath PATH /usr/bin
appendPath PATH /bin
appendPath PATH /usr/sbin
appendPath PATH /sbino
appendPath PATH /Developer/Tools

Note that prependPath and appendPath are functions defined earlier in the “environment” file.

Darwin Ports Notes

Warning: These notes are mostly plagarized from some other website but I wanted them on mine for easy lookup.,

sudo port selfupdate                   
sudo port upgrade
sudo port install vile
port search 'vile'

The search facility uses standard regular expression syntax, so you can also do much more complex searches. Additional Steps: fetch, configure, build, destroot, install

Once the port has been installed, you may want to delete all the intermediate files that DarwinPorts has created while building the port. To do this, simply use the clean option:

port clean vile
port clean --all vile

Getting Information about a Port

port info vim
port search '.+'
port list
port installed
port installed
port outdated
port contents vile

Variants and Dependencies

Before you install a port, you may want to check what variations of that port are available to use. Variants provide additional configuration options for a port. To see what variations a port has, use the variants option: port variants vile

You also may want to see what dependencies a port has. You can use the deps option to check: port deps vile

If you want to find out which ports depends on a port you have installed, use: port dependents gettext

For more information you should look at the port manpage by entering: man port. The portindex command

Most of the time you won’t need to use this command as it is used to build the index of all the available ports, but sometimes the index you have is out of date or innacurate for some reason. When this occurs you will get an error message like ‘port search failed: expected integer but got “PortIndex”’. You can fix problem by moving to the dports directory (/Users/mike/darwinports/dports in our examples) and executing: portindex. This will go through all the available ports in the dport directory and build an index file called PortIndex.

Removing ports

Ports are removed using the port command described above, simply execute the command: sudo port uninstall vile

Upgrading ports

You can check if a port is outdated with the following command: port outdated gnome

To check if you have any outdated ports: port outdated

To upgrade a port execute: sudo port upgrade gnome

This will deactivate the old version and install the new, and also install the newer versions of the dependencies of the port.

If you would like to upgrade the port, but not the dependencies of the port, you can: sudo port -n upgrade gnome

To upgrade all installed ports simply do: sudo port upgrade installed

If you dont like that upgrade just deactivates the old version of the port, you can get it to uninstall the old version by using the -u option: sudo port -u upgrade gnome

Using force

While upgrading you can run into cases when you have to use force (-f). This is especially true if you are upgrading a port that wants to install a file that another port allready has installed, or if you use the -u option to upgrade (and uninstall) a port that could be installed as a dependency. Allways remember to use the -f option with caution.

Rails, Plural table names - lame

O.K. I’ve been working with Rails for several weeks now and am loving the ease for cranking out websites. Good stuff.

But…

(and that’s a big butt)

For some insane reason the developers of Rails decided plural table names was a convention worth promoting by having it as the default.

Most experienced DBAs will tell you that the name of a table should describe what one record in that table would represent. Who would recommend plural table names? Developers seem to like plural names because they equate database tables with Collections (think java.util.List). I guess I come from a more traditional background where I think of tables as set theory.

Naming guidelines aside there is another reason not to go down this route. Rails then has to be smart enough to parse the plurals for almost every noun in the English dictionary.

What short-circuited in the developer’s brains? They develop this slick environment and then slap in some hacky idea. I think it is only useful to add to the perceived “wow” factor that the Rails enthusiasts get at conferences. yee-ha!

Luckily there is a work-around to make Rails work just as nicely with singular table names.

Thanks to this post on justinram.wordpress.com for providing the answer on how to switch off this really stupid bug in rails:

Add the following to the bottom of your config/environment.rb file:

# Include your application configuration below
ActiveRecord::Base.pluralize_table_names = false

Design by convention

Final thing that “really grinds my gears” (Family Guy) is that it goes against the grain of “design by convention” that is Rails major contribution to the web space. Why would all my controllers, views, helpers, etc be called Employee and my table name be Employees?

Why would my code refer to “Sheep” and my table name be “Sheep”. Well, maybe that wasn’t a good example.

I guess in the end there is a difference between convention magic: “Hey, all my MVC objects are named the same so I don’t have to configure them - that makes sense” and spooky “under the covers” magic “Hey I magically figured out that your Alumnus class should be related to the Alumni table”

It is a good thing that Rails has that call to the Dictionary.com web service to get the plural name for every model.

Be a Better Blogger

This week I’ve stumbled upon a great web link that I’d like to share with all of us who feel compelled to pound out a few paragraphs a day on a favorite topic:

50 Writing Tips

Note: if the above link no longer works see my notes at the bottom of this article.

I haven’t traversed the entire website yet but the “Writing / Editing” section is excellent. I clicked through the “Fifty Writing Tools” articles and they are relevant and entertaining. Entertaining? Yes. Author Roy Peter Clark deserves respect for not only presenting his writing tips clearly but also for sampling across great literature as examples.

Dammit Jim, I’m a tech blogger not a Journalism major!

Make no bones about it, if you blog or comment frequently in a public space you are a journalist. You don’t need the degree hanging on your office wall but you should try to write like you do. Have you ever stopped reading an article because it was confusing, had spelling or grammar mistakes, or maybe the author’s laptop was missing all of the punctuation keys? We are judged both on our ideas and how well we express them.

Here’s an exercise: The next time you are reading your favorite board, take a critical look at how the posters express themselves. Which posts do you think give off a sense of authority? Which ones make the authors look juvenile or just plain ignorant?

How do you want to be perceived?

I’m by no means a successful blogger. I get maybe a half-a-person a day to come read my stuff but I do post a lot on other boards. The main purpose for this blog is to practice writing and expressing myself so that if the opportunity comes up to write professionally, I’ll be practiced and in shape. Regardless, I’m trying to write like I have a large base of constant readers.

Of Course! Head slap.

Ok, here is the bad news. These 50 writing tools are supposedly going to be taken down soon because the author has a book deal and the publisher doesn’t want the content online. I’ve used FlashGot to download all of them locally so I have a chance to go through them. Anyway, I think the site is worth a look and as long as Google stores cached versions.

Shh, don’t tell the publisher but…

Alright, have you heard of the WayBack Machine. Why, no Mr. Peabody. Well it is an internet archiving site that basically makes snapshots of the internet how it was throughout time. Want to see what the Google home page looked like eight years ago?

Well if they do take the 50 links off the main site you may be able to still find them somewhere else.

Tech Resumes

Recently, I’ve been helping out interviewing prospective candidates for Java design and architect level positions. You wouldn’t believe how much writing affects your chances of getting an interview. Or maybe I should say you wouldn’t believe how fast your resume gets dragged to the trash can if it is not clear and effective.

Before you apply for your next position get someone you trust to take a critical look at your resume. Even if you have to shell out money to have someone prepare a professional resume for you it is well worth it. Don’t make the mistake of letting your resume get in the way of your next job. This is especially good advice if English is not your primary language.

Does it matter?

I think there is the perception out there that for tech resumes all you need is a pile of acronyms and a list of companies you worked for. This isn’t true.

Find a standard template that suits your experience

There are many good books out there on effective resume writing. There are great examples on the web. You should try to find a template that emphasizes your abilities and can be easily tailored for each position you are applying for.

If you are new to the job market, you may want to move your education section before your experiences. If you’ve been on the job for awhile you may want to trim down the descriptions of jobs you held 10 years ago.

Tech resume essentials

  • No spelling, grammar, or punctuation errors. Period.

    Now that the tech-job market is bouncing back you may be able to get jobs with your sloppy resume. All that means is that you are missing out on better positions.

  • Tech grid.

    Yes, you need the dumb little table that tells the HR-bots all of the acronyms that you have under your belt. AJAX, HTML, JAVA, CSS,…. Try to make this grid clear and easy to read for the humans. Try not to include every last technology you’ve come across. Only list the technologies where you consider yourself proficient. Don’t put Ant down if all you’ve done is run an ant build someone else wrote. Don’t put Tomcat down if all you’ve done is write a JSP that someone else delivered to a production box. You don’t have to be an expert on everything you put in your tech grid but you should be experienced to the point where you wouldn’t need training or mentoring on that technology.

    Believe me, if you have a technology on your grid that the client cares about you will be asked about it. If you then say you’ve only had a whiff of experience with it you will not be taken seriously. Remember that a job interview is all about establishing trust. If the client doesn’t trust you they won’t hire you.

  • Describe how you directly affected the projects you worked on.

    One recent resume I read spent 4 pages advertising for the companies the guy worked at. Entries like: “Ford Motor Company is a large automotive concern whose annual earnings exceed xxx….” Your resume is supposed to be an advertisement for you - not a brochure for others. If anything list the company and the projects you worked on in one or two sentences. What the interviewer wants to know is what did you do at that position? Try to think of specific highlights. How did you positively affect the project’s outcome?

  • Use metrics Use specific metrics if you can get them.

Compare:

  • Team leader
  • Increased performance on data tier
  • Authored many articles on software process improvement
  • Helped bring in the project under budget.

to:

  • Lead team of 20 developers
  • Helped increase performance on data tier 150%
  • Wrote over 30 articles on company Wiki regarding software process improvement
  • Helped my team bring in the project $100K under budget.