Meet a Java project

I’m going to be a Meetup junkie. London is brilliant and full of tech meetups. I’ve missed some London Java Community events in the last few weeks. It was a huge mistake. Luckily I’ve cached the last one. Meet a Project was the event’s name. There we had Mani who talked about OpenJDK related community projects like Adopt OpenJDK and Adopt a JSR. I don’t know which one is the more important. I’m trying to figure out. Dealing JSRs looks more exciting for me.

The London Java Community has an important part of the Adopt a JSR project. Here is a list of them: https://java.net/projects/ljc-london-jug/pages/AdoptAJSRProgram

Incomplete JSRs:

I’d like to choose some of them, driving inside these JSRs, and helping the community. As Mani’s mentioned it: This programme impacts ~10 million developers & over 1 Billion end users!

PHP meetup with The Creator

I recently started visiting PHP meetups. The reason is quite simple: networking with other developers, looking for new projects (as a freelance developer) and getting some free beer. Today I went to a meetup where the creator of the PHP gave a  presentation. He’s Rasmus Lerdorf. So it was a really interesting meetup. Hearing about the stone age of the web development and what is the PHP’s future. Rasmus mentioned that he doesn’t believe in MVC design pattern because its completely unnecessary,  we should just do coding from scratch, building micro frameworks. Oh yeah, and we shouldn’t use any Frameworks of course. It was a real disappointment. Thousands of developers are working on a Framework, testing it, and millions of  users are using it, creating feedbacks. So a garage built framework without any MVC is better than a Symfony or Zend. It was the conclusion of this evening. I completely disagree with it. I like to use well built frameworks. I think it’s more safer than using ad hoc tools.

Clojure quick start

I visited a London Java Community meetup where Robert Rees’d spoken about Clojure. That was a really great presentation. He mentioned that Clojure is a great choose if you need to deal with huge character streams. So I’ve just decided I have to make a text processor application based on Clojure.

Where can I start? I need some resources. I dug into the Google and found these:

http://clojure.org - official site where everything is beginning

http://tryclj.com/ - playing online with Clojure

http://planet.clojure.in/ - Clojure Community Blog

http://incanter.org/ - statistical computing platform

https://github.com/languages/Clojure - Clojure is the #24 most popular language on GitHub

And the core mailing list on Google Groups: https://groups.google.com/forum/#!forum/clojure

Using Comparator Interface to sort an object list

The Comparator interface exists in JDK since version 1.2 so it’s a mature part of Java tool box. And it’s a useful Interface. It provides two methods: compare and equals. We can use these methods when we’d like to sort an Array or Collection. Wicked.

So let’s sort a List with full of Object references.

Need a POJO like this:

Beer
-name
-strong

And the task is we’d like to have the strongest beer because we haven’t got enough time so you know. This case we need a Comparator for the stength of beer:

class BeerStrongComparator implements Comparator<Beer> {

  public int compare(Beer b1, Beer b2) {
    return b1.getStrong() < b2.getStrong() ? -1
     : b1.getStrong() > b2.getStrong() ? 1 : 0;
  }

}

And finally the usage:

  Collections.sort(allBeersList, new BeerStrongComparator());

You just put the Comparator as a second parameter in Collections class sort static method.

How can you change two variables without temporary variable

This is one of my favourite interview questions. It’s a really simple question.

OK. Let’s see the typical wrong answer:

int a = 5;
int b = 6;

//store 'x' in a temp variable
int temp = a;
a = b;
b = temp;

This answer is wrong because it contains an unnecessary variable.

And there are some good solutions:

a = a * b;
b = a / b;
a = a / b;

or

a = a + b;
b = a - b;
a = a - b;

or

a ^= b;
b ^= a;
a ^= b;