so here’s the story, i got an interview at a consulting firm. since i already passed the preliminary technological interview this time around i was told that the interview is going to be focused on object-oriented design. so, i met the interviewer and he gave me a problem for me to solve. here’s the initial problem.

“suppose we have a class of Animal. because this is Animal class it can have much variety of Animal in the future. but for starters, let say if we have four different animals: Cat, Dog, Horse, and an Elephant. now, these animals have some behaviors such as sleep, run and carry. the rule for implementing the behaviors is to prevent any duplication of code, copy-and-paste is not good. i have defined several behaviors to you, but there will be more additional behaviors in the future. here’s the specific behaviors for the animals. all animals will be able to sleep and use the same sleep function. all animals can run, but each animal runs differently. only Elephant and Horse can carry things. remember, because we may have gazillions of classes in the future, any additions should have minimal impact to the module. build me your design.”

Read the rest of this entry »

Mail Support in .Net

March 26, 2008

.Net doesn’t have a native supported API like Java do (JavaMail). So, it’s up to contributors to do the job. One of the highly recommended library was Indy Sockets from IndyProject. The library was once implemented for Delphi and right now are being ported to .Net. However, I found the design and the functionality is still lacking and on different level with JavaMail (I only looked at the CLR code and not the Delphi version). So, here’s one of the things that I want to do when I got the time: Is to write a .Net Mail API that can be comparable to JavaMail.

it’s been a while since I looked at stl. and this trip into stl and c++ native programming really brought me into senses once again. i built a simple project using stl, the program itself is very simple. i want to have a dictionary where entries can be looked-up using strings and the result is also in strings. only this time, i want it all to be in stl. i know that we can use map to do this, but to brush up my skills and to see the effect of composability, i used a list combined with a pair in the structure. it’s a one liner very easy. or so i thought.

 the problem arises when i tried to use find to get an entry. suddenly all hell break loose. all those cryptic stl error messages pouring down in my error window and it forced me to decrypt the messages one by one. the problem seems to originate from the inavailability of string operator==. so, i figured that the string operator== needs to be defined. no sweat. bool operator== ( const string& left, const string& right )… that should do it. but no, the error just wont get away. okay… maybe the pair operator== needs to be defined: bool operator== ( const pair<string, string>& left, const pair<string,string>& right )… no sweat.

again, i tried to recompile it, but the error just refuses to go away. what happened? doh… i tried various thing. i changed the pair to a pair of ints, it went smooth. i tried various combinations, i tried putting the find logic itself out from the funtion and put it in the source, but to no effect. after i tried for a while, i thought it is the time to try google. so i did. I surfed through the forums, but c’mon no forum will discuss this kind of problem specifically right? instead, i found a hint. written in a forum is a small advice: ‘put it inside the std namespace’. then it struck me! damn, i declared the operators outside the namespace! i put it inside the namespace cage, and… voila! everything works fine.

things that i learn:
1. mind the namespace.
2. decrypt stl messages by means of substitution, eg: basic_string<char, chartraits> = string
3. don’t blame the library. 99.99% of mistake is of your own doing (as i have written before)
4. respect the semantics.

about no.4, i have given a thought why string doesn’t have operator== defined. i dont have the full answer, but i guess it might be because of performance problem. or, because of semantic problem.

just found this video on the internet. very funny.

posting in a forum…

February 8, 2008

lately there’s been quite a stir-up in Channel9. the problem is about a newcomer that just entered the forum for a while. well, being a newcomer i know that we shouldnt have expect much of him. but a series of controversial and provocating threads that he started drove most of the community against him. it wasnt really that bad. knowing that most of channel9 members are decent people, i know that it couldnt get seriously bad like what ive seen in other forums. but, this move against him makes the newcomer feels very unwelcome at c9. some of us tried to easen the situation and we tried to give him an understanding on why does it happens and what he did wrong as well as not taking all of it too seriously or literally. but he just cant except it and then vowed not to return to the general forum (and move to the tech-forum) ever again,… by posting a thread saying goodbye. Read the rest of this entry »

ネットをしらべた結果、日本では.Netフォーラムはあまり存在しないようですね。それは結構かわいそうだと思います。.Net開発は日本では結構新しいのでまだ分っていないところ結構あると思います。ですが、聞く場所がないのでほぼ皆さんハック(hack)をしたり遠回りにしたりすることになりました。どうかこの状態を助けたいなぁとちょっと思いついたが自分の日本語はそんなに自慢できるレベルではないのでなかなか自身つきません。.Netに興味がある皆さん、これはただ小さなのブログなんですが質問があれば遠慮なくコメントに出してください。できるだけお返事します。

client for 2channel (2ch)

February 7, 2008

 so, because of the super-ugly appearance of 2channel and because it is so unintuitive to always refresh your browser to keep up with the thread in there, i thought of writing a client for it. well, of course there are other clients that is available for it as my friends have told me once. but, then after looking for a while, i know that there’s client that’s based on .Net. furthermore, there’s none for WPF. so, i thought it might be nice if i can make one.

 however, looking at how 2channel works, i began to wonder if there is a special API for this to work. i mean, if there are clients outthere, it’s not too much hoping somekind of ‘backdoor’ like webservice or rss feed available, isn’t it? my search returns me nothing. oh well, maybe it is unofficial or seldom discussed API or something, so i looked up at 2ch free open source clients and pop the source code open on my VS…. to my suprise, they’re all parsing the html page and building their request strings manually (doh). it seems that 2ch doesnt have an API from which a client can hook-up to. plzzzzzz give us an API.

 btw here’s the clients that i’ve been talking about:

Follow

Get every new post delivered to your Inbox.