Java passes parameters by value or by reference?

Today I was talking to the usual suspect and we were discussing about people that get stuff into their CV without even know the basics of it. Somewhere in the middle of the conversation we got to talk about pointers and how Java developers usually don’t give a fuck about them. I must admit, I don’t! The thing is that’s something intrinsic to the language itself.

I know this has been heavily discussed in blogs and foruns, but hey it’s never too much to remember: Java is pass-by-value!

I’ve done the following program to help understanding the issue:

class Test {
  public static void main (String[] args) {
    Person p1 = new Person("PPires The Master of The Universe");
    System.out.println("Person name is " + p1.getName());

    // now let's change name
    changeName(p1);

    /*
     * OK by now, if Java is passing 'p1' as a reference everything
     * in the method 'changeName' shall be reflected.
     */
    System.out.println("Person name NOW is " + p1.getName());
  }

  static void changeName (Person p) {
    p.setName("César é lhammu!");

    /*
     * If "p" is a reference, then the instance of "p" will now be changed!
     * Else the instance will be the same and name will be "César é lhammu!"
     */
    p = new Person("O João Pereira já não dá uma pra caixa..");
  }
}

class Person {
  String _name;

  public String getName() {
    return this._name;
  }

  public void setName(String name) {
    System.out.println("Setting Person name to " + name);
    this._name = name;
  }

  public Person(String name) {
    this._name = name;
  }
}

This prints out:

ppires@davinci:~$ javac Test.java
ppires@davinci:~$ java Test
Person name is PPires The Master of The Universe
Setting Person name to César é lhammu!
Person name NOW is César é lhammu!

Get the point? For more detailed info check out this link provided by the usual suspect, once again!

Oh, and btw, the names used in this proof-of-concept are totally fruit of my mind. Any similarities with dead or living people is pure coincidence!

Advertisements

Nokia E71 vs iPhone

Disclaimer: I know this post will raise some discussion as I know there are many iPhone lovers, Nokia lovers and boy lovers out there. But please, do not take me wrong on this. This post is 100% my personal opinion and as such does not need your personal approvement.
Update: If you think I’m a dork, it’s OK, I can live with that, but I won’t permit such behavior as trolling! So, any hate comments will be promptly deleted.

First of all, this post was meant to be a Nokia E71 mobile phone review, but my previous post raised some comments on my rather biased claims about the E71 “kicking the ass off iPhone” (I actually said iPhuck, and that’s probably what triggered all this situation). So, I’m not just doing a review but also comparising the two devices.

Note: Even that I’ve tried an iPhone for some time now, I do not own one. So beware that my arguments may not be accurate. I expect you, iPhone owners to help me keeping this straight. Let’s start..

Overall

E71 on top of iPhone

E71 on top of iPhone

The E71 is slightly lighter and slimmer than the iPhone, [114 x 57 x 10 mm] vs [115.5 x 62.1 x 12.3 mm]. It provides a QWERTY keyboard while the iPhone relays on the touchscreen both for navigation and text-input (more on this later). On what concerns visual interface iPhone presents you with a 3.5″ wide screen while E71 has a smaller 2.36″, whose quality differences are deepened by 480×320 vs 320×240 pixel resolution respectively. Also no one doubts iPhone UI is extremely appealing, one of Apple’s breakthroughs against Symbian “standardization” on mobile user interfaces, even that some people have complained about freezes and slower usability with recent software updates.

They say that an Operating System marks the difference. Well the stripped MacOS inside the iPhone does the trick for the fashion whores, but I much prefer an OS with true multi-tasking that enables me to listen to music while writing an e-mail and having a chat in my favourite IM client. “Oh my god, my iPhone has a Last.fm client” – Yes it does, now try listening to Last.fm and getting it into background so you can do something else. Sorry no can do.. Yes, yes, you can even argue that background applications eat battery and you are right if you tend to leave those applications running unmanaged, which would tag you as dumb. But hey, this dumb here has a Nokia. I can buy a couple spare batteries and carry them around. You, iPhone owner can also.. oh wait, no you can’t! I totally forgot you have an irreplaceable battery.

On the multimedia side, iPhone is a clear winner.. if you want to upgrade your old iPod. Everyone knows that iPhone has all the iPod abilities plus native integration with some media-sharing services and iTunes store. But hey, E71 has a better camera (3.2MP vs iPhone’s 2.0MP), native podcasting support, Ovi and other media-sharing services too. Now, E71 has MMS, video-recording and video-call support (it has a tiny camera in the front specifically for that use) while the iPhone does not support any of these. Some of you may say that you don’t use MMS and that it’s lamme when you use it to receive football goals footage or nude chicks licking each other, but let me ask you: you took a picture of you and your girlfriend. How are you going to send it to her?! And that brings me to the next point…

Talking about connectivity, E71 beats the shit out of an iPhone. Bluetooth in the iPhone is so limited that even a guy with a couple yogurt cups and a string would have more functionality. You cannot pair any kind of Bluetooth devices at your will. You will not be able to send files to other phones, and not even use your 3G connection through Bluetooth to access internet on your computer. Well I can do this and much more with my E71. I can even install JoikuSpot which converts my 3G phone into a wireless gateway.

Also E71, as most of the S60 mobile phones now natively support VoIP (SIP). I’ve got mine registered with Ekiga in one minute. Oh yes, and I use it, more and more as Symbian allows you to use VoIP over GSM when available!

Just on a side-note, I installed Fring, an IM/VoIP/file-sharing service. Very cool also supports MSN, Google Talk, ICQ, Yahoo, a lot of SIP registrars (like VoIPBuster and Gizmo), GMail notification, Twitter (only chat) and Orkut for the social-networking fanatics!! For the iPhone I’d recommend the same tool as it’s available through the Apple Store.

Of course we couldn’t go on without talking about web browsing and e-mail support. iPhone has a bigger browsing area, faster and smoother scrolling and great Flash support(1). Symbian’s web-browser is OK but I truly recommend installing Opera Mini. No arguments here, iPhone definitely wins. But what about e-mail support?

Well I must admit that to me Nokia win’s by far by just having a physical keyboard instead of the touch-sensitive virtual one.Many people have complained about the iPhone’s virtual-keyboard and I quote a Wired reviewAfter three days of iPhoning, typos were relatively common. After three hours with the E71, they’re pretty much nonexistent“. Also E71 brings a very realistic text-to-speech engine with Portuguese (as spoken in Portugal, not Brazil or other Portuguese speaking countries) support that you can download for free almost seamlessly while configuring this option. I love having some unknown girl called Isabel reading my e-mails or SMS with that sexy voice! My girlfriend keeps asking me who the hell am I talking to.. works like a charm 😀

Still on the keyboard issue, have you tried using the iPhone keyboard on the move? I tried while on the train and god, please help! Things just get worse when you’re inside a car, or even drunk.. yep, happens to me all the time!!

Now, what I didn’t expect and discovered soon is that iPhone doesn’t support copy n’ paste! Allow me. WHAT THE FUCK?! Must. Resist. Saying. ROTFLOL. This is one of the most basic features for using the web, e-mail, office-tools all together. And yes, E71 includes QuickOffice. Does the iPhone have something similar?!

This review could continue and enter the gaming or the SDK worlds, but personally I don’t give a fuck about the first one and I hate the second, since the Apple SDK is just a bunch of more shackles to developers. I’m not saying that Symbian’s SDK is perfect, no, not at all. But come on, when Apple released their first SDK they asked us to sign an NDA which specified that developers couldn’t exchange info between them regarding everything that concerned iPhone applications development. They don’t even support Java. Well fuck you and your SDK. Oh and Symbian will become open-source soon..

Concluding

Both are mobile phones. Both are beautiful pocket friends to have around. But in the end, for me, my Nokia E71 wins and that’s why I’ve bought it! Apple tries to block their users to do things the way they want it. Nokia let’s me choose whatever application I want to install without having to jailbreak my cellphone. I can even interact (copy files, synchronize) with my Linux desktop and my Macbook seamlessly without having to use the Nokia PC Suite which happens to run only in Microsoft Windows.

Nokia E71 - my precious..

Nokia E71 - my precious..

Oh and just for your information, in Portugal the iPhone is only available through mobile operators with some stupid contracts. The E71 is network-free for just 419 Euro (as we speak at Ensitel stores).

(1) – Celso Pinto pointed me out that IPhone doesn’t support Flash. I must admit, I didn’t try YouTube. Thanks dude!

Ping

It has been some time since I last posted, but well, I got good reasons for that.

Firstly, I moved (again) to a new place. It’s bigger than the last one, more equipped and it’s around the same rent I used to pay. Not to mention the sightseeing. Photos won’t be posted as there are a lot of maniacs around here. I know. I’ve been there.

Also, I’m no longer working at Nokia Siemens Networks. Even that it was a short-term – only two years -, I learned a lot and made some friends which is all very positive. But, sometimes in life things don’t go as we expect them to and so I felt it was time to get along and grab a new challenge. And so I did..

As for now, I won’t give you much details as everything is still very fresh, but I can say that I’m still in the Software Development department oriented at Telecommunications, but this time focused on the Mobile scene. Terms like “mobility”, handover”, “cellphone carrier services” and “java me” will be strongly read in this blog from now on.

Oh and btw, for all of you geeks out there, check out my latest acquisition, Nokia E71. This baby rocks hard and beats the hell out off IPhoda-se (IPhuck in English). A review shall be made available soon…

Nokia E71

Nokia E71

What UPS to buy?

Hi fellow geek,

I’ve got an ASUS barebone, V3 P5-G965 which goes up to a maximum consumption of 300W. Also I’ve got two Samsung 20″ Wide TFT LCD, 205BW reaching 75W tops. Now, I want to protect them from power-outages and, if possible, keep working for one hour. Could you give me some advices on what UPS to buy?

Thanks 🙂