Tuesday, October 25, 2005

Project1 - SMS Service Web2Mobile and the Challenge

In the sidebar I have provided the link for SMS Service. This is a small module I wrote. It works perfect, I have only tested it for T-mobile yet. But please if you a chance try it and let me know the results.
There are many limitations to this though:
1. It needs carrier information. If you have a friend who knows nothing about your carrier, then she/he cannot conveniently send you SMS without knowing your carrier. Is there any way that this can be resolved? I know they call it reverse lookup, but how do i do it programmatically? I don't want to run curl and parse html of certain existing sites that do this for free. There should be some interesting and elegant solution to this.
2. Currently only ascii based text messages upto 160 characters can be sent. It would be genius if this limit can be surpassed and html-based sms messages with unlimited length could be sent using the same Email Gateway system! I don't think this has been ever done before by anyone succesfully.

Both the above limitations can be overcome using pricey solution, where a wireless modem is used to actually send the messages. But you know, the network is in place [Email Gateways], infrastructure is in place, why then opt for pricey solutions? We are techies and lets see if we can nail this down! It's an open challenge.

Mutator - getter functions answered

Let me be very brief. For getters() if they return objects, i mean large objects, it makes sense to return be reference. But most of the times these objects are aggregated prviate members hence best solution that complies with OO semantics as well as provides optimization:

const ClassType& getClassType() const { .....}

All comments are most welcome.

Monday, October 24, 2005

Mutator - getter() functions

How should the getter() be declared?
what is best option to declare getter() such that it holds with OO semantics and also gives maximum optimization .... ?

Thursday, October 20, 2005

Inline functions optimization - answered.

Below is a simple copy-paste of the answer provided in comments of this post's question. The credit goes to Eklavya.
The reason the compiler has been given the control is because programmers can be sloppy and can thus take uninformed decisions w.r.t to making functions inline. The idea behind inline functions is to avoid the overhead associated with the creation of new frames for functions that are small say less than 10 lines or so. It would be best to execute them inline.
Now say if a programmer is given such control and he/she marks a very big function as inline, imagine the amount of code bloat that would ensue as a result esp. if that function was invoked at several places in the code. This would increase the size of our executable image with the same copy of the function lying at several places. The basic idea behind using functions would be lost. Such functions would never be inlined by the compiler.
Although, it should be noted that if the same function is invoked only once during the entire execution of the code, it would make sense to make it inline. Hence although the programmer is allowed to request for inline privileges, its only the compiler that should take the decision. Comments/suggestions/rants welcome!

Wednesday, October 19, 2005

Inline functions optimization?

Inline functions are definitely way better choice over macros! C++ has introduced this feature which is yet another indicator of the richness of this language.
But though this is a great feature for optimization, it's not in complete control of the programmer. The decision of actual inlined function code inclusion rests with the compiler.
What do you think is the reason that the compiler has been given the total control of the decision that whether an inlined function should be actually inlined or not? And then if some functions are not inlined by compiler, why aren't they?

Returning Private members

This article is especially in reference with:
http://myspad.blogspot.com/2005/03/return-private-member-variables-of.html
Here, author has code snippet that gives unrestricted access to private member data! Well this is violation! So though a correct way of returning by refrence "&" has been used but still it misses one more important design detail.
Lets try to analyze this whole thing using an example.

class A { int i; };
class B {
A a; int y;
public:
// Note this function declaration
const A& getA() const;
}

The above function getA() completely maintains the semantics and though access to private member has been refrenced, it still does not allow user to modify the contents.