Tuesday, October 27, 2015

Steve Jobs explains what Object Oriented Programming is in Rolling Stone interview 1994

Interviewer: Would you explain, in simple terms, exactly what object-oriented software is?


Steve Jobs: Objects are like people. They're living, breathing things that have knowledge inside them about how to do things and have memory inside them so they can remember things. And rather than interacting with them at a very low level, you interact with them at a very high level of abstraction, like we're doing right here.

Here's an example: If I'm your laundry object, you can give me your dirty clothes and send me a message that says, "Can you get my clothes laundered, please." I happen to know where the best laundry place in San Francisco is. And I speak English, and I have dollars in my pockets. So I go out and hail a taxicab and tell the driver to take me to this place in San Francisco. I go get your clothes laundered, I jump back in the cab, I get back here. I give you your clean clothes and say, "Here are your clean clothes."

You have no idea how I did that. You have no knowledge of the laundry place. Maybe you speak French, and you can't even hail a taxi. You can't pay for one, you don't have dollars in your pocket. Yet I knew how to do all of that. And you didn't have to know any of it. All that complexity was hidden inside of me, and we were able to interact at a very high level of abstraction. That's what objects are. They encapsulate complexity, and the interfaces to that complexity are high level.

Monday, October 26, 2015

Project Euler Solution using C#: Problem 29 : Distinct powers

Problem:

Consider all integer combinations of a^b for 2 ≤ a ≤ 5 and 2 ≤ b ≤ 5:

2^2=4, 2^3=8, 2^4=16, 2^5=32
3^2=9, 3^3=27, 3^4=81, 3^5=243
4^2=16, 4^3=64, 4^4=256, 4^5=1024
5^2=25, 5^3=125, 5^4=625, 5^5=3125
If they are then placed in numerical order, with any repeats removed, we get the following sequence of 15 distinct terms:

4, 8, 9, 16, 25, 27, 32, 64, 81, 125, 243, 256, 625, 1024, 3125

How many distinct terms are in the sequence generated by a^b for 2 ≤ a ≤ 100 and 2 ≤ b ≤ 100?

Solution:
static void Main(string[] args)
{
    var aMin = 2;
    var aMax = 100;

    var bMin = 2;
    var bMax = 100;

    List lst = new List();

    for (int a = aMin; a <= aMax; a++)
    {
        for (int b = bMin; b <= bMax; b++)
        {
            lst.Add(Math.Pow(a, b));
        }
    }

    var distinctRslt = lst.Distinct().ToList();
    distinctRslt.Sort();

    Console.WriteLine("Result : " + distinctRslt.Count());
    Console.ReadLine();
}

Output :

Wednesday, October 21, 2015

(Solved) Error: Unable to make the session state request to the session state server

Error:

Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same.  If the server is on a remote machine, please ensure that it accepts remote requests by checking the value of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters\AllowRemoteConnection.  If the server is on the local machine, and if the before mentioned registry value does not exist or is set to 0, then the state server connection string must use either 'localhost' or '127.0.0.1' as the server name.

Solution:

1. Go to Run command, type services.msc



2. Right click over the ASP.NET State Service and click Start or Restart if it is already Started.




Note:
You could set the service to automatic so that it will work after a reboot.