October 24, 2007

Calm Sea


a1 1, originally uploaded by Aditya Pal.

Pic taken by Aditya in SFO

October 19, 2007

OOPs

Inheritance Vs. Composition vs Parameterized Types:
Inheritance - white-box-reuse. Internals of parent class visible.
Inheritance defined at compile time. Possible to modify implementation. (overriding)
Disadv - Parent class influence the physical representation.
Composition - black box reuse. No internal details visible.
Composition - defined at run time. Wont break encapsulation. Class hierarchies will remain small.
General rule of thumb - Prefer Composition over Inheritance.
Parmeterized Types - Generics , Templates

October 18, 2007

Soul touching renditions

By Nusrat Fateh Ali Khan
Tere bin dil naiyo lagda - http://youtube.com/watch?v=rrfITzLhCqM
Afreen Afreen - http://youtube.com/watch?v=zmB8yt-wf7A
Piya re - http://youtube.com/watch?v=7oscIjdZix8

October 14, 2007

Short n sweet

I came across this algorithm - Sieve of Eratosthenes to generate prime numbers from 2 to n.

public boolean[] sieve(int n)
{
boolean[] prime=new boolean[n+1];
Arrays.fill(prime,true);
prime[0]=false;
prime[1]=false;

int m=Math.sqrt(n);

for (int i=2; i<=m; i++)
if (prime[i])
for (int k=i*i; k<=n; k+=i)
prime[k]=false;

return prime;
}