in

Blog By Bob

Blog by Bob

December 2006 - Posts

  • Five (Or So) Things You Didn't Know About Me (and probably don't care)

    So, I was reading through my daily blog list (I am still not a big RSS fan) and noticed that Jayson, as is popular right now, wrote his "Five Things You Didn't Know About Me" and...tagged me at the end, which I assume means I have to go next!!

    I never really thought about this before, so there is no telling how this is going to come out.

    1. My first computer was a Commodore 64, complete with the sweet .98 mhz processor and super deluxe tape drive. Though a floppy frive was soon to follow. This was when I was 12 years old.

    2. I didn't have alot of money in my teen age years, so when I decided that maybe IBM wasn't the evil and I wanted a PC, I built one myself. I used an Intel Compatible clone chip called the NEC V20 that ran at 12 mhz. I had to skimp on the case (cases were $100+) so I built it in a cardboard box that was shaped like a case and painted white. I was ~16 at this time.

    3. I fell out of touch with computers for awhile, even though I am programmer now, I just got into computers as a career after turning 30. I went straight from making Basic programs with line numbers (10 Print "Hello" 20 Goto 10) to writing in C#. Initially trying to grasp the event driven model almost broke my little brain.

    4. Like Jayson, I had hair down past my shoulders until I was 20. My hair is now short enough that any shorter and it would be shaved.

    Well, it looks like I lied. There really isn't a number 5, I just don't have that many interesting things about Bob. If I think of something else, I will add it. I am also going to decline to "tag" anyone, since I really don't know all that many other bloggers.

  • Why VB.NET is a Bad Choice

    I posted earlier that I recently changed jobs, which means that I went through a good bit of interviewing trying to find the job I thought was right for me at this point in my career.

    Some of you may find it silly, but one of the criteria that was pretty important to me was that all new code was going to be written in C# and not in VB.NET. One of my interviewers asked me why.

    VB.NET in its very design tries to solve the wrong problem.

    Visual Basic.NET is touted as a nice easy to use language for a novice to learn to make applications. The they learn to make applications in VB.NET and continue to write in VB.NET. This comes to the problem. Writing code is easier than reading code. Go ahead, Google it. VB.NET tries to solve the problem of writing code (the easy part) but makes the hard part harder (reading code).

    So you spend 6 months creating that jazzy new VB.NET application that saves the world for you company. How long do you spend maintaining and extending that application? 4 or 5 years? Longer?

    VB.NET is different.

    In this case, different is not good. Different makes the above problem (writing code is easier than reading code) even more obvious. When you are integrating with other code, reading someone else's code, trying to replicate behavior from some other application in your application; most likely you are reading something totally unlike VB.NET. Hell, even if you are rewriting a legacy application, VB.NET isn't even like Visual Basic 6, so you aren't gaining anything there.

    C# on the other hand, shares many structural simularities with C, C++, Java, Javascript and others. Even if you can't write in those languages just because you know C#, you can most likely at least get an idea of what is going on by reading them. C++ looks like Moon Language to a VB.NET developer.

    Well, you know what? VB.NET looks like Moon Language to everyone except a VB.NET developer.

  • My New Favorite .Net Method, GetSchema()

    Someone might remember the other day, when I discovered SqlConnectionStringBuilder and fell in love. Well, move over, its a new day! I am piddling around with writing a mini ORM (who isn't now adays) and stumbled across my new love!
    As of .NET 2.0, there is a new method hanging off your connection called GetSchema. Say you are writing an ORM and want to get a list of the catalogs in your database:

    SqlConnectionStringBuilder connectionStringBuilder = new SqlConnectionStringBuilder();
    connectionStringBuilder.DataSource = myServerName;
    connectionStringBuilder.IntegratedSecurity = false;
    connectionStringBuilder.UserID = userName;
    connectionStringBuilder.Password = password;

    SqlConnection connection = new SqlConnection(connectionStringBuilder.ConnectionString);
    connection.Open();
    myBindingDataControl.Enabled =
    true;
    myBindingDataControl.DataSource = connection.GetSchema(
    "databases");
    myBindingDataControl.DisplayMember =
    "database_name";
    connection.Close();

    Then once your unsuspecting user has chosen the catalog they want to use, you can quickly grab a list of the tables in the catalog:

    SqlConnectionStringBuilder connectionStringBuilder = new SqlConnectionStringBuilder();
    connectionStringBuilder.DataSource = myServerName;
    connectionStringBuilder.IntegratedSecurity = false;
    connectionStringBuilder.UserID = userName;
    connectionStringBuilder.Password = password;
    connectionStringBuilder.InitialCatalog = cbDatabases.GetItemText(usersCatalogName);

    SqlConnection connection = new SqlConnection(connectionStringBuilder.ConnectionString);
    connection.Open();
    myBindableDataGrid.DataSource = connection.GetSchema(
    "tables", new string[4] { usersCatalogName, null, null, null });
    connection.Close();

    But wait you say! That list has more than tables in it! You would be right. GetSchema also sees views as tables, but I think that is a great thing, since my ORM wants to see Views as well, and you can always get rid of them from your data source if you don't like them. You can also use restrictions to limit by owner and you can grab the columns out of a table in the same way. Here is a nice link that I found when I originally stumbled across GetSchema.

    And best of all, GetSchema returns a DataTable natively so you can quickly bing to it, even in Windows Forms, where the DataReader is the evil and won't bind.

  • Are ORMs Worth It?

    I have been using an ORM called LLBLGen for the last year and a half and am battling internally what the benefits are and whether or not it is a battle I should pick when I start my new job on the 2nd. Should I try to get them to purchase it? (This is a bigger question now that they changed their licensing model to per seat)

    I decided to use the Community Server tables and create and example since, well, I don't have any other databases on this server.

    First, for ADO.Net as it currently is:

    SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString);
    string query = "select * from cs_posts join cs_posts_incategories on cs_posts.postid = cs_posts_incategories.postid where categoryid=1003";
    SqlDataAdapter adapter = new SqlDataAdapter(query, connection);
    DataSet dataset = new DataSet();
    adapter.Fill(dataset);
    DataTable posts = dataset.Tables["cs_posts"];

    foreach (DataRow post in posts.Rows)
    {
        Console.WriteLine(post["subject"].ToString());
        Console.WriteLine(post["postdate"].ToString());
        Console.WriteLine(post["formattedbody"].ToString());
    }


    Then, LLBLGen:

    EntityCollection posts = new EntityCollection(new PostsEntityFactory());
    RelationPredicateBucket bucket = new RelationPredicateBucket();
    bucket.Relations.Add(PostsEntity.Relations.PostsInCategoriesEntityUsingPostID);
    bucket.PredicateExpression.Add(PredicateFactory.CompareValue(PostsInCategoriesFieldIndex.PostID, ComparisonOperator.Equal, 1003));
    Adapter adapter = new Adapter();
    adapter.FetchEntityCollection(posts,bucket);

    foreach(Posts post in posts)
    {
        Console.WriteLine(post.Subject);
        Console.WriteLine(post.PostDate);
        Console.WriteLine(post.FormattedBody);
    }

    As you can see, they are the same number of code lines, but the true question is, what does the code mean (and yes, I used * which we wouldn't in real life)? At this point, the only thing LLBLGen appears to have gained us is a different syntax and strongly typed objects.

    First, the ADO.NET code wouldn't be ran that way.

    If we were using ADO.NET directly, we would need to create a business object:

    public class Post
    {
        private string subject;
        private string postdate;
        private string formattedbody;

        public string Subject
        {
            get { return subject; }
            set { subject = value; }
        }

        public string PostDate
        {
            get { return postdate; }
            set { postdate = value; }
        }

        public string FormattedBody
        {
            get { return formattedbody; }
            set { formattedbody = value; }
        }
    }

    Then, of course we would need a method to load the objects, we'll keep it simple and pass in a single int for the where clause, and reuse our code from above:

    public static Post[] PostsGet(int CategoryID)
    {
        SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString);
        string query = "select * from cs_posts join cs_posts_incategories on cs_posts.postid = cs_posts_incategories.postid where categoryid=@id";
        SqlDataAdapter adapter = new SqlDataAdapter(query, connection);
        adapter.SelectCommand.Parameters["id"].Value = CategoryID.ToString();
        DataSet dataset = new DataSet();
        adapter.Fill(dataset);
        DataTable postTable = dataset.Tables["cs_posts"];
        Post[] posts = new Post[postTable.Rows.Count];
        int i = 0;

        foreach (DataRow post in postTable.Rows)
        {
            posts[i].Subject = post["subject"].ToString();
            posts[i].PostDate = post["subject"].ToString();
            posts[i].FormattedBody = post["subject"].ToString();
            i++;
        }

        return posts;
    }

    And that doesn't even count the code we were originally writing that prints them out to the console, which is now:

    Post[] posts = PostManager.PostsGet(1003);

    foreach(Post post in posts)
    {
        Console.WriteLine(post.Subject);
        Console.WriteLine(post.PostDate);
        Console.WriteLine(post.FormattedBody);
    }

    *And* this doesn't even touch on having to save new posts or update existing posts. LLBLGen definitely seems to provide enough value to warrant asking my new company to purchase it for creating new applications.

    The only thing that throws murk into this equation is the upcoming additions of ADO.Net Entities and Linq. From what I have seen so far, Linq is still too SQL like for me, I want to work in C#, not C# and Transact SQL, so anything that abstracts the SQL language away and allows me to work more object based is a plus in my book. And for ADO.Net Entities? The team seems very excited about the technology, but from what I have seen so far, they are far from completion and I don't know that they are going to hit that sweet spot of abstracting the SQL away, creating strongly typed entities and still making it usuable enough to really be the new thing. They seem to be running in alot of different directions at once and not getting anywhere fast in the process.

    But that's just what I see, they may have made some good progress recently and I am just in the dark.

    The other thing to consider when choosing LLBLGen is the learning curve. If the developers you are working with have not used something similar in the past, it can be a pretty steep climb. But once it clicks and you just "get it", the journey is very well worth the trip.

    Well, I rambled alot there and I apologize for that, I am not even sure I was making sense the whole time, nor whether or not the post is cohesive. Its really too long for me to read back through again ;)

    Disclaimer: I can't guarantee all the code compiles and works as expected. I just formatted (again, its a hobby, really!) and Visual Studio is still installing, hence the massive free time to write such a long post...

  • Paperclip, Burnt Orange Style

    The last time I played with themes on subText, I made a really cludgy, but decent orange skin. I really dig the colors and decided to do the same for the Paperclip Theme in Community Server. It still needs some work and some things are still in the wrong color, but all in all it was a pretty quick, painless conversion.

    Well done Telligent for making the CS file relatively easy for even someone like me!

  • Community Server First Impressions

    Now that I made the plunge and switched to Community Server (admittedly only because my host had issues running the latest subText), I wanted to voice my opinion, since that is what I do ;) Take it all with a grain of salt since I have only had CS installed for less than 24 hours.

    The first thing I noticed is that managing Community Server is more complex than I thought it would be. I understand that with flexibility and power comes complexity, but it seems that the complexity increased more than the feature set.

    Looking around in the forums, I think there is a general agreement on this. One thing that would *really* improve that for people like me (and once again, many of the personal users would agree) is if there was a "Community Server Lite" edition targetted for single blog users such as myself. The benefits to this would be the blog would be the default page, which is a common request. You could get rid of the forums and remove all the magical multiblog options (setting them all to on so the individual blog settings could be used to enable or disable for the blog itself). I know there really isn't any motivation to do this, since the single blog users would be generally using the free version anyhow, and none of the features would be portable to the paid versions. Still, I can wish can't I?

    On a more positive note, Community Server is much more professional feeling that the other solutions I have played with. This includes the quality of the themes available, as well as the quality of the adminitration section. The administration section often looks like it is the poor step child in some solutions because noone but the admin sees it anyhow. It is nice to have something so polished when I am trying to get my blog settings tweaked, though the administration section is sometimes confusing and hard to navigate.

     All in all, I am quite happy with the conversion and am glad I finally made the switch!

  • Windows 2003 Server SP2 goes RC

    Windows 2003 Server Service Pack 2 goes to Release Candidate. Get it while its hot! http://www.microsoft.com/technet/windowsserver/sp2.mspx. The install went well on my R2 boxes.
  • Joined the Masses

    Well, I finally took the advice from Jayson and switched to Community Server. I had been using subText after hanging on to .Text for a long time  and was really happy with it, but alas, the latest version of subText didn't get along with the server settings my host is using, so here we are.

    All in all, after changing the blog to be the main page and getting rid of all the non blog stuff, I am pretty pleased. I would expect to find some things not working correctly over the next couple of days, but it should all get ironed out. The import process went smoothly from an blogML export from my old blog. Surprisingly, the same can not be said for subText, it failed to load the blogML exported from an older version of itself. Weird.

    I had been tinkering around with making custom themes on subText, but there appears to be enough themes for Community Server that I will just use one of the much better than I could make ones instead.

    So far so good, let's see how it goes!

  • Changing Jobs

    Well, I am in the middle of changing jobs, I've finished transitioning the work load from my old job to my replacements and am looking forward to beginning my new duties after the holidays.

    Change is a good thing! (Well, I guess change is good when you initiate it yourself!) Having said that, I really enjoyed my old job and will miss the team there.

  • The Xbox That Was Almost A Wii

    I have been debating getting a Wii for some time, and finally decided to make a decision and get myself a Christmas present! But in the end, I decided on an Xbox 360 and boy is it awesome!

    Wii - Pros
        Less Expensive
        Cool new WiiMote
    Wii - Cons
        Wont even do 720p, though this was not necessarilly a deal breaker
        Won't currently play DVD's, this was probably the biggest deal breaker
        Nintendo has alot of games but is lacking in the areas I like most

    Xbox 360 Pros
       720p and 1080i which my projector loves projecting on its 113" screen :)
       Awesome graphics
       Awesome graphics
       Media Center Extender
       Plays DVDs
    Xbox 360 Cons
       More expensive
       Games will probably be more expensive
       No WiiMote!

    As for the playstation, I didn't even give it consideration. Comparing it to the Xbox 360 is just silly, you get so much more with the 360, especially if you plan on using it as a media extender.

    At the end of the day, I am very happy with the choice I made. The graphics are phenominal, playing Madden 2007 on the big screen is like watching it on television. The second main thing, I had a PC in the living room for media center, and it's been seamless to replace it with the Xbox's media extender. Very happy with my purchase, and would definitely recommend it to all you geeks!

  • Blogbybob Looking For a New Host

    blogbybob.com is looking for a new host, anyone have any recommendations? I wont get into any details, but I definitely won't be recommending ASPNIX to anyone in the future, and to those I talked into going there, you have my deepest apologies. They were good once, really.
  • Exchange 2007 Goes RTM

    Jayson made sure to remind me that Exchange 2007 went RTM. I think I might have to give it a test drive when it hits MSDN. Anyone know what the Groove Server is? I keep debating downloading it, but it scares me ;)
  • Best Video Ever

    And here I assumed Weird Al was dead. I remember him doing spoofs of Michael Jackson and Queen when I was knee high to a grasshopper...
More Posts
Copyright © :: BlogByBob.com
Powered by Community Server (Non-Commercial Edition), by Telligent Systems