Thursday, January 31, 2008

Old Code Part 2: XML / XSLT Before it was Cool

For this issue of Old Code I'll be going way back. Before .NET, before Visual Studio, before broadband. I wrote this app before many of you were even working. This was probably my favorite project of all time, still stands up to that today. Since this was so long ago I can give more details than in the last issue so here we go.

Background: The year was 2000 and companies small and large were realizing they had to get online. Some because they had a business need to do so, others because "everyone else was'. This was a case of an actual business need.

I worked for a smallish web design / development company called DigitalDay, they had just changed their name from Mozes Cleveland and Company. We had some good sized clients like Sherwin Williams and Ernest & Young but our biggest (duh) was GE. We did a lot of work for GE Plastics and their Silicones division, incredibly huge multi-national companies. Anyway, one day I had just returned from TechEd 2000 in Orlando and was pulled into a conference call with a branch of GE Silicones in Europe. It was actually a joint venture between GE and Bayer (yes, the aspirin people). They had a problem.

Problem: When these two separate companies were merging their ERP systems it was concluded that they systems were incompatible so they switched both companies to SAP R/3. The E-Commerce team had been given a nearly impossible deadline of getting a system online using the new SAP system within just a few months. They did accomplish this goal (don't worry, we'll get to my role soon) as this was right after SAP had released the MySAP module which contained its own proprietary web server and exposed SAP modules online. Done, first goal accomplished. But there were issues.

Issues: While they met the milestone, no one was satisfied with the results. The web application wasn't branded GE Bayer Silicones but instead was branded MySAP including colors, logos and everything. Also, this was long before most manufacturing companies in Europe had broadband Internet and for them this application was incredibly slow. Customers complained. Then came the call.

So on this call they got us into the application to take a look around and wanted our opinion on if we could do anything to speed it up. It didn't take long before I had identified that the biggest issue affecting speed was the .js files being downloaded. They totaled around 300k. Even today in the AJAX and JSON world 300k .js files are a little excessive but in 2000 that was out of control. So the call ended and I went back to work only to be asked minutes later if I had a passport. Two weeks later I'm on a plane to Amsterdam to spend 10 days looking at the issue in Bergen Op Zoom Holland.

Once there I dug into the MySAP solution to see what I could do to fix it. So after three trips to Holland totaling over three months I had built them a solution that I am still proud of today.

Solution: The big requirement was to display a screen to the user with information on 300+ purchase orders in the quickest time possible. I crafted a solution where the page would have an embedded XML Data Island (linking XML was less reliable in those days) and linked XSL file, CSS file and JS file. The XSL/CSS/JS combination gave the ability to create HTML on the fly for two different layouts and allow sorting and filtering as well. All in client side code.

MySAP had already constrained them to using IE only, so I also had them use 5.0 or higher which gave me access to browser XML support and also having to only code the JavaScript once. I worked with ABAP programmers from Deloitte to get the information to me that I needed. I then had to learn SAP's server side language BHTML, which was simplistic but different, to craft the XML to send with the page. Due to the size constraints I went against "proper" XML design and used single character element names and no whitespace at all as every byte meant a lot when it would be repeated hundreds of times ((once in opening tag + once in closing tag) * number of results). Oh yea, and I built this entire app in Notepad. Not kidding. No IDE, not even Notepad Plus.

Conclusion: While using XML with client code in a browser may be common-place today, it was totally new at the time. XSL Transforms done in the client browser still isn't common, I did it in 2000. Basically between three months in Europe, totally cool technology and one of the best project managers I've ever worked under, this was my favorite project ever.

Lessons Learned:

  • Two-Day shipping from Amazon to The Netherlands cost more than the book itself
  • Never spend an anniversary in Amsterdam unless you can do it every year (I did, I haven't, I hear about it frequently)
  • Never take wife to Europe unless you can move there (I did, I haven't, I hear about it frequently)

Monday, January 28, 2008

Model Railroads Are For Geeks Too

Like many people I had toy trains as a kid.  It was nothing huge or elaborate but my dad and I (well, mostly my dad as I was about 10) built a 4'X8' table in our basement with an HO layout on it.  It was fun and I enjoyed adding buildings and stuff to it but it never really 'grabbed' me.

Fast forward a few many years and here I am playing with trains again.  This time they are bigger, O Gauge instead of HO Gauge (1/48 scale instead of 1/87 for those not 'in the know').  And while there is still the fun of watching trains run around the track, and seeing the pure joy on my son's face while watching them would make anything better, there is something more this time.  Trains are 'smarter' then they were when I was a kid.  Current trains are fun for the geek in all of us (at least the geek in everyone reading a programming blog).

January 2008 043 The two largest companies in O Gauge railroading today are Lionel and MTH.  Lionel is the same company that made the trains your granddad played with.  MTH is a newer company but still very much into it, and the competition between the two helps them each do some great things.  Now I'm not saying that these guys are all these is, far from it, they just are the biggest.  There tons of companies that make all sorts of stuf.  You can even buy track that is so realistic it comes with wooden ties that are spiked to the rails like real track!

But what is cool for geeks?  I'll tell you :)

DCSRemote New engines from either company have a ton of features other than go & stop.  I have a remote control from MTH that lets me blow whistles, sound bells, launch station announcements, cause train wrecks, adjust volume, drop cars and a ton more.  And I can do this for multiple engines at one time, while walking around the room.  Trust me, it's a lot more fun than it sounds.  You have total control over multiple engines, can throw switches and even operate accessories, all from the one remote.  The home theater market could learn a thing or two from these guys :).

 

currentlayout Also for geeks, there is the planning.  You can't just throw track on a board and hope it all fits.  There is software these days to help you determine what the layout will look like (and if it will fit).  This software makes it easy to figure out how much of what type of track you can fit in the space you have available.  You can even look at your layout in 3d and give it accessories, buildings and mountains.

 

January 2008 300 And then there is the wiring.  A simple loop requires simple wiring, a couple of wires going to a lock-on (easy device for connecting wire to track) and you are done.  The more complex the layout, the more complex the wiring gets as well.  My layout shown here has 18 switches, three separate loops (each in numerous blocks), six sidings and numerous operating accessories.  All of these items require their own wiring, some needing soldered to toggle switches or screwed onto terminal posts.  You can't see even a fraction of the wiring from this one picture and this isn't even done.  That piece on the left will have about 20 sets of three lead wires heading into it soon.

Really I'm not quite which is more fun.  Playing with the trains or building the layout.

Old Code Part 1: Plug-In(able) Web Application

Today I'm starting a series that I'm calling "Old Code".  This will be where I go over some project I've worked on that was notable for some reason but may not directly translate into a "how-to" for developers today.  These posts will more be about some problem to which there was no simple solution but to which a solution was found that was usually either particularly creative, cutting edge (for its time) or a total hack but that got the job done.  Some of these projects I'm proud of, others I'll be telling you about even if it may not be my best work.  Overall though I think we can all gain by looking back at our past projects and letting the public review them for with us.  In most of these I won't be able to provide code samples or even give application / company names because of NDAs but I don't think that will impact the overall posts.

I this first installment I'm going to be talking about a project I was working on about four years ago. Disclaimer: My memory of 2004 may be a little fuzzy but I don't think I can take full credit or blame for this solution.

Background: The overall project was to create a web-based management application for complex devices which did have their own internal memory.  Basically this application was to replace numerous desktop applications with a multi-user, accessible anywhere, cool, user-friendly, do everything management application.  When the project got started it was 2004 and we were building it in C# and ASP.NET on the .NET 1.1 framework.

Problem:  Of these devices that the application was to manage there are numerous 'families' to which the capabilities of and communication to are drastically different.  This application was to allow the ability to be installed with the ability to support one or more family and have the ability to support future families possibly being added by third-party developers.  They didn't want to release the source code or to have to recompile every time a new family was to be added.  In theory a third party company that makes these devices would have the ability to create their own "plug-in" and install it at a customer location without our companies involvement.

Issues: With it being 2004 none of us had a ton of .NET experience but we did know a lot.  To our knowledge (and I still think this was true in 1.1) all code-behind files for a web app were compiled into a single DLL at build time.  This is where the real issue existed:  How do we let third-party developers seamlessly add pages to our .NET 1.1 web application?

Solution: Now the architecture that was devised to handle this is hard to explain without examples.  Who am I kidding, it's hard to explain with examples.  Many good developers took months to really grasp what we were doing, we'll see if you get it quicker.  Basically the application was split into pieces.  It was already n-tier with a full business object model based on Lhotka's CSLA framework.  Basically an architecture was created in which any family specific code would exist in satellite dlls that are loaded using reflection at run-time based on information coming from the SQL Server database.  This included the code-behind files for any pages or user controls that contained family specific controls/data.  Much work was done to construct generic widget classes that only contain fields that all widgets have regardless of family and then having the family specific classes derive from those classes and add their own fields / methods as well as all update logic.  While that is standard for OO business layer development, it's something else to apply that same paradigm to web pages. 

We ended up creating a structure where the base application would know that there was a widgetconfig.aspx page.  Then at run-time an intermediary page would intercept the request for the config page and append a family specific folder name in front so that the request would get to the correct page.  These was still the issue of the code-behind pages.  This is where it gets tricky.  For each family specfic page the actual aspx would only contain the generic header and footer user control declarations (this was pre-master pages) and a declaration for a user-control of the same name as the parent page.  In the directive for the family specific user control the assembly would be named to find the class in.  This assembly was a family specific dll that housed all code-behind files for that families pages.  In the class for that user control it would name the actual .ascx file to associate with the controls defined in the class. 

Through this method we were able to create a way to add a new family to an installed server by adding some dlls to the bin and some code-less aspx & ascx files to the application folders.  So it was possible to do this without touching the original source.

Conclusion:  After much coding effort and even more in education this strategy went untested for nearly four years.  Just today we got word that the first true use of this plug-in model had been successfully implemented using our SDK and without touching our source code.  While I'm sure that there were probably more elegant ways to accomplish this and that I'm glossed over much of the complexity this was a solution for the problem that worked.  Of course in .NET 2.0 it would have been much easier, but that didn't exist yet.  I was going to have a co-worker from that project review this before I posted it but what the hey, he can review it by reading it :).

Don't worry,  some posts in this series may contain actual code :).

New Developer Events in NEO?

Quick post here...

I've been talking with some people lately about getting more developer events up here where we "Get The Shaft". Another active Cleveland developer took the first step of creating a Google Group with the objective of getting people a forum to actually work together to make this happen. If anyone reading this is interested in helping get new developer events to the NorthEast Ohio area head on over to Google, join the group and do what you can. We need help in every way you can think of too btw: sponsors, locations, speakers etc.

Thursday, January 24, 2008

How Dinosaur Web Developers Can Regain Their Shine: Step 1

Last week I posted that a large number of us that have been web developers since the first Internet boom are becoming dinosaurs.  I may have said COBOL programmers, but it's the same thing :). 

I also said that one of the things we need to learn in order to catch up is CSS.  Now, we all used to think we knew CSS, and we did they way it worked at the time, in the browsers of the day.  Through trial and error we learned what you could and couldn't do that would look consistent across the major browsers of the day.  Along the way we learned to stay away from things like dynamic positioning, you were pretty sure to have things look bad unless you wrote a TON of special code to account for browser differences.

Well, the browsers have matured along with us but while our hair may have thinned or waistlines grown the browsers have become more standards compliant.  Now the MS bashers will say that IE is still not compliant and sure, there are issues, but overall, wow, they all do a lot of cool stuff consistently now.  You might say that while we are moving steadily toward middle age, the browsers are finally just able to buy us a drink.  Positioning of elements, cool dynamic looks and even whole page layouts can now be done using nothing more than CSS and some images.  Better yet, it looks the same in all major browsers.

The longer we wait to learn the new standards, the harder it will be for us. 

mix Are you not convinced yet of what can be done with CSS?  Take a look at the site for MIX08 and then look at the exact same site with a different (and plain) stylesheet.  Pretty amazing huh? 

 

 

 

csszengarden Still not convinced?  Ok, check this one out: CSS Zen Garden is a site created to demonstrate the capabilities of standards based CSS design and provide the resources to help you do it.  Play around with the site by choosing different designs and you will see what I'm talking about.  There are samples of all of it along with links to plenty of other resources.

 

 

 

So, do you think you have what it takes to use standards based web development already?  If so then head over to the restyle site and enter the contest with your cool design.  You can get a trip to Vegas out of it and hear some guys named Ballmer, and Guthrie talk about cool stuff.

Wednesday, January 23, 2008

I WILL be an MVP

Now maybe this isn't a practical goal but I truly think it is possible for me to be named a Microsoft MVP in ASP.NET when they are announced in December.

Wanna know how I'm going to do it?

Basically I'm doing the same things that I've been preaching that we all need to do:

  • Learn the newest stuff
  • Evangelize to peers
  • Be active in the community (online and in person)
  • Make yourself known
  • BE AN EXPERT

So that last one is the hardest, but I'll talk about that a little later. First I'm learning the newest stuff and catching up on stuff I've fallen behind in. For me this means getting up to date on dynamic positioning, learning ASP.NET AJAX and finding the limitations with Silverlight and trying to find ways to get around them. It means not just reading about these things online but also watching videos, reading books, building sample apps on my own time and also trying to convince my employer to use them in production. I'm well into this phase already, the only trick is going to be able to keep up the momentum.

Evangelizing to peers is something I've always done so that's not a hard one for me. When there is something I'm passionate about everyone around me knows it. I tend to talk a lot when I find something cool and want everyone else to see how cool it is.

Being active in the community is also not a hard one but takes a time commitment. For the last couple of week I've been all over the forums at asp.net answering questions about asp.net left and right. I've also learned a few things as well which is a great thing about forums, you may have a solution but someone else may know of a cleaner / cooler / more elegant solution. The in person community is a little harder just because of the time / distance issue. This is also something that I've done in the past so I need to get back at it. I had a contract gig at the Cleveland Clinic that was only a few months long but still was able to get an internal ASP.NET monthly lunch discussion going which had pretty good turnout. I also try to get to the .NET SIG at the MS office but that's about it at the moment. I really need to offer to speak at one of these groups to really push me to get involved more.

Making myself known kind of comes along for the ride if you do the "be active" item from above. You you are active enough and vocal enough then people will notice. You just need to make sure they notice you for your wisdom and insight instead of for your ignorance and stupidity.

Be an expert. This one is hard to quantify. What makes a person an expert? Is it a certification? Nope, I've seen plenty of people disprove that. What about an advanced degree? Again nope, that may give you academic knowledge but I don't think that makes anyone an expert. Personally I think you are an expert when someone else calls you one. Preferably numerous people. You can't name yourself an expert and expect it to mean anything unless you have people that truly think that you are one. Some people call me an expert in .NET web development already but I don't think I'm there yet. I will be before this year is up though, because I WILL BE AN MVP.

Monday, January 21, 2008

Well, Maybe Cleveland Doesn't Get The Shaft

Ok, so my earlier ranting must have paid off. Well, maybe not but at least I have answers to some of the stuff. I was right about one point, Cleveland is NOT getting an MSDN event this quarter. The reason is that we are getting a launch event which is bigger and full of sessions like what's at MSDN. And the launch event has been moved up about two months earlier than they had originally said, to March 13th. So now it's only about two weeks after the first event, instead of three months.

So maybe it's not all that bad up here after all.