Sunday, June 28, 2009

User-centered Design Helping Java Programmers

In general, analysts and programmers spend time taking care of user interfaces but researchers at Carnegie Mellon University's School of Computer Science decided to focus on the user experience of those analysts and programmers instead. They developed the tools Jadeite and Apatite which are intended to help Java developers exploring the language API (Application Programming Interface) using human-centered design techniques.

A basic feature of the Jadeite tool is to collaboratively improve the Java API by allowing developers to suggest modifications according to their needs. For instance, if you think that a class doesn't have a method you were expecting or a parameter missing in a method signature then you are allowed to add them as you wish. This feature may help API designers to improve their libraries but programmers may still miss the implementation of those modifications, of course. The tool also increases the size of the font according to the frequency of use. This frequency is based on the number of Google hits, the crowdsource which well represents what most of people are doing. I think it is useful to help developers to decide what to use from the API, since most people are using these possible choices too.



The Apatite tool takes a different approach, allowing programmers to browse APIs by association, which helps them to see packages, classes and methods that tend to go with each other. It also uses statistics about the popularity of each item to provide weighted views of the most relevant items, representing them as a cloud of tags.

To get more information visit http://www.cmu.edu/news/archive/2009/June/june17_javatools.shtml.

Wednesday, June 17, 2009

Has JavaFX a Strategy?

Some time ago I was a bit severe with Sun Microsystems here. Now I don't care anymore because Sun is Oracle and Oracle for me is a database, not a company. I never stopped to think about Oracle's stocks, or Oracle's acquisitions, or even the Oracle support for the Java platform, which sucks! But I was always worried about SUN, criticizing and praising as an independent observer. I did that because I admired the work that SUN has been doing on the Java Platform and the proximity the community has to Sun's top engineers. Even criticizing, it doesn't mean I don't like Sun. On the contrary. I do care about them in the pure essence of carefulness, as Randy Pausch stated in his book, transcribing the words of his football coach:
"- When you are doing something badly and no one’s bothering to tell you anymore, that’s a very bad place to be. Your critics are the ones still telling you they love you and care."

Sometimes we don't like to listen to critics and advises from our friends, but this is actually the best proof that they are really our friends. But people at Sun didn't understand that and they came to me, in defense of Sun, to reply the post I've mentioned above. A top Sun's engineer wrote to me:
"Any big company consists of people. Different people. Companies also have ups and downs. Does your current point of view make sense? Absolutely. But it's not the only one. I can tell you something that it's hard to argue with: Sun is very good at executing long term projects. Look at Java and Solaris."

And then I replied to his message:
"I'm completely sure that SUN is good. I have been working with SUN technology since 1998. I've never touched a .NET code. All my projects, costumers, students are Java oriented. This is possible because SUN is good. But do you believe that these long term projects that you mentioned can solve SUN's lack of profit? Java is not service, but marketing for SUN. Solaris is service, but less than 5% of them. Is JavaFX also a long term project? It was developed in a hurry! I wonder for what I can use it in my professional life. Should I rewrite my web and swing applications? No way! Don't you think that the fastest way to spread the JavaFX adoption is allowing the improvement of existing applications? Why to spend a lot of resources to drag an applet from the browser to the desktop if we need the network anyway? More space? Develop just small applications? I would give more priority to hide the Java logo from the final user, or at least allow its customization, because an advantage of the flash technology is that it is so imperceptible and the final user doesn't even realize that he is using that technology. You have no idea how it is important for the user interaction. Take a look out there, almost nobody sees this Java logo animation. Why people should start to see it from now on? Imagine websites like big portals. They have dozens of flash animations. Imagine how uncomfortable is to see dozens of Java logos."

Since we can use other programming languages (Scala, Python, Ruby, and Grove) to develop our applications on the Java Platform, why not execute JavaFX script in our existing applications too? For instance: I need to develop a special animation in my application and doing it using threads and pure Java AWT will consume a lot of time. If the JavaFX team had prioritized the execution of their scripts in existing Java applications, I would save a lot of time doing this task using JavaFX. What they did was exactly the contrary. They allowed JavaFX scripts to reuse existing Java classes, which is useful only for new projects or features out of the existing contexts. It reminds me of an interesting sentence: "Who was born first: the egg or the chicken?"



Yes, I'm criticizing SUN again. Maybe, this is my last chance to do it before the expected announcement of the completed fusion between SUN and Oracle. I hope Oracle gets the point here and does something to fulfill the expectations of most Java Developers. If I feel things getting better, in the right path, I will keep my support as I have been doing. Otherwise, I will be excited to evaluate and definitively adopt other platforms as I have been thinking about.

Thursday, June 11, 2009

Java: My Past, Present, and Future

Last week San Francisco hosted the last edition of JavaOne under the responsibility of Sun Microsystem. From now on, Oracle owns Sun and all its technologies. They promised to invest more and more on the Java platform and all related technologies. Oracle is a powerful company and this new juncture makes me relax and keep believing that my present and future are definitively Java-oriented.

I started working with Java in 1998, eleven years ago, developing applets to exploit data about criminality in my city and about the volume of water in the main lakes of my state. This work was really exciting because it introduced me to this nice language and also because I had to learn it by myself through the Internet and buying books from Amazon, since no course was available at that time and no book wad been written in Portuguese yet. I started using the JDK 1.1.4 which was really basic in comparison with what is available today but very useful to plot graphical data using the awt graphics library.

I've learned from that first experience that Java is not a complex language, but the object-oriented paradigm is really difficult to learn when the developer is used to work with the functional paradigm. The languages I've learned before were Pascal, Delphi, Visual Basic and C. None of them were purely object-oriented, so I had the freedom to code as I wanted. Learning Java, a 99% object-oriented language (1% of primitive types), I realized that my programs had much more code than my algorithms actually demanded. On the other hand, even with more code, these programs became more readable and with a better abstract representation. A class, for instance, represents an element of the real world, like a book, a house, a product, a video, a category, a group or anything else, concrete or abstract. Each class is composed of its properties, represented by attributes, and behavior, represented by methods. If you have an algorithm to implement, you will do it inside one of more methods, writing it as a behavior of the class. The problem is how to do it in a way that the abstraction is consistent with the algorithm and vice versa.



For those who are learning Java and didn't get my point yet, it's time to dedicate more time for it. Java is a powerful language, it can solve most computational problems and it's the most adopted programming language by far, almost unanimous in all computer science courses of universities around the world. So, it is the right choice, but it demands dedication, persistence and creativity to get the work done.

I had 4 years of experience teaching Java for hundreds of people and I'm absolutely convinced that it is not possible to learn Java alone or just attending Java classes. It's veeery important to join a community of developers and exchange knowledge with them. They will share with you what they've learned and you will reinforce your knowledge teaching other people too. This is the main role of Java User Groups (JUG) and it is also the main success factor of these groups. As a former Jug leader (CEJUG), I know what I'm talking about ;).

Wednesday, June 10, 2009

Not a Single Protein Lost

One of the things I really miss from Brazil is the Japanese food! - WHAT??!! Japanese food in Brazil?! :O - I'm serious! At least in my city, there are dozens of Japanese restaurants offering all kinds of Japanese food. They started around 10..12 years ago and we all thought that they would stay opened for a while only, since they were offering raw food for a culture of well cooked meal, but they have consolidated and expanded business through the years.

When we lived there, we went to Japanese restaurants at least 2 times a month to eat something like the picture below. A sushi boat with 42 peaces. It is too much, I know, but a small portion always lets us wishing for more.



For our surprise, some friends in Belgium invited us to a Japanese dinner. Wow! I couldn't believe that we were going to eat something we hadn't eaten for years! I think I was the first to confirm the invitation. This emotion was equivalent to the one I had in Portugal when I went to a churrascaria (a restaurant specialized in Brazilian barbecue), to taste different kinds of meats from Brazil.

The dinner was AWESOME! Delicious! So good like the ones I ate before. We also helped, preparing some caipirinhas and people really enjoyed it (at least, they asked for more!) We would like to thank our friends one more time for these great moments, which also brought great memories. I made the video below to register the occasion. ;)

video

Monday, June 8, 2009

Not Exactly a Recipe of Caipirinha

If there is one thing that represents well the Brazilian soul and culture, this thing is our most known drink: caipirinha! There is nothing really special in the recipe of this drink to make it so unique. You just need sugar, lemons, and cachaça and mix them, pressing all the ingredients with a wooden bat in a common glass or improvising somehow with clean hands.

The secret is the quantity of each ingredient and this quantity is totally subjective, managed by the heart of the bartender. Look at these guys. The caipirinha they prepare must be great, but not because they have experience doing that, but because of their feelings represented by an authentic smile :). The meaning of this feeling is simple: "I want you happy and feeling good as I am, so I'm going to improve your mood through this caipirinha". It is not actually said, but felt. You feel your mood changing when you start to drink it and you can be sure about that when you ask for a second one.



The main ingredient of caipirinha is cachaça. It is a traditional strong drink from Brazil, around 40% of alcohol. Of course you have all the freedom to drink it as you wish, but you will miss the Brazilian spirit if you drink it pure or alone. Why can't you drink it pure? Because it is too strong and you will not find happiness, but the floor. Why can't you drink it alone? Because you cannot find happiness alone. So, every time I give a bottle of cachaça as a gift I always advice: "This bottle is yours but never ever drink it alone.". People don't understand, but I insist without any further explanation. Now, I finally decided to explain it here.

The recipe of caipirinha mixes sugar with cachaça, reducing the alcohol effect to the body. Drinking it with friends will make you happy, everybody happy and their happiness will come back to you in double.

So, if you received a bottle of cachaça as a gift or you bought one, follow my advice: wait for a moment of good mood, invite some friends and use any recipe available on the internet. It doesn't matter. What matters is how good you want to make your friends feel.

Wednesday, June 3, 2009

Creating a New MySQL Database for Dummies

I'm writing this post for self reference because I always forget how I've created my last MySQL database. Well, I'm sharing because it could be useful for you too. I consider that you already have MySQL 5.0 or superior installed and running normally. I also consider that you configured the path of your operating system, pointing to the bin folder where all MySQL commands are located. If you don't fulfill this prerequisites, you can easily find solutions for each one using Google. It depends on your operating systems, so I would never be complete here.

I'm going to use the basics, avoiding specific tools that can accelerate the process, because if you fulfill the prerequisites then I know you have these basics. So, execute the command below to start:
c:\> mysql -u root -p

It will create a client authenticated session to access MySQL. "-u" means that you are passing the user of the session in the command line and "-p" means that you want to type the password right after the command has been executed. The user "root" has enough rights to create the database, but we will not use it all the time. Once authenticated, type the command below to create the database and a dedicated user for it:
mysql> create database book_shop;
mysql> create user bs_user identified by ’(password)’;
mysql> use book_shop;
mysql> grant all privileges on book_shop.* 
to bs_user@’%’;
mysql> flush privileges;

The database will be created, a new user too and finally we give all privileges for this user to operate the new database. To check if the database was appropriately created, execute the following command:
mysql> show databases;

Check if the database "book_shop" is in the list. It should be ;). Then we have to sign out from this root's session and open a new session for the new user to create the database structure. Please, follow the sequence of commands below:
mysql> quit;
c:\> mysql -u bs_user -p
mysql> use book_shop;
mysql> source (path of the database script)/script.sql;

Well, that's it! You should use the new user, "bs_user", in your application avoiding the super powerful root guy. My intention is not to be complete on this post, but helpful. Maybe you can find a lot of additional good practices out there but this is the fastest technique I recommend you to do in order to start developing your project.

Any question? You know... comment below ;) !