Posts

Showing posts with the label programming

Rule of thumbs for API designing

I have just read a very interesting article " API Design Matters " by Michi Henning . He discusses the problem with bad designed and gives some rules of thumb. We all have some time used an API that does not feel right and makes the coding hard. It is very interesting to read Michis analyze of this and why. My feeling is that he had put the hammer right on the nail. Here is a summary of the rules he discuss. I assume you will feel like me when you read them; yeah thats obvious. But thats the nice thing and the important is to get the list. An API : must provide sufficient functionality for the caller to achieve its task. should be minimal without imposing undue inconvenience on the caller. should be policy free if it is general purpose. should be policy rich if it is special purpose. should be designed from the perspective of the caller. don't let the caller configure "everything". should be documented before it is implemented. If you want to read the discussion...

How to find the interesting TV shows?

I have had the possibility to do some coding this weekend. Which also gave me the possibility to learn XSL(T) , look closer on iCal, and xmltv. The result is a small application to search TV charts including the descriptions of the TV shows. It uses xmltv to fetch information about whats on TV. Then there are a very googly search interface to find the interesting shows. Out comes a new reduced XML file in the same format as xmltv but only including shows that match your search. This XML-file can then be translated to either HTML or iCal using XSL. Its is of course possible to write other XSL-files to create other formats. It is written in Python. I am not ready yet to publish the application. It needs some documentation and packaging. My main reason was not to write the program, it was more about to play with different algorithms and programing techniques. The program was just a side effect. I will write more about this software when I am ready to publish it.

Don't write another line code until you have seen this

I think this talk is one of the best talk I have found in Googles Engineering series. Google talks are generally very good, but this is even better and has a good speaker. Joshua Bloch talk "How To Design A Good API and Why it Matters" presents a lot of good information what to think about when creates API:s. Even if you aren't writing another framework it is important. I think people seems to believe today that reuse can only be done using frameworks. Joshua points out the importance of good API:s inside your program and for different modules. I would also like to add that this is important when designing new XML-DTD:s, which is a kind of API. For instance, I have seen XML file formats that says the address-tag includes space separated e-mail addresses. Why not use multiple address-tags, one for each address. In this way I can solely use my XML-parser to parse the file and do not need add extra code to separate the sting at spaces. If you do not have an hour at the mo...

JavaZone end

I continued the day by listening to a re-run of Ivar Jacobssons talk, which where I missed yesterday due to the room got full before I got there. It was the most interesting talk at the conferens, even if it wasn't about Java. As you may know Dr. Jacobsson is one of the three gurus behind RUP . He admitted during the talk that RUP and Objectory were too heavy and why throw out everything if only one part of your process fail. Instead he have broken down processes into eight practices . Practices are parts of processes which more or less all processes include in different forms. Example of practices are teams or architecture. There are not only one way to implement a team, so there will be several practices that describes teams and you should select the one that fits your organization. Jacobsson have one way to implement each of the eight practices. Other will present others, in total there are 100s of practices. Each practice is documented as ten to twenty cards and then some page...

JavaZone day one continues

After a quick lunch I planned to listen o the OO and process guru Ivar Jacobsson but the room was full even before I got my sandwich. Instead I entered a seminar about REST which was quite interesting. Teh speach presented the fundamental architectural principles and explained problems and possibilities with real world examples. Then I entered a seminar about how to structural code in a good manner to allow the software to evolve. It is quite connected to my old research area of maintainability of object oriented programs. The conclusion is the same as for ten years, but they need to be repeated; Avoid circular dependencies. Have cleare aims of your packages, modules etc. If you get circular dependencies, do refactoring. Of course it may break backward compability. You need of course think how to handle lack of backward compability. So far I haven't seen any Linux computers, except of my own Ubuntu. The rest are Mac or Windows, I wonder why.

Python and Java

Since I do Python programming at my spare time and Java programming, including a bunch of other Java technologies such as JSP, JSTL etc, at work. These articles were very interesting to read even if they are 2½ years old: Python is not Java Java is not Python, either Python interfaces is not Java interfaces

find is an amazing tool, but it can't use Gnome-vfs

I use the find command line utility nearly every day. It is amazing to manipulate large directory hierarchy with files. Unfortunately, I have missed the possibility to do like this: find ftp://ftp.sunet.se/ -type f -exec gnomevfs-copy {} . \; The example above is of course stupid since it will take for ever and fill my hard drive but you get the idea. I need the similar functionality to copy video-files from my PVR, Kiss DP-558, to my Ubuntu server. This weekend I decided to solve the problem, so I created gvfsfind . The prefix gvfs since it is based on gnome-vfs. The tool has a help that I hope can get you to start using it. Just start it with the flag -h. This example prints all directories on the ftp-site: gvfsfind.py ftp://video.foo.org --type d --print To copy all files ending with .vob from the host skipper to the local host: gvfsfind.py ssh://skipper/srv/movie --type f --name ".*\.vob" --exec "gnomevfs-copy %u ." Create all directories on the remote host ski...

Let the build flow like the Hudson river.

Today at work I found a wonderful continuous build-tool. One will often start a new build and regression test after each check in to the revision control repository. The tool I found is called Hudson . Some of the feature I have found useful are: * Reporting by e-mail or jabber when something goes wrong (or when it goes right) * Builds can start based on time or on events. * It gives you nice statistics about your build * For Java projects there are good plug-ins to get statistics about code coverage using Emma and regression testing using japex and JUnit . * It works against revision control systems * It can tag the builds, depending on the result * You can see history of build, and control when they should be purged * It's easy to install, no external needs except Java. * Hudson can be used with non Java applications too. (Hudson have support for maven, ant and shell script from the beginning.) * It looks easy to write your own plug-ins * A remote XML-API exist. * It's ope...

Advanced Linux Programming

I run into an online version of the book Advanced Linux Programming . It is a good book when you are interested in start writing programs with inter process communication and threading. From my perspective is it not advanced in those topics. Even if you are not into these areas of programming you should read chapter 10 Security if you are doing any programming on any kind of system; Unix, Windows, embedded, what ever. It points out some important stuff that you need to know. Learn to avoid buffer overrun, symbolic link race conditions, etc. Remember, always validate the input you get to your program.