Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Wednesday, October 17, 2007

Why use log adapter (generic logging)

Long time ago I have a question "Why use common logging, why not use log4j?"
The answer is "Because you can use different log implementation".
Unsatisfying answer.
But past week ago I found SLF4J and I use it for jSMPP projects.

It comes answer that we are creating API/Component that might be use with application using unpredictable log implementation.

Saturday, September 8, 2007

Why I love jEdit

jEdit, this is an awsome programmer's text editor. Might some of people said that the user interface is ugly, but it's powerful, believe me.
Give it a try for some time range, try to find out "how do I do things in jEdit", try to see the available plugins.
Here is my favourit plugins:
  1. Buffer Tabs
  2. Project Viewer
  3. Open It (just assign shortcut here ctrl+shift+o, and set the refresh interval to 10 seconds, and automatic import path to project path)
  4. Sidekick
  5. Error List
  6. Plugins related to xml things
  7. Ruby plugins if you want to use Ruby application
  8. PHP Plugins if you want to develop PHP application
  9. SuperAbbreviations (this is cool)
The most great thing is free of charge.

Sunday, September 2, 2007

Value Object, Entity and Data Transfer Object

There are several type of object on Object Oriented Programming. There are a lot of misconception of those. Below is some explaination of some type such as Value Object, Entity and Value Object.

What is Value Object?

Value Object is not Entity. According to Martin Fowler http://www.martinfowler.com/ap2/valueObject.html "An object whose conceptual identity is based on a combination of values of its properties." So what was that? It's like Integer, Date, etc. When you want to do an equality those object to another it should compare all it's meaning properties.


public class Grade {
private Subject subject;
private float gradeValue;
....
public boolean equals(Object o) {
...
Grade other = (Grade)o;
// compare all the meaning objects
return subject.equals(subject) && gradeValue == other.gradeValue;
...
}
}

It might have more than one instance of Grade in memory. John has Grade and Brad has it too, we can check the equality by it's properties (subject and the gradeValue). They both might have the same grade.
Address class can be another good example. Lets say that a store have a lot of customers. Addess is composite of city, street, and floor. When we find some customers life on same place we might say they are on the same city, street and floor.

So what is Entity?

Entity might be POJO and Value Object "might" too. It recognized by their identity.

public class User {
private String username;
private String password;
private Group group;
....
public boolean equals(Object o) {
...
User other = (User)o;
return username.equals(other.username);
...
}
}


We only concern to username property as identity and ignore the other properties of User class (password, group). We can imagine entity is like a record on database table which has primary key.

So what is Data Transfer Object?

According to Martin Fowler http://www.martinfowler.com/eaaCatalog/dataTransferObject.html, DTO is "An object that carries data between processes in order to reduce the number of method calls.". The main idea is object that transfered in order to reduce method calls over the network. We can call it as Value Object or we can call it as Entity. When it does? It depends on how we compare the object - Value Object if based on it's properties or Entity if based on it's identity.

references:

Tuesday, June 19, 2007

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.