Skip to main content

Posts

Showing posts from 2007

Life goes on

It’s been quite some times that I have started to blog, not that I was not interested…it was just that I did not have time.
My work place recently has started to become busy. And guess what I have started to come to work early. The weekends, ye they come and go, seems that Saturdays and Sundays go too slow compared to working days.
Three to four months before , I was hooked up to the computer and learning new things on the weekends, and now the weekends go as if there is no computer at home at all.
Hopefully, I’ll be getting over this, and maybe you’ll see more posts on this blog.

Sri Lanka , where is it heading?

So it seems that months pass by with no peace, there were several bombing the past month. And still living in fear…
Ha.. some said, Sri Lanka is going to change, but it’s obvious that it’s degrading worse very day, not to mention that he has done a few (may be a lot for others) good things to improve the stability of the country.
But this does not prove any overall improvement in the society, and I guess every one would agree with me on this, as it is obvious to person who know what’s going around him.
Every day there seems to be a murder somewhere in the corner and the number of people kidnapped as increased. In my opinion and in most, the country is not going anywhere until what ever the shit is settled with the TIGERS.
The living cost as increased and gradually increasing more… who is responsible for this?, well , the answer to this I think everyone knows , but some may try not to show it though…
Is it the leadership of the country or is it some other thing that should be responsible fo…

I love when it rains....

It’s raining more then cats and dogs in Colombo these few days, and it became even worse yesterday.
It took me nearly 4 hours to go home instead of the routine 1 hour, and that was hell of a traffic in Colombo.
Sort of enjoying work these days, it’s raining , the air conditioner chills more then ever, come to office around 11 am and leave at minimum 6.
Coming to office is also a bit of a war, by the time I get to office; I am soaked from waist to toe, despite carrying a bigger umbrella.

Rain is a must, but too much of rain…. Na..

We are into the finals !

I am a cricket fan, (well that’s the only sport I know to play!) .
I remember how I enjoyed watching the last World cup, although our guys you know…
But this time, it seems that I have lost a certain amount of interest, of course after the busy day and also the busy day ahead does not let me watch the matched until late night.
I am damn happy that our guys got into the finals, after all it’s my mother land , Sri lanka.
But what makes me sad is that I have missed all the action when our guys were at the peek in this World cup.

Hopefully, the final will be watched, and will be there to cheer our guys when they hold the cup !.

Wrestle Mania 23

Finally, Wrestle mania 23 is here…
Yep folks, it’s on April 1st. These are some of the events I would not want to miss watching..
Undertaker vs Batista - for the World heavy weight championship.
John cena vs Shawn Michel - for the WWE championship.
Battle of the billionaires – Umaga vs Bobby lashly

For more information visit wwe.com

A Crouching tiger waits for it’s prey

A Crouching tiger waits for it’s prey…
Sometimes you will not respond immediately to your foe, but rather wait until the correct time.
This does not mean that this person is not smart enough to defend him self, but what it really means is…, planning the attack takes time.

Hack of a week

This week has been frustrating for me. First I did not have sufficent work at office, and I had to stare at the monitor for half of the time I was there at work.
Then the hard disk of my computer at home got corrupted, so I had to buy a new computer (anyway I was planning to buy one cos' the one I had was a bit old. All that money!!).
Thirdly, I got soar throath and a fever, and the drugs that I take to cure these makes me feel sleepy all the time at office.

Localization tips..

These are something that you would need to consider when planning to localize your system.            Externalize all the hard code strings, that is, move it into a separate resource file.            Do not move your strings into the forms own resource file (talking about .NET Win forms), this is because every time you add a new language support or even if you change something on the form through the designer, the forms resource file gets regenerated, and your newly added keys are lost !!! , therefore move it into a separate resource file.Do not use hard code string concatenations, for an example : String str = “Something ”  + value + “ something more”;Don’t move only the strings “Something ” and “ something more” into the resource file, try adding a value in the resource file as “Something {0} something more” and in your program code : String str = string.Format(resource.GetString(“the_key”,value));The reason for this is that in another language, the whole sentence may be in a differ…

Method inlining

Executing a method has a cost, this cost can be partially avoided by method inlining.
Method inlining means basically moving the method into the callers body for an eg. Take a look at the code

int Calc()
{
return x * y;
}

int num = Calc();

when Calc() is inlined what it basically means is
int num = x * y;

Unlike C++ (as I read) C# does not have inline keyword to explicitly inline methods, this is due to JIT handling it by itself.
JIT uses heuristics to select methods that are to be inlined.
The following are some of the heuristics JIT uses

Function code that produce less then 32 bytes IL

Function code the has simple control flow , this includes if- else if – else statements, functions containing swith and while flows are not inlined

Virtual functions are not inlined

Functions containing exception handling blocks are not inlined , but if the exception is just thrown without handling code it would be inlined.

InitilizeComponent() visited

Well these are two scenarios that happened to me:
In one of the earlier projects, just before a release I was working on a alignment issue in an aspx page and no change to the code behind file was done. But when the setup was tested on a fresh machine, the application threw exceptions !!. Finally what we found out was that the code behind of the file has really changed, to make things worse, the URL of the web service was hardcode to “Localhost” . After the release (went home at 6.30 in the morning that day), had some time to investigate this matter.
What I found was that someone has instantiated the web service proxy reference inside the InitilizeComponent() , and every time there is a change in the aspx page design , the InitilizeComponent() gets regenerated, and because the web service proxy reference was instantiated inside this method , the auto-generated code assigns the URL property of the proxy to “Localhost”.

I ran into the same sort of problem yesterday, the application was run…

More on localization...

I was changing the Region and language settings in the control panel, and was expecting that text in the forms to show up in the language that I had set, with no luck.Did some reading and ……
CurrentUICulture is a per thread settings that governs from which resource file the ResourceManager class uses in a localized application. CurrentUICulture is a language setting and does not have any thing to do with date or currency formats.
The CurrentUICulture is determined from the users default language, or if this is not set, the language used by the o/s
The CurrentUICulture can be changed as follows
Thread.CurrentThread.CurrentUICulture = new CultureInfo(“fr”);

The CurrentCultrue is not a language setting, CurrentCultutre determines the date formats , currency formats etc.. This can be changed from the Regional option from your control panel. The CurrentCulture ctor takes a culture (a region and a language) as a parameter and will throw an exception if a neutral culture is specified
In a web appl…

Arguing with a egg head !

Well, after posting a mail on Stringbuilder vs String to a group in Sri Lanoka (BITPROJECTS), A guy named Ranga, started pointing out a mistake in my example, well I proved that he was wrong !!.
But I guess the guy did not wanted to give up, so he started talking about everything else other then StringBuilder
Think he might have got really frustrated, loosing !!!.
So finally I thought of giving up, as I did not want him to go to ANGODA .
Damn, I can’t think there are people in this world who think they are PERFECT. All for sure he was not perfect, he was a egg headed MUTT, who was stubborn to listen to anyone. People like him are going to have a hard time living in this world !!!.
I hope god helps him out!!!.

String vs StringBuilder

Take a look at the code given belowstring str = string.empty;for(int i= 0 ; I < 100; i++){str += i.ToString();}You should never use string concatenation inside a loop, the reason for this being that strings in java and c# are Immutable.What this mean is that each time you concatenate a string, a whole new string object is created with the older value appended to the concatenated value, ok what happens to the older string object ?? well it is left for the garbage collector.So we got two points here1) object creation means processing power and memory usage 2) in this example the garbage collector needs to clean up nearly 100 string objects !!!So what’s the solution ?? Use StringBuilder class (C# - found in the System.Text anmespace), StringBuilder (java not sure of the namespace).What StringBuilder class does is it actually appends, without actually creating a string object on concatenating , therefore u will be using only one StringBuilder instance in this example, which basically m…

Java vs C# - Virtual methods

In Java, instance methods are virtual by default—they can be overridden in subclasses unless they are explicitly declared final. In C#, by contrast, instance methods are non-virtual by default. To make a method virtual, the programmer must explicitly declare it virtual. Why is non-virtual the default in C#? There are several reasons. One is performance. We can observe that as people write code in Java, they forget to mark their methods final. Therefore, those methods are virtual. Because they're virtual, they don't perform as well. There's just performance overhead associated with being a virtual method (more on this in the next mail). That's one issue. There are two schools of thought about virtual methods. The academic school of thought says, "Everything should be virtual, because I might want to override it someday." The pragmatic school of thought, which comes from building real applications that run in the real world, says, "We've got to be real…

Something I ran into

This something I found out about ASP.NET 2.0, As I am not doing ASP.net at the moment, I thought of just logging this, incase I may need it.You can not simply address a control in java script. (I am using Master page) 
document.getElementById('TextBoxEmpName').value you have to replace the above code line with..
document.getElementById('<%=TextBoxEmpName.ClientID %>').value

If you use GridView and  you have a  " Date " field column that you want to format it using  DataFormatString="{0:d}" , this won't happen unless you change the property HtmlEncode="false".Actually this is not an issue, this is what my friend Sanjaya has found, for 24 hour display time column field you have to use formating string as DataFormatString="{0:HH:mm}".[http://www.sumudusharp.blogspot.com/]

Workout machine

I was gaining waight has hell, so i decided to buy my own work-out machine.What really caught my eyes was the Obitrek, it was a cool peice of machine and cheap, I decided to buy it.
Now it is laying near the kitchen(not in the kitchen), I had a go yesterday and today morning, it was amazing cos' it does not develope cramps as normal jogging does.

Back to work !

After a long relexation,I am back in a new project. This time it was a project from a huge service provider, the part I am working on is a plug in to a bigger project. Currently it just me and the tech-lead in the project, the scary thing about this project is that I am playing the role of a senior software engineer. Well anyway I am only allocated into the project for a period of less then 2 months, Thats a relief !!!.
My frist task is to localize the appliaction into 14 different languages, hope everything would go fine.

EXISTS vs COUNT()

COUNT may be used in SQL to check if a record exists like for an exampleIF(SELECT COUNT(CUSTOMER_ID) FROM TBL_CUSTOMER WHERE CUSTOMER_ID = 100) = 0BEGIN /*LOGIC*/ ENDBUT using the keyword EXISTS gives better performance THEN COUNT()IF EXISTS(SELECT CUSTOMER_ID FROM TBL_CUSTOMER WHERE CUSTOMER_ID = 100)BEGIN /*LOGIC*/ ENDIf in case the row count is needed @@ROWCOUNT can be used and also if only the first record is needed the TOP KEYWORD can be usedSELECT TOP 1 * FROM TBL_CUSTOMER

One more left in the CRM Reporting team

Samith left the company yesterday, to go abroad for his MIT. The CRM Reporting team started with Hashan, Crisanth and Samith , later joined by me in the mid of September.Crisanth left  the company in October and Hashan left in December and now Samith.Reporting was a tough module, it was the first time anyone of us has done queries on a Data warehouse via MDX, we lacked experince in this area but quickly got used to it and deliverd the module (was accepted by the clients).Working with this team was lot of fun and experince has I learnt a lot from them.

Assor's wedding

Yeaterday was a day of fun, I headed out to kandy with my collegues at Parangon (the place where I used to work prior joining Virtusa) to attend the wedding of Asoor( another collegue at Paragon).Everyone was present except Kasun and Chaturanga. We had a great deel of fun, talking about all the nuttiest and gross things in the world. As usual Fahim got hooked to himself after I threw a joke at him and he did not change his mood for the rest of the day.  Well Assor was in a good mood, he had his lunch with us ad alos said that 2 weeks of holiday after the wedding was not much to enjoy, Fizan too called for UK and had a chance to talk with all of us.Manjula’s secret came out as well. We had tea at Rafi’s (Paragon’s Managing director) place in kandy with a piece of cake.Alltogether the day was owesome. Thanks to Paragon.

ASP.NEt 2.0 Viewstate and good practices

View state is one of the most important features of ASP.NET because it enables stateful programming over a stateless protocol such as HTTP. Used without strict criteria, though, the view state can easily become a burden for pages. Since view state is packed with the page, it increases size of HTTP response and request. Fortunately the overall size of the __VIEWSTATE hidden field (in ASP.NET 2.0) in most cases is as small as half the size of the corresponding field in ASP.NET 1.x.The content of the _VIEWSTATE field (in client side) represent the state of the page when it was last processed on the server. Although sent to the client, the view state doesn't contain any information that should be consumed by the client.In ASP.NET 1.x, if you disable view state of controls, some of them are unable to raise events hence control become unusable. When we bind data to a grid, server encodes and put whole grid in to view state, which will increase size of view state (proportional to the dat…

Nice way to start my blog

Woo what a nice way to start the blog. Today we received the acceptance for our project from the clients.This project was on the customer relation management domain, I was working on the data warehousing module, and after a long struggle, all went well