Posts Tagged ‘Netbeans’

Lines per method

Netbean 7.4 introduced something really weird:

Netbeans 7.4, max lines per method

Apparently this is some sort of simplistic, ill-conceived metric for code quality. I can’t imagine the number of lines in a method matters at all compared to its role in the overall application architecture, its cohesiveness within its containing module, and its dependency on other methods and modules.

On an ArsTechnica article regarding why government IT projects fail so badly, one notable comment stood out to me:

I think that meaningless metrics may be one of the most dangerous things we see in modern society. I’m not saying that the metrics of the past were much better, but now it seems like we have so many more (more data is better right?) and people actually believe they’re somehow objective because they’re “data-driven” and numbers don’t lie. A worthless metric becomes a number that’s indistinguishable from a good one a spread sheet which leads others to see it to simply optimize the one they can most easily optimize. Of course this then leads to the highly tempting situation of designing your metrics to be easily optimizable. Combined with the fact that few people pay close attention to what the metrics actually say, it’s not wonder that most of these “objective” measurements basically say nothing.

I think lines per method clearly falls into the category of meaningless metric, and it’s terrible that code may be evaluated by it and programmers judged by it.

Netbeans RTF Copy plugin

I made a little plugin for Netbeans to allow copying text from the editor as RTF; mainly, preserving the foreground colors from its syntax highlighting. I wanted something akin to what’s possible with Visual Studio.

Download plugin

Source at bitbucket

netbeans copy as rtf

Taking the copied RTF text and running it thru Rtf2Html, I can then post nicely colored code:

header('Content-type: application/xml; charset=utf-8');
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";

The NBSpecialCopyPaste by Casper Bang was incredibly helpful as a starting point for this plugin.

There’s an issue I wasn’t able to resolve before releasing this; fields (by default, highlighted green by the editor) aren’t copied properly in some cases. The API seems to give no indication that these tokens are colored differently. I know this is true for Java and PHP code, but not true for XML. The code to get the necessary AttributeSet is exactly what’s in NBSpecialCopyPaste:

private static AttributeSet findFontAndColors(Token tkn, FontColorSettings fcs)
{
AttributeSet as = fcs.getTokenFontColors( tkn.id().name() );
if (as == null)
{
// ...try to get from its category
as = fcs.getTokenFontColors(tkn.id().primaryCategory());
}

return as;
}

I’ll dig deeper and try to resolve this in a future version.

Java IDEs, The KMPlayer, and the uncooperative bedfellows

I do a lot of programming in Java. I’m required to. Being the non-Luddite that I am, I almost never write code outside of an IDE; I’ve experimented w/ most of the major Java IDEs:

  • Netbeans: Seems to have a nice set of features, but I dropped it pretty fast as it was horrendously slow. It seems to have to freeze the IDE and write to the HD after every few keystrokes or every time the code completion dialog had to popup; incredibly stupid behavior considering I always had a ton of memory free.
  • Eclipse: Probably the most popular IDE and it seems to be loved by the open source community. As with Netbeans, nice feature set, but not as pretty, in fact the interface is pretty ugly. It doesn’t have the nice “open on mouse-over-tab” side menus which I first fell in love w/ in Visual Studio and I always seemed to be fighting to see my code. Also, in terms of performance, Eclipse is no rabbit. It’s significantly better than Netbeans, but there is quite a bit of disk thrashing and its code completion is not very responsive. However, this was a very long time ago and a few months back I attempted to do an install of the latest version to see how far Eclipse had come, and I couldn’t get it installed; I remember some stupid error during setup, but can’t recall exactly what it was. I decided it wasn’t worth my time given my previous experience.
  • JCreator: The IDE I currently use. I’ve been using the LE version, and will likely get the Pro version depending on how much Java is in my future. The most notable feature missing from the LE version is code completion. Even w/o code completion, this is the best Java IDE I’ve come across, excellent performance and very responsive in all areas, stable, easy setup, and it has those nice side menus I mentioned above. It’s not as rich as Visual C#, but it does seem to take a lot from the Visual Studio family which is a very good thing.

These criticisms may no longer be valid or fair as I don’t actively keep up w/ new releases, but first impressions do matter.

Now for something completely different…

I’ve used Winamp for a long time. There’s really only a few other good media players around for Windows: Windows Media Player (function, but the thing’s a beast), iTunes (same crit as WMP, performance is also crappy on older machines), VLC (seemed like the greatest thing since sliced bread, but I installed it a while back and just couldn’t get it to play anything). I liked Winamp, but lost favor w/ it b/c of it’s poor support for video formats and, more than anything else, installing a new version of it placed a ton of AOL shortcuts everywhere (start menu, desktop, bookmarks, etc.).

In my search for a new media player, I discovered The KMPlayer a while back. It has great video support (there are a few color issues in the odd video here and there), great audio support (as long as it had mp3 and ogg I would have been happy, but it also played a bunch of old MOD files I had lying around), and a really nice interface. Just fuckin’ sweet.

Now, I have an incredibly weird situation on my system. KMPlayer and JCreator don’t play nice together. If they’re both open, some JCreator panels and menus are suddenly blank and don’t refresh and the side tabs panel is transparent, showing thru to the desktop. As for KMPlayer, I can’t open anything, clicking play (which plays the last file opened when nothing else has been loaded) does nothing, and certain items are mysteriously missing from the context menu. This hasn’t been a big deal for me, and I still use both JCreator and KMPlayer, but it would be nice if they worked together. Also, I have to wonder, what is the common component causing the conflict here, what would a media player and a java IDE both be using or trying to access concurrently? (assuming there is a conflict for a common component, which I suspect might be the issue here)

Independently both products are great, they just don’t seem to like each other.