Thursday, May 12, 2005
Unit Testing with nUnit
In case you're into unit testing: TestDriven .Net(www.testdriven.net) is an addin for VS.Net which allows running of nUnit test cases from within the IDE without having to run the nUnit GUI. A nice tool which saves you a lot of debugging time along with nUnit. Another add-in which is a must have atleast for VS.Net 2003 and below is Resharper (http://www.jetbrains.com/resharper/), makes refactoring a lot more easier.
Dot Net (.Net)? Not Yet
UPDATE: I've posted the VB.Net code sample in another post.
Off-late I've learning quite a few things about .net (mostly asp.net) the hard way (actually that is true as of now for almost everything in life). Anywez here are few more things that I found out.....
Off-late I've learning quite a few things about .net (mostly asp.net) the hard way (actually that is true as of now for almost everything in life). Anywez here are few more things that I found out.....
One of the requirement in this project is to show a list of RadioButtons within a DataGrid (could be a DataList or Repeater for that matter). Now the user gets to see the list of conferences in a grid and he can choose one (only one) from that list. So basically all I had to do was define a templatecolumn in the grid, include a RadioButton within the template and give it a groupname (the groupname ensures that the radiobuttons rendered are mutually exclusive). Seems to be a 5 mins job but guess what? I did exactly the same and when I ran the code, I could select all of the radio buttons within the grid at the same time. I checked the source html and found out that all the radio buttons rendered had unique names, thought I did something wrong so I debugged and debugged but couldn't figure out what was wrong so I resorted to my ol' faithfull friend: Google and voila MS has confirmed it to be a bug (http://support.microsoft.com/default.aspx?scid=kb;en-us;Q316495)! (aside: while typing I sowehow lost the entire content after this so have to type in everything again!!, very very bugged!). Googling further I found a workaround on CodeProject, the code basically creates a custom RadioButton which derives from the RadioButton and overrides Render method to ensure that same html name is rendered (using the GroupName property) and implements IPostBackDataHandler to persist the state of attributes on postback. The only problem was that the code was in C# and my current project is on VB.Net, converting C# code to VB.Net or vice-versa is a pretty trivial matter and generally does not take more than a minute per line of code or so I thought! this is where I learn another subtle but very big difference between C# and VB.Net, though C# allows you to re-implement an interface(in my case IPostBackDataHandler) already implemented in the base class (RadioButton), VB.Net does not and generates compile time errors!
(end aside) I really don't understand why such a feature would be only supported in one language and not another when MS is pushing both the languages equally now!! So this option was also ruled out but not to be deterred I thought of inheriting the custom control from one level up than RadioButton and then perhaps I could re-implement the IPostBackDataHandler well no luck, cause RadioButton inherits from CheckBox which actually implemnts the interface, so had to go one more level up: WebControl..now creating a RadioButton by inheriting from WebControl is no trivial matter..that's when suddenly a tool amazing tool called Reflector(www.aisto.com/roeder/dotnet/) came to my mind, basically Reflector allows you to reverse-engineer .Net Assemblies. Downloaded it and installed it and reverse engineered the code for radiobutton and checkbox and with few tweakings here and there, I had my custom radiobutton control ready which were mutually exclusive when placed within the grid or for that matter any container which implements INamingContainer in VB.Net! And am I pleased about my feat, you bet.
Saturday, May 07, 2005
A tech post at last!
ASP.Net 1.x flames:
I've been working on a asp.net web-site project which has to be cross browser compatible (it is supposed to support IE 5.x+ and Netscape 6.x+) and it is something which I never had chance of working on before on .net. Few things that I found out, the client side validation for asp.net validation controls don't work on Netscape or for that matter on any other browser except IE! (including Mozilla & FireFox) not that these "new" versions of mozilla based browsers don't support the latest Javascript standards but it's due to the way these validation controls spit out Javascript which is very very IE specific (and that btw doesn't follow any standard!). First of all the client script by these controls is only thrown if the browser is listed in Machine.config as a "supported" browser (even though mozilla based browser do support latest JS standards, the config file only has IE listed). Second problem is the way WebUIValidation.js is written which uses document.all (a feature only supported by IE, the standard is to use document.getElementById) to find a control on the form. Fixing these two is easy but that doesn't make the client script validation run on mozilla based browsers! the biggest problem is the little script block that is emitted by the base validator control (all the validation control extend it) on the OnRender event, which again uses document.all! So basically it's impossible to add client side validation for non IE browsers unless you're willing to extend the base validator control, override its OnRender method and write validation controls which extend from the custom validation control!
Second thing that I hate about ASP.Net 1.x is the Postback feature, I think GMail revolutionized the way postbacks are handled by using remote scripting. It's really illogical for the entire page/form to post itself back if the user changes a value in a dropdown list (can you believe it ASP.Net also has a server event for TextBox.Text_Changed, imagine the user typing a character and the page posts back, nice way of making sure that the users don't visit your site ever!!!). The good news is that MS has finally woken up with ASP.Net 2.0 and most of the control support remote script callbacks for e.g. the GridView (successor of DataGrid in 1.x) uses remote scripting to refresh the grid for sorting/paging. ASP.Net 2.0 uses XmlHTTP for remote scripting and the irony is all Mozilla based browsers have XmlHTTP built in whereas in IE 6.0 you have to use an ActiveX control. Hopefully IE 7 would have XmlHTTP implemented w.o having to use ActiveX and praying users would lower their security settings to allow ActiveX controls so that the page can function properly....MS are you listening?
Apart from the flames read a nice article on Google vs MS (http://www.fortune.com/fortune/technology/articles/0,15114,1050065-2,00.html) and the popularity of GDS, infact I myself am trying to build a plug-in for Yahoo!IM Archive: more or less there just have few frills to add..hope to have it rolled out at Sourceforge by next week some time.
PS: When would google wake up and add Category support for blogger?
Thursday, May 05, 2005
Friday, April 29, 2005
Thunder Over Louisville
April 23rd was Thunder Over Louisville, I remember the last year when I was there with Chhavi. Had some amazing time over that weekend (thanks to Debbie, btw talked to her couple of days back, was a nice feeling). Just went down memory lane today thinking about the event and that weekend...
Sixth Sense
Recently watched the TV show "The Mysterious world of Alain Nu", Alain Nu (www.alainnu.com) is a mentalist with very strong ESP. Some of the things that he performed on the show were: (a) He hands out a deck of cards to a volunteer, who shuffles and re-shuffles and re-shuffles, Alain takes 15 seconds to "read" the ordering of the cards by looking at them and then tells the cards in exactly the same order as they were stacked first from top to bottom and then from bottom to top! Atleast I can't memorize 52 cards' order in 15 seconds. (b) He hands over a deck of cards to a volunteer and him to call any two digit number (volunteer calls 22), asks another volunteer to calls any card (the volunteer calls 9 of clubs) and voila the 22nd card turns out to be indeed 8 of clubs (he doesn't touch the cards after the volunteers have made their choices). (d) He bends metal spoons w.o. even touching them by just moving his hands around the palms of the volunteer who has the spoon within them (c) Another one: He has 2 clean slates and a piece of chalk, he sandwiches the piece of chalk between the two slates and asks a volunteer to think of the name of a person and behold the name was written by an invisible hand even though the volunteer never said it aloud! There were quite a lotsa feats which were quite unexplainable by using "normal" logic and laws of physics. Almost all the feats that Nu performed were mentioned in Brunton's book "A Search In Secret India".
I know the first thing that comes to the mind after watching such "magic" feats is that it's just a magician's trick or an illusion. Is it really an illusion or the fact that since childhood we've been taught to use only 5 senses and anything which cannot be felt by one of these sense makes us call it as an illusion, just because we can't feel these things doesn't mean that they don't exist. Why do we have at times such a strong sense of deja vu? Why do we at times feel positive vibes when we meet someone for the first time and sometimes vice-versa? I think at times it's good to put aside the laws of physics and "normal" logic to understand certain things and events that happen in our lives, remember that all laws of physics are based on assumptions!
Thursday, April 14, 2005
One year with Blogger.com
It's been one year since I've been blogging at blogger (seems to be a long time!) and am more or less pleased with the service that they provide..yeah it's a little lame when compared to other blogging site like weblogs but blogger.com is actually meant for not so tech-savvy bloggers. Few things sure need revamp: features like category support, a calendar with links to the dates you've blogged (I really like this thing in MovableTypes/weblogs), better commenting system etc. apart from that the interface is pretty decent and you can change the look n feel of your blogs with skins and has now pretty nice support for posting your pictures using Picasa. Life has changed a lot over the past one year since I started blogging which I think is reflected in my blogs over the time; they have been less tech-centric and more focused around my personal life not that nothing is happening in my professional life it's just that it doesn't matter to me any longer.
Started reading An Ordinary Person's Guide To The Empire by Arundhati Roy, hits you right between the eyes kinda book, should be able to finish tonight.
Started reading An Ordinary Person's Guide To The Empire by Arundhati Roy, hits you right between the eyes kinda book, should be able to finish tonight.
Monday, April 11, 2005
Good decisions, bad decisions
Off-late something has got me thinking: what is classified as a bad decision and what is classified as a right decision? Is it that if the outcome is good then it is a good decision and if it is not then a bad decision? or is it that if you do what others would have done then it is a right decision else if you decide to back your own instincts and do what you feel is correct then it is a bad decision? Well, according to me no decision is right or wrong at its face value, we generally tag a decision as bad or good based on the results, since results are the future events while you are about to make a decision how can you know the result? so I feel that no decision is right or wrong, yes you can perhaps make more "sensible" decision by following what "others" who were already in the same situation did. I've a problem with following "others" too, everyone has a different set of priorities in life, everyone has different endurance levels and everyone has his own unique circumstances to deal with...to me a good decision is a decision which is made by the person keeping in mind his circumstances, endurance levels and above all his priorities or things that matter to him & things that don't, irrespective of the outcome.
I took a decision some time back to move to US which some feel (no prizes for guessing) is not the most correct decision. They feel that it's gonna "screw up" my life, well according to me you can't screw up a life which is already screwed up! worst come worst I might have to write off the year(s) that I would be in the US but hey what if things work out? Doesn't it then seem to be a sensible decision? I know a lotsa people would have given up hope at this stage but as I said everyone has his own endurance level and everyone's got his own priorities and to me this is the thing that really matters something for which I don't even mind writing off my entire life forget about few years. So just keeping my fingers crossed and hoping that one day things would be back on track just like they used to be nearly an year ago (seems to be long time!).
By the way read a book called The Monk who sold his Ferrari by Robin Sharma, how is it? who knows, who cares.
I took a decision some time back to move to US which some feel (no prizes for guessing) is not the most correct decision. They feel that it's gonna "screw up" my life, well according to me you can't screw up a life which is already screwed up! worst come worst I might have to write off the year(s) that I would be in the US but hey what if things work out? Doesn't it then seem to be a sensible decision? I know a lotsa people would have given up hope at this stage but as I said everyone has his own endurance level and everyone's got his own priorities and to me this is the thing that really matters something for which I don't even mind writing off my entire life forget about few years. So just keeping my fingers crossed and hoping that one day things would be back on track just like they used to be nearly an year ago (seems to be long time!).
By the way read a book called The Monk who sold his Ferrari by Robin Sharma, how is it? who knows, who cares.
Friday, April 08, 2005
a new old friend..
It's been long since I blogged had too many things to take care of, I quit my job in Hyderabad and joined a company which got me shipped to New Jersey, anyone who knows what's been happening in my life would know why I joined them. Many people asked me to re-think about my decision but I knew what I was doing and why. I have no liking for my current place or the work apart from the fact that they are pretty decent folks, I joined them for totally other reasons which cannot be termed as professional. I joined them because I wanted to be close to Chhavi, we were (were? I for sure am still just as much in love with her and I hope it's same with her too) madly in love with each other and the best thing was that we were not just blindly in love but would see fault in each other too and try to learn from one another. I have never in my life felt the same sort of comfort while talking to anyone else even the ones who were very close to me. we would talk for hours everyday and still feel like talking more...we would be with each other over the weekends (every weekend except 2 out of the 12 weeks that I stayed there) when I was in Louisville and still feel like being with each other every day. I have never met a person who was so much giving, so caring & still being so receptive to new thoughts/ideas (I know these qualities are pretty much still in her) as her, circumstances or twist of fate or whatever else it was (I don't blame her for anything) we stopped talking and according to her she moved on with her life and that's what she told me even after 10 months since the date we stopped talking. So why am I still trying when it's been more than 10 months? why am I still hoping that we would be together back to same old days when perhaps everyone else would have written us off? am I being impractical? or am I being overly hopeful? I don't know yet what is the right thing to do but I would do just anything to have her back in my life. I don't want her to come back just for my sake but because she also hopefully feels the same way. ..
I am,
You are.
& nothing else matters
in our private universe!
I am waiting for the day and I would see her smiling at me again & waiting with open arms..is it too much to ask for?
I will end this blog with my favorite lines from Ghalib (chubby also loves it): -
hazaron khwaishen aisi,
ki har khwaish pe dum nikle.
bahut nikle mere armaan,
lekin fir bhi kam nikle.
I am,
You are.
& nothing else matters
in our private universe!
I am waiting for the day and I would see her smiling at me again & waiting with open arms..is it too much to ask for?
I will end this blog with my favorite lines from Ghalib (chubby also loves it): -
hazaron khwaishen aisi,
ki har khwaish pe dum nikle.
bahut nikle mere armaan,
lekin fir bhi kam nikle.
Tuesday, March 15, 2005
Bye bye Hyderabad
12th of March was my last day in Hyderabad, I moved out of Bangalore in february and joined a company based out of hyd. I stayed in the co. for little over than a year though even before joining the co. I knew it wasn't the place where I can survive for long. I still find it tough to understand how can some company be so unprofessional in the way they do their business: starting from managing clients, to managing its own people! but well they're a 10 mln $ company so perhaps that's why no one is complaining. Met few nice guys in this company, no technical studs though: Satish, Amudhan, Sai, and Rao to name a few, hope will meet some of them again in future...even though the work wasn't at all great in the company I got what I joined them for so am not complaining at all and job satisfaction was not one of them. Anyway, I know someone would be unhappy over the fact that my next job is not in bangalore but well that's the way it goes, let's see where life is heading next.
Tuesday, March 08, 2005
8th of March
People born on 8th of March have their sun in Pisces: which means the person is a dreamer, very compassionate & self-sacrificing: so is it true for every piscean or is it a generalization? Well, I don't know about other pisceans but since past two years(ok not just past two years, I'd first met her around 15 years back). I've been knowing a piscean born on this day and I see all the above qualities in her plus a lot more (no prizes for guessing who she is).
8th of March is not just significant because it's her birthday but also it was the day when we met again after 13 years: still remember standing in front of Laxmi-Narayan temple in delhi at 7 o' clock in the morning & waiting for her to come to meet me....also last year we were together on this day in chicago, so this is the first time in past 3 years that we haven't been together on this day & sure it doesn't feel that great but as they say it's not if it's when!
Very Happy b'day wishes to a person whom I have the privilege to know and be with, wish you good luck & lotsa happiness and sunshine and hope to be with you on 8th of march, 2006 and all the 8th of marchs then after.
8th of March is not just significant because it's her birthday but also it was the day when we met again after 13 years: still remember standing in front of Laxmi-Narayan temple in delhi at 7 o' clock in the morning & waiting for her to come to meet me....also last year we were together on this day in chicago, so this is the first time in past 3 years that we haven't been together on this day & sure it doesn't feel that great but as they say it's not if it's when!
Very Happy b'day wishes to a person whom I have the privilege to know and be with, wish you good luck & lotsa happiness and sunshine and hope to be with you on 8th of march, 2006 and all the 8th of marchs then after.
Saturday, February 26, 2005
Love is on the run
February 24th was anniversary of two people both of whom are very close to me. They came together 2 years back and have been lost in love & each other since, but twist of fate, circumstances or whatever else you wanna call it, they haven't been together off-late. Knowing them I know they still feel just the same for each other & would love to be together again. I wish them luck and hope they'll come out of their hard times pretty soon even stronger, I see them walking hand in hand in near future, do you?
Wednesday, February 09, 2005
Why Do I Blog?
(Aside: tried posting this blog via the email that blogger provides, more than 1 hr. and the entry has still not shown, guess it's better to post it via the web interface only!)
Read Eric’s post (http://blogs.msdn.com/ericgu/archive/2005/02/08/369506.aspx) about the hazards of writing blogs which is open to public. I’d been thinking about the same thing off-late: why do I blog, do I blog and hope that the “world” would read it or do I blog just for myself as that way I can maintain a web diary and scribble down everything and anything that comes to my mind? Well, I blog for myself and yes though I know that my “diary” is public and can be read by all and sundry I still blog just for myself. If people read it and leave a comment fine, if they don’t still fine with me. I have shared my blog address with very few people whom I know (as of now I can only think of only 3 who are pretty close to me) though a lots of my acquaintances know that I blog.
The one problem that I face while blogging is that at times there is something which is personal enough to be not shared among all the acquaintances, generally in those cases I blog about it obliquely, the ones who know about it understand what I actually meant, and the ones who don’t are free to draw their own conclusions. So why do you blog and what you do in cases where you don’t want all your acquaintances to know about something?
Read Eric’s post (http://blogs.msdn.com/ericgu/archive/2005/02/08/369506.aspx) about the hazards of writing blogs which is open to public. I’d been thinking about the same thing off-late: why do I blog, do I blog and hope that the “world” would read it or do I blog just for myself as that way I can maintain a web diary and scribble down everything and anything that comes to my mind? Well, I blog for myself and yes though I know that my “diary” is public and can be read by all and sundry I still blog just for myself. If people read it and leave a comment fine, if they don’t still fine with me. I have shared my blog address with very few people whom I know (as of now I can only think of only 3 who are pretty close to me) though a lots of my acquaintances know that I blog.
The one problem that I face while blogging is that at times there is something which is personal enough to be not shared among all the acquaintances, generally in those cases I blog about it obliquely, the ones who know about it understand what I actually meant, and the ones who don’t are free to draw their own conclusions. So why do you blog and what you do in cases where you don’t want all your acquaintances to know about something?
Monday, February 07, 2005
Who is John Galt?
[Update (2/14): Got author of Celestine Prophecy all messed up, it's James Redfield and not Robert Redford as I mentioned in my post!]
Read two books off-late: Atlas Shrugged by Ayn Rand & Celestine Prophecy by James Redfield. Both books more or less have a philosophical tinge, Atlas Shrugged is about the "movers" of the world and why they fight their biggest & hardest battle against the people whom they love, Atlas is the greek mythological God on whose shoulder the entire earth's weight rests. Atlas carries the burden of the world unselfishly and the world in return just keeps on adding to the weight. In this book, Ayn Rand suggests that Atlas should shrug the world off his shoulders. Book is pretty crisp in the beginning but meanders a lil' towards the end and gets more or less Bollywood style ending! Net net I would rate this book above average but not something amazing.
Celestine Prophecy is a parable which gives you 9 insights into the life, some of the insights being: Co-incidences don't exist, everyone you meet has a message for you etc. etc. The books draws metaphors from physics and relates our lives to relativity and kinetic model i.e there is no static amt. of energy within this universe, based on our energy level the energy around us also increases or decreases. This book is more or less like Alchemist though Redfield lacks Coehlo's style of writing...again something which I would rate slight better than average.
By the way for those who are wondering, Who is John Galt? is a slang used very often in Atlas Shrugged & is used in situations about which ppl. are helpless or want an alibi.
Thursday, February 03, 2005
[No Title]
Have been trying today to change the look and feel of my blog, haven't made any progress yet but found that www.blogskins.com has some nice skins for both Blogger and MovableType. I picked up one template and tried making one on my own but guess don't have any patience/time to do it, so another one goes in my pending list.
What else? everything else is same old, same old: have to stay in the office late these days due to almost daily conference call with the client, it's one of the things that I really hate about Onsite-offshore model, other thing that I hate is the communication gap that can arise due to not having a face to face interaction. IMO face to face conversation is far more better than talkin over phone or chatting over IM or just exchanging mails back and forth. One of my teammate over here is planning to move on, got an offer from a big company (A..) The work seems to be nice and hopefully he will learn a lot more than wasting his time over here. Good luck to him in future! it was sure nice working with him.
Finally got myself a birthday present: it's a Fossil leather strap watch, looks nice I guess though I keep on forgetting to put it on as am not used to wearing a watch.
Tuesday, February 01, 2005
Days of future passed
Haven't been feeling great for some reason today, nothing has changed; things are just as I expected them perhaps that is what is making me feel a little low: that things haven't changed off-late and going on in the same direction where they've been going since past few months which is basically going nowhere. Work life is nearly non-existent, I can't make myself to work these days, if I get some work I fret and try to push it back as much as I can: something which I never did before, maybe it's because I don't like the job that I am into or maybe it's because I don't want to work! I don't know what is the reason but it's screwing me no doubt. After-work life is also non-existent perhaps even more than the work life: in office I feel like going home and when I reach there, I feel like coming back to office.
Looking back at the last one year from 1st Feb to 1st Feb, life has changed so much, perhaps way too much for me to handle. Feb, Mar, Apr, and May were the best months and since then life has been going downhill and even though it's going down consistently but at times thigns have happened way too unexpectantly, the worst of months being June and Dec. and the way Feb 1st has been, perhaps even Feb. Don't know how to handle things maybe I need to stop expecting from people, maybe I need to do some introspection and see what I've been doing wrong, or maybe I just need to shut my mind and stop thinking all together!
Thursday, January 20, 2005
Technical mumbo jumbo
Thought will write a small note about few things about .net which are not too obvious.
a) Difference between new and virtual methods:
We all know that new keyword(Shadows in VB.Net) is used to obscure a base method implementaion which is not declared as virtual. This particular functionality is particularly useful when you are inheriting a "third-party" library's class where the original developer didn't find it necessary to declare the method as virtual (Aside: Another flame say we are building a class library which can be used/extended by any set of developers shall we make all possible methods virtual or only those methods which we "think" might need to be overridden: I think it should be the latter). Given the "power" of new why does one have to declare his method virtual when anyway the inheriting class can obscure the base implementation whenever he needs to? Let's take a look at a sample code around new keyword:
class Base
{
public string A()
{
return "base";
}
}
class Child : Base
{
public new string A()
{
return "child";
}
}
public static void Main()
{
Base b = new Child();
Console.WriteLine(b.A());
}
Any OO guy would tell you that in the above code Child's A() should be invoked but that's what sets new apart from virtual. Which particular implementation is invoked in case of new is totally dependent on the variable type and not on the instance type (unlike virtual methods), since the variable type is of Base class, Base.A() would be invoked and "base" would be printed. As you can see "new" breaks a lotsa OO rules so my advice would be to use it only where it is absolutely necessary and perhaps usage of new in an application signifies a bad design.
b) Implementing multiple interfaces:
Another code snippet:
interface I1
{
string A();
}
interface I2
{
string A();
}
class Concrete : I1, I2
{
public string A()
{
return "A()";
}
}
public static void Main(){
I1 i1 = new Concrete();
Console.WriteLine(i1.A);
I2 i2 = new Concrete();
Console.WriteLine(i2.A);
}
Since C# allows implementing multiple interfaces which both define a method with same signature I need to only implement it only once and in both the above case "A()" would be printed. But what if I want different implementation for the A() declared in the two disparate interfaces? Here's how to do it:
class Concrete : I1, I2
{
string I1.A()
{
return "I1.A()";
}
string I2.A(){
return "I2.A()";
}
}
Another thing that never struck my mind was that there is one more way of making a non-inheritable class instead of using the keyword "sealed"...just make the ctor private, the only problem with this approach being that also means that no one can do a "new" on this class, stilll wondering though why would not want to use "sealed" keyword in such a scenario.
a) Difference between new and virtual methods:
We all know that new keyword(Shadows in VB.Net) is used to obscure a base method implementaion which is not declared as virtual. This particular functionality is particularly useful when you are inheriting a "third-party" library's class where the original developer didn't find it necessary to declare the method as virtual (Aside: Another flame say we are building a class library which can be used/extended by any set of developers shall we make all possible methods virtual or only those methods which we "think" might need to be overridden: I think it should be the latter). Given the "power" of new why does one have to declare his method virtual when anyway the inheriting class can obscure the base implementation whenever he needs to? Let's take a look at a sample code around new keyword:
class Base
{
public string A()
{
return "base";
}
}
class Child : Base
{
public new string A()
{
return "child";
}
}
public static void Main()
{
Base b = new Child();
Console.WriteLine(b.A());
}
Any OO guy would tell you that in the above code Child's A() should be invoked but that's what sets new apart from virtual. Which particular implementation is invoked in case of new is totally dependent on the variable type and not on the instance type (unlike virtual methods), since the variable type is of Base class, Base.A() would be invoked and "base" would be printed. As you can see "new" breaks a lotsa OO rules so my advice would be to use it only where it is absolutely necessary and perhaps usage of new in an application signifies a bad design.
b) Implementing multiple interfaces:
Another code snippet:
interface I1
{
string A();
}
interface I2
{
string A();
}
class Concrete : I1, I2
{
public string A()
{
return "A()";
}
}
public static void Main(){
I1 i1 = new Concrete();
Console.WriteLine(i1.A);
I2 i2 = new Concrete();
Console.WriteLine(i2.A);
}
Since C# allows implementing multiple interfaces which both define a method with same signature I need to only implement it only once and in both the above case "A()" would be printed. But what if I want different implementation for the A() declared in the two disparate interfaces? Here's how to do it:
class Concrete : I1, I2
{
string I1.A()
{
return "I1.A()";
}
string I2.A(){
return "I2.A()";
}
}
Another thing that never struck my mind was that there is one more way of making a non-inheritable class instead of using the keyword "sealed"...just make the ctor private, the only problem with this approach being that also means that no one can do a "new" on this class, stilll wondering though why would not want to use "sealed" keyword in such a scenario.
Thursday, January 13, 2005
Gizmo wishlist
Update 05/26/05:
Update 05/07/05:
Update 05/07/05:
A laptop (I like the dell model).(got the Dell Inspiron 600m yesterday)
- 20GB IPod.
A Sony or Cannon 5Mega Pixel Digi cam(ordered Canon A95 @ Amazon today).- Handspring Treo or HP IPaq smartphone.
My birthday is on 1st so please to gift me one of these.
Tuesday, January 11, 2005
Tuesday afternoon
My songs wishlist:
1) Bless the wings : The Moody Blues (Just can't understand how can this band come with such amazing lyrics).
2) Driftwood : The Moody Blues.
3) Still...you turn me on : Emerson, Lake & Palmer.
4) From the beginning : Emerson, Lake & Palmer.
5) Broken Dream : The Moody Blues.
6) The sun ain't gonna shine anymore : The Walker Brothers.
Somewhere there’s children playing,
Somewhere far away running with open arms to greet me.
Over the hill the sunset dies and fades away.
I turn and I close the door with one last goodbye,
I will return no more, I’ll take my heart and let it fly.
-Justin Hayward (Broken Dream)
1) Bless the wings : The Moody Blues (Just can't understand how can this band come with such amazing lyrics).
2) Driftwood : The Moody Blues.
3) Still...you turn me on : Emerson, Lake & Palmer.
4) From the beginning : Emerson, Lake & Palmer.
5) Broken Dream : The Moody Blues.
6) The sun ain't gonna shine anymore : The Walker Brothers.
Somewhere there’s children playing,
Somewhere far away running with open arms to greet me.
Over the hill the sunset dies and fades away.
I turn and I close the door with one last goodbye,
I will return no more, I’ll take my heart and let it fly.
-Justin Hayward (Broken Dream)
Subscribe to:
Posts (Atom)