SRP / DI / IOC : Don't Leave Sub Main Without Them

I'll be giving a talk at the Philly.NET Code Camp on 5/17/2008

The Single Responsibility PrincipleDependency InjectionInversion of Control

If you don't already know and apply these concepts in your day-to-day development this talk is for you. 

The talk will present a very easy learning curve into these topics.  We will cover the "why" as well as the "how."  We will take a simple application written without these techniques and transform it step-by-step. 

While we will see that these things make testing your code much easier, we will also see that their use goes far beyond testing scenarios.  

In order to better communicate the "how" , we will not be using any pre-existing IOC framework such as Castle, Spring.NET, StructureMap, etc. Rather, we will build our own simple implementation during the talk.

I'm not a Jedi

In this post James Kovacs is talking about becoming a ReSharper Jedi.  Recently I attended a training class given by JP Boodhoo who is probably Obi Wan to these guys, if not Yoda himself. 

I admit to being completely overwhelmed for most of the week, not the least reason being the obsession with this topic - Keyboard=Good Mouse=Bad. 

I was shocked that someone would do training this way - after all, I was there to learn programming concepts, and that was greatly hindered by the fact that I just couldn't keep up.

But the real shock for me was how enthusiastic the class was (other than me that is).  They took to it big time.  Everyone wanted to learn which key combination did what and worked really hard at it.  Well except for me.  I gave up on that after the first day and was a lot happier.

Now, I've worked at call centers and collection agencies for most of my career, so I definitely appreciate how the keyboard is better when speed of input is the primary goal.  You want your collectors or reps talking and typing and hitting the next call key even while hanging up as quickly and graciously as possible with the current call.  I've got that.  I've DONE that :)

But I can tell you for certain that in my programming career it is never the speed of clicking File | New that slows my development efforts.  Or the speed of using the mouse to right click on the project and Add a Class.  Sure hitting some key combination would be FASTER.  But I just don't need that kind of speed.  Most of my time is spent thinking.  I'm a pretty fast typist when I'm actually putting some code down, but...  I just don't see programming as a hand-eye coordination type of endeavor.

It is really a bit humbling to me.  I imagine these guys are so much smarter than I am, that in their mind they have already written the next 3 classes and they just need to push them onto the disk as fast as they can so they can move on to the next project.  Wow!

VSS Better Than Backups?

So, I've been dealing with an infrastructure team that didn't have backups of a web server recently...  We were told "You don't need backups - that's what you have VSS for, right?"

Hmmm... 

Maybe its just because I came up on the "operations" side of IT, and the backups were my highest priority, but it took me a while to realize they were serious.  As in "we're gonna argue about this for a while."  For better or worse, the infrastructure guys carry a lot of clout at the company I work for now, so I couldn't just scowl at them and tell them how stupid this sounded to me.  I had to try and reason about something that just seemed obvious to me.

One thing I've learned is that anything that seems "obvious" to me probably means I don't understand the whole thing :)

I thought I had a perfect, easy to understand example of why that idea doesn't work - config files.  We deploy these apps with certain things configurable after the fact, and some other support type person can change these settings without our knowledge, I explained.  Our copy in VSS would be unaware of any edits that have gone in since the app was deployed.

No dice.  The infrastructure guys were even pushy enough to get the development boss to start wondering if perhaps we should make sure that whenever anyone updates the config files those should be checked into VSS.  Forget the fact that different deployments might have different configs, yet only one VSS.  "We can make a subdirectory for each one."

I just refused to roll over and die on this one, which got me some nasty comments after the meeting.  We did hammer out a tentative "in a catastrophic failure you can beg and plead and we will grab stuff from tape for you - but you had better first help yourself by having copies of your files in email or subdirectories or something."

So please tell me - Am I just wrong on this?  Is my own past experience of being responsible for "the backups" making me want to place too much burden on the infrastructure team?  After all, this is a different company, with different priorities and challenges, etc.

Thanks!
Travis

Parker Says YES!

So our wonderful two-year-old Parker (he's 3 now but I'm just slow posting these days) was having an argument with his mom..  Things were getting just a bit heated when Jessica yelled out the the standard line:

Mommy Said NO!!!



To which Parker had a resounding answer:

PARKER SAYS YES!!



I suppose she didn't like it when Carter and I laughed so hard we had to leave the table... :)

Philly.NET Code Camp 2008.1 - Looking for Speakers!

I'm looking for speakers in the Tools/Languages track for the Philly.NET Code Camp 2008.1.

This will be held on Saturday, January 12, 2008 at DeVry University in Fort Washington.

Some topics not yet covered but I'd love to see presented are:

  • NDepend
  • NAnt
  • MSBuild
  • CIFactory
  • Reflector
  • ReSharper

If you would like to present on any of these, or have other ideas please let me know!

Travis

Firefox Search Plugin for Google Code Search - By Me!

Google has recently unveiled a new search site centered on source code for developers. It's pretty fast, and I love the results.

So of course I wanted to add a search plugin to my Firefox.

 


Lo and behold, I couldn't find one! So, I learned how, and have created my first Firefox plugin. I'm sharing it hoping that others find it useful. Travis

 

Clipmarks

If you have not yet tried Clipmarks, you owe it to yourself to give it a look. The URL is: www.clipmarks.com This is a twist on the "social bookmarking" theme, where you can do a bit more than bookmark and comment and tag. You can "clip" the content as well. You can create a single "clipmark" containing content from many different articles you've found on the web. Then of course you can follow tags or people or whatever - to find related content. I think it's the coolest thing on the internet. Anyway, I clip lots of stuff, and if you'd like, you can subscribe to an RSS feed of my postings, at this URL: http://rss.clipmarks.com/clipper/travislaborde/ Of course, I'll clip my blog posts from now on. Hmmm... Should I clip my blog posting about clipping? I think not. I'll clip any NEW blog posts I make in the future. Travis

Using a Filter to build the HEAD section of a page in ASP.NET

I've posted my first article on CodeProject!

In ASP.NET (1.1) one of the things that's not so straight-forward to do is dynamically generate the tags that go within the HEAD of the page.  Of course there are many ways to do it, but none of them seems to be perfect.  I've used a few different methods over the years, and finally came up with something that I thought was cool enough to post about :)  It's different, anyway.

If you're at all interested, take a look at the following link: http://www.codeproject.com/useritems/HeadFilter.asp

So far the ratings are pretty good, and I'm excited about it!

Travis

 

Yahoo Mail doesn't like IE7

I'm torn as to whether I'm going to keep this thing installed or go back to an image :)

IE7 brings us tabbed browsing - much better than the MSN toolbar did thank goodness.  And some other niceties I'm sure.  But here are the glitches I've found so far:

1) Yahoo mail thinks it is an “old” browser, so falls back to “old ugly mode.”  Ugh.  Granted, this is probably not an IE bug but still, it's not nice.

2) The toolbars are in the wrong order and you can't move them the right way?  What?  Maybe it's me.  I've got the address bar on top, then the tabs, then the “pulldown” menus.  And I can't move the menus to the top like “every other piece of Windows software in the world.”

3) The tabs are just plain UGLY.

4) Some of this may be caused by the IE7 not liking the MSN Toolbar :)  It appears in the menu with no title.  Just a “blank” entry.  Good, I hated it anyway.  I tolerated it for the tabs :)

But speaking of tabbed browsing - Can we get an option added that will warn you if you close IE while more than one tab is open?  OMG how often have I closed the browser because I'm so used to “Open in New Window” instead of “Open in New Tab.”  ARGH!

 

Does Oracle Suck? Or just Oracle DBAs?

Since leaving the job I was at for 8 years, I've had three gigs since December.  First I took a contracting gig to get me through the holidays, at Centocor.  This was a great experience, and I'll have to post about that one day.  When that was up (even though they wanted to extend me) I took what I thought was going to be a great full time position at a company I'll leave un-named :)  This was a horror story for another post.  I left there as fast as was possible, and landed now at a truly great place to work.

The funny thing is - all three of these places are big Oracle shops.  So, I've had my first experiences with Oracle.

At Centocor, they were doing their first big “validated” SQL Server rollout, and wanted to bring in someone to sort of “be there” to help them get it all sorted out, and to get thier practices in place, etc.  Basically I worked with the Oracle DBA's and tried to show them how to accomplish in SQL Server the things they already knew how to do in Oracle.  And I wrote a lot of scripts :)  If you've never gone through a 21CFR11 Validation, be glad - it's a LOT of documentation.

At the “other” company I was the team lead and manager on some very cool and complex Windows software in .old and .NET.  Oh, how I wish things would have been better there.  I'll post about that one day when I know how to do it without being mean.

At the new place, I'm “just a developer” trying my best to do everything in .NET and maintaining the .old stuff when they force me to.

But at any rate - at all three companies I've noticed something regarding Oracle usage that is driving me crazy:

No stored procedures.  All three companies insist on the developers writing their SQL as a bunch of sql = sql + ... command.  UGH!

OK, maybe Centocor had some sprocs.  But there was a lot of dynamic stuff going on there.  The “other” company told me there were performance issues with using stored procedures in Oracle.  What?  Of course I had no idea, but deep inside I was sure I was talking to idiots.  Did I mention I hated the place?  This is the same place where the database group would change the schema and not tell the GUI developers until the app failed in QA :)

Now, even where I am now, I'm finding a LOT of dynamic SQL.  NOT for cross-platform compatibility purposes, but the DBAs really don't want to create sprocs.  What?  Why?  Again, I'm told it's a performance issue.  Something about sprocs taking up all the RAM.  I can't stop laughing, but - is there any merit to this?

Of course, we also have three different versions of Oralce, none of which support ANSI joins so I'm pulling my hair out trying to write even simple queries.  How has Oracle survived without this?  OMG.

Another example - Just the other day I had a fight on my hands.  I was working on an app that had previously been partially developed.  I needed to build a GUI around a certain table for maintenance.  But there was no unique identifier.  It had an ID field.  But all the rows were NULL.  I asked if it could be made to be an auto-number Identity like field.  No - that apparently is hard in Oracle.  Hard?  I told them Access can do that, how can it be hard?  Well, it just is.  OK.  So, finally they agreed to make it a varchar field so I can put in GUIDs that I'll create in my .NET code.  And, get this, they insisted that it be 50 chars wide “just in case Microsoft changes the width of the GUID in the future.“  That darn Microsoft - always screwing things up!

I've heard horror stories for a long time now, about dealing with DBAs.  But, I've always BEEN the DBA, so of course I laugh it off and think “no way it's that bad.“  But now I think I'm getting the picture.

So - can anyone shed some light?  Have I just seen three extreme examples in a row?  Or am I just spoiled by SQL Server?

 

 

 

Butt Dust?

I found this in my travels today, and had to share it.  Apparently it is a true story :)

A visiting minister during the offertory prayer:

"Dear Lord," he began with arms extended and a rapturous look on his
upturned face,"without you we are but dust..."

He would have continued, but at that moment one very obedient little
girl (who was listening carefully for a change!) leaned over to her mother and asked quite audibly in her shrill little girl voice,"Mommy, WHAT
is butt dust?"

Church was pretty much over at that point..

Original URL: http://www.avoidingevil.com/blog/archives/002617.htm

 

Using XML To Send Multiple Rows At Once Into A Stored Procedure

From time to time, people ask the question "How can I insert many records at once into SQL Server?"  The purpose of this quick article is to describe that process in very basic details.  I'll give a very simple example, so that you can then take it from there.

 

I find that it's easiest to visualize if you start with a very simple XML document.  Here is an example XML snippet:

 

<items>

            <item id="1"></item>

            <item id="4"></item>

            <item id="12"></item>

            <item id="112"></item>

            <item id="234"></item>

            <item id="605"></item>

</items>

 

Let's say you have a checkboxlist, and you want to send the list of "checked" items into a SQL Server stored procedure, making an INSERT for each checked item.  You want to create a string containing text that is formatted as above, and for each checked item, insert a "row."  Here is a simple class in VB.NET to abstract that functionality:

 

Public Class XMLItemList

    Private sb As System.Text.StringBuilder

 

    Public Sub New()

        sb = New System.Text.StringBuilder

        sb.Append("<items>" & vbCrLf)

    End Sub

 

    Public Sub AddItem(ByVal Item As String)

        sb.AppendFormat("<item id={0}{1}{2}></item>{3}", Chr(34), Item, Chr(34), vbCrLf)

    End Sub

 

    Public Overrides Function ToString() As String

        sb.Append("</items>" & vbCrLf)

        Return sb.ToString

    End Function

 

End Class

 

As you can see, there is nothing special or fancy going on here.  The purpose of the class is just to make the next example easier to understand:

 

Dim MyXMLItemList As New XMLItemList

For i As Integer = 0 To MyCheckBoxList.Items.Count - 1

    If MyCheckBoxList.Items(i).Selected = True Then

        MyXMLItemList.AddItem(MyCheckBoxList.Items(i).Value)

    End If

Next

 

Given the above, you can use the MyXMLItemList.ToString method to get a string representation that is formatted like the XML snippet described in the beginning.

 

All that remains then is to call your stored procedure, passing in the string produced above as a parameter.  Here is how that stored procedure would be written:

 

alter procedure usp_InsertManyRows

@XMLDOC varchar(8000)

AS

 

declare @xml_hndl int

 

--prepare the XML Document by executing a system stored procedure

exec sp_xml_preparedocument @xml_hndl OUTPUT, @XMLDOC

 

 

--insert into table

Insert Into testtable

            (

            InsertedID

            )

Select

            IDToInsert

From

            OPENXML(@xml_hndl, '/items/item', 1)

            With

                        (

                        IDToInsert int '@id'

                        )

 

 

Now follows a comparison of how each performs.  The following tests were run with simple ASP.NET pages using a local SQL Server database.  The results are quite dramatic, and would only be more dramatic if the hits had to go over the network:

 

First, I created a simple page that hit the database 10 times, each time inserting one record.  Here are the results of that test:

            97 Requests Per Second

            28254 hits in 5 minutes

            282540 records inserted

           

Next, I created a simple page that hits the database only once, sending in all ten records to be inserted together at once, using the XML format mentioned in this article.  Here are the results of that test:

            186 Requests Per Second

            55349 hits in 5 minutes

            553490 records inserted

 

Quite an impressive difference!

 

Looking for work!

The time has finally come for me to move on, and I'm looking for a new start in 2005!

I've been "Director of IT" for 8 years, "Database and Application Developer" for 12 years, and in some aspect of IT Management for 15 years.  I've been the primary DBA for SQL Server 7 and 2000 for the past 6 years.  My focus for the past few years has been on ASP.NET and SQL Server.  As seen on this blog, I've devoted a lot of time to Performance Tuning, and I think I have a lot to offer the right company.

I've done all of the database design, implementation, maintenance, and tuning, while also doing a great deal of the application development.  As the company grew, I hired other talented developers, but always kept a part of the development work for myself, so my skills are sharp.

My skills and experience are mostly Microsoft based.  I began with VB3 and VBA.  I “graduated“ into writing web applications back before ASP was an optional add-in for NT4, and never looked back.  I've done a LOT of ASP.OLD work.  I've created a LOT of COM objects to host in MTS/COM+ for use in those ASP applications.  I've created and used custom ActiveX controls for intranet applications.  I've converted large ASP applications to ASP.NET, written Windows Services, a ton of Web Services, and utility type software in .NET.  I've developed Disaster Recovery Plans, and have had to actually implement those plans.  I will bring experience, integrity, and a great work ethic with me.

I'm seeking a company that will allow me to continue to develop my skillset.  I think I'd be equally excited about a DBA position, a .NET Developer position, or another Leader type position.  I don't want to be “just a manager.“  And I don't want to have to care about the Exchange server going down :)  That can be outsourced.

If you know of any opportunities in the greater Philadelphia area, please contact me via the form on the blog.

Thank you!

Travis Laborde

 

Yellow Babies, Big Boobies, and Apple Juice

I'm the proud papa of a new baby, Parker James Laborde!  I have no idea what I'll do to rename my blog, because of course I can no longer be just “Carter's Dad.”  Any ideas?

Anyway, Parker was born on 10/28, perfectly healthy except for one thing... Jaundice.  For those of you who don't know, Jaundice is a condition that affects a lot of new born babies, but usually isn't anything serious to worry about.  The visible sign is that the skin turns very yellow.  There are certain chemicals in the blood that don't get cleaned up because the liver isn't fully developed yet, or something like that.  If it gets out of control, it can cause major problems, such as some forms of brain damage.  My first son Carter had it really bad, but came through just fine.  Parker had a milder case, and had to stay in the hospital a bit of extra time, but now we're all home and happy - and out of the woods!  I thank God for His blessing.

So, where do the big boobies and the apple juice come in?  Here's the story....

Carter was watching his mom breast feed Parker, and wanted to know what was going on.  Of course, we explained about mother's milk, and how that works, and that he himself had been fed that way when he was a baby.  He had no problem with that explanation, but he wanted to know... “Daddy, do you have milk in your boobies?”  As if that wasn't funny enough, when I told him that only mommies could do that, he thought about it for just a little while... then he got a gleam in his eyes, and asked me:

“Do you have apple juice in yours daddy?”

 

Expansion Diary Part 7 - The Rush

After weeks of testing and a small rollout we've finally put our new queue system into play for everyone.  What a rush!  There were glitches at first, when the new system was under heavy load for the first time, and we worked hard all day... but in the end it was and is AWESOME.

I have a profiler running constantly which logs for me every query that takes 5 seconds or more to run.  I use this to keep an eye on what needs to be tuned, as well as to let me know what business activities are hitting at any moment when the system is dragging.  It is an easy sign of progress to monitor this list closely.

I'll share with you perhaps the most easy to understand metric that shows how well the new system is performing:

When you sum up the number of seconds that these long running queries take to run for a given day, plenty of days it adds up to well over 1000, sometimes more than 3000 minutes.

Yesterday, with more users than ever before: 101 minutes total for the day.

Oh, I guess there is one more metric worth mentioning - the smile factor.  Ahh, walking around this place is a fun thing again :)