Monday, June 25, 2007

Eclipse - Generating code, constructors, getters, and setters

Sometimes we have to work with POJO, like when we work with Hibernate. The main problem is after we create all the member variables, we should create the getters and setters. To create N properties, it need N * 2 method (of getters and setters), that would be an extra job for your fingers. The same problem comes when we want to create a constructor that has parameter from the member variables . Thanks god, Eclipse come to save us.

Assume we have create UserProfile class.



Now we will create the constructor
"right click + source"
or
"alt + shift + s" on windows
or
"alt + cmd + s" on mac
then select
"Generate Constructor using Fields..."

Select all fields you need



and click OK, it should be like this



and let's generate the getter and setter, open the source menu like above, then select
"Generate Getters and Setters..."



"Select all" or what ever you need, then boom, Eclipse save your fingers.

Tuesday, June 19, 2007

How to download using curl

Hello, I'm new on Mac, previously I'm using MS Windows and I still use it on my office. The first thing when I'm using my mac is "Where is my free download manager, where I can perform resume on my download?". Nix platform already has great tools to download "curl". How do I download using curl.

When you want to download, you have to find the URL for an example "http://www.downloads.com/filetodownload.zip".
To start download you can type

curl -C - -O http://www.downloads.com/filetodownload.zip

You can cancel your download or there might be an network error found, we can resume the download as long the server support for the resuming.

just type the same command on the same directory

curl -C - -O http://www.downloads.com/filetodownload.zip

Thats it, the download will resume.

Pure Object Oriented Language

What is Object Oriented? Based on this article written by Bjarne Stroustrup on http://www.research.att.com/~bs/oopsla.pdf , "A language or technique is object-oriented if and only if it directly supports: [1] Abstraction - providing some form of classes and objects. [2] Inheritance - providing the ability to build new abstractions out of existing ones. [3] Run-time polymorphism - providing some form of run-time binding". So, when a language have this three of features, we can call it as an Object Oriented Language.

So what is pure Object Oriented Programming Language? Which one is it?
What do I ask above question?
Well, there is some discussion, and someone says that Java is not pure Object Oriented Language instead of C++. Wow, it's shocking statement. So lets the amazing Google help us, and I find this http://www.jvoegele.com/software/langcomp.html , where stated where object orientation of language can be separated by:
1. Pure
2. Hybrid
3. Multi-Paradigm
4. Add-On
5. Partial Support

In this articles, consideration of pure Object Oriented Language should support such of qualities of :
1. Encapsulation / Information Hiding
2. Inheritance
3. Polymorphism/Dynamic Binding
4. All pre-defined types are Objects
5. All operation performed by sending messages to Objects
6. All user-defined types are Objects

Well, Java and even C++ doesn't fit with above definition. The Eiffel, Smalltalk, and Ruby is the winner as pure Object Oriented languages.