Posts

SQL Server amazes me!

Well, SQL Server amazes me, but not because I am impressed! Today I wrote an application that does the following: 01) Find all ZIP files in a specific folder 02) Open each ZIP file in turn 03) Extract an XML file from the ZIP into an array of bytes 04) Insert that data into a table There are 1,978 files in this folder and the XML within each ZIP file is around 2MB in size. I ran this app and was really surprised at how soon my PC started to crawl, it was so slow that it was taking over 10 seconds to switch between MSN and a Skype text-chat window. So I decided to monitor the process..... Importing the zip data into SQL Server took a total of 19 minutes and 15 seconds (this includes unzip time). What concerns me is that SQL Server's RAM usage went up to 830MB at its peak, this is what was crippling my PC. Twenty minutes after my app had finished SqlSevr.exe was still holding over 700MB of RAM, I then restarted my PC. SQL Server was using more RAM than I had available

DaDa

Today my baby girl looked at me, said "DaDa" for the first time ever, and then giggled. What a great day! :-)

Delegates

I just remembered another technique for calling methods discovered via reflection! It is possible to convert a MethodInfo to a delegate and call it, this is just as fast as calling the method directly. So if you have a method that you call often which was discovered via reflection you should try this.... private delegate bool DoSomethingDelegate(object a, object b); MethodInfo methodInfo = type.GetMethod(.........); DoSomethingDelegate method = (DoSomethingDelegate) Delegate.CreateDelegate(typeof(DoSomethingDelegate), methodInfo); for (int i = 0; i < 1000000, i++) method(this, this);

Onion, more on signals

I've been trying to think through every type of feature I can that people might want in an application, and then seeing if I can think up a way of implementing it using signals. A couple of days ago I thought up something I couldn't implement using the exact approach I had. I once wrote an app that had a treeview on the left hand side, the user could drill down to a customer of their choice and then when they clicked on that customer the display would update and show their details. This made me realise that a simple "SelectCustomer" signal would not be sufficient, what I actually needed to do was to have multiple SelectCustomer signals and indicate which customer to select. The changes I have decided to make are as follows: I will introduce a struct called SignalCreateParameters. This will hold a string property "Parameters" which may be used to automatically populate some of the properties of the created signal, ie the customer identity. The signal facto

Onion, part 3

Image
Women can multitask No matter how many times you might be told "women can multi-task!" it's just not true, humans can only do one thing at a time. I don’t doubt for a second that my wife's brain can keep track of multiple subjects much better than my single task brain, but at any one point her brain is only concentrating on a single task! It's exactly the same for software. People may wish to deviate from their current task in order to fulfil some adhoc requirement, but that task is an interruption, it does not occur in parallel to what they were doing before. Once that interruption is over the user of your software wants to pick up where they left off. This is what a process driven (or "task oriented") approach to writing software is about. Process driven work flow A process in this context is a single task performed within an application in order to achieve a specific goal. The goal may be just about anything such as "Delete customer", &

Onion, part 3 (teaser)

Image
Seeing as I haven't had enough free time to write part 3 recently I thought I'd post this little teaser. Would it surprise you to know that this very diagram generated into code and I was able to run it? The signals on the ShowWelcomeMessage had to be hand coded, but hopefully I will be able to get some kind of custom code generation plugin to get the signals auto generated in future.

Seven deadly sins of application development

Here is a list off the top of my head 1 - Ugly code! Why do some people set local variables to null when they have finished with them? This is .NET! The garbage collector will collect "unreferenced" objects when it is ready, an object is unreferenced if you no longer use the variable that holds the reference to it! Why do people name variables so poorly? Firstly I *hate* Hungarian notation. C# is a strongly typed language so I cannot multiply a boolean by a string, so why do people use variable names like "bIsMale" and "iAge"? 2 - Catching all exceptions An exception is something you expect to happen, but shouldn't happen if all goes well. If such an exception occurs you might know how to solve the problem and enable your application to continue, but if the exception type was unexpected how can you possibly know the cause of the error or what state your application is now in? Therefore I hate code like this try { DoSomething(); } catch { } 3 -