Pages

Showing posts with label software. Show all posts
Showing posts with label software. Show all posts

April 01, 2007

Object Oriented Thinking.

If you are not programatically inclined, the code below just proves the point that I spend the major part of my day thinking thoughts that are not really worth thinking (you might want to read the stuff in green though). I spend the few precious minutes left behind (if any) thinking the thoughts that I really ought to be thinking. So why did I post this class below if I know the result already?

Because this is one crazy space
(nothing extraordinary goin' on up there) and I plan to maintain it that way :p

/*
* Class to estimate how I end up spending all the time
* in my life. Best results when program is executed every
* 6 months and results compared.
*/
package com.lex.rs.thoughts;

public class ThoughtsOfRS
{
public static final boolean confused = true;
public static final long SECONDS_IN_DAY = 43200;
public static final long MAX_TRIVIAL = 10000;
public static final long MAX_RANDOM = 5000;
public static final long MAX_CRITICAL = 5000;
public static final long MAX_PAST = 5000;
public static final long MAX_FUTURE = 5000;
public static final long MAX_HYPOTHETICAL = 5000;
public static final long MAX_INDIA = 5000;

//Variable introduced after k explained that my previous class
//assumed I would think trivial thoughts all day long!

protected long actualTrivialTime = 0;

ThoughtsOfRS()
{
//Note that this does not honor the
SECONDS_IN_DAY field.
while(confused)
{
think();
}
}

public void think()
{
initTrivialThoughts();
initRandomThoughts();
initCriticalThoughts();
initPastThoughts();
initFutureThoughts();
initWorthyThoughts();
}

public void initTrivialThoughts()
{
long startTime = System.currentTimeMillis();
brain.getTrivialThoughtsFromCache();
brain.processTrivialThoughts();
brain.recheckProcessing();
brain.storeChurnedThoughtsToCache();

long endTime = System.currentTimeMillis();


actualTrivialTime += endTime - startTime;

if (actualTrivialTime > MAX_TRIVIAL)

{
brain.storeChurnedThoughtsInLongTermMemory();
addToLoadForTomorrow();
actualTrivialTime = 0;
return;
}
else
{
initTrivialThoughts();
}
}

//Similar methods for random, future, past, hypothetical and
//critical thoughts in decreasing order of importance.


public void initWorthyThoughts()
{
long otherTime = MAX_CRITICAL + MAX_FUTURE + MAX_HYPOTHETICAL;
otherTime += MAX_INDIA + MAX_PAST + MAX_RANDOM + MAX_TRIVIAL;
long worthyTime = SECONDS_IN_DAY - (otherTime);
//As of current estimate, I get a whopping 3200 seconds to
//think all of my worthy thoughts !
}
}
/*
* If the GOF ever read this program, they would definitely publish this
* as a classic antipattern. Oh well, as long as I get my name on a published
* book...*sheepish grin*
*/

/*
* If you work with me, just fyi this is my evil twin who doesn't know a
* thing about programming.
*/

/*
* And if you are wondering about the weird green and yellow color theme (I know this link is not blue, but humor me and click it anyway :p)
*/

© Ramya Sethuraman, All Rights Reserved.