free geoip Jayson's Blog -
A conduit to the voices inside my head.

Jayson's Blog

  • Gallery Updates

    Uploaded some new pics, check ’em out.  More to come.
  • Longhorn Team RSS Blog

    Amidst all the news of Rss being baked into Longhorn, it turns out the Longhorn Rss team has started a blog.  Subscribed.
  • Strongly Typed Datasets and XML

    I’ve posted numerous times before about my feelings on Xml parsing (and not just as it relates to .Net, but Xml in general), so I won’t rehash my feelings on the subject here except for one sentence:  I love Xml, but I abhor querying/parsing/handling it.  It’s great in principle, but in practice there is a lot to be desired (IMO).  It is getting better though with XQuery support in 2.0, but it’s not quite there yet.

    So, I found myself with some free time this weekend to work on a small project I’ve wanted to do for a while now, ever since Ray pointed out that our favorite online music streaming company publishes an Xml file of their playlists; build a WinForms gui that wraps up this playlist and offers more functionality than their website (which is *painfully* slow I might add).  The structure of the Xml file is pretty straightforward, but I’m always hesitant to parse Xml files due to the reasons mentioned above, and lack of strong typing (I really don’t like seeing a lot of strings in my code, it’s error-prone and I usually end up anti-debugging methods that deal with Xml parsing).

    I initially set out to consume the file in a dataset, then realized that setting up all the relationships manually was going to be tedious at best and would end up taking more time than just XPath’ing the document.  I don’t know why I didn’t think of this before, but it hit me that I should be able to create a strongly typed dataset based on the schema of the file.  I’ve worked with typed datasets before, but it’s always been with RDBMS structured data, never with Xml.  It turned out the be quite simple actually…in short I was blown away with how simple it was.

    • Create a new System.Data.Dataset.
    • Create a new XmlTextReader and point it towards the Xml file to write the schema for (in this case, the Xml file published by DI).
    • Load the file into the dataset by calling ds.ReadXml, passing in the XmlTextReader as a parameter.
    • Call ds.WriteXmlSchema and specify the path for the resulting .xsd file.
    • Open a .Net command window and run xsd <path\name of file>.xsd /d to create the C# class file.
    • Add the resulting class file to your project.
    • Instantiate the new class, and read in the original Xml file via the steps mentioned above.

    I was a little skeptical if this would work as DI’s file has no schema information in it, but through the magic of WriteXmlSchema it was all inferred.  What you now have is a fully typed container for your Xml data…no messy XPath navigation, traversing nodes…and did I mention it’s fully typed?  No more f5’ing just to see if your XPath statements do indeed return the results you need (well, in my case at least…I highly doubt someone of say, Dino Esposito’s stature would ever doubt their own code).  It may be a bit of an overkill for a file as simple as DI’s (the resulting class file from xsd.exe is close to 3000 lines of code), but why not leverage the built-in functionality of the runtime wherever possible (plus I’m partial to typed datasets, for WinForms at least).  What would have taken me who knows how many lines of XPath to parse/navigate the document took me only a dozen lines (and virtually no rebuilding…since it’s typed you know that it will “just work”).  All of the relationships are built in, so finding child rows is easy as this (where ChannelInfo is my typed dataset and ContentSection is a homegrown user control to house the data retrieved).

    That’s it.  Minimal code, minimal testing.  As for performance, I don’t have any raw data in front of to see if it’s actually faster than the comparable XPath…my guess is that it would be though.  As far as the application I’m writing to wrap up the DI playlists, it’s a secret for now…but I plan on building some pretty cool stuff into it.  I have the shell built which mimics DI’s interface, but I plan on adding a lot to it (basically just a utility that sits in your systray, will enable full control of streaming media from any site, will be completely pluggable/extensible/the usual stuff…plus features like pinging you when a specific track comes on, etc…lots of ideas, so little time to code).

    I’ve been a web guy for as long as I can remember, haven’t really worked on any WinForms stuff on any scale…I’m pretty impressed with what I’ve seen thusfar.  This is gonna be a fun hobby project!

  • Don't Forget the Thermal Grease!

    Thanks to MotherBoard Monitor, I noticed that the chip in my new rig was running a little hot at idle (around 110 degrees farenheit, god only knows how hot it was getting during actual use).  This being an AMD chip, I didn’t really think much of it as I remember the older chips ran very hot.  I mentioned it to Bob, at which point he reached through the internet and smacked me; “did you use thermal grease (aka High-Density Polysynthetic Silver Thermal Compound) between the chip and the heatsink?”  Whoops.  Hey, it’s been a while since I built my own machine (I’ve used it on all previous builds, simply forgot this time).  So I ran and got some, took the chip out, applied a gratuitous layer of the “compound”, and put everything back together…and then spent 30 minutes washing my hands trying to get rid of the crap that had glued itself there.  The chip is now running around 90 degrees F, so good call.  It’s actually running cooler than my Intel rig.  Don’t forget to use this stuff.
  • Community Server 1.1 RTM

    Community Server v1.1 has been RTM’d. I will update my test site when it’s not 4:30AM (f’ing insomnia is driving me crazy as of late).  To rehash the announcement by Scott:

    As stated before, the key focus on this version was performance and bug fixes. For those of you who installed RC3, there is a small patch in the binary download which should fix a couple small reported bugs.

    As I’ve said before, I’ll probably hold off until 1.2 before I upgrade my own site…as I’ve also said before, the source is very much worth having a look at.  Details to follow.

  • News of the Disgusting

    I try not to link to plain news stories, but this is just flat out disgusting (and therefore worth blogging about).  From the article:

    Marcus Wesson, the domineering patriarch of a clan bred through incest, was convicted Friday of murdering nine of his children, whose bodies were found in a bloody pile last year at the end of a police standoff.

    Wesson's conviction on nine counts of first-degree murder makes him eligible for the death penalty. He also was found guilty on all 14 counts of raping and molesting seven of his underage daughters and nieces.

    In the words of Jules Winnfield; “This is some fucked up repugnant shit.”  I simply can’t even begin to fathom what possesses some people to act the way they do.  The article also mentions that his family (I'm assuming the members he didn't kill) still supports him?  At some point you really have to just walk away…let it go man.  Bleh.

  • Email Hell

    As an independent consultant, email is my life blood…without Outlook my career would cease to exist.  I get a lot of email, and being a little OCD I keep pretty much everything that comes through my inbox (as it relates to news/projects/friends/family/etc); from day one as a consultant I was rabid about keeping everything organized/setting up rules (god bless Outlook, especially 2003…IMO it’s the best consumer level product in MS’s portfolio, search folders are the bee’s knees man), this coupled with Lookout makes for a pretty powerful combination.  I was also smart in that when I worked for MS, I subscribed to a ton of their internal mailing lists…when I left I took my .pst with me (don’t tell anyone), so Outlook is usually one of the first places I go when I have a question (after Google of course).

    At last count, I had 98 rules, 240 folders, and 76,645 messages @1,690,973 kb (not including my sent items folder which I also never empty).  My .pst is 2,662,545 kb.  And yes, every single one of them matters :-).  I’m also fortunate in that I’ve had the same email address for over 5 years.  I’m fanatical about backing up my .pst once a week (thank you XDrive, 10 bucks a month for 5 gigs of storage…can’t beat that); I would be royally screwed if I lost my contact list (over 100 recruiters/clients/headhunters).  Can anyone top that?  Cheers.

  • Optional Parameters in VB.NET -- Lazy Coding and Bad Style

    I was speaking with a colleague (names omitted to protect the innocent) earlier about a new project he’s working on; like myself he sticks with C# whenever possible…but we all at some point get stuck maintaining a project that isn’t written in our language of choice…in this case, VB.NET.  Like most .Net developers (hopefully), we both know enough of VB.NET syntax/keywords to stumble through a project and pick up stuff as we need to.  He brought up an interesting point that (until today) I had never thought about; he thought it a bit strange that as VB.NET supports the Optional keywords for method parameters that the system he’s working on still used overloaded methods (in essence with Optional params you could just define one method signature and declare all params as optional (and with default values), then from calling code just feed whatever parameters your routine needs processed).  At first glance, this makes sense…but if you think about it, it lends itself to lazy programming, doesn’t follow correct OOP concepts…but most of all, not all languages targeting the CLR understand the notion of Optional params (namely, C#).  It’s also a breaking rule in FXCop. 

    The only thing I can think of offhand that optional params might come in handy is if you’re dealing with legacy COM code where there are numerous optional params in a method (I’ve seen some methods that take literally dozens of optional params, passing in null to all the optionals looks pretty ugly); so if you’re simply wrapping up some legacy COM code (and you know that your assembly won’t be referenced by another language, which is never guaranteed), I can perhaps see some advantage to this.

    In the case of C#, if a VB.NET assembly is referenced with members containing optional params, they will simply be ignored; you must supply a value for the parameter regardless, even if there is a default value specified in the VB.NET member signature.  Overloading members provides a more terse, declarative way to describe exactly which member to use in whatever scenario…if the assembly follows good design rules and exposes overloads correctly, this is a huge boon to the developer using the component.  Optional parameters is one of those programming constructs that seems beneficial at first glance (seemingly cutting down on code typing…leading to less unit tests, less documentation, etc), but in the OO world they are no substitue for properly overloaded type members.

  • Nice Community Server Skin

    Dave Burke sums it up much better than I do, so go read his post about a very nice Community Server skin that Jaxon Rice has created.
  • CS Tidbits #4: Adding Raw Header Information

    A really cool new feature that was added in Community Server 2.0 is the ability to add raw header information to your site without having to edit any of the skin files like you did in 1.x.  The location of this is <siteRoot>/controlpanel/Settings/SiteContent.aspx; you’ll see a text box called Raw Header.  Basically you can use this to insert any code you like, and it’ll be automatically be placed in the <head> tag of all your pages.  I personally use it for my Google Analytics, StatCounter, and global javascript code…but you can use it for anything that’s allowed inside a head tag.

    A feature that may or may not make it’s way into 2.1 is in addition to the global raw header section, each application would get it’s own raw header, i.e. if you’d like to put different tracking codes for separate applications this would possible, and only that application would have that header information.

« First ... < Previous 83 84 85 86 87 Next > ... Last »

Copyright © ::
External Content © :: Respective Authors

Terms of Service/Privacy Policy