I’m busy re-writing vast swaths of my low-level code in order to support a new database schema. One of the classes that I wrote that got used all over the place is called “Playlist”, and its various subclasses. Playlist has an abstract clone() method. I almost never write clone() methods, so somebody must have asked for it. And I think I know who now.
As part of this re-write, I using Eclipse’s “Find References” function a lot to see if some method needs to be re-written or can just be deleted. While doing that, I found an interesting bit of code in an obscure part of the system that I’ve never looked at before:
private Playlist doClonePlaylist(Playlist playlist) {
Playlist clonePlaylist = null;
// need a special clone
// as the playlist cone function
// doesn't copy the playlist
// external id which we really need
if (playlist != null) {
clonePlaylist = (Playlist)playlist.clone();
clonePlaylist.setExternalID(playlist.getExternalID());
}
return clonePlaylist;
}
If the guy who’d written this bit of cruft still worked here, I’d want to ask him why the fuck he didn’t just tell me that I’d left one parameter out of my clone() method, or even better, fix it himself? Ideally, I’d want to ask him while dangling him over the edge of a multistory building, but that isn’t going to happen.