Monday, November 29, 2004

Re: General Stuff

I agree with Rahul... no harm making the blog public. The idea is to make our asses less dumb as time passes!

Ok that's two for going public. I guess we'll do it. But remember, that puts pressure on us to please the shareholders.

Rahul update the blog header to what you think is ok. I forgot what it was before.

Also, do you guys mind inviting a wing-mate of mine? The guy's name is Nikhil and he knows a whole lot of stuff about computers, programming and stuff... would be really good to have him on the blog.

Not at all. Five heads are better than four. Send me his email address and I'll send him an invite.

Re: General Stuff

I agree with Rahul... no harm making the blog public. The idea is to make our asses less dumb as time passes!

Also, do you guys mind inviting a wing-mate of mine? The guy's name is Nikhil and he knows a whole lot of stuff about computers, programming and stuff... would be really good to have him on the blog.

I have a dumbass doubt about AOP... missed the earlier discussions, and too lazy to read all the archives! Are there any AO languages like we have OO languages or is it just a way of designing software?


Re: Quantum Computing??

Quantum mechanics applies in the microscopic world. You can't substitute cats and coloured balls for electrons... it just doesn't work that way.

I don't know about qubits; I won't comment on them. But don't generalise your thoughts about the qubit to quantum mechanics. The biggest success for quantum mechanics lies in the fact that it agrees with experiment. I don't think I need to say anything further; and if agreement with experiment isn't sufficient to convince some people about the correctness of a theory, I don't give a damn.

And btw, if you don't know much about a subject and there's some genius who's spent his entire life studying it, it would be rational to actually listen to that guy...
I may not have a degree in physics, but I'm not going to sit quivering over whatever the great minds tell me. I think for myself and do believe that physics concepts should be and could be explained to the average joe.

lol!

Sunday, November 28, 2004

Re: General Stuff

One use I can think right away is security. Make sure before something is executed that it has the right permissions or something.

Authentication is one of the standard uses of AOP. Any more ideas?? You might just get the reason for the entire world to start using AOP.


And unless something like this is baked into the system itself (like Java or .NET) it won't be very popular. What dyou feel?

I had been to an IBM techday Live seminar in Mumbai. The speakers were good. And at really high posts. One of them was the consultant for the other IBM consultants. The guy who teaches the million $ an hour fees IBM consultant. Whoaa!! So I asked him the same "What are the uses of AOP beyond the general Logging etc?" question. He told me that AOP concepts would be used within the next tools with Model Driven Architecture(MDA). Before he could explain further he had to break; and continue; with the seminar. Now I am not sure about MDA. Ever read anything about it? It seemed like using tools to auto-generate code. Design patterns are described for which code is generated. Don't ask me questions on this!!

Another future trend I heard of is Business Process Execution Language (BPEL). Also BPEL is a standard on which even MS is doing some work. BPELJ is the Java implementation for BPEL. I saw a few demos for BPELJ. Again I do not know enough to explain. Read on any of these topics?? I think I'll just go back to reading the String class in the Java API.

Now these things have industry support, wider than AOP. And these things are getting baked in Java atleast.

So I suppose even though ours is a private blog, it may not really matter.
And by the way why aren't we public??

First, what is avivaint? I couldn't find the word on the codeword page that came up on google.


avivaint was a site I made, and had put some app of mine on the site for downloading. You'll find avivaint in this blog.



And dyou want to make it public? You want others reading our dumbass discussions?


If we get good readers, they might want to join. And getting more inputs will be a good thing. I do not see many guys out here, who are really passionate for programming and I suppose if we get guys like us (those who indulge in dumbass discussions) it will be beneficial. Then again getting public may not get us anything. But it seems better. I say we get listed in Nasdaq too!!

Btw if you think we should go public, change to an appropriate blog header

Saturday, November 27, 2004

Re: General Stuff

As Mohn mentioned, the Proxy class feature is similar to an AOP in a way. Both essentially inject code. I have not been able to get many uses of AOP. Always get the same examples like Logging, Authentication and a few more. You guys see anything more? What do you think would be the uses of the Proxy class?

The biggest benefit of the Proxy class feature is that it is dynamic. You can create a bunch of "pluggable" components and hook them into the system at runtime. Thats a huge advantage. And since you can inject your own code dynamically I guess you can do almost anything you want. You are like the gatekeeper. One use I can think right away is security. Make sure before something is executed that it has the right permissions or something.

Somehow I feel AOP will take a while to take off. Right now there is a bit of buzz about it, but it may take many years before it becomes mainstream. There's already enough to learn as it is. And adding another entry to the acronym soup isn't very encouraging. And unless something like this is baked into the system itself (like Java or .NET) it won't be very popular. What dyou feel?

So I suppose even though ours is a private blog, it may not really matter.

And by the way why aren't we public??


First, what is avivaint? I couldn't find the word on the codeword page that came up on google.

I realize even though ours isn't a public blog it will still show up on google and other search engines. I was just saying that since it's not public, there is less visibility so the chances of others finding it and linking to it are less.

And dyou want to make it public? You want others reading our dumbass discussions?

Thursday, November 25, 2004

Re: GNU Classpath

Did you know about this project? Apparently it's associated with Red Hat. These guys are developing the Java API from scratch. Since Sun isn't making it open source, they are doing the next best thing.

I guess the rational behind this project is that the JCP doesn't really listen to the "small guy". Only big companies have a voice. So with this anyone can include their 2 cents.


Its understandable that some guys want a FREE modifiable version of Java. But personally I think it will harm the language as it will definitely break WORA.

Gnu guys have a lot of good software. But Gnu Classpath will not work as there is no industry support. You'll just have a bunch of ultra geeks coding in it for kicks. Check out Gcj. This is one of the compilers
in the Gnu platform which allows Java code to be compiled to native binaries directly.

Sun is not making Java free for modification. But almost all the source is open. At this link you can download the entire source of the Sun JDK. So not only are the Java API's open but also the JDK which is really really amazing.

Any small guy can make himsself heard if it is really sensible. There are so many open source projects which are causing changes in the Java API because the ideas are really good. But no one is really interested in Gnu Classpath.

Re: Quantum Computing??

Whoa!! Wait a minute! I'm not calling "Quantum Mechanics" irrational, there is obviously phenomena related to the atomic and sub-atomic level, what I think is irrational are the explanations and the conclusions formed on the basis of not really knowing whats happening there! Prime example again is Schrodinger's Cat Experiment!

I do believe quantum mechanics still requires a rational explanation, perhaps Lewis Little's "Theory of Elementary Waves" will provide that, I surely hope so!!

And again, the qubit is a contradiction (atleast to me), unless it can be proved that it isn't, I won't accept it. It would be great to have a computer as fast as what a 'quantum' computer could do, but not yet sure it's possible with the qubit.

I may not have a degree in physics, but I'm not going to sit quivering over whatever the great minds tell me. I think for myself and do believe that physics concepts should be and could be explained to the average joe.

Dinesh.

Wednesday, November 24, 2004

Re: Quantum Computing??

I concur with Mohnish on this one...

Please provide some context to that. I have no idea why the theory of gravitation even came up!!

I just gave that as an example, because that's the most well known theory in all of physics.

By the way, we got "used" to it because it's a law of nature, not something followed as a matter of convenience.

Quantum mechanics is very accurate when it comes to predicting phenomena the quantum level and it's not followed as a matter of convenience. Experiments agree with it and it is a well established theory.

And for the record, as far as gravity is concerned, it's not an exact 'law' of nature. It works for all day to day situations but when you scale things up, when it comes to predicting the motion of heavenly bodies accurately, gravity breaks down. That's where you need general relativity. Similarly, at the other end of the spectrum, at the quantum level, gravity fails; even general relativity does. That's where you need quantum mechanics.

I don't know about 'string theories'. They could be mathematically beautiful but inaccurate... I have no clue. But general relativity and quantum mechanics are the two massive pillars of physics and they're very strong.

We are not scientists so we will never fully comprehend this stuff, but I have no reason to doubt the work.
But these guys are the pretty bright and I trust they know what they're doing.

Exactly. And bright is an understatement. Supremely intelligent human beings like Richard Feynman have contributed to quantum mechanics. We're not even qualified to comment on the fundamentals of the subject, let alone judge it. And here we have someone with not even an undergraduate degree in physics calling quantum mechanics 'irrational'. That's more than just ridiculous...

GNU Classpath

Did you know about this project? Apparently it's associated with Red Hat. These guys are developing the Java API from scratch. Since Sun isn't making it open source, they are doing the next best thing.

Dyou think this is good or bad for Java? I doubt it will have much impact. Java is already available on a plethora of platforms and all the source for the APIs is available if you're curious. I don't see much benefit in this project cause any "forking" they do won't run on other Java VMs. And that will prevent many people from using it cause the cross platform bit is a big point for Java.

I guess the rational behind this project is that the JCP doesn't really listen to the "small guy". Only big companies have a voice. So with this anyone can include their 2 cents.

Re: Quantum Computing??

Have you ever read anything on "String Theory"?? Scientists pine about how they wished reality would conform to the "String Theory", it is just mathematically beautiful and symmetric. But reality really refuses to conform to it, lol!

Can't say I have read anything substantial on String Theory. And it's just as well cause I doubt I'd understand it. But I have seen many documentaries on the subject. This one in particular I thought was quite good.

I don't get why you have such skepticism regarding quantum mechanics and the irregularities associated with it. We are not scientists so we will never fully comprehend this stuff, but I have no reason to doubt the work. I guess you could call it blind faith (something like religion) at this point since it's all just theory right now. But these guys are the pretty bright and I trust they know what they're doing.

I have read that String Theory is just mathematically beautiful and a great effort, but it holds little reference to physical reality.

So why dyou readily believe the stuff you've read discrediting string theory as correct?

I hope something as fast as the quantum computer is possible though. That would really be neat. But so far, unless quantum mechanics can be rationally explained, I see no hope for it.

I think they already have working models of very very simple quantum computers at research labs. I read that IBM has something going. Try googling it.

Re: General Stuff

Great to have everyone back on codeWord. Lets write some good blogs!!

the Proxy class in java.lang.reflect in the Java Documentation.

As Mohn mentioned, the Proxy class feature is similar to an AOP in a way. Both essentially inject code. I have not been able to get many uses of AOP. Always get the same examples like Logging, Authentication and a few more. You guys see anything more? What do you think would be the uses of the Proxy class?


Also I have changed my display name. Simply to get codeword as a link when I search for myself on google. ;). I do get a few hits at ncb.ernet.in and a few linux posts I made, but codeWord would be much better to be linked to.

lol. You realize this is a private blog right? It's not listed in the blogger directory anywhere, so no links pointing to it. Google ranks based on popularity of site. Based on that, I wouldn't get my hopes up. Anyway, I helped you out... gave the search bots something to chase on your behalf.


Try this link. codeWord is there as of now. So I suppose even though ours is a private blog, it may not really matter.

And by the way why aren't we public??

Tuesday, November 23, 2004

Re: Quantum Computing??

Coming to the question about 'rationality'. You wouldn't call the theory of gravitation irrational, would you? After all, why the hell should two bodies attract each other just because they have mass and that too with the inverse square law? But it's something we've gotten used to.

Please provide some context to that. I have no idea why the theory of gravitation even came up!!

By the way, we got "used" to it because it's a law of nature, not something followed as a matter of convenience.

Dinesh.

Monday, November 22, 2004

Re: Quantum Computing??

I hope something as fast as the quantum computer is possible though. That would really be neat. But so far, unless quantum mechanics can be rationally explained, I see no hope for it.

I don't know much about quantum computers but from whatever I know about quantum mechanics, I wouldn't call it irrational... no way. It may not follow directly from common sense but it is mathematically sound and explains things at the microscopic level. The quest for the 'grand unified theory' won't lead us anywhere for quite some time... that's what I feel... it will be way too complicated. And we have two theories to explain phenomena at two totally different levels - general relativity and quantum mechanics. So we aren't lost...

Coming to the question about 'rationality'. You wouldn't call the theory of gravitation irrational, would you? After all, why the hell should two bodies attract each other just because they have mass and that too with the inverse square law? But it's something we've gotten used to. Unfortunately, quantum mechanics is not so simple and it would take a lot to get 'used to' it. But the theory's amazing. Whether quantum computing can become a reality is a totally different question...

Sunday, November 21, 2004

Re: Quantum Computing??

Have you ever read anything on "String Theory"?? Scientists pine about how they wished reality would conform to the "String Theory", it is just mathematically beautiful and symmetric. But reality really refuses to conform to it, lol!

I have read that String Theory is just mathematically beautiful and a great effort, but it holds little reference to physical reality.

I hope something as fast as the quantum computer is possible though. That would really be neat. But so far, unless quantum mechanics can be rationally explained, I see no hope for it.

Saturday, November 20, 2004

Re: General Stuff

Mohn.. could you post more on the Java Proxy classes you mentioned in your recent AOP like post. I am aware of basic Reflection and stuff but what you mentioned was something new. Does .Net have something similar?

Look for the Proxy class in java.lang.reflect in the Java Documentation. It will probably explain things much better.

But for just a basic overview. Proxy has something like a factory method called newProxyInstance() which will give you back an object instance. You give newProxyInstance() a list of interfaces to implement and an InvocationHandler. So the object instance that you get back will in effect "implement" the list of interfaces you gave it. You can cast the object to any one of those interfaces and invoke methods on it.

This is where the InvocationHandler comes in. InvocationHandler is an interface with one method... "invoke( Object proxy, Method method, Object[] args )". Everytime you invoke a method on the proxy object, the invoke() method in InvocationHandler is called and the system passes it the object instance on which the method was called (proxy), the method that was called (method) and the arguments passed to the method (args). This is the point where you do something useful.

Here's a simple example - might help to understand.

Here are two basic interfaces.

public interface Interface1
{
    public void method1();
}

public interface Interface2
{
    public void method2();
}


You want your proxy object to implement these interfaces. You pass it to newProxyInstance() along with an InvocationHandler.

Class[] interfaces = new Class[] { Interface1.class, Interface2.class };

InvocationHandler myInvocationHandler = new MyInvocationHandler();

Object proxy = Proxy.newProxyInstance( interfaces, myInvocationHandler );


At this point you have an object (proxy) that implements the interfaces, but doesn't do anything. So we have to write an InvocationHandler that will intercept the method calls and do something useful.

public class MyInvocationHandler : InvocationHandler
{
    public Object invoke( Object proxy, Method method, Object[] args )
    {
        if ( method.getName() == "method1" )
        {
            System.out.println( "method1" );
        }

        if ( method.getName() == "method2" )
        {
            System.out.println( "method2" );
        }

        return null;
    }
}


So here, MyInvocationHandler intercepts the method calls and does something. So if you invoke the methods on the proxy object...

Interface1 if1 = (Interface1) proxy;
if1.method1();

Interface2 if2 = (Interface2) proxy;
if2.method2();


... it will output...

method1
method2


The important thing to realize is that everything is dynamic. There is no concrete class anywhere that implements Interface1 and Interface2. It's all done at runtime. And what I said last post about AOP was that in MyInvocationHandler's invoke method, I could add anything I wanted before and after the method call...

public class MyInvocationHandler : InvocationHandler
{
    public Object invoke( Object proxy, Method method, Object[] args )
    {
        System.out.println( "Rahul Revo codeword" );
        System.out.println( "Rahul Revo codeword" );

        if ( method.getName() == "method1" )
        {
            System.out.println( "method1" );
        }

        if ( method.getName() == "method2" )
        {
            System.out.println( "method2" );
        }

        System.out.println( "Rahul Revo codeword" );
        System.out.println( "Rahul Revo codeword" );

        return null;
    }
}


The output now will be...

Rahul Revo codeword
Rahul Revo codeword
method1
Rahul Revo codeword
Rahul Revo codeword
Rahul Revo codeword
Rahul Revo codeword
method2
Rahul Revo codeword
Rahul Revo codeword


I couldn't find anything similar to Proxy class in .NET. I would be surprised if you couldn't do it though... just have to find out how! I'll look some more and get back to you.

Also I have changed my display name. Simply to get codeword as a link when I search for myself on google. ;). I do get a few hits at ncb.ernet.in and a few linux posts I made, but codeWord would be much better to be linked to.

lol. You realize this is a private blog right? It's not listed in the blogger directory anywhere, so no links pointing to it. Google ranks based on popularity of site. Based on that, I wouldn't get my hopes up. Anyway, I helped you out... gave the search bots something to chase on your behalf.

Re: Quantum Computing??

Welcome back. Good to have both Hrishi and you blogging again.

Is this really possible, I really doubt it. For long scientists have been saying that at the quantum level, causality is broken, that is just too dumb! For example, the whole experiment regarding Schroedinger's Cat is ridiculous! The claim of an event happening only when our eyes fall on it is just too goddamned subjective!!

From what I've read, it looks like the laws of phsyics literally break down at the quantum level. I don't see any reason to dismiss it. There is some sort of incompatibility between quantum mechanics and general relativity. And physists are trying to make sense of it all with "string theory". They are trying to unify everything from the very big to the very small. That's why sometimes it is called "the theory of everything".

True we don't know yet exactly what happens at the quantum level, but to infer from that a truly chaotic view of it is absurd. How can something be two different things at the same instant of time?? I'm perplexed, someone explain!

As you say, unlike digital computers today where a bit is either on or off, qu-bits can be 0 and 1 at the same time. It's based on the fundamental ambiguity inherent at the quantum level. They key to quantum computers is that one would present it with a problem and a way to test the answer. Through some disambiguating process (don't ask me to explain how!) the failing answers cancel each others out and only the one that passes the test remains. This is why it's so effective in cryptography.

I've been wondering for sometime if something like quantum computing is possible, it's very base seems shaky! True I'm no physics expert, but still I can't accept a contradiction as the basis to a scientific theory.

And if you think about it quantum computers will definitely be an eventuality. The transistors are getting pretty damn small already. By 2020 they will reach atom size. And at that point we will have no other choice but to deal with quantum mechanics.

I dunno if that appeased you in anyway (I'm guessing probably not!) but that's how I understand it.

Quantum Computing??

Reading the post on Crypto and the effects quantum computing has on it, I thought I'd write a few things.

The whole concept of quantum computing is based on the rational of what they call a Qubit. A qubit is a bit of memory that is capable of holding of both boolean values 0 and 1 simultaeneously!!

Is this really possible, I really doubt it. For long scientists have been saying that at the quantum level, causality is broken, that is just too dumb! For example, the whole experiment regarding Schroedinger's Cat is ridiculous! The claim of an event happening only when our eyes fall on it is just too goddamned subjective!!

True we don't know yet exactly what happens at the quantum level, but to infer from that a truly chaotic view of it is absurd. How can something be two different things at the same instant of time?? I'm perplexed, someone explain!

I've been wondering for sometime if something like quantum computing is possible, it's very base seems shaky! True I'm no physics expert, but still I can't accept a contradiction as the basis to a scientific theory.

There is one theory though, "The Theory of Elementary Waves" by Lewis Little thats seeks to explain quantum mechanics rationally!

Dinesh.

Long-time No Post

Hey guys!!

It's been a long time since I posted. Was not following the blog either, but it's good to see that Revo and Mohn kept it alive and kicking.

Will write more later. Started on a File System Simulation project, it's pretty interesting. I'll talk about it on another post.

Dinesh.

Friday, November 19, 2004

General Stuff

Firstly great to have Hrishi back on codeWord. Try and post whenever.

Mohn.. could you post more on the Java Proxy classes you mentioned in your recent AOP like post. I am aware of basic Reflection and stuff but what you mentioned was something new. Does .Net have something similar?

Also I have changed my display name. Simply to get codeword as a link when I search for myself on google. ;). I do get a few hits at ncb.ernet.in and a few linux posts I made, but codeWord would be much better to be linked to.

See this link from James Gosling's blog. Follow links to the Solaris guys blog and then the HP's original post. Surely will lift your spirits. Hey Hrishi, what do you think of Solaris getting open sourced?

Tuesday, November 16, 2004

Re: Secret Key Cryptography

I didn't understand this. What dyou mean 25 times in a row?

I'll post the entire unix password encryption process a little later. However, in brief - while storing passwds, unix encodes a block of 64 zeroes using the key got from the passwd entered by the user. The cipher text is again encoded using the key. This process is done 25 times. So when someone is attempting to log on, the system compares the final cipher text got from the passwd entered by the user to the cipher text got from the passwd the user entered when the account was created (or the passwd was last changed). If the cipher text matches, he's in.

This method of encrypting 25 times was done to slow down the passwd cracking process (basically the key search) 25 times. However, with the computing power available today I don't think it's of a whole lot of importance. If you go through the link I'd posted on DES, you'll see that it uses certain tables to encrypt stuff. The unix passwd encryption system tables different from those specified in the standard DES. This is done so that hardware encryption chips for DES can't be used to crack unix passwds.

Yeah Crypto is an interesting topic. I guess lots of maths is involved. I've read that since a lot of it comes down to factoring large numbers, quantum computers would basically shatter all encription. So they need to come up with new methods to secure data.

The security of the cryptosystems basically depends on the computational infeasibility in factoring large *prime* numbers. Their feasibility comes from the fact that it's easy to generate large primes. As computing power increases, larger key sizes are being used. Don't know much about the exact speed of quantum computers but to keep the current systems secure they'll have to use obscenely large key sizes or like you said come up with new encryption algorithms.


Re: Secret Key Cryptography

BTW, the unix password encryption uses DES... 25 times in a row.

I didn't understand this. What dyou mean 25 times in a row?

Yeah Crypto is an interesting topic. I guess lots of maths is involved. I've read that since a lot of it comes down to factoring large numbers, quantum computers would basically shatter all encription. So they need to come up with new methods to secure data.

Secret Key Cryptography

This is typically a 'symmetric' type of cryptosystem. You use the same key for encryption and decryption; which is why the key needs to be kept 'secret'. The most commonly used encryption algorithm is the DES (Data Encryption Standard).

DES is a block cipher. It operates on 64-bit blocks. It has a 56-bit key. The actual encryption algorithm is very complex. I won't go into the details (that's because I don't remember most of it! ;-)). However it uses several permutations; generates 16 keys from the first main key and then does a whole lot of stuff before coming up with the cipher text.

The way to crack DES is to try out all the 2^56 keys! That entails *massive* computing power; however it can be done. May take days and months to crack the key for one message but it can be done. So it's not entirely secure.

So what they do is they use Triple-DES. It uses 3 keys - that gives an effective key size of 168 bits. Now that's almost impossible to crack with the current computing power that we have. Security guru Bruce Schneiner (not sure of the spelling) said - There isn't enough silicon in the galaxy or enough time before the sun burns out to brute-force Triple-DES.

Here's a lot of info about DES.

BTW, the unix password encryption uses DES... 25 times in a row.

Virtual functions called from ctors and dtors

Here's an interesting difference between C++ and C#.

Consider these two classes...

// C++
class Base
{
    public:
        Base()
        {
            cout >> "Base::ctor()\n";
            method();
        }

        ~Base()
        {
            cout >> "Base::dtor()\n";
            method();
        }

        virtual void method()
        {
            cout >> "Base::method()\n";
        }
};

class Derived : public Base
{
    public:
        Derived()
        {
            cout >> "Derived::ctor()\n";
        }

        ~Derived()
        {
            cout >> "Derived::dtor()\n";
        }

        virtual void method()
        {
            cout >> "Derived::method()\n";
        }
};


What dyou think this prints?

{
    Base b* = new Derived;
    b->method();
    delete b;
}


The output is:

Base::ctor()
Base::method()
Derived::ctor()
Derived::method()
Derived::dtor()
Base::dtor()
Base::method()

But if you have the same two classes in C#, the output is:

Base::ctor()
Derived::method()
Derived::ctor()
Derived::method()
Derived::dtor()
Base::dtor()
Derived::method()

The derived method is ALWAYS called.

The reason is that in C++, the type of an object changes. When you create a new Derived object, it's constructor calls Base's constructor automatically. In Base's constructor, the type of the object is "Base". So when you call method() in its constructor, all it knows about is itself. So it calls its own method(). Only after you get to Derived's constructor will the object's type be "Derived". Same thing with destruction. Derived's destructor runs first, destroying itself. It then goes up to Base's destructor. Again at this point Base only knows about itself and calls its own method().

It's different in C#. An object can only ever have one (fixed) type. It doesn't morph like in C++. So when you call Derived's constructor, it calls Base's constructor automatically. But at this point the type of the object has already been set to "Derived" and the system knows that it has overriden method(). So in Base's constructor, method() drops down to Derived's implementation. Same with destruction.

Apparently, the difference in C# has to do with the fact that it has a GC. The GC always needs to know the exact size of the object... it can't change. I dunno if this is the case in Java as well. I would assume so.

Personally, I feel the C++ way makes more sense. It's more logical. What dyou think?

Re: Happy Birthday CODEWORD

Good catch Rahul. I didn't remember myself. And I saw the post on the 14th but took my lazy ass till today to reply.

Overall I've been very happy. Pretty much exactly what I had hoped it would be about. Got a lot out of it and some discussions have been very insightful. Dyou ever go back and read previous posts? Sometimes I'm quite surprised and sometimes laugh at dumb stuff (mostly Rahul's posts ;-).

Here's to another good year... Cheers!

hey!

Hey guys,

I'm back. Not much techie stuff to write right now but I'm back on the blog... good to be back!

Recently I've gotten interested in stuff like crytography, security etc. Uses a lot of number theory and it's fascinating. I'll try and post some related stuff soon.

Sunday, November 14, 2004

Happy Birthday CODEWORD

Well its been one year since Codeword began. Hopefully we'll go on much longer and discuss more tech stuff. And lots of years from now, look back and laugh at some really lame posts, like those from Me!!

Friday, November 12, 2004

AOP

So all this talk of Aspect Oriented Programming going on right now. Still don't have a crystal clear picture of what it involves but I'm beginning to understand what it's about and its benefits.

We had a project in my CS class which helped me understand the potential of AOP. My prof had no clue about AOP so that was not his intent - just something I realized on my own after our discussions on the subject.

We had to create a proxy object. The client would provide a list of interfaces and implementations for the proxy object. Essentially the way it would work is that instead of having a concrete class that implements certain interfaces and has an implementation, you would only have a proxy object and tell it to dynamically create objects that implement the interfaces and have access to classes that provide an implementation for the interfaces.

    Proxy
|-----------|
|If1 | Imp1 |
|If2 | Imp2 |
|If3 | Imp3 |
|-----------|


So if you have a handle to the proxy object, you can call any of the methods on the interfaces it implements, but first you would need to cast it...

Class[] interfaces = new Class[] { Class.forName( "If1" ), Class.forName( "If2" ), Class.forName( "If3" ) };

Class[] implementations = new Class[] { Class.forName( "Imp1" ), Class.forName( "Imp2" ), Class.forName( "Imp3" ) };

Object proxy = ProxyFactory.getNewInstance( interfaces, implementations );

If1 interface1 = (If1) proxy;
interface1.someMethod1(); // 1

If2 interface2 = (If2) proxy;
interface2.someMethod2(); // 2


So the way this works is that the proxy object internally has an InvocationHandler. The InvocationHandler intercepts any calls on the proxy object. So when 1 is executed, you get to the InvocationHandler and the system tells it which method is being called (someMethod1) and on what interface (If1). So at this point, InvocationHandler will create an object of type Imp1 and actually call the method on that object. Same thing when 2 is executed. In this case, an instance of type Imp2 is created and the someMethod2 is called on it.

interface1.someMethod1() --> Proxy --> InvocationHandler --> ( new Imp1() ).someMethod1() --> Return

interface2.someMethod1() --> Proxy --> InvocationHandler --> ( new Imp2() ).someMethod2() --> Return

Basically what this provides is a level of indirection. This is possible in large part because of reflection. The most important part is that your InvocationHandler is the one calling the actual method implementation. Normally we would manually create an object of Imp1 or Imp2 and called the respective methods, but here we don't interact with them directly. So you could executed some additional code before and after the method is called. The most common example for AOP given is Logging. So we could log information before or after the method call is made.

interface1.someMethod1() --> Proxy --> InvocationHandler --> Log --> ( new Imp1() ).someMethod1() --> Log --> Return

interface2.someMethod1() --> Proxy --> InvocationHandler --> Log --> ( new Imp2() ).someMethod2() --> Log --> Return

This ability to inject your own functionality between someone else's method calls is quite interesting.