Sunday, July 07, 2013

Raanjhanaa and religion ...

It doesn't sound odd at all when movies are out in the media for being censored or banned or attacked by groups. It's an added advantage that the distributors get for the publicity. What took me by surprise is the ridiculousness of the reason for which it is banned in Pakistan!

Why is Raanjhanaa banned? How can a person belonging to a community not marry a person from another community? This is not supported by a government. This is not even a real marriage, it's a movie (let's call it an artistic representation). Are we in the century where governments are democratic, secular and respect individual freedom and rights?

I try to understand religion as a (1) process of self-purification through introspection,  (2) means to attain higher levels of spirituality or (3) simply a belief and submission to a greater power. A religion at a broader level should advocate peace, harmony, equality, inclusion, connection and collaboration. Why does some religious practices ignore and sometimes even oppose practices in the other faith? Is it because the religion itself claims the ultimate wisdom in the scriptures? I would say it is those who try to interpret the scriptures and decide the rules. Christopher Hitchens, a famous author and journalist, in one of the debates on intelligence squared argues that any religion which is monotheistic is aggressive and hence is not tolerant to other religions.

Like John in the movie "Man from the earth" puts it, "Piety is not what lessons bring to people, it's the mistake they bring to the lessons." How does marrying a person from other faith or community tarnish the sanctity of the individual or the community to which they belong? 

Wednesday, July 03, 2013

Equals : Java inheritance abstraction leak


if(youKnowJavaCoding) 
startReading();
else 
break;


There is a java class Point2D.
int x, y;
Point2D defines equals which says if x values and y values are equal for two classes, then they are equal.
This is how it happens in the java world.

public void boolean equals(Object obj) {
if(!(obj instanceof Point2D)) {
return false;
else 
return this.x == obj.getX() && this.y== obj.getY();
}
}

Another class Point3D extends Point2D.
It can live upto the name but decides to do a different way.

public void boolean equals(Object obj) {
if(!(obj instanceof Point3D)) {
return false;
else 
return super.equals(obj) && this.z == obj.get(Z);
}
}
 
This breaks symmetry
Point2D says (1,2) is equal to (1,2,3)
Point3D says "No".

We tell Point3D to be the dragon warrior (or the man of steel) and find his parents.

public void boolean equals(Object obj) {
if(!(obj instanceof Point2D)) {
return false;
else if(!(obj instanceof Point3D)) {
return false;
else 
return super.equals(obj) && this.z == obj.getZ();
}
}

obj.getZ() doesn't work for Point2D.
Point3D still doesn't think (1,2,0) is equal to (1,2)

We cannot rely on simply letting super class handle the comparison, correct? 

Programmer(fuming) : Let the hell break loose, all Point3Ds are Point2Ds. Simply return super.equals(obj) , for all Point3Ds also. Sounds great! 

But, wait!

(1,2) equals (1,2, 1) and (1,2,-1). Aren't we being rude to transitivity here, honey?  

We can have another method in Point3D which says canEqual(Object obj) or few if clauses in the equals method which say if your z is 0, you can compare the Point2D and Point3D. Don't even think about it otherwise!

We have to sometimes come out of the abstraction to see the solution.