Thursday, February 23, 2012

Annotation in C# for mapping JsonProperty to a variable

If for some reason you are .NET Framework 2.0 and using Newtonsoft.Json libray than this is gonna be very useful.
You have a case where your Json property contains a '-' sign, than obviously you can't have a C# variable to map the same as variable naming scheme does not allow - signs.

I recently faced a similar problem and spent hours googling to figure out how to do it in .net 2.0 but all the efforts were in vain. Than after a lot of hit and trial and reading source files I hit this annotation JsonProperty("my-name") and hurray it worked. Just to provide a small example usage:

JSON:
{"my-name" : "Biplav"}

C# snippet:

public class Name
{
   private String m_my_name;


   [JsonProperty("my-name")]
   public String my_name 
  {
      get { return m_my_name;}
      set  { m_my_name = value;}
  }

Tuesday, February 21, 2012

How function overriding is different in C# from Java?

If you are moving from Java to C#, than this is one thing which you would find very funny.

Suppose you wrote the following code:

class a
{
   public void display() 
   {
     Console.WriteLine("A");
   }
}

class b:a
{
   new public void display()
   {
    Console.WriteLine("B");
   } 
}

And did something like:

A a = new B();
a.display();

B b = new B();
b.display();

The output would be:
A
B

Although we expect here that as we have overriden display in B, so the display of B must be called. But this assumption is incorrect as we have reserved reference for A, so the C# compiler won't know that B can override display function. Hence we need to tell the compiler that there is a possibility that display can be overriden in derived classes and please check for it. To do so we would have to define the baseclass function which can be overriden as virtual and than use override keyword in all the derived classes. So that compiler can create a function pointer map or whatever it creates and point correct function pointer for various derived types.

This is done in the following way:


class a
{
   virtual public void display() 
   {
     Console.WriteLine("A");
   }
}

class b:a
{
   override public void display()
   {
    Console.WriteLine("B");
   } 
}

And did something like:

A a = new B();
a.display();

B b = new B();
b.display();

The output would be:
B
B

I hope this helps a few java developer to understand c#.
So, what i figured out from this is C# gives us a slight more flexibility for overriding a function with new but I am not yet sure will i like to use it? And if yes, a very good usecase for it.


Tuesday, February 7, 2012

Facebook Hidden Messages Folder

I did'nt notice this till now, and there are chances that you might not have too. There is a hidden(not exactly) messages folder on facebook where all the messages from you non-friends go to.


To reach this folder, first click on messages on the left-hand bar and than click on the others just below it. You might discover lots of messages from various contact since you have been on facebook. I was suprised to see that there were no. of messages/events from the pages i follow, which I would have loved to read and attend but now its too late :(.

On doing a little more research about this simple feature on Facebook, this is what i found on there blog


The Social Inbox

It seems wrong that an email message from your best friend gets sandwiched between a bill and a bank statement. It's not that those other messages aren't important, but one of them is more meaningful. With new Messages, your Inbox will only contain messages from your friends and their friends. All other messages will go into an Other folder where you can look at them separately.

If someone you know isn't on Facebook, that person's email will initially go into the Other folder. You can easily move that conversation into the Inbox, and all the future conversations with that friend will show up there.

You can also change your account settings to be even more limited and bounce any emails that aren't exclusively from friends.
This kind of message control is pretty unprecedented and people have been wanting to do this with email (and phone calls) for a long time. Messages reverses the approach to preventing unwanted contact. Instead of having to worry about your email address getting out, you're now in control of who can actually reach you.
 Apparently, this feature has been there since November 25th,2010 atleast. Wonder how i never bothered to click or even notice that Other link.

I am preety sure, by now you would have gon to check out your messages folder, so I can blabber a bit which is mainly my own observation.
On UX side of it, as the Other button is rightly less acessible as it is supposed to have unimportant messages, but i guess its too less. So how to solve it?
  • As soon as we click on Messages button, my eye balls are fixed on messages and I usually don't care about whats there on the left side, so a good approach can be having a button near New Messages on the top of the page, so that it would be hard to reach and one level down in the accessibility ladder.
  • A better descriptive name for others, may be a simple Un-Important would work more for me.
  • Have something like user-defined folders, etc before or after others , than the left section would catch more eye-balls. With just one sub-folder its tough to notice.
These are just a quick ideas which I can get. I am confident the UX engineers at facebook can come up with much better placement.

Thursday, February 2, 2012

junglee.com Review

Many of you would have seen junglee.com and would be wondering what so special about it? I was doing the same, till i had this unofficial interview with Junglee.com (JC). Read along:

Me: What is junglee.com ?


JC: I would like to describe ourself in one word, Product Search Engine, rather it became three.

Me: I can search on Google and find my product. Whats so special?

JC: Okie we have a product comparator. We would devoid you of the pain of going to various websites and comparing the prices and reading the reviews before you buy anything!

Me: Ahh!Now you are speaking sense. So you are advanced version of yellow pages. So, do i get the cheapest products over here?

JC: Yes and No.

Me: What do you mean "yes and no"?

JC: Technically, it lists prices from most of the online and offline stores in India. So you can get the cheapest price. But it does not have the prices from flipkart.com and infibeam.com

Me: What, I usually buy all my books from flipkart. Than how is it a product search engine if it can't search from the entire internet.

JC: There you go, you are already pointing fingers, wait a while, we are still in beta and we already have over "1.2 crore products and 14,000 brands" and hundreds of retailers. Give us some time, either we would kill them or else we would add them to our database.

Me: Oh, okie, so there is a plan out there. Sounds interesting. What is onething that I should love about you?

JC: The website easy to use, clutterless, single column design. Our site has taken inspirations from mobile sites and brought its simplicity and make sure it looks the same on all platforms. We have a huge search bar on top which reminds you of the purpose and lots of reviews and prices below that makes it easier for you to make your informed choice.

Me: Okie, so you are not selling products, than how does Amazon gains out of it. How will you earn?

JC: Thats a smart question, to answer that let me ask you one question. What the toughest things about selling. Can you list them?

Me: Ummm, to find customers, to find customer who actually want a product, to decide the price to offer him so that he can't decline, hmmm thats all i can think of.

JC: Are you a marketing guy? You just nailed it. So what junglee does is that make customers who wants to buy something, come over here instead of junglee looking for them. Than he searches for the product and sees the prices. We show him the prices from all the sites including amazon, if its available ;). We know what he wants, we know the prices offered by the competitors so we know the price to offer. Right now we just show handful of products from Amazon, but eventually when we would have a bigger presence in your country than we can push more products to him(and her -- we are not sexist) .

Me: Smart, so basically this is how you are trying to kill?

JC: Yes, kind of and moreover with the amount of real time data and our IITian Business and Data Analyst, we are sure to kill the competitions.

Me: If this is your plan? Than why are competitors tying up with you?

JC: This is the undercover business model, but actually we are like Justdial or Sulekha, we are just generating more leads for them. Why would they miss such an opportunity.

Me: Smart!! Is there any way I can compare prices from flipkart and infibeam on junglee?

JC: There are some smart people like Amit who has written some tools for it. You can know more about it over here.

Me: Thank you, that was quite insightful. All the best.











Building Successful Products in the Maze of a Large Organization

  *Image is generated using AI Large organizations offer a treasure trove of resources and stability for product development. However, navig...