“Is it free for you during weekend?” he asked her.
I got shocked, not realizing what exactly he wanted to ask her.
She dint get it either, she responded back with a question mark on her face.
“I mean, is it free for you to make a call from your cell phone during weekend?”
She responded positively this time, “yeah”
“Which service provider do you have?”
“US carrier”
“Do you have network coverage now?”
“Yeah, we get it here; it’s the only one which has coverage in this area”
“Do you mind if I use your cell phone to make a call?”
Again a bit of hesitation on her face, but she responded with “yeah, of course”
He had to make a call to his girl friend and there was no network coverage for both T Mobile and AT & T service provider !! Its surprisingly strange that even in such a well known tourist places, there won’t be good coverage by these well established service providers!
While I was driving through one such remote [or rather no coverage] area, suddenly I got a message, and it was a Voice Message. That was the only time I appreciated “You have a new Voice Message” getting displayed on my cell. I took my car to a halt at the shoulders and for next ten minutes, we guys were busy making calls!
===============================================
There is more of coverage problems, though very different one this time. One of many disadvantage of being away from home [in a different country] is Coverage of Medical Insurance. If your parents/dependents are away, then your medical insurance won’t cover them! I need get medical insurance for my mother and sister, who live in India.
===============================================
During our last meeting at office, out Product Owner told, “Team, our coding/software release standard says that we should be having at least of 80% coding coverage from now onwards and lets start with You [pointing at my friend]”
“But, why me?” was his immediate response.
I told him, “Dude, I have 2 tips for you, code it so that you don’t have many if else and switch statements and the 2nd one is, if ever you have lots of such codes, comment out all else statements with #if 0”
Having said that, I started thinking on that on a serious note. It can be a good practice if we write code with ifs and not else.
For example:
Rather than writing code with lots of ifs and elses, I think its better to write it so that, we avoid else conditions.
Advantage being:
(i) well readable [lots of if else confuses me a lot]
(ii) maintenance is easy [maintaining blocks of if else or to modify one is a tough job]
(iii) don’t have to worry about code coverage!
One such sample code [which I wrote now, though this might not have lots of significance]
int AddContacts(ContactDetails* pContacts) {
int res = OK;
if(pContacts){
ContactDetails* contacts = new ContactDetails;
if(contacts) {
if(pContacts->name) {
contacts->name = new char[strlen(pContacts->name)];
if(contacts->name) {
strcpy(contacts->name, pContacts->name, strlen(pContacts->name));
//copy other data similarly...
...
}
else {
res = ERR_MEMORY;
}
}
else {
res = ERR_ARGUMENT;
}
}
else {
res = ERR_MEMORY;
}
}
else {
res = ERR_ARGUMENT;
}
return res;
}
Re-writing the same with avoding the else condition.
This function below takes care of all the error condition that above code is doing and also the same functionality.
int AddContacts(ContactDetails* pContacts) {
int res = ERR_ARGUMENT;
if(pContacts){
//set error as ERR_MEMORY
res = ERR_MEMORY;
ContactDetails* contacts = new ContactDetails;
if(contacts) {
//set error as ERR_ARGUMENT
res = ERR_ARGUMENT;
if(pContacts->name) {
//set error as ERR_MEMORY
res = ERR_MEMORY;
contacts->name = new char[strlen(pContacts->name)];
if(contacts->name) {
strcpy(contacts->name, pContacts->name, strlen(pContacts->name));
//copy other data similarly...
...
res = OK;
}
}
}
}
return res;
}
And also, one can write C++ codes very effectively and efficiently by avoiding if else statements with polymorphism [by constructing an object of different type for each such cases and directly invoking that functionality on that object]
===============================================
When asked us about who is suppose to work on a task, my colleague/friend of mine told my Product Owner, “I am done with my part and now its Girish’s responsibility”
I said, “Ok, I will do it” though I seriously got pissed off with this, but I dint utter a word at that time. I came back to my desk and avoiding a conversation with him as I knew that if I do, I might take a toll at him. Even after giving more than an hour gap, I was still unhappy about it and I wanted him to know about it.
“Since when you started deciding upon what I am supposed to be doing?” I asked him.
And this time he got pissed off for me asking like that and he stopped talking to me ;)
===============================================
When we were entering office through the main entrance, we saw few of our colleagues standing outside the back side entrance in a group and into some serious discussion. We ignored them and got into elevator, and I could not resist my curiosity and asked my friend, “what would be they doing down there?”, but I asked that in kannada (my mother tongue].The lady who was in the elevator with us, got that context though the last thing she would know is a word from Kannada and told me, “Few Indians and few Chinese are trying to communicate with a Spanish to guide her to USA Embassy”
No comments:
Post a Comment