Bill Robertson's Blog

Human Interaction Amazes Me

Sorry all for the bad photo, you could read it on my iphone, but when I uploaded it, it horribly mangled the photo.  Here is how it looked on my phone. with an transcription below.

I also realized my neighbor’s name was on the paper. However, I wanted to give those interested the story, and get around to writing another blog post.  That gets Windows Live Writer in my recent when I click start and should “hint” me to remember.

photo

 

Dear Neighbors

Whoever “took” my newspaper, I would appreciate if you would have allowed me to read it before you.

You are welcome to knock on my door and I would gladly give it to you, however, only after I’ve had the change to peruse it first.

Goto Statements

I've been quietly lobbying to my programmer friends about the utility of using the old "goto" keyword.  I've gotten a little push back from them, mostly dismissive scorn, but hey, not everyone can be good.  :) I should start a series on this and this will serve as my first post on the glories of GOTO.

The other day I posted a twitter image showing a good case of a goto statement.

goodgoto 

This is a utility method I use when parsing Xml documents into objects.  I received some push back from this specific twitter, mainly from my friend @gbattle.  The requirements I gave to Greg were: "no nested if's, no multiple exits, no unnecessary object assignments and better error explanation"

He posted about his code for doing the same thing without using gotos.  There were a couple points where he was incorrect, and I wanted to walk through his post.  I start trivially and then increase for performance and readability.  He still made his points regardless of the library being used.  There was only one point, property accessing, that does behave different in .NET than say C++.

I will accept from Greg that breaking down each error condition into exactly what caused the specific failure might be better, but on a utility method like this, if I can wrap up the failure condition into a single statement be accurate, I'm fine with it.  "Node should have one child CDATA section with data."  Sure, specifically telling the user which 3 words of the all inclusive error might be better, but any software dev that can't follow that error message and look at the node that caused the failure, prolly should not be programing anyway.

// For style reasons, I always put the constant on the lhs within an if statement
// for the compiler to automatically discover nasty undesired assignment errors
if (1 != node.ChildNodes.Count)

I understand the sentiment of the lhs positioning of constants, and in my c++ days, I was an advocate of his pattern; however in .NET it is an error to do an assignment in an IF evaluator.  (Which was extremely frustrating starting out because I wanted to do it sometimes)

// There is no reason for you to create a new XmlNode return the value.
// You waste time creating a new object and the assignment. Not needed.
XmlNode dataNode = node.FirstChild;

The assignment operator doesn't create a new object.  It creates a pointer to the return object of calling property FirstChild.  Creating a pointer to a Property result is the fastest way to access the property when you are accessing it more than once.  When loading an property it first must resolve the memory location of the containing object, then look into its method offset table, calling the accessor (get) method, which walks more memory offsets, to return an object.  Rather than repeatedly calling the Property (get method) I store the results in a stack variable pointer to the actual data returned by the Property call.  (I'm ignoring the code inlining that might occur at run time, but that doesn't meet the speed of storing the reference locally)

Now the money shot for why gotos are good in this situation is something in his code he did not account for.  When he is checking the number of ChildNodes off the parent node, if it comes out to zero, he has opened his code up for a NullReferenceException.  If ChildNodes.Count == 0, then FirstChild will be null.  Checking FirstChild.Value when first child is null will result in an exception.  And here lies the nested if statements that I'm trying to avoid.

If the ChildNodes.Count property is 0 (or negatively not 1, the actual node count we are looking for), then you must branch this utility method into either a quick return or a nested if statement that continues checking the validity of the XmlNode when there are the correct number of ChildNodes.

NYC January Code Camp and the Large Object Heap

I presented my Garbage Collection/Memory Management talk this last weekend at the NYC Code Camp at the Microsoft Office.  I had a great time and it was enjoyable catching up with old friends and meeting new people.

To the gentlemen who was asking about the Large Object Heap and DataSets.  A DataSet will not be placed on the LOH.  A value of a DataColumn instance might be placed there, but the DataSet itself has a footprint much smaller than the 85 K size required to be placed there.

The Large Object Heap is a heap structure used by .net to allocate large objects greater than 85K.  It is not the size of the object graph that places it on the large object heap.  Translated to this example, the memory allocation of the DataSet is NOT the size of all the rows and all the columns.  The size of the object is determined immediately before the constructor executes (before the DataSet has any rows).  This is determine purely by the size of all the fields in the object, and some additional object overhead.

When the memory size is determined and is (currently) above the threshold of 85K, it is placed in the Large Object Heap.  The LOH is very similar to the Small Object Heap in behavior with the ptrNextObj and serial allocation.  (The one covered in the session).  However, it does not have generational support and most importantly the LOH is never compacted.

The lack of compaction is what will create out of memory exceptions because the LOH becomes fragmented and with the new allocations always appearing at the end of the heap, you can run out of memory.

Using the new 2.0 MemoryFailPoint object you can test the allocation and create an InsufficientMemoryException rather than the more fatal OutOfMemoryException. 

This is only a tease because you still can't force a compaction of the LOH.  It is valid, in some scenarios, force a GC.Collect to help with the SMO and free up some memory.  However, the SMO is usually handled quite well by the CLR's collector and calling GC.Collect is nothing more than Jazz Hands to make you feel important.  Don't call it, ever...unless you have a good reason...but never call it.

PDC 2008 Recommends List

I thought I would share the sessions at the PDC I really enjoyed and would recommend for viewing for those that didn't attend.  And you know who you are.  :)  And those who did attend but didn't get to watch these.  I'm sure there are more that were great, but these are the ones that stuck out to me.

Deep Dive: Dynamic Languages in Microsoft .NET

Jim Hugunin gives a great session on Dynamic Languages.  This was the best talk I went to the entire PDC so I'm listing it first, but you should watch The Future of C# below first.  It is very reminiscent of the few Computer Sciences courses I've taken.  You won't learn any skills here that will directly apply, but covers theoretical aspects of cross language support.  He is also very entertaining to boot!

The Future of C#

Anders Hejlsberg shows what's coming in C# 4.0.  He covers Dynamic Languages with javascript from c#, optional parameters values for overloads and named arguments.

named optional parameters

With the dynamic language potentials, they must find a way to have an intellisense generator just like how the asp.net designer has its own plug in framework.  Maybe with interop type generation?

dynamic video = youTubeServer.GetVideo( "" ); // returns xml

   1: dynamic video = GetYouTubeVideo( "3f73fv" ); //returns wrapped xml string 
   2: ltTitle.Text = video.Title;
   3: ltObject.Text = video.Embed;

The c# interpreter was really neat at the end.

ASP.NET and JQuery

Stephen Walther taught me everything I needed to know about jquery in his hour long talk about it.  I know javascript extremely well and this just filled in the gaps so I could transfer my existing knowledge.  In fact, I am refactoring my advanced javascript talk to include jquery now, especially since it was announced Visual Studio will formally support JQuery.

ASP.NET: Cache Extensibility

Stefan Schackow explains how the new Cache Api can work and what you can do when you open up the caching framework.  This will allow more powerful extensions such as David Penton's Cache Pattern being tied directly into the framework.

Project "Velocity": A First Look

Murali Krishnaprasad does a good job introducing the new distributed caching framework called "velocity".  The option of a sending a read/write provider to a cache call  has some interesting possibilities.

Posted: Nov 02 2008, 12:15 AM by Bill Robertson | with 2 comment(s)
Filed under:
How to log remote user off...remotely

You're about to leave for the day, but you need to push one more thing to the data center.  You pop open trusty Remote Desktops and connect to your environment.  Then this message hits you in the face like a wet, smelly dog tail.

remotedesktopexceeed-thumb1

"Connect to console"?  Nope that doesn't help.  Normally, you holler across your team and tell whoever isn't on the servers, to log off; however it's late and everyone else is gone.  Or if someone is already on the server, ask them to use taskmgr to find your least favorite person and force them out of the server.  (Does anyone else get a power rush out of that?)

logoffremote

The above only works when you have access to the server.  When you don't, you can log people off remotely.

There are two commands that are included in at least Windows Server 2003 and beyond:

  • quser.exe - used for querying users logged on to a server
  • logoff.exe - used for logging user off a server

Using just quser.exe will give you the list of users that are logged onto the current machine.  You can also query a remote machine using the /server:<machinename>.  This will give a list of users.  The import things to notice are the ID and the State.  There are two states that I use when deciding who to kick off: Active and Disc.

I always try to kick off Disc before active.  (There's no additional explanation)

After you pinpointed the user to bounce, look at the ID column because that's what the logoff.exe command needs.

The screen shot below shows how to query the users on WEB01 and then log off the disconnected session, named Session ID 2.

logoffcommandline

With nearly all dos commands, passing "/?" as the only parameter will give you additional information about these commands.

August NDDNUG Advanced Javascript Presentation

I had a great time presenting an advanced javascript and MS Ajax at the North Dallas .NET User Group.  Attached is the slide deck and code samples I used.  I know...I didn't clean up the project files so there are some extra dll's included.

The code samples are located at /Default.aspx and they run in increasing complexity.

The code samples include:
  • Ajax Helper - Helper class for registering client side script to work with MS Ajax, including the powerful RenderUserControl method.
  • Object pattern - This includes a javascript singleton pattern, namespaces, constructors, inheritance, static and instance methods.
  • Event Modal - Two different patterns for event handling in javascript, with a focus on my preference Event Level 0, inline function declarations.
  • JSProcessor - This will combine multiple JS files into one and will remove excess spacing, comments to make the raw JS as small as possible.
  • JSShortCircuiter - For reaching around the embed scripts when in debug mode so you don't have to constantly rebuild the dlls.
There are many examples of client side caching, retrieving html from server, getting and saving Server Side objects.

There was more interest than I thought on the client side ThreadPool object, so I've included that.  It isn't functional as it stands because there are some other frameworks it relies on.  Send me a message or post in the comments if there is interest for me to make this object standalone and only require the .net framework and I'll work towards that.

Also, if there is any interest I can release a ajax back button module.  It is different from the MS Ajax one in that it is delegate based rather than serialized querystrings.

Hit me with any feedback or questions you have on the presentation or the code.

Thanks!

download

Posting Again

After a long hiatus, I'm back to posting again.  Look forward to more frequent updates.  :)

Thoughtiest Decision of my Life

I've been working at Telligent for the last year and a half; it is without question the single best employer I've ever worked for.  [Or traded value with depending on your economic theory]  August 14 was my last day of employment with Telligent.  This post took a while to write because I've been reflecting on the changes brought to my life by Telligent.

Increased Caloric Intake.  At previous employers we would have lunch provided for us at the yearly or bi-yearly company outings, or if I was lucky enough to go out of town I would have an expense account provided.  However, at Telligent, we started with Monday/Friday lunch, sometimes catered, sometimes a menu was passed around, then no lunches at all, then lunches returned for Monday.  It's been an ephemeral lunch schedule at times. 

There were two refrigerators full of nearly every type of coke, and if the variety of beverage didn't suite your taste, a little sweet talk with Laura [redundant, she is so sweet] would buy any beverage you wanted.  There was a constant stream of snacks to help with the low-blood-sugar and ping pong fatigue.  I won't forget the beer in the fridge [not until after 4], or the game nights where you could destroy each other virtually or with a playing card.

Name Dropping.  I've worked with some of the industry heads in the .NET community.  I've been beat in ping pong by Rob Howard, been shot with balls of paint by Jason Alexander.  Scott Dockendorf has given me the confidence to publicly speak at user groups.  I've learned much about architectural design from Scott Watermasysk.  I've been invited to private parties at developer conferences through these connections.

Professional Development.  I've worked with some of the brightest developers that bring me humbleness.  The hiring process at Telligent is intense, and you interview with random developers on the team, not the HR staff.  You have to be knowledgeable, be able to communicate, and have a genuine ego.  Even the "best" developer will meet someone at Telligent more brilliant in an area.

I have increased my javascript skills, database skills, project management skills, sales theory skills, public speaking skills, and any other skill you could imagine.  I'm not going to name the contributors individually because 1) I know I will forget someone and 2) this post must end at some point.

I totally recommend [like totally, Valley Girl style] seeking employment with Telligent.  If the situation ever presents itself, I know I would re-seek employment. Everyone there will be sorely missed by me, probably more than they miss me.

So long, and thanks for all the [teaching me how to] fish.

American Airlines Business Practices

I booked a flight for a trip to New York City and was completely floored by what was presented to me.  I found a 9 hour American Airlines return flight from JFK to DFW.

Nine hours?!  What could possible be the cause of that?  I pulled the details for the flight and saw there were two stops.  Remember my goal is to return to Dallas.  I had to read the chart below several times.  I've highlighted the piece that had me completely confused.  Let's play "What's wrong with this picture?"

 

trip

 

Give up?  Yeah, remember my goal flying from New York to Dallas.  My first stop is in...Dallas.  WTF?  To get to Dallas I have to first fly to Dallas, change planes, and fly to Austin.  Then I must change plans again and fly back to Dallas.

Seriously guys?  My first thought was I'll just deplane [their term] in Dallas the first time and cut 5 hours from my trip.  However, if I want to get my luggage I must:

  • Bribe a TSA agent to let me in the restricted area so I can claim my baggage before it gets moved to another plan.  [Sadly, it probably won't be very expensive to bribe them.]
  • Come back to the airport 5 hours later after my trip to claim my baggage.
  • or, Sit in the airport and wait for my baggage to return from its trip.

The fourth option, also the option I executed, was to fly with an Airline that has some semblance of a efficient company, ie Continental.  Sure, requiring me to buy two extra tickets efficiently increases the cash in the coffers of America Airlines, but that sure isn't how I want to allocate my resources. 

How to delay all outgoing email in Outlook

I've been burnt many times on sending out an email that wasn't quite ready to go out.  This could happen for a couple different reasons.

  • I was really pissed off when I composed the email and wasn't thinking properly about it.
  • I copied and pasted something and outlook on all machines I've used randomly will send before I'm finished.
  • I wasn't ready to send the email or I didn't think hard enough about the question I was going to ask.

I'm sure I'm not the only person that has typed out an email in a fit of rage, cursing the entire time and hit alt-S with two powerful finger punches you felt invincible, only to quickly realize that "email" could end up in your personnel file, require some anger management classes for you, or you look like a complete dumbass because you're wrong and the person you were going after is right.

I would think random sends would only be me, except this has happened on every machine I've every used.  Also I've been on the receiving end of some not-quite-ready-for-consumption emails.  It might be some combination of keyboard shortcuts I use to paste as special.  Also my alt key will get stuck on my work machine.  I think the person that had this machine before me was an avid gamer and lived on control keys.  So when I hit 'S', the email will send...followed by a stream of profanity.

The final situation where this has been a face saver for me is when I'm typing out a quick question I'm sending to a mailing list or answering an existing email thread.  Since it is a quick statement I go straight to the alt-s so I can get on with other work.  Sometimes after hitting alt-s, while the sentence is still burned into my retina, I either realize I already know the answer, or the answer I've put out is wrong and I don't want to look the fool.  I don't mind looking the fool, not at all, but looking the fool when I tried to look the hero is pretty humbling.

Please download Outlook Outgoing Delay and let me know what you think.
 

 

Single Blog Mode Configuration for CommunityServer

This site has been updated to CS 2007 sp3.  In doing so I broke the old way I was charming CS into single blog mode.  Single Blog Mode is when you have a blog on a CS site and you want it to take over the root.  ie http://BillRob.com takes you to the default landing page for my blog.

This is a excellent resource for setting up a CS 2007 site in single blog mode from ScottW.  Enjoy.

Single_Blogs.zip

Here is the full forums post if you want to dig into it further.

A Single Blog, the Easy Way

Also, thanks to recent Telligent hire Kar for letting me know my rss feed was broken.

Community Server and its "Poison" to McAfee

I came home tonight to another automatic virus scan of my machine.  Yes, it's McAfee, so there is problem one.  Problem two is an issue that's being going on with me between Community Server and McAfee anti-virus software in general for nearly a year.  Community Server has some great looking blog skins that can be pulled over with a default install.  This works well for visually diversifying the plethora of blogs running CS.

One of those skins has the name "PoisonIvy".  It's a nice looking skin, but not quite sure where the name comes from.  When the skin was first released internally everyone's McAfee [default in-office install] recognized it as a virus and quarantined it.  Any text file named PoisonIvy is delete by McAfee.  It would be great if it were a virus, but

It is NOT a virus!

It has the same html as all the other skins.  This a testament to the crack anti-virus team developing McAfee's virus engine.  I sure hope no one renames the virus to anything other than PoisonIvy.  They aren't even looking at the contents of the file, only the filename.  I've contacted McAfee about this and what I could do to remove that "definition" from my list or exempt that directory.  I'm paraphrasing their response: "No, you can't, our software sucks and you are a fool for buying it".

Now that McAfee has completely confirmed they won't do anything about it, I must shift my focus back to the Community Server team.  The "Enterprise Version" provides a workaround.

CS team, pretty, pretty please with a cherry on top rename the PoisonIvy skin.  It gets worse every week because I have more CS sites on my machine.  I've spent the last hour and a half running SVN cleanup on directories and re pulling so I could work.  I'm sure there are other people in the wild downloading CS for the first time and McAfee pukes up at them.  Do those users give up and move to a competitor and tell others CS has a virus embedded in it?

I will personally hand deliver no more than 3 beers to any CS developer in Dallas that would get this changed.  This offer stands for any developers when they come to the Dallas office.

More Blogging

I'm sure this won't be the last time I drop off blogging for a while.  This hiatus is attributed to Jose.  The Community Server team was packaging up CS 2007 and I wanted to play with Morpheus.  Morpheus is the extension added to Community Server that enables the separation of the membership store with CS data.  I was playing a scenario where I had to different CS sites and one membership store.

I had a couple problems with it, mostly my own fault.  Jose helped me through and got it all up and running.  He then asked me to type up a blog post on how to create two CS sites that shared membership.  I started on that post and never finished it.  There are too many other cool things I'm working on at Telligent and took most of my time.  I had committed to myself I wouldn't do any posts until that one is done.

I'm breaking that commitment now.  Sorry Jose, perhaps I'll get it typed out someday.

March North Dallas User Group

I've had it as a goal of mine for nearly two years and I finally was able to pull it off.  It was a long arduous journey to get there, mostly out of confidence reasons, but I finally found a topic I was knowledgeable about and not everyone does.  I've seen too many Ajax Extender demos to last me a lifetime.

I gave a talk about garbage collection, addressing the algorithm and covering the Dispose pattern.  I hope the code samples for the dispose pattern will be useful.  I will be extending out the slide deck for my next go.  There were some good questions brought up at the end of that I would like to cover as part of the presentation.  However, that is for a later time.

I've attached my slides and code demo.

If you have any questions about it, post a comment, or send me a message.

I never imagined the day

 

Tivo always suggests some music shows from my girlfriend's viewing habits.  I've normally just let them fall off, but recently I've been watching more and more MTV.  I'm doing research for an application that targets the MTV market using new mobile phone technologies. 

Almost throughout every episode you can text something somewhere and get something.  If you want to subscribe to jokes text: "Fun1" to 66300, or "Ring this song as your ringtone, text "22354".  And that's through the show.  I've started watching more of the commercials because this is a commercial application and I want to understand how that market uses their mobile phones.

I went to the kitchen for a commercial and come back and see soap on the TV screen with naked women behind it.  It is blurry looking through the soap, but then she squeegees the window slowly, seductively.  Her voice is pleading the viewers to "Let us [some had two women] clean your cell phone window, text <something>".  Man...you press 6 buttons and basically have access to a strip show on a pocket sized device.

More Posts Next page »