Posts Tagged ‘Java’

“Law of Demeter” as a Software Metric

June 3rd, 2012 Comments off

The “Law of Demeter” (LoD) is one important principle to achieve low coupling in your code. And it could be turned into a software metric easily.

To measure the coupling, you could count the “LoD violations” per method. “0” means that no violations occured and the result is increased by 1 for every violation that was found.

I am wondering if someone implemented such a metric and if it could be used in Eclipse or NetBeans.

Here is a small example.

Read more…

Remote File System for NetBeans 6.9.1

February 12th, 2011 7 comments

A few months ago, I provided a patch for the Remote File System” plugin for NetBeans to make the FTP file system work with the current NetBeans version 6.9.1. The patch is available in the repository on Kenai, but till now there was no binary distribution. Several people asked me for that and so I created one: nb-remotefs-0.1.3

Plus, I fixed a bug today within the SFTP module so that SFTP and FTP are working both. Remotefs is still in an early stage and many features are still missing, but I recovered the basic functionality so that you can edit your remote files in NetBeans 6.9.1.

The initial developer has no time to maintain the project and I don’t have much time either. I don’t know if the missing features will ever be implemented. Maybe you can tell me what you are missing most and I will try to find some time to do it.

Automatisches Ressourcenmanagement in Java 7

March 10th, 2009 Comments off

Wenn in einem Java-Programm Ressourcen (Dateien, SQL-Verbindungen, usw.) geöffnet werden, muss der Programmierer darauf achten, die Ressourcen auch ordnungsgemäß wieder frei zu geben. Geschieht dies nicht, erzeugt das Programm ein “Ressourcen-Leck”. Die Folgen können unterschiedlich sein, von nicht spürbaren Performanceeinbußen bis hin zur Instabilität und Untauglichkeit des gesamten Programms.
Um diese Fehlerquelle im Vorfeld zu vermeiden, wäre es also wünschenswert, dass eine Programmierplattform das Ressourcenmanagement weitestgehend automatisch durchführen kann. In Java ist das bisher nicht möglich, aber für Java 7 gibt es einen Änderungsvorschlag dafür.

So sähe dann mit Java 7 z.B. das Kopieren einer Datei aus:

    static void copy(String src, String dest) throws IOException {
        try (InputStream in = new FileInputStream(src);
             OutputStream out = new FileOutputStream(dest)) {
            byte[] buf = new byte[8192];
            int n;
            while ((n = >= 0)
                out.write(buf, 0, n);

Read more…

Categories: Programmierung Tags: