Randomness: 5:01 A1C

I had been putting off taking my A1C for at least a few months.. knowing that I was slacking off on being regular with my medication, and I had been eating crap and drinking pop.    Last time it was taken was at the doctor’s, I think it was a 6.0 or a 6.2, which is technically really good, I was sure it would be up around 6.5 or 7.0 by now.

So after all kinds of procrastination (I need to do dishes… no, the lawn first… how about some more minecraft… I can’t find my self-test kit…) I finally took it.

5.7 ??? WTFudge?   That’s AWESOME!

I’ve been on a semi-gluten-free diet.  As in, avoiding gluten Sunday-Thursday, and then treating myself on Friday and Saturday.  

“Treating” is a relative word.. “enjoying delicious treats” followed by “twitchyness, and joints that hurt”.  

“Avoiding” is also a relative word.   More like “1 oreo cookie every two days”.    Occasional donut relapses.  Its so hard to turn away when they are placed in front of me.  I could easily be a food addict.. I love my sugar, and eating in general.  (I have been to OA.  I will go if life becomes unmanageable.  They are good folks.)

I think this (relative) lack of gluten in my system.. is what has been saving me.  So I can have that pop without guilt, right?  No, maybe I’ll have a Coke Zero or Diet Pepsi instead.   There’s something in regular Pepsi that I absolutely crave, that I don’t get from regular Coke.  

5:01 And I’m Outta Here

There’s an article going around, I just caught it off the S.H. feed:  

I feel guilty about this. 

  • Very often I am watching the clock, trying to get all my billable hours in to continue justifying the wonderful salary that I’m paid.
  • When I was in my 20’s, I definitely coded for fun.  A lot.    At its worst, my life was: drive to work, drive from work to a college campus and code for 2-3 hours, drive home (125 miles total) and code some more.  Eat at Wendy’s.    I was involved in running an LPMud, and there was a lot of fun stuff to create, and I loved it.
  • I receive a boon of 4 hours of “personal coding time” at work to have fun with.  I look forward to using it every week.   I have two projects to work on it with.  But all it takes is one day where I don’t meet the billable hours, and I loose a little more play time.    Like today: I had to leave early so I could be an announcer at my son’s soccer game.
  • I think the truth is, I have about 6 hours of “natural focus” in me that I can apply towards coding.  After that, my brain just plain shuts down, and it takes a lot of energy to try to kick start it into focusing more.   And because I’m in an environment where there are no meetings, there’s nothing to distract me from coding.. I hit that wall very quickly.  

But I can be proud of myself too:

  • So far, this job has been my best trade:  hours for pay, + in line with the joy of learning good things, + the joy of working with good people.     I’m going to keep on doing it, as long as I am able.   Wrist braces do help, as do adjustible-height desks and larger (25”+) monitors.  #lawn
  • It may take me 50 hours of “clock” time, but I am definitely going to give them their money’s worth.   Because I’m definitely better for it as well.
  • To that end, I’m willing to go at my natural pace during the week.. not push it too hard.. and if I have to work on Saturday, try to do it with as little of a hissy as possible.  Note: not my employer’s request.  My own voluntary contribution. (The hissy is directed at myself)
  • If I do get to noon on Friday, and I have 4 hours of joyful coding time available to me.. queue the Oh Yeah! song by Yello.  http://www.youtube.com/watch?v=Tq0skIEkfUw
  • And I seriously get good stuff done at work.  I am of service, I build things, I am detailed, and my work is solid.    I get it done.
  • When paired up with a more passionate faster developer, I switched gears:  Make sure he is unimpeded, shield him from other’s ineptitude, and watch him shine.     I wouldn’t want to make that my day job, but wow, that was an interesting experience.

Bye Bye iPad

I gave my iPad 1st Gen 3G to my mom.  She needs it for internet access at her store .. so she can show her customers what options they have.    (KCUniforms in Morgantown, WV).  I only twitch a little bit, at night, now that its not here.

The plan is to buy another tablet towards the end of the year, hopefully with the Christmas Bonus.  I haven’t made up my mind yet.. I know for sure it will have a Retina display, but I need to see what Windows 8 goodness comes out in October.   The default would be an iPad3, but there’s some really strong contenders, and honestly I get more done on Windows.  

Entertainment List

There is way more entertainment available to me than I have time for.   This gives me the ability to say “that’s wonderful, but Nope” when new options arise.. like the impending release of Borderlands 2, which has my work buddies all in a tizzy, and the previously released Diablo 3.    My list right now for entertainment is:

  • Brainveg: catching up on Facebook, Twitter, and several blogs including Slashdot Science and Geek{Mom|Dad}
  • TV: shared with wife:  Dr Who, Top Gear America, Grimm.  Thank you Tivo!
  • Music:  Listening to more current music (compared to: 80’s), really enjoying Maroon 5 at the moment
  • Comics: Schlock Mercenary (I just got the new board game!)
  • Games:
  • Books: http://www.warriorcats.com/warriorshell.html  2 more left to read in the original series

Okay.  Family is home.. the game tonight was rough, my kid got tangled up and was the source of a PK; we lost 3-1.  One of his best friends got nailed with 5 seconds left, has a concussion (ouch).  Son and Wife are torturing the opinionated cat upstairs right now (lovingly), I better go and see what’s up.

Cheerio!

Selenium

I started using Selenium with my current client .. on the side, mostly because logging into the website involved: “wait click text text click click text click wait click wait click”. Additionally, any time I compile, it wipes my logged in session, and thus repeat. 

Last night at my son’s soccer game, I was chatting with another technical parent.. he was starting to use Selenium also!  In his case, Selenium IDE and converting that into code for tests.   Having played a bit with that side of things, and ending up with Selenium WebDriver + some ideas of how to do it nicely, I decided to compose this post to share my experiences so far. 

  • Code on Github (learning github for windows);
  • VS2012, Nuget package restore enabled;
  • Total time taken to write code (from scratch) = Less than taken to write this post talking about the code.  

Targeting NerdDinner

My client would have a cow (and a chicken, and maybe several other barnyard animals) if I put any of their code outside their network.  And I’d get fired.  So I recreated the pattern I am using against www.nerddinner.com.  A certain dude whom I respect created it as a demo website. It had about the right mix of complexity – it was not just searching on google  – but it wasn’t navigating gmail either.  Thank you Scott.

First Attempt at Code.

See github branch here; Excerpt from here

        [Test]
        public void MainPage_CanSearchForDinners_ButNeverFindsAnyInKY()
        {
            using (IWebDriver driver = new FirefoxDriver())
            {
                driver.Navigate().GoToUrl("http://www.nerddinner.com");
                var input = driver.FindElement(By.Id("Location"));
                input.SendKeys("40056");
                var search = driver.FindElement(By.Id("search"));
                search.Click();
                var results = driver.FindElements(By.ClassName("dinnerItem"));
                // at this point, i don't know what to do, as there's never any search results.   
                Assert.AreEqual(0, results.Count,
                                "No dinners should be found.. omg, if this works, then its worth it to change the test");
            }
        }
  • This code is using NUnit (out of scope for this post)
  • This is how you navigate
  • This is how you find things
  • This is how you send text
  • This is how you click things
  • Every time you run, you’re starting of with no cookies, so you’ll have to log in every time.

Whee.  Good start.  Okay, now lets get serious[er]. 

Second Pass At Code

Per the recommendations of Jim Holmes (@aJimHolmes, http://frazzleddad.blogspot.com/), whom I met in person at http://www.codepalousa.com/ and whom I have also derived a great deal of respect, I know what smells funny:

  • The first pass is very brittle.  If somebody changes an ID or a classname, you have a LOT of tests to go change.   Solution: Page Pattern
  • What does one do when one does not have a second bullet, but there seems like there should be one?

What I accomplish with all this Jazz:

image

The overall branch is here; the rewritten test here:

        [Test]
        public void MainPage_CanSearchForDinners_ButNeverFindsAnyInKY()
        {
            MainPage.LocationToSearch.SendKeys("40056");
            MainPage.SearchButton.Click();
            var results = MainPage.PopularDinnerSearchResults;

            Assert.AreEqual(0, results.Count,
                            "No dinners should be found.. omg, if this works, then its worth it to change the test");

        }

Much simpler.  The Page Helper Class is here, and partially looks like:

    public class MainPage : PageBase
    {
        public MainPage(IWebDriver driver)
            : base(driver)
        {
            Wait.Until(d => d.Title == "Nerd Dinner");
        }

        public static MainPage NavigateDirectly(IWebDriver driver)
        {
            driver.Navigate().GoToUrl("http://www.nerddinner.com");
            return new MainPage(driver);
        }

        public IWebElement LocationToSearch
        {
            get { return Driver.FindElement(By.Id("Location")); }
        }

        public IWebElement SearchButton
        {
            get { return Driver.FindElement(By.Id("search")); }
        }

  • The constructor takes and stores a reference to the Driver.  The calling program is responsible for creating and disposing the driver (as its an expensive resource)
  • It uses a PageBase class which creates an additional WebDriverWait (the Wait variable)
  • The constructor waits until we know we’re on the right page.  This allows us to click something somewhere else, and new up this object, and then wait till the page actually loads. 
  • Because this is the root of the website, I include a NavigateDirectly() routine which says “I don’t care where you were, now go to this page”.  I only do this on overview or login pages, the kind not derived from a click.
  • It exposes IWebElements to the callers (tests) so they don’t need to know where on the page various things are located.
  • In WebForms – I have to implement extension methiods which search IWebDriver and IWebElement for id’s Ending In Text, because ID=”btnSearch” ends up being “ctl00.BoogerBooger_04.HumDeDum_03.YabbaDabba.WickedBackbtnSearch”

Another excerpt (here):

public List UpcomingDinners
        {
            get
            {
                var upcomingDinnersUl = (from e in Driver.FindElements(By.ClassName("upcomingdinners"))
                                         where e.TagName == "ul"
                                         select e).FirstOrDefault();
                if (upcomingDinnersUl == null) throw new NotFoundException("could not find ul.upcomingdinners");
                return upcomingDinnersUl.FindElements(By.TagName("a")).ToList(); 
            }
        }
  • When doing complicated finds, I usually search By.ClassName or By.Id or whatever first, and end up with e.TagName second, because they do NOT provide an e.Id or e.ClassName routine.   (You can do e.GetAttribute(“id”) but I’m not sure if that returns null or empty, and nulls can be a bummer).
  • new ByChained(x,y,z) does not mean an element which matches x,y and z, but instead an element x which contains an element y which contains an element z.   

Third Pass – the Developer Helper

If I run the Console App which is the library that has all the page helpers, I get something like this:

image

  • The purpose of this app is to let me quickly get to sections of my website that I need to play around in.
  • The keywords yield a more detailed list; the more detailed list is used in navigation; using the old trick of:
    delimited = “|“+delimited+”|“; if (delimited.contains(“|xxx|“) … 

    which is what we did before arrays #GetOffMyLawn #WheresMyTeeth

  • Once the site is up, it stays there (until I choose somewhere else to go)

Additionally, in tests, I redid the creation/deletion of the driver as follows:

        [TestFixtureSetUp]
        public void FixtureSetup()
        {
            
        }

        [TestFixtureTearDown]
        public void FixtureTeardown()
        {
            AbandonDriver();
        }

        [SetUp]
        public void TestSetup()
        {
            if (Driver == null) Driver = new FirefoxDriver();
            MainPage = MainPage.NavigateDirectly(Driver);
        }

        [TearDown]
        public void TestTeardown()
        {
            
        }

        private void AbandonDriver()
        {
            if (Driver != null) Driver.Dispose();
            Driver = null;
        }

  • I am not creating a driver for every test; however if a test is going to mess up the relative state of a driver, it can be abandoned and a new one started.
  • This saves several seconds per test, which helps once you break the 5-6 test mark.  Especially if what is saved is not as much “start the driver”, but more “start the driver, go to the web site, log in, and get to the page of interest”.

Conclusion

Once you’ve done it once or twice, its remarkably easy to write some pretty neat tests.   This may not be the perfect way to do it, but its something that works for me; hope it works for you!

Minecraft #2/2: Layers of Adventures

When I searched for information about Minecraft, I found a lot of mind-numbing detail.. and a lot of tutorial videos.. but nothing I could use as a roadmap through the overall game (other than the achievements thing inside the game, which I somehow missed for quite a while).  So, I’m putting this together.  Its what I know so far.. there are many more things which could go on here, but I think this is the basics to get to the advanced stuff.

Adventures in Minecraft

Image creation notes – used desktop wallpaper from http://minecraftwallpapers.com/blueskys-96.html ;  Diagram created with CreateLy

I’ve tried to arrange all the above-ground stuff on the top-right, and the below ground stuff going, well, down.

One Side effect I have noticed:  When I first started playing, getting 4 blocks of wood seemed monumental, I had no idea of the scale at which I could grow and harvest things.  As a result, I held onto those 4 blocks, the single chest, etc, very tightly .. all resources were scarce.. till I learned how to plant trees and get renewable and efficient.  I think the same is true in real life … as I learn the patterns of real life, I go from being scared in the world to being confident and efficient. 

Click the image to zoom in on the detail. 

A Word on Mining

Each time I do a mine, I seem to pick a different pattern.. I’ve finally found one that I think I like.  Its related to Branch Mining Layout #1 in this Wiki article … with these additions:

  • The center section is 3×3 or 5×5 with a tunnel going straight up.   I’m having very good luck with branches every 6 (ie, skip 5 then start a new branch).
  • Try to keep all the ceilings 2 tall so that Endermen cannot teleport in
  • Use Wood Panels as markers – this way back to center – and as markers to know where I found something (because I’m filling as I go)
  • If I break into a cave, patch that enterance with wood paneling – which serves as a reminder to self, don’t open this.  (Problem: Mobs will spawn in there.  Endermen teleport.  Hence the ceiling height)
    • I suspect after I master lava I might try some creative way of killing all mobs in a cavern
  • Use Shift-F3 to see real light levels; drop a torch on the ground when RL=3 yields an overall lowest light of 8 between torches which prevents mob spawns.  Even better, use the torches at every 6 (branch mine) just as a pattern.
  • When I go down some levels, leave 3 blocks between levels (ie, go down 5) – and then do the branches the other way (if it was an east/west the first time, do north south the next time).

Bulk Mindset

I am finding that instead of doing things “just barely what I need” (ie, I need 4 wood, get 4 wood), its more efficient to batch up my operations.  So If I’m planting wheat, I plant 21 in a row yielding 63 harvest – which gives me a full stack.    If I’m creating torches, I create all 64 of them.    This way I’m not context switching all the time.

Further Adventures

These are the things I have not yet done (and may not get around to … or I might …)

  • Travelling in search of another NPC village (the one that my friends found, we didn’t protect the villagers, and now they’re all dead.)
    • “Villager Farming” .. growing the village (something about Golems?)
  • Visiting the other Biomes (or starting basic survival in one of them)
  • Building Railroads and Powered Rails for fast transport
  • Building above ground (everything I’ve done has been a hobbit-hole dwarven lair type of thing)
  • Building under water
  • Playing with Gunpowder and TNT
  • Playing with Lava
  • Playing with Circuitry
  • Pets
  • Enchantments
  • Endgame

Minecraft #1/2: What I love about Minecraft

imageThe last two weeks I’ve been spending every free waking hour (and some I should not have spent) playing Minecraft.  A lot of people don’t get it.. and that’s okay.  I have a lot of thoughts floating in my head, so here’s my geeky post.  #TrueToSelf  (image: view of HobbitHole v2.0 – showing tree farm, animal farm, sugar cane and wheat)

What I love about Minecraft – Background

Back in the 90’s, I coded the equivalent of BCL’s on an LPMUD (related: LPC programming language) named Vincent’s Hollow.  (Its dead now – the software doesn’t run on any modern O/S).  Some of these included: the standard monster model, weapons, armor, statistics/enchantments, talk and chat system, email client, etc.   It was the most fun I ever had coding in my life.   (In addition to learning OOP and how to build amazing reusable systems, I also learned what it takes to lead (herd) a group of volunteer programmers, teach people to code, and in retrospect, the most important, to love people for who they are.)

I also loved the games NetHack (well, Moria to be exact) and Ultima 5.  They had a top-down game play that worked well for me – using my imagination to see what that world looked like. It was seamless, I did not see blocks, I saw beaches and woods and paths and stuff. 

As I proceeded in my paid career.. every new technology I learned – and I’m dating myself here — Clipper, SQL, Perl, C#/.Net, Signal/R, Mongo – I dream[ed] of writing a Mud with it.  It has never truly left me.  (related: when I saw WoW, it raised the bar so high that I could never touch it.  The dreams subsided for a while) (related link: my 2004 attempt at a mudding livejournal.  Precious.) 

While being a Mud “director”, I also spent a lot of time thinking about where gameplay could go.  I saw people get up to the level max of 20, and then.. then what?  Not everybody wanted to code.   So I started designing what I called “Frontier Land”, where you could either gather resources yourself to build castles and civilizations, or rope the locals into labor (if you paid them well enough) to do a lot of that for you, so that the competition could be taken to “who has the coolest most successful city”.    It was going to be a randomly generated world, with forests, villagers, mountains, monsters, etc.  There was going to be a monster mode where you could “become” a monster (not leaving a certain area) to go and kill players.  There was going to be a Karma mode where your actions to help or hurt other people (never liked griefers) changed your “luck” which stayed with your soul.. and to create a character, you had to be born into the world (to parents), when that character died, it was gone, but your soul went back to the lobby.

Enter Minecraft

I look in the game, and what do I see..

  • A blocky, unlimited, randomly generated world
  • Where you can build systems and processes and stuff
  • With a client and server model, multi-player

It definitely taps into several of my core patterns.  It is feeding a part of me that’s been hungry for a while.   Right now I’m still exploring it as a game, but there’s a part of me that is looking at a bigger picture.

Aside: Minecraft also feeds my love of LEGO which is the predecessor to blocky worlds for me.  When I was 12, I used to try to recreate the dioramas of canyons where Wile E. Coyote would chase the Roadrunner using LEGO.

So What Now?

  1. I have a whole other post brewing about  a “build” order of adventures in Minecraft.   (It was going to be part of this post, but single-responsibility, KISS, so I’m refactoring it out to its own class… err, post.)
  2. My dreams of writing an awesome mud(lib) (again).. now are transformed.  I want it to look like Minecraft.   I could do it in C#, and Signal/R, and .. and.. and.. oh yeah, only at the opportunity cost of everything else in my life.    Darn it.   #LotteryNowDangit
  3. I have several adventures left to experience in Minecraft – carts, rails, mapping, lava, villages, and cats is the short list.

So What Now — Second thought – transformed

Why build new when there’s already something that works?  What if Minecraft started allowing for Lua scripting .. so people could write behaviors into the world in creative mode… building some amazing worlds, games, adventures.. for adventure mode?

It could inspire a gazillion kids into their first programs.. like Muds did for my generation of tweens.

Not to mention recreate C-Robots – program your monsters to a fight to the death.. arena.. with Lava flows to avoid.

In Conclusion

I’ll put in a link to the adventure build order post when I get that done.   I’m pretty sure my wife is going to wake up any moment now, and I have promised this day to making our house better.   And… POST!

Working from Home

I started an experiment this week –  I set up a home office, and I attempted to work from home as the rule rather than the exception.

Pro’s and Con’s

The “Previous” column applies to previous work situations, when I was not in a consultant role.  It helps highlight how awesome my current setup is.

Green = Better, Red = Lesser, Purple = Can Be Improved

Topic Work from Home Work at Office Previous
Commute Time 5-6 hours/week time gained back not commuting 120 miles Time to listen to cool podcasts like Hanselminutes; (annoying traffic) Best commute time ever = 7 minutes walking.  (UGS)
Boot/Flow “Roll out of bed, make coffee, log in, and absorb / plan the day; then take a shower, and start getting things done” => My energy flows into work more gracefully, not rushing things so I can “get to work” (I have a hard time getting started in the mornings)  
Owning My Home I get to experience the house all to myself.. it feels good. ++Introvert (Never at home by myself – left in chaos and came home to chaos.  Didn’t know anything  was missing)  
Music Listen to music out loud, sometimes sing along and dance while coding I close my door so people don’t get disturbed “Nice work Geddy Lee” – Sean H – in response to my singing out loud with headphones on – I didn’t know I was singing
Ergonomics Standing desk, wall mounted 25” monitors (eyes don’t work so good) can be upgraded  
Light (Basement) but I put a lot of lights in Nice big window, office, door I can close (cubicles are so cramped)
Equipment Purchase own equipment; choice
(but costs money)
Good stuff provided (crap for hardware)
Snack-ology Lots of healthy snacks (and some unhealthy ones too)
(Too easy to get to snacking)
(Must avoid Free Oreos and Pop) Not free = good?
Lunch Food Easy transport of leftovers – keeping the fridge clean! (I keep forgetting to bring in my lunch)  
Pets Dogs curled up at feet = warm footrests and easy to love on; take a break to snuggle with cat    
5 minute / long compile breaks Dishes / cleaning gets done, house cleaner, don’t have to do in evening, I like cleaning as a mind-wiper. I do the Kitchen Inventory and Burndown graph of coffee supplies I used to do Sam’s Club runs for Cheesy-Poofs at a startup
Post work flow Walk around the block = exercise = clearer head    
Errands Easier transition to errands — all my errands are near my house, not near work; Life works better.
(Loose the 6 hours that were gained here)
(Have to plan for errands meticulously)  
Geeky Friends   Love the lunch time conversations about everything geeky  
Working as a Team   Much easier to whiteboard / see where folks are at / interact (“We’re all in this awful thing together” team mentality)
Time worked / Time Taken (Too easy to ADHD/interrupt – must use the force to stay on target) Default focus = work, nothing else to do  
2nd Half of Day (3pm: Take a break, suddenly its tomorrow) 3pm: Take a break; still at work; get back to work  
Underlying Motive “Working to be of Service” is what sustains me, “working for the man” mentality slips away (Used to confuse the two – now getting clearer) (“Working for the man” mindset – see below)
Interrupts (Wife/Family interrupts – when they are at home.  Working on it) Very few, to the point where they are welcomed (constant interru- now what? –pts)

Conclusions thus far

At first I thought it was an either/or situation – I had a primo office at work, if I started working from home, of course I should give up my work office for somebody who wanted it.   However – we’re now expanding our work areas.  My work place is cool enough that .. I may not need to give up my awesome work office if I start working from home more – I can have both.

It also depends what project I’m on.  My projects right now are solo efforts – the only people I interact with are on the Client side – so not being in the office is no big deal.  However, if I’m working with buddies at work – I would really rather be at work than working from home.    Especially if there’s a whiteboard involved.   Note, there are lots of tools now to get that accomplished – but nothing beats face to face time when working on a problem with somebody else.

The Motive Angle

Working from home is cleaning up my motives. 

I didn’t realize it, but the last 5 years of working at a certain company, I totally bought in to the (subtle) mentality of “the world is against us, woe woe woe, how can we survive today”.  The focus was to show up, figure out expectations, get exactly that done to not get in trouble, sprinkle in some fun if anything left over, and call it good.    It wasn’t really about being of service – the people we were servicing felt like they owned us (since they brought in the money, and we were an expense), and all blame flowed down to development.  I could still be of service, but I had to dig deep.

When I switched over to my current job, I brought some of that “yes master” stuff over with me.  Constant questions on “am I doing this right, is this as expected”, etc … I had an underlying lack of confidence that what I had was enough, I kept trying to act in a play that didn’t exist.

At the old place, working from home was “tolerated” – they would say “we need you here to be present to help out”; I think the truth was more like “You might not be working” and “We own you”.    

The new place – we were having some office space difficulty – need new offices built out.  I had an Idea, and asked if me working from home temporarily would help smooth some of that over.  To my surprise, they said “no need to give up your office – try it out and see if it works for you; we have faith in you”.  I was floored.

So I did it.  And in getting all that set up, I realized.. that “I must work to meet expectations” model just doesn’t work at home.  The people to please just aren’t there.    So what am I left with? 

For me, the underlying answer has always been:  To be of service.  To solve the problem at hand.  To do the next right thing.    To make people’s lives better. 

So that’s what I’m doing.   

Mvc concepts

I’m reaching the end of my first professional (== I got paid) MVC application.

I learned a lot. This is an attempted visualization of most of the topics that I learned.   You may need to click in to see the details.

In addition, as I found good sources of information on the ‘nets, I included links in my source code in comments.  Here is a compilation of those nuggets of goodness. If your post is mentioned on this list — thank you.

Link Goodness
 http://stackoverflow.com/questions/4367723/get-enum-from-description-attribute Embedding meta-data about things in enumerations
 http://ayende.com/blog/1595/nhibernate-mapping-creating-sanity-checks (NHibernate) Integration test to validate mapping completeness
http://www.codingoptimist.com/2010/11/nhibernate-hidden-gems-speed-up.html (NHibernate) Caching configurations (gain: 1 second, not worth it, dropped)
http://stackoverflow.com/questions/325156/calling-generic-method-with-a-type-argument-known-only-at-execution-time Having multiple types with shared logic was a wonderful spot for co-variance, but after about an hour, it was time to move on
http://www.nickriggs.com/posts/getting-the-id-and-name-attribute-generated-by-typed-html-helpers/ I had to drop down to a TextBox with an @class setting, and thus I couldn’t use TextBoxFor, so this came in very useful
http://www.codeproject.com/KB/cs/stringenum.aspx Used by a coworker somewhere in the guts of an automatic model-to-.Where()-clause LINQ query extension
http://www.mikesdotnetting.com/Article/125/ASP.NET-MVC-Uploading-and-Downloading-Files Made it oh-so-easy for me to save and upload intermediate files from this file processing system
http://stackoverflow.com/questions/1151987/can-i-set-an-unlimited-length-for-maxjsonlength-in-web-config/7207539#7207539 Before we got the Grid getting only 1 page at a time, we were getting everything – thus needing this
http://code.google.com/p/autofac/wiki/Mvc3Integration Autofac was just amazing. It made sense to me! Its what I would have done if i was writing an IoC container…
http://slynetblog.blogspot.com/2012/03/using-aspnet-mvc-4-webapi-with.html Using ASp.Net MVC4 with NHiberate and AutoFac .. pointing me in the right direction
http://forum.jquery.com/topic/span-text-new-text-not-working-in-ie  <span/> to <span></span> did the trick, then I could .text() it
http://stackoverflow.com/questions/10588587/jqgrid-does-not-render-correctly-in-chrome-chrome-frame An annoying bug that sent me searching for at least 15 minutes
http://stackoverflow.com/questions/5248183/html-partial-vs-html-renderpartial-html-action-vs-html-renderaction When the views became too large, I could refactor|extract view
http://stackoverflow.com/questions/2498187/system-web-extensions-trouble-deploying-net-framework-4-website-on-iis7 The target server to install on did not have MVC3; so I had to include it in the XCOPY deploy

Software Estimation Review #1

One of my recent projects had this burndown:

At the start of the project, the “desired” hours were coming down at the speed of the “high” estimate.  If I had used the first 5 data points to predict the end of the project, it would have been near T=7, at a cost of 6N or so, and the estimate was only for 5N.   Not good.

Luckily, things started to sort themselves out as the project progressed.   However, I wanted to understand what was going on.

At work, I track every slice of time at a project and “top level task” level.   I also note down what exactly I’m doing (and usually its outcome – success, interrupt, break, etc – especially useful if there is fragmentation, you can see how interrupted you were – a metric to show pain).

I exported this detail into Excel, and created an item by item grid of time taken for each line item  in the original estimate.

In the process I found several items that I worked on that didn’t have a home in the estimate, and I got “actual hours worked” for each of the line items.   It was shocking.  Here is an abridged version:

  • I saw tasks much larger than the original estimate.
  • I saw some tasks much smaller than the original estimate.
  • I missed several features.
  • I left out entire categories such as refactoring (as the project grows), documentation,  styling and usability.

Possible Interpretations

I did well.

The project was done within the time allotted.  This was a success.  Perhaps the individual line items were not, but the overall project was – I was lucky that I overestimated several items.  If I had tried to squeeze every line item, I would have been in trouble.

Could more Up Front Design yield a better estimate?

The Waterfall thought would be I didn’t do enough up-front design.  However, I spent longer putting this estimate together than I should have – because in this job, putting together an estimate is not billable time!  If I had spent more time on it, I would have had more line items – yielding a higher estimate – yielding a greater risk that the client would not approve the budget – and I would have still gotten it done on time – perhaps even less time.

I have done this before = takes less time

I had previously done a similar project.  As a result,  I estimated several items fairly low. Examples:

  • 5 to 8 (actual: 23)
  • 5 to 7 (actual: 12)
  • 5 to 7 (actual: 14).

This is equivalent of an handyman stating: I’ve built a house before, so hanging drywall won’t take as long.   Incorrect!   It takes time to build software, even if you know exactly what you are doing.

 “Sure that Technology will be easy to integrate”

My coworker (on loan to me for two weeks) spent a lot of time trying to get a grid to work correctly.   Actually, the grid worked fine, the helper classes to interface it with MVC did not.     Trying to get them to work took the majority of the hours on one of the pages.

In the end, he scrapped the helper classes he had downloaded – they worked only in specific circumstances – and rolled his own – and coded the rest of the page in record time.

I’m not sure which way to go on this.  Perhaps having a bucket of “research” hours?    Timebox the items that we research to save research budget in case its needed later?   It seems every project I’ve been on, there’s been one or two things that took some time to get the approach figured out.

I left out parts of the project from the estimate

There were several items that I had not estimated up front that are a part of any project.  See below for a running checklist.

I skipped parts of the estimate

Some functionality turned out to be trivial, or unnecessary. For example, we went straight from a grid of Endor to editing Endor without a stop at a detail page for Endor.   Or, one of the setup pages – thought to be three seperate pages – collapsed into a single grid.

These “mistakes” are what saved the project.

Overall Analysis

I think my mistake was trying to specify everything in the estimate at a line by line level.  As DPR207 at TechEd 2010 pointed out on slide 16, there are different levels of uncertainty as a project progresses.  I was estimating at too granular a level too early – guaranteeing I would miss items, as well as specify some items that were unnecessary.

Doing it Differently

In this particular project, how else could I have estimated it?

Agile, Story Points, etc.

Using Story Points and approaching a project in an agile way (Scrum-like) are my favorite ways of handling project estimation and management.  However: In my role as consultant, with clients pre-approving blocks of hours (based on a high end estimate), I don’t get to do that.   So I’ll pass on that solution.   I HAVE to have a number of hours up front, or I need to find a very understanding client.

Estimate at a higher level

Rather than estimating at a very detailed level, I could estimate in bigger chunks like this:

Level 1: Systems “A Website”“A Batch App” 50,100,150,200,300,500 hours
Level 2: Functions / Features / Pages Grid of FooEditing Foo

Selecting Bars for a Foo.

Reading in an xxx file.

Validating xxx information

10-20, 20-30, 30-50 hours

Fibonacci Numbers

I will definitely continue using Fibonacci numbers for estimation.  It saves me brain power – Its either a 5 or an 8.  I don’t have to argue with myself whether its a 7 or an 8 or a 9.

I use a slightly modified sequence:   0.5, 1,2,3,5,8,15 … somewhere in there, I jump into adding zeros:  5,10,20,30,50, etc.

Going Forward

Jim Benson (@ourfounder) gave a presentation at CodePaLousa: “We are Not Engineers“.   (I tried to find a link to a powerpoint, and then I remembered, it was truly a powerpoint free presentation. I did find similar materials here)  The gist of the presentation was:  “Humans are horribly designed for doing estimation”.   If I estimate based on gut feel, I’m going to be wrong.   Thus, for my job, I either need to stop estimating, or start to build a toolkit.

This is the toolkit so far:

Keep track of all time and match it back up against the estimate at a line by line level.

It takes about 15-30 minutes to export from Harvest and match things up in Excel.   Its a form of instant feedback.

Estimate in larger chunks.

Rather than counting the number of fields on a page (which is what I did previously), I need to find the average time to write a page, and then double it if it’s a big page.    Try not to estimate in anything smaller than, say, 10 hours, for a chunk – a page, a file processing feature, etc.

Keep a checklist

My checklist at the moment:

  • Initial project setup
    • Machine setup
    • Project setup – layers (DAL, etc) – into SVN
    • Stub version of project that can be deployed
  • Test data strategy (in support of integration testing)
    • Test data creation and deletion
    • Setting up automated integration tests to run automatically
  • Individual Items (Project specific)
    • Larger chunks
    • Include testing time for each item – writing unit or integration tests, and testing by hand.
  • Growing pains
    • Refactoring is inevitable (and not specific to any particular item)
    • Configuration and Deployment (as the project enters different environments)
    • Merging between branches if branches are called for (any time there is a phased release, or a separation between UAT, QA and DEV)
    • Necessary Documentation (after complicated things get done)
  • Project Management
    • Dependent on each client. 10%  of a 35 hour week = 3.5 hours of email, status updates, demo prep, and demoing – which is about right for a good client.  Other clients, the number has been closer to 20%.
  • Research bucket
    • For the unfortunate item(s) that will pop up that just don’t work
    • Also can be used to take extra care to simplifying something so it stays more maintainable.
  • Usability, Look and Feel
    • Cross browser testing
    • “Making it Pretty” – fonts, colors, grids
    • “Making it more functional” – renaming things, page organization, number of clicks to do something
  • I18N and L10N
    • Dependent on client and project.

The Request

How do you estimate your projects?  How close do you get?   I truly want to know.  Shoot me a comment or write it up and add a link.

Where did my time go?

This week i’ve felt hurried.. it felt like life kept getting in the way, preventing me from working the work hours I should to be working.

I can’t argue with a feeling, so I took an inventory, and mapped it out. With some help from my wife, and a history of text messages, I could mostly put together what was going on. (Harvest, the time keeping app for work, helps)

Inventory Result

The Blue is work.  Most of it was Working-At-the-Office (WAO), though some was Working-At-Home.. (WAH).. either in the Basement, or Outside. (Outside = it was a beautiful day)

The Yellow (yellow) is hanging with my spouselet .. which also happens to be very good for me, I enjoy that time immensely.   We’ve been watching Season 6 of Doctor Who.

The Orange is hanging out with people – my spouse’s family on Monday, and with a buddy for breakfast on Wednesday.  Note: Monday and Tuesday lunches should have been in Orange as well, I’m trying to make it a point to hang with the guys at work.

The Other Warm Color is “stuff I had to do”.  Some of it is house hold related stuff – some of it is being of service to other people.

And lastly – there’s Purple, the stuff I do for me.  Which includes writing this blog post, and my little jog around the block, and puttering around on whatever I want to do.

Analysis

Monday was bleah.  I had a family thing to go to, didn’t get my hours in.

Tuesday, I tried to catch up.  It was fairly training.  Wife and I recovered it well though.

Wednesday was shot – My son needed some assistance with homework, so there was some time lost to transit.  The good news there is, I could work from home – I multitasked – I had the dogs out, and the cat out, as I worked from my laptop.  It feels good to crittersit the critters and spend a little time with them.

What’s the problem? What’s missing? What needs to change?

I find myself lagging behind in my work hours and spending Friday, the day when I get 4 hours to work on anything I want (including this blog) — I spend it on catching up the hours I didn’t get done earlier in the week.

What causes this lag?    Its usually “household” things.  Sometimes its “people” things. Both of those are important, and they’re not going to budge.

The good news is, the days that I don’t have “life” going on, I can easily stay at work to get caught up.    Or even work from home to get caught up.  (I find that I can only work from home when I’m alone there – otherwise, my family drags me into their lives).    If I stay extra at work, I can usually put a workout in there as well.

Other Optimizations

I might try sleeping in till 7am, and not tossing and turning for an hour.

As mentioned earlier, I would like to add more exercise.   I’m not sure where – the current idea is, on days that “life” isn’t going on, work late, and add in a jog there.

Random thoughts: The YMCA is on my way to/from work, but the time needed after a workout to take a shower is a detriment; yet my chances this week of doing something on the way home .. there was only Tuesday.  I did jog on Tuesday.   So.. mission successful? Operating as designed?   Maybe the Late Night Jog is the best way to go, i used to jog at about 10pm or so, when I first started jogging.   After dinner, even, help with absorbing all those calories (diabetes related).

The Big Picture

I’m not seeing a lot of wasted time in there.. hours spent in front of a TV, flipping channels.

I am operating at 90% capacity, easily – with the remaining 10% necessary for buffer, sanity.   The occasional breaks – in white, with question marks – are signs of sanity, not places to cram more stuff in.

As a very wise person once told me – as my life progresses, I am going to find more and more good stuff that doesn’t fit.

What If I Were Retired

If I were retired, how would the ingredients change?

I suspect there would be a lot more puttering, and helping, and hanging with people going on.  And probably a lot less “creating” things (my current work).

Calories In Minus Calories Out


There was a conversation at work. Simplified:

VP (Visiting Person): “What Kind of Cookies do you have here?”
Me: “I don’t know, I haven’t checked. I’m not eating Wheat right now, and that shelf is all wheat.”
VP: “How’s that going? I’ve heard about that.”
Me: “Pretty good. I’ve lost a few pounds even without exercising.”
VP: “Yep, calories in and calories out.”

My brain took off on that conversation. Hence, this blog post.

Normal

The assumption is that people simply control the calories out. “Just work out harder”.

# Powershell
"Normal Situation: "
"Calories In : {0}" -f ($caloriesIn = 2000)
"Calories Out: {0}" -f ($caloriesOut = 2000)
"Net Calories: {0}" -f ($netCalories = $caloriesIn - $caloriesOut)
"Gain/Loose {0} lbs per week" -f ($netlbsperweek = $netCalories * 7/3500)

Normal Situation: 
Calories In : 2000
Calories Out: 2000
Net Calories: 0
Gain/Loose 0 lbs per week

True, but there’s a twist that I found out, due to my type two.

Conjecture for DM2

This is only my understanding of it. It is not proven or fact.

The hidden factor for me was insulin release, and and insulin resistance.

Lets say that for the calories I was taking in, my blood sugars bumped up to the 140+ range. Lets assume that I’m not working out actively at the moment. (when engaged in physical activity, some other form of transport happens, and sensitivity to insulin goes up).

My body is desperately trying to shove this energy into my cells, and is pumping out insulin (all that it has). The insulin has the effect of transmuting some of these calories to stored fat – almost immediately – before I have a chance to use it.

# Powershell
"Actual Situation: (not on drugs)"
"Calories In:  {0}" -f ($caloriesIn = 2000)
"Converted to fat due to high insulin levels: {0}" -f ($insulinToFat = $caloriesIn * 0.15 )   # total guess
"Fat gained per week: {0} lbs" -f ($fatperweek = $insulinToFat * 7 / 3500)
"Body must make do with {0}" -f ($bodyAvailable = $caloriesIn - $insulinToFat)
"Feeling as though only consuming {0} calories - ie, starving" -f $bodyAvailable

Actual Situation: 
Calories In:  2000
Converted to fat due to high insulin levels: 300
Fat gained per week: 0.6 lbs
Body must make do with 1700
Feeling as though only consuming 1700 calories - ie, starving

My evidence for myself:

There were 2-3 months that I went off my medication, but was watching and logging what I ate.
During that time, I ate 1800-2100 calories a day. Yet, I gained 5 pounds in about 4 weeks.

My deduction:
By storing those 5 pounds => that would mean 17500 calories over 28 days = 625 calories a day.
Which meant that I lived on around 1200-1400 calories a day.
And yes, I felt starved the whole time. (not really starved, but you know, the feeling? I have never really starved, except perhaps once)

So what the heck does my medication (Metformin) do?

Everything says “it limits the production of hepatic (liver) sugar”.
What does that have to do with anything?

My understanding (only my understanding) is:
The body MUST MUST MUST not get into a hypoglycemic situation – because the brain dies. Therefore, it monitors it very seriously.

As blood sugar gets too low, it tells the liver to go make some more. Its not an all or nothing – its a gradual release type thing. However, its tuned based on “relative” levels of blood sugar, not absolute levels.

Being diabetic, and having repeated elevated blood sugar levels “reset” what my body thinks normal is. So my body is churning out sugar even when I’m at a comfortable spot, like 110. It thinks 110 is low.

By jumping in and cutting that link (or reducing it, anyway), Metformin allows my “average” sugar levels to come back down to what they are now.. a fasting number of 80 or so.

And once I get down to 80.. and if I watch what I eat, such that any meal, 2 hours after, I’m back under 140 (these are numbers I’ve chosen for myself), my body leaves the second equation, and goes back to the first equation. Or maybe, the 0.15 goes down and becomes a 0.5. I don’t know exactly.

What I do know is: If I stay off Metformin, my weight goes up, and my fasting blood sugar levels go up. If I stay on it, and I eat wisely, they come back down to normal levels.

In Conclusion

All of the above is my explanation to myself.
Its probably wrong. The reality probably has something to do with aliens, monkeys, ninjas, and a turtle.
If you have a better explanation, grand unifying theory of blood sugar, please do post it and point me at it.

Snot Funny

Insert standard: “Oh I don’t post enough” post here.  Seriously, i believe I have 2 readers other than myself.  (Hi Doug!  Hi Molly!)  (i just set myself up for disappointment, maybe its less than two)

I thought I would fall back to my dastardly plan of re-posting old stuff from the “geeky” tag from my livejournal, but what I found there was:  a whole bunch of started projects with nothing finished.  Not worthy of posting. A few cool pictures..

In other news, my wife thinks I might be somewhat ADD-ish.  Her diagnosis was on the basis of opened cabinets I left behind after working in the kitchen for even a small amount of time. I disagreed with her at the time. However, given the previous paragraph, that might be true.

Given all three previous paragraphs, I should refrain from starting yet another thread that I might or might not finish, so I won’t talk about what my plans for this blog are.

So all I can leave behind, then, is something like this:

a. Save Points

When I play a computer game that has Load and Save points.. the first 10-15 minutes back in reality.. I feel strangely out of touch.. imagining that life had load and save points and being utterly surprised that it does not.

b. Snot Funny

Sinus Infections have re-upped my anti-snottery artillery.

  • Throat Coat to remove itchy ickyness so i can swallow again. Add Honey as needed.
  • Because water doesn’t go down well, heat it up, add honey, then it goes down fine.
  • Neti-pot. for washing the gunk out of sinus cavities. Makes your cat look at me funny, as I kneel over the bath tub. There are other tricks to this trade, but they’re kinda gross.
  • Salt water gargle. Mouthwash gargle. I have not tried Vodka gargle.
  • Stuff gunked up? Cayenne pepper + lemon tea! Heavy on cayenne.
  • Vicks Vapor Rub! I’m never too sure if its a de-gunker or a runny-snot-dryer. I think i use it as both? And a throat-soother.
  • DayQuil and/or NyQuil. Take with food to avoid upset stomach.