Off Topic

A Little Piece Of Advice For Tech Bloggers

6 commentsWritten on December 29th, 2010 by
Categories: Off Topic

I saw 2 blog posts today from tech bloggers who were talking about their new-year resolutions. Both of them said that they wanted to increase the number of posts they'll write next year. Both of them had over 50 posts this year. There's nothing bad (on the contrary) about writing 50 posts in a year. Hell, that's actually a great pace because it's reasonably sustainable and it leaves you with enough time to focus on a variety of things.

I've been blogging for 3,5 years and i have 565 posts so far. That's an average of 161 a year, or almost 13,5 a month or a little over 3 a week. That's insane. And it really isn't sustainable because you will run out of material before you know it and if you're not careful, you'll be tempted to stick to your posting schedule just to keep the visitor stats up. And let's be honest here: we all care about those stats just a little bit too much... don't trust the bloggers who say they don't ;) . And once you get into that habit of wanting to write posts just because you feel like you have to, it's time to take a small step back. You're blogging, which is great, but it really isn't all that important. It's not worth putting in the time and effort unless you really feel like doing it.

So to summarize my advice: blog when you want to, when you feel like you've got something interesting to share. Don't blog when you don't really feel like it and don't blog because you think you have to. Make sure you have enough spare time to spend on things outside of blogging and technology in general.

As for me, i'm aiming for 50 posts next year instead of the usual 161 and i don't think there's anything wrong with that. At all :)

Independence Day

21 commentsWritten on December 9th, 2010 by
Categories: Off Topic

I'm one of those rare people who's spent more than a few years with his first employer. In fact, i've been there for 8 years and 2 months now. I spent the first 5 years and 3 months working for a client of ours, and then another 6 months working for another client. After that, i moved to our own office where i worked on some projects at first, and then mostly on our products. I've learned a lot of great stuff during those 8 years, and i've grown a lot as a person as well. But the time has come for some serious changes.

I recently started my own company, called That Extra Mile (no website yet). As of January 3rd, i'm going to be working at a client that i'm very excited about. I also plan on doing some other stuff such as (very) short-term consulting, occasionally some workshops/training and i also want to get into iPhone/iPad (and perhaps Android) development. If you were wondering why it's been so quiet on this blog the past few weeks, now you know why. But now that everything has been taken care of and has been set up properly, things can finally get back to how they used to be around here :)

Got 15 Minutes To Help Out With A University Study? I Mean, To Play A Game?

No Comments »Written on March 8th, 2010 by
Categories: Off Topic

Bram De Moor, one of my coworkers, has developed a small game which is a part of a university study. I can't tell you what the study is about, since that would ruin the purpose of the game (and if anyone leaves a comment mentioning it, it will be deleted) but it's pretty interesting. The game itself is pretty nicely done, though you obviously shouldn't expect too much. So if you can spare about 15 minutes and want to participate in this study, download the game here, play it and answer the questionnaire at the end. Don't do it for yourself, do it for science! ;)

Wanna Review My Code?

16 commentsWritten on February 23rd, 2010 by
Categories: Off Topic

I just wrote some code, and i’d like your opinion on it.  The thing is, i’m not going to provide any context as to what it does or why certain decisions were made since i know you guys like to be challenged.  You also might want to keep the following in mind when reading it:

  1. it might contain bugs that i’m not aware of
  2. it contains weird parts that were either brainfarts on my part, things i did on purpose to avoid possible issues, or both
  3. it contains at least one bug that i know about, yet don’t care about
  4. i removed the comments that i originally put in it to make things more interesting
  5. i haven’t tested the code yet
  6. i haven’t even executed it yet
  7. i think it’s ok… but i’m not sure

Questions will be answered if you have them (and i’m sure you will) though i can’t make any promises as to how soon i can answer them… I will post a follow-up post to discuss the code in its entirety later on, though i’ll probably wait a few days to do so.

This is the code:

    public class TenantSessionFactoryManager : ITenantSessionFactoryManager

    {

        private readonly ITenantContext tenantContext;

        private readonly ITenantInfoHolder tenantInfoHolder;

        private readonly string mappingAssemblyName;

 

        private readonly object writeLock = new object();

        private Dictionary<Guid, ISessionFactory> sessionFactories;

 

        public TenantSessionFactoryManager(ITenantContext tenantContext, ITenantInfoHolder tenantInfoHolder, string mappingAssemblyName)

        {

            this.tenantContext = tenantContext;

            this.tenantInfoHolder = tenantInfoHolder;

            this.mappingAssemblyName = mappingAssemblyName;

            sessionFactories = new Dictionary<Guid, ISessionFactory>();

        }

 

        public ISession CreateSessionForCurrentTenant()

        {

            var tenantId = tenantContext.CurrentTenantId;

 

            if (!sessionFactories.ContainsKey(tenantId))

            {

                CreateSessionFactoryForCurrentTenant();

            }

 

            return sessionFactories[tenantId].OpenSession();

        }

 

        private void CreateSessionFactoryForCurrentTenant()

        {

            lock (writeLock)

            {

                var tenantId = tenantContext.CurrentTenantId;

 

                if (!sessionFactories.ContainsKey(tenantId))

                {

                    var connectionString = tenantInfoHolder.GetDatabaseConnectionString(tenantId);

 

                    var sessionFactory = new Configuration()

                        .Configure()

                        .AddProperties(new Dictionary<string, string>

                                {

                                       { "connection.connection_string", connectionString },

                                    { "cache.region_prefix", "Tenant_" + tenantId }

                                })

                        .AddAssembly(mappingAssemblyName)

                        .BuildSessionFactory();

 

                    var newDictionary = new Dictionary<Guid, ISessionFactory>(sessionFactories);

                    newDictionary[tenantId] = sessionFactory;

                    sessionFactories = newDictionary;

                }

            }

        }

 

        public void RemoveSessionFactoryForTenant(Guid tenantId)

        {

            if (!sessionFactories.ContainsKey(tenantId))

            {

                return;

            }

 

            lock (writeLock)

            {

                if (!sessionFactories.ContainsKey(tenantId))

                {

                    return;

                }

 

                var sessionFactory = sessionFactories[tenantId];

 

                var newDictionary = new Dictionary<Guid, ISessionFactory>(sessionFactories);

                newDictionary.Remove(tenantId);

                sessionFactories = newDictionary;

 

                sessionFactory.Dispose();

            }

        }

    }

Never Underestimate Your Own Stupidity

9 commentsWritten on January 7th, 2010 by
Categories: Off Topic

I was trying to deploy one of our applications on a customer’s environment.  We have a database server on their network, and a web server.  I installed the database, installed the web application and tried to run it.  It didn’t.  Our logfile showed this:

System.InvalidOperationException: Timeout expired.  The timeout period elapsed prior to obtaining a connection from the pool.  This may have occurred because all pooled connections were in use and max pool size was reached.

I figured i had made a mistake with the configuration of SQL Server, so i checked some settings and tried it again.  Still didn’t work.  Did this a couple of times but i couldn’t get it to connect to the database and i kept getting the same error.

Eventually i wrote a stupid winforms app with a button that would connect to a database based on a connection string in its app.config file.  Copied it to the webserver, copied the connection string from the web application to the config file of the stupid winforms app and tried it.  Still got the same exception.

I figured there might be a problem with connecting to the database from the web server, so i copied the stupid winforms app to the database server and tried it there.  It still didn’t work, even though i could connect without problems using SQL Server Management Studio.

After a while i finally noticed that i had mistyped the name of the database server in the connection string, and once i typed the correct name, everything worked :)

Total time lost: about 90 minutes.

Required change: adding 1 extra character to the connection string.

Then again, i would’ve noticed this sooner if the exception message was a bit more clear about the actual problem (not finding the server) ;)