Objective C Pitfalls for Java and C# Programmers

These were my first experiences with Objective-C, Xcode and the Mac

Can you read this, Luke Skywalker?
If you came from Java or C#, your most prominent errors or pitfalls with Objective C might be:

  • Pointers and the asterisk: http://stackoverflow.com/questions/1105815/placement-of-the-asterisk-in-objective-c
  • The type “id” is always a pointer, so no asterisk there
  • Strange effects happen when you “#inport” .h files with cyclical references. I didn’t find a better solution than having id instead of the Type I wanted to use in one of my classes
  • There are no null pointer exceptions. This means you’ll all the time miss the initialization of some object or some reference and won’t recognize it. Since recognizing this, I love null pointers exceptions. But this is language design in Objective C. So if you definitely need to be sure, throw an exception if you want to be sure and / or add some unit tests.
  • When the application crashes, you won’t get meaningful answers from the console often times. To get some more information you’ll need to set a breakpoint in the last thrown exception statement. You can find out more here.
  • When you want to use a simple integer like 5 and get the warning / error “makes Pointer from integer without a cast”, you need to use [NSNumber numberFromInt:5]
  • Always correct header file first, implemetation file second and always correct from top to bottom, as the compiler does this too. When the compiler sees an error in the header file for example, it might make up 50 more errors somewhere below. This is literally top-down debugging.
  • Don’t try to mess with XML too much yourself. Use this nice, free and fast XML framework instead.
  • There are great resources for iOS development out there, for example the full open source Canabalt game or framework-like libraries that could make some things easier, if you see it before you’ve implemented all such things yourself.
  • To find such resources, I’d read this blog and follow it’s writer on Twitter.
  • Oh yeah, and Google and Stackoverflow should fix the rest.

Creative Commons License photo credit: Stéfan

We need a “Delete old Documentation Day”

DODD - Delete Old Documentation Day 15 feb
Old documentation in maven and ServiceMix caused much trouble for me, and I know for many other people. And I’m sure these are not the only projects that have a lot of meaningless, deprecated documentation around doing nothing than confusing people. Then people always cheat and say they are to busy to update documentation everytime they add a new feature or they fix a bug or something else changes; as documentation is nothing more than time waste, right?

You know, we have Google. If all the wrong documentation were gone, we would either find the correct documentation or the programmers would realize nobody can use their software and had to write new, up-to-date documentation.

Therefore, I propose DODD! Let’s make a Let’s make a “Delete Old Documentation Day”, once a year, where everyone just deletes old stuff that is misleading or inaccurate to make the whole average documentation clear and concise?

What do you think? How about 15.02.? The day after Valentine’s we should have enough love for everyone else and the outdated documentation they need to read.

Struts2 Präsentation für Programmierer

Grade wollte ich mir bei Scribd dieses längere und scheinbar sehr interessante TechnoPhilosophische Paper zum Thema Risiken von künstlicher Intelligenz runterladen, als ein Popup auftachte, dass ich dafür was hochladen solle. Aber was?

Bei Ascora / Abelssoft machen wir jeden Monat eine interne Veranstaltung um uns etwas weiterzubilden und schöne neue Technologien kennenzulernen. Diesen Monat war ich dran und habe was zum Thema Struts2 erzählt, DEM aufstrebenden Java Webframework.

Also, für den Fall dass sich jemand einleiten lassen möchte (oder dass ich diesen Vortrag nochmal woanders halten möchte, wo es eine Internetanbindung gibt), hier die Präsentationsfolien. Aber Vorsicht, ohne Erklärungen machen zuminstest die Codebeispiele wenig Sinn.

Struts2-Einleitung-für-Programmierer

Getting started with ServiceMix 4.2 and WebServices (with Maven and Eclipse on Windows)

(Under this post I noted down some great resources for getting started, so if you’re searching for those, have a look at the bottom of this article)

Okay, I had a really hard time getting started with ServiceMix, as there’re so many technologies involved and I knew none of them. Maven. OSGi. ServiceMix. Karaf. Most of the time, you only want something to work so you can apply the same or nearly the same technique again, right? So here’s a little plan what works and where you can start your journey:

- Install maven. Install Eclipse.

- Install the m2 plugin for eclipse.

- Download ServiceMix 4.2.

- Open a windows command terminal. Navigate to %servicemix_home%/bin

- “servicemix.bat” starts ServiceMix. You get into the Karaf console. Typing TAB and “y” shows you a lot of commands you can try out. (If you want, try some … easy administration!)

- Open Eclipse. Seriously. Import –> Maven project

- In the wizard, browse to %servicemix_home%/examples

- Pick the “cfx-osgi” folder and use the pom.xml the wizard finds there for importing the project. Finish the wizard.

- Change the sourcecode of the HelloWorldImpl.java file to do what you want and save that file.

- Right click the project –> Run –> Maven install. A .jar file gets generated.

- Copy that jar file into the %servicemix_home%/deploy folder.

- Get back to Eclipse … there’s a client.html file in the imported project. Right click that –> Open With –> Web Browser

- Click the “send” button. Smile.

- (Optional: Now remove the .jar file from the deploy folder of servicemix. Click the “send” button on the HTML form again. Smile.)

If you want to learn more, you can look into the FUSE ServiceMix documentation (FUSE is documenting and selling support for ServiceMix, but they don’t put much more on top of ServiceMix, so the documentation is pretty good). Or try the text files that come with the examples.

Hope this helped you a bit.

Edits and Updates:

  • I found this tutorial VERY helpful dealing with and understanding BCs: http://servicemix.apache.org/hello-world-bc.html
  • And as you will be using Spring anyways and there’s no way around it, just to understand how simple it works, begin with this small tutorial: Getting started with Spring
  • FUSE is a trademark that’s selling support for servicemix and label servicemix as “FUSE”. No matter if I got that right, FUSE is basically just ServiceMix. As the FUSE people are apt writing nice documentation (and the ServiceMix-page documentation basically sucks), you should head over to FUSE and read their docs (click on documentation and see a lot of nice PDFs). They explain everything you need in a well-written way – OSGi, Spring, Karaf, Maven, CXF, …
  • If you want to use Eclispe and Maven to build OSGi bundles, read this page calmly. It explains how you configure all the OSGi stuff in the pom.xml. Additionally, don’t try to use Eclipse’s plugin-development features as this will mess with your dependency resolution. Maven seems to say: put everything into my hands and you’ll be fine (even if you don’t like me).
  • This is a neat wiki article for getting started with building OSGi bundles for ServiceMix from Eclipse.
  • Here’s a nice article and tutorial explaining how to develop OSGi Bundles with Eclipse.

Setting up Eclipse for Web Development with Tomcat on Windows 7 (64bit)

This has been a major headache for me. This is what you have to do:

  • Uninstall any JDK or JRE you might have via Windows (or the uninstaller in the appropriate installation directory)
  • Download the 64bit JDK version 20 (important! version 21 is buggy!). Its on this page. Search for “JDK 6 Update 20 with Java EE”, choose 64bit version (skip registration) and download and install it. (just ignore the other stuff you’re installing with it)
  • get Tomcat 6.0.28 (the 64bit version, or the itanium 64bit version if you have an intel processor)
  • get the Galileo (important! Helios is buggy with Tomcat!) 64bit version (important!) of Eclipse. This is no official download: Its the “Windows (x86_64)” version on this page.
  • as for 64bit there’s only the basic version of Eclipse Galileo available, install the Web Developer Tools via Help > Install New Software
  • create a Server with the Tomcat runtime you just downloaded
  • (for some reason my autocompletion didn’t work, needed to activate it in Window > Perferences > Java > Editor > Content Assist > Advances > check Java Proposals)