<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>midnight muse</title>
	<atom:link href="http://midnightmuse.com.au/feed/" rel="self" type="application/rss+xml" />
	<link>http://midnightmuse.com.au</link>
	<description>Richard Wright's musings about software and other things that take his fancy</description>
	<lastBuildDate>Thu, 06 May 2010 05:43:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>MySql Connection Problem</title>
		<link>http://midnightmuse.com.au/2010/05/06/mysql-connection-problem/</link>
		<comments>http://midnightmuse.com.au/2010/05/06/mysql-connection-problem/#comments</comments>
		<pubDate>Thu, 06 May 2010 05:43:18 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://midnightmuse.com.au/?p=198</guid>
		<description><![CDATA[I really don't like MySql with .NET]]></description>
			<content:encoded><![CDATA[<p>Everyone loves MySql. It is everywhere. This website runs on it.</p>
<p>But I keep having problems when I use it as the database for .NET applications.</p>
<p>I delivered an application last week. A fairly standard windows desktop application. Except that the database it was connecting to was MySql. As usual, I did my data access using my favourite OR/M tool, LLBLGen. The application crashed at the client&#8217;s site as soon as they tried to access the database.</p>
<p>I checked the connection string, and that was OK. In any event, the exception didn&#8217;t look like that was the problem. It seems that the ado.net provider was missing. But that made no sense to me.</p>
<p>So I loaded it up on  a clean install of XP, that is what the client is running, on a virtual machine that only had the .Net framework and MySql installed. Everything else came straight from source control. And it worked fine.</p>
<p>I hate bugs that I cannot reproduce, and it is driving me crazy!</p>
<p>I am now in the process of cleaning out everything on my laptop, copying those things that I think I need to an external drive, and reloading Windows from scratch. I will try to reproduce the bug on it.</p>
<p>It sounds crazy that I am spending all this time trying to produce a bug. I usually spend my time trying to get rid of them.</p>
]]></content:encoded>
			<wfw:commentRss>http://midnightmuse.com.au/2010/05/06/mysql-connection-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Killing a Process</title>
		<link>http://midnightmuse.com.au/2010/05/06/killing-a-process/</link>
		<comments>http://midnightmuse.com.au/2010/05/06/killing-a-process/#comments</comments>
		<pubDate>Thu, 06 May 2010 05:35:14 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://midnightmuse.com.au/?p=196</guid>
		<description><![CDATA[Sometimes a process just won't roll over and die]]></description>
			<content:encoded><![CDATA[<p>I had a problem today that I have not seen before.</p>
<p>I am running Windows 7, 64 bit. I had a document open in Word. The version of Word I use 2010 and, following Microsoft&#8217;s recommendation, I am using the x32, or 32 bit, version. I was scrolling through the document and it froze. I have had all sorts of applications freeze in the past, even some of my own. Or is that especially some of my own?</p>
<p>The usual fix is to open TaskManager, or in my case Process Explorer, which is part of the Sysinternals suite. Right click the process, in this case, Winword, and select Kill Process. It didn&#8217;t work.</p>
<p>So I tried taskkill from the command line. Didn&#8217;t work. So I tried taskkill /F, which is supposedly a forceful task kill. Still didn&#8217;t work. Back to sysinternals and tried its pskill, which is supposed to kill a process. And that didn&#8217;t work.</p>
<p>This has never happened before.</p>
<p>So I did a reboot. Now when right click the system tray and select Task Manager, or do the same from a Ctrl-Alt-Del, I get an error message.</p>
<p>I have no idea what is going wrong, but I can see I have some things to fix.</p>
]]></content:encoded>
			<wfw:commentRss>http://midnightmuse.com.au/2010/05/06/killing-a-process/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Arms Race</title>
		<link>http://midnightmuse.com.au/2010/04/29/the-arms-race/</link>
		<comments>http://midnightmuse.com.au/2010/04/29/the-arms-race/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 15:03:05 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://midnightmuse.com.au/?p=194</guid>
		<description><![CDATA[There is a battle going on and we will all be winners.]]></description>
			<content:encoded><![CDATA[<p>Visual Studio 2010 is out, more or less. It will be officially launched in May and be available through retail outlets in June. But it is available now via MSDN for subscribers.</p>
<p>I&#8217;ve played around with the beta and the RC versions for a while, and I downloaded the RTM version last week. My only gripe is that it is slow to start, but once it is open it is a joy to use.</p>
<p>I first started using .Net when version 1.1 was released in 2003. Version 2 of the CLR which was released with Visual Studio 2005 was a big improvement, as you would expect. When I moved to VS 2005 I also discovered Resharper and I have been a fan ever since.</p>
<p>One thing that I have noticed over the years is that each new Visual Studio release has incorporated some of the functionality that was provided by Resharper. For Resharper you could substitute CodeRush + Refractor and the statement would also be true. I think if I had tried CodeRush before I got used to Resharper then I would probably use CodeRush instead. They are both great products and both have substantial numbers of loyal followers.</p>
<p>However, to get back to my point. Resharper and CodeRush &#8211; and I think there may be one or two others, there certainly used to be, but these are the main contenders &#8211; provide some functionality that is missing from Visual Studio. As each subsequent version of Visual Studio incorporate some or most of this functionality, Jet Brains and Developer Express need to add more functionality to Resharper and CodeRush otherwise no one would buy or upgrade their products.</p>
<p>Resharper 5 has just been released. It too has been in beta and then RC versions for some time. I was very disappointed that the RC versions that I tried did not have highlighting of the current line. A very small issue, but one that made coding, for me at least, so much easier. Maybe its usefulness was more perception than reality, I don&#8217;t know. Except that when it wasn&#8217;t available in VS 2010 I was bitterly disappointed. But the final version has it restored and so all is well with the world.</p>
<p>And Resharper has a whole bunch of new stuff as well. It has to if it wants to stay in the market.</p>
<p>So the result is that with each version of Visual Studio we developers get a better environment in which to code, and our add-ons keep improving at the same time.</p>
<p>I recommend that you try out VS 2010 and also give Resharper or CodeRush a try as well. You won&#8217;t be disappointed.</p>
]]></content:encoded>
			<wfw:commentRss>http://midnightmuse.com.au/2010/04/29/the-arms-race/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My Own Stupidity Amazes Me!</title>
		<link>http://midnightmuse.com.au/2010/04/14/my-own-stupidity-amazes-me/</link>
		<comments>http://midnightmuse.com.au/2010/04/14/my-own-stupidity-amazes-me/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 14:28:01 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://midnightmuse.com.au/?p=192</guid>
		<description><![CDATA[You'd think at my age I might have learned. But I haven't.]]></description>
			<content:encoded><![CDATA[<p>It doesn&#8217;t seem to matter how often we hear or read about what we should do. We still don&#8217;t do it. I even tell my clients what they should do, but I don&#8217;t do it. And today it bit me on the bum.</p>
<p>12th April was a significant day for Microsoft developers. Visual Studio 2010 was launched. It was 13th April here in Australia, because we are so far ahead of most of the rest of the world, except for New Zealand, and that is a real worry. But I digress.</p>
<p>Yesterday morning I downloaded Visual Studio. Actually I started the download and then went to see a client and didn&#8217;t get back until late afternoon. And then I had to install it.</p>
<p>I couldn&#8217;t install it straight away because I had the RC version already installed. And I had enormous trouble getting it uninstalled. Eventually, after many hours, it was gone. Or so I thought. I then tried to install VS 2010 and it told me that it couldn&#8217;t install because I still had a component left on. I uninstalled it and tried again. It started out fine but got to installing the .Net Framework V4 and there it hanged, hung, I&#8217;m not sure which.</p>
<p>I rebooted and tried again. Same thing. I got a cup of coffee and tried again. Still no go.</p>
<p>I downloaded the framework separately and tried that. It wouldn&#8217;t budge. I got another cup of coffee and played a few games of Sudoku, and that didn&#8217;t help.</p>
<p>At this stage I thought that it might be time for a clean install on the pc, and even though that thought fills me with dread, it probably is time, soon. I thought that I had better check my backup files and make sure that I have everything that I need. My client apps aren&#8217;t a problem, they are all under version control on a separate machine. But I have other backups sitting on two 1 tb external disks. Only one was connected to the pc at the time and the other one has some useful stuff on it. It hasn&#8217;t been connected since I re-arranged my office some time ago. So it was now time to dig it out and crawl around the floor under the desk and plug it in.</p>
<p>I tried one more time to install Visual Studio, and what do you know, it is working. It is chugging along quite nicely as I write. But it is now 12:20 am and I have been at this for hours.</p>
<p>The moral is, if I hadn&#8217;t installed the RC version I probably wouldn&#8217;t have had these problems. I wanted to try it out and so I installed it. I didn&#8217;t use it for any production work, I&#8217;m not that stupid. But I do have VMWare installed on this machine. And I have a couple of virtual machines set up for this purpose. Why didn&#8217;t I install the RC version on a vm? Cause I am dumb. Lazy and dumb.</p>
<p>But I have another confession to make. Before I got the RC version, I had a copy of a beta version. I didn&#8217;t install that on a vm either.</p>
<p>I said that I am not only dumb, I am lazy. If I was smart and lazy I would have stuck both these versions on a vm. It is a lot quicker to delete a virtual machine and then make a new clone of a clean vm and install the beta and release candidate versions on the new vm.</p>
<p>I have learnt my lesson, this has been a nightmare.</p>
<p>At least it is going well now and tomorrow I can play with it.</p>
]]></content:encoded>
			<wfw:commentRss>http://midnightmuse.com.au/2010/04/14/my-own-stupidity-amazes-me/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Source Control needs its own machine</title>
		<link>http://midnightmuse.com.au/2009/11/27/source-control-needs-its-own-machine/</link>
		<comments>http://midnightmuse.com.au/2009/11/27/source-control-needs-its-own-machine/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 12:24:27 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://midnightmuse.com.au/?p=188</guid>
		<description><![CDATA[It was brought home to me today why source control should really sit on a separate computer.]]></description>
			<content:encoded><![CDATA[<p>I use Subversion. Not because I think it is any better than any other source control system. It&#8217;s just that I have come to know it and get used to it. But I was reminded today that regardless of the source control, or version control, program you are using, it should be on a separate PC.</p>
<p>Yesterday morning I was doing some work and everthing was fine. I had to go out for a few hours and when I returned in the afternoon my development computer had died. I rang up my friendly PC repair guy who said it is probably the power supply, but it could be the motherboard. I left it with him and came home.</p>
<p>The only problem was that I had to deliver an application to a client this morning. There were some minor changes that I hadn&#8217;t finished. I was planning on finishing them yesterday afternoon, but that was now impossible. But all was not lost. I was able to grab the latest build from myh buildserver pc which holds the Subversion repository and does continuous integration using TeamCity. The latest changes that I was working on were not in Subversion. I hadn&#8217;t checked them in yet because they weren&#8217;t complete and they would have broken the build if I had.</p>
<p>And if I had kept the source control repository on my development machine it would have been quite safe, and I do nightly backups, things would have been different. I could have got the lastest stuff from the nightly backup, but not as easily. Stuff is the operative word. I would have had to stuff around getting it onto my laptop and then recompiling and checking that everything was OK. Probably a couple of hours work.</p>
<p>But this time it was easy. I had to go out first thing this morning. I got home around 9:30, had a cup of coffee, copied the latest build onto CD and had it delivered to the client by 10:15.</p>
<p>A separate pc hosing source control and continuous integration can save a lot of time, a lot of hassle, and probably a lot of hair.</p>
]]></content:encoded>
			<wfw:commentRss>http://midnightmuse.com.au/2009/11/27/source-control-needs-its-own-machine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Databinding</title>
		<link>http://midnightmuse.com.au/2009/10/29/databinding/</link>
		<comments>http://midnightmuse.com.au/2009/10/29/databinding/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 14:31:23 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://midnightmuse.com.au/?p=186</guid>
		<description><![CDATA[I have had a long held hatred of databinding. I am starting to change]]></description>
			<content:encoded><![CDATA[<p>Back in the good old days (were they really that good?) when I started programming in Windows I used Visual Basic version 3. The C++ guys down the hall would sneer at us, but we got stuff built pretty quickly compared to them, and, mostly, it worked.</p>
<p>Then along came VB4, and VB5 and VB6, each an improvement, although VB4 had some wrinkles that caused me problems. But that is all so long ago.</p>
<p>The one lingering problem, though, was databinding. Microsoft said that it was the greatest thing since sliced bread, and all the sample apps they provided worked just fine. But when you tried it in a real application it was problematic, at best. At worst, it just didn&#8217;t work.</p>
<p>I gave up using it in VB3. When each subsequent version came out I would try it again and again I would abandon it.</p>
<p>The problem is that some controls require it. The winforms datagrid, for example, could only be filled by using databinding, so I didn&#8217;t use the datagrid.</p>
<p>Then along .Net. Since I was a VB programmer I started out in VB .Net, and I tried databinding. It was supposed to be better, and maybe it was, but it was still pretty crook. So I still didn&#8217;t use the newfangled datagrid.</p>
<p>But things have changed. When Visual Studio 2005 came out I made the change to C#, and I once again tried databinding. And, at last it works. I still rarely use the datagrid, but I am binding to a lot of other controls, listboxes and combo boxes being the two most obvious.</p>
<p>I now use a lot of <a title="Developer Express" href="http://www.devexpress.com/" target="_self">Developer Express</a> controls and they make databinding a breeze.</p>
<p>I have read a lot of stuff from the Agile guys, and they generally don&#8217;t seem to like databinding. But if you don&#8217;t use it then you are fighting the tools that the IDE provides, rather than working with them. And now that WPF is getting better and better it is likely to become more mainstream, especially after Visual Studio 2010 comes out next year, databinding will take off in a big way. There are just so many ways that you can bind data in WPF, it makes no sense at all not to take advantage of it.</p>
<p>I have become a convert. Databinding has made my life so much simpler, and now it really does work.</p>
]]></content:encoded>
			<wfw:commentRss>http://midnightmuse.com.au/2009/10/29/databinding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Back to a WPF UI</title>
		<link>http://midnightmuse.com.au/2009/10/29/back-to-a-wpf-ui/</link>
		<comments>http://midnightmuse.com.au/2009/10/29/back-to-a-wpf-ui/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 14:11:13 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[Presenter]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://midnightmuse.com.au/?p=141</guid>
		<description><![CDATA[I have found a better solution to the dual screen problem]]></description>
			<content:encoded><![CDATA[<p>In the previous post I wrote about the problem I had showing a WPF window on a second screen. And this is a major requirement of the application. After much searching I came to the conclusion that it could not be done easily. The only reasonable solution seemed to be building a winforms app and hosting a WPF control for the second screen. I tried that and it worked fine. The way to do it is pretty simple. I created a new project called WPFControls, it would get a better name in the real version – this is just to try it out – and created a WPF control which contained a Rich Textbox. It won&#8217;t stay that way; it will ultimately be a FlowDocumentReader or a FlowDocumentPageReader, but at this stage I don&#8217;t know which one. And in the previous code in WPF I had built a RichTextBox for editing songs and so, to test this line, I will just use the same code to load a song, hence the RTB.</p>
<p>The Rich TextBox loads the song from the database by reading in the flowdocument stored in the lyrics field for the song. All this is described in the previous articles.</p>
<p>On the windows form, which can  be shown on any screen, we place a control of type System.Windows.Forms.Integration.ElementHost. In my case this was given the name EditSongHost.<br />
When the EditSongForm is loaded it loads the WPF control and sets the Song property to the currently selected song.<br />
<code><br />
private void EditSongForm_Load(object sender, EventArgs e)<br />
{<br />
WpfControls.SongEditCtrl ctrl = new SongEditCtrl();<br />
ctrl.Song= song;<br />
EditSongHost.Child = ctrl;<br />
}<br />
</code></p>
<p>This worked just fine, but I now had a winforms application with some WPF controls, and this was a second best solution, as far as I was concerned. I really wanted a WPF application. I could have approximated that by building all the user controls in WPF and hosting all of them in windows forms, but that seemed to me to be madness. WPF is a relatively new technology, and maybe that was the only way possible at the moment. If so then, so be it.</p>
<p>But today I came across another solution on the <a href="http://forums.msdn.microsoft.com/en-US/wpf/thread/5d181304-8952-4663-8c3c-dc4d986aa8dd">Microsoft Forums</a>, in a reply given by Larry Olsen, WPF Program Manager. This is his solution</p>
<blockquote><p>1.<br />
Started a new WPF Application project in Visual Studio<br />
2.<br />
Added the needed references to System.Windows.Forms (needed for Screen) and System.Drawing (needed for Rectangle)<br />
3.<br />
Removed the StartupUri in the App.xaml file and overrode the OnStartup() method in code-behind. I did this because StartupUri points to just one Window, Window1.xaml, in the WPF Application template and OnStartup will let me control what happens when the application starts.<br />
4.<br />
Added Window2.xaml to the project so that I would have a second Window to display on a second monitor.<br />
5.<br />
Added code similar to the article you linked to the override of OnStartup  which was:</p>
<p>Code Block</p>
<p>protected override void OnStartup(StartupEventArgs e)<br />
{<br />
base.OnStartup(e);</p>
<p>Window1 w1 = new Window1();<br />
Window2 w2 = new Window2();</p>
<p>Screen s1 = Screen.AllScreens[0];<br />
Screen s2 = Screen.AllScreens[1];</p>
<p>Rectangle r1 = s1.WorkingArea;<br />
Rectangle r2 = s2.WorkingArea;</p>
<p>w1.Top = r1.Top;<br />
w1.Left = r1.Left;</p>
<p>w2.Top = r2.Top;<br />
w2.Left = r2.Left;</p>
<p>w1.Show();<br />
w2.Show();</p>
<p>w2.Owner = w1;</p>
<p>}</p></blockquote>
<p>I adapted that code so that the second window was displayed after clicking a button. It worked perfectly! I just need to make a few changes. First I needed to set the window style to none so that I had a full screen window with no title bar or maximise, minimise and close buttons. This is why it is important to set the window&#8217;s Owner property. If you don&#8217;t set that and close the main window the second screen is still active and the program is still running. In any event, the second screen needs to be entirely controlled by the primary screen.</p>
<p>When I ran the program the second screen duly opened, but it wasn&#8217;t maximised. So I set its WindowState to Maximized and then tried it. It was maximised but it was showing on the primary monitor, not the second monitor. Why was this happening? I have no idea. But after trying a few things I decided to call the Show method and then set the WindowState property to Maximized in code, after the Show() method. I don&#8217;t know why this makes a difference, but it does. Well, actually I can see why my solution works, but I don&#8217;t understand why setting the property before the Show() method makes a difference. I don&#8217;t know what is going on in the bowels of windows, and just to be sure I moved the WindowState property setting line of code to just before the Show() method, so that it was being set in code, not by the designer. I didn&#8217;t expect it to help, and it didn&#8217;t. No matter, it all seems to work fine.</p>
<p>Here is the code I used, hooked up to a temporary button<br />
<code><br />
private void btnShow_Click(object sender, RoutedEventArgs e)<br />
{<br />
DisplayWindow displayWindow = new DisplayWindow();<br />
Screen s2 = Screen.AllScreens[1];<br />
Rectangle rectangle = s2.WorkingArea;<br />
displayWindow.Top = rectangle.Top;<br />
displayWindow.Left = rectangle.Left;<br />
displayWindow.Show();<br />
displayWindow.WindowState = System.Windows.WindowState.Maximized;<br />
displayWindow.Owner = this;<br />
}<br />
</code></p>
<p>The only niggling doubt I have is that winforms and WPF use different units for screen and control measurement. Winforms uses pixels, and WPF doesn&#8217;t. Rather they have Device Independent Pixels which are equal to 1/96 of an inch. There are benefits to the way that WPF does its screen rendering, but even though it looks fine on my two monitor set up, I will have to test it on a projector which is likely to have a drifferent resolution to my monitor. I don&#8217;t think that WPF will have a problem with that, but the Screen properties, specifically the WorkingArea is a winforms property. I don&#8217;t expect a problem, but it will need to be checked.</p>
]]></content:encoded>
			<wfw:commentRss>http://midnightmuse.com.au/2009/10/29/back-to-a-wpf-ui/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Entity Framework</title>
		<link>http://midnightmuse.com.au/2009/10/01/entity-framework/</link>
		<comments>http://midnightmuse.com.au/2009/10/01/entity-framework/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 15:39:00 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://midnightmuse.com.au/?p=179</guid>
		<description><![CDATA[I have recently tried out Microsoft's Entity Framework. It wasn't a happy experience.]]></description>
			<content:encoded><![CDATA[<p>I am working on a project for a client that is a little different to others that I have done. It is a simple project which needed two winforms applications. One was to be used by all and sundry, and the other was uesed by the project administrators.</p>
<p>I could have used one application, and usually I would have done so. Except that the first application was to be run on a system with a touch screen. I didn&#8217;t want a bunch of menus and a login screen for administrators. It was simpler to just write two applications.</p>
<p>The other difference with these apps from others that I am used to is that they use a MySql database. In the past all the applications I have written in the .Net world have used either MsAccess or SqlServer. Fortunately, the Access apps have been getting fewer, although I do have one on the go at the moment, and that is also a painful experience which I will write about in a subsequent post.</p>
<p>The problem with MySql is the data providers. I use an Object Relational Mapper for database access whenever I can. My ORM of choice is <a href="http://www.llblgen.com/">LLBLGen Pro</a>, a mature and powerful product. There are many others, and in the .Net sphere <a href="http://sourceforge.net/projects/nhibernate/">NHibernate</a> is probably the most popular. The problem I had is due to the licencing of the MySql data provider used by LLBLGen. I may have gotten this wrong, but at the time I wrote version 1 of these apps it looked like the problems were, if not insurmountable, at least difficult to overcome. So I wrote my own data access layer using datareaders and, in some cases, datasets. I wasn&#8217;t happy with the result, but it was a very small application and it worked. As with most small applications it has grown and I decided that I wanted a better data access layer. I didn&#8217;t feel that I had was robust enough and I wasn&#8217;t happy with the code. And I certainly wasn&#8217;t happy with the datasets as the program grew.</p>
<p>What to do?</p>
<p>Microsoft hs brought out two relatively new data access technologies. The oldest, and it has been around for a few years is LINQ &#8211; Language Integrated Queries. I really like LINQ, and combined with lambda expressions it gives you a very concise way to query collections. And along with LINQ came LinqToSql, the ability to use LINQ against a Sql database. You are now able to write something very similar to Sql queries in code, as opposed to a string expression. LinqToSql works with a number of different databases provided you only want to read the data. If you want to do updates or inserts then it will only work with Microsoft SqlServer. From what I have read there are no technical reasons for this, so I assume that it was a marketing decision.</p>
<p>More recently Microsoft has released Entity Framework. This has been described by Microsoft as <em>much more than an ORM.</em> My experience is a little different. It seems to me to be very much less than what we would expect in an ORM. Object Relational Mappers have been around for years now. They have been popular in many other platforms &#8211; Java,f or example has had Hibernate since 2001, I think. Other languages have used them since the early 1990&#8242;s. They aren&#8217;t a new phenomenon. If Microsoft had introduced Entity Framework in the early days of .NET, say when .Net 1.1 was all we had, then I think we could put up with what they have given us. But it is no longer 2004. The .Net world has moved on and in 2009 Entity Framework just isn&#8217;t good enough.</p>
<p>And it isn&#8217;t as if Microsoft cannot product good products. The CLR is a pretty good framework. Visual Studio is a good environment to work in, and VS 2010 looks like it will be very nice. WPF and Silverlight are not perfect but pretty good and getting better. C# is an enjoyable language to program in. The Java crowd will deride me for saying all this. But I believe that C# has overtaken Java and it is continuing to evolve. Microsoft has undoubtedly got some talented people. But they missed the boat with Entity Framework.</p>
<p>What&#8217;s wrong with it? First off, it is very slow. Over the past few years performance has become less of an issue in the sort of business applications that I write. Computers are fast. Most have multiple cores and memory to spare. In most of the applications I write the biggest impact on performance is data access. You have to go to the database, get it to its own crunching and return some data. Entity Framework uses reflection to create the objects. The first time you send a database call is the worst. After that it is is still slow, but getting closer to acceptable. LLBLGen, on the other hand, creates the classes as part of a data access project. The runtime experience is very good. It is no differenct from creating any other object once you have the data. The difference is that with a decent ORM your performance is once again determined by your database.</p>
<p>The second problem with Entity Framework is that it is very difficult to use. Julia Lerman has written a book about Entity Framework and is in the process of writing an update. She has an article, <a href="http://www.code-magazine.com/articleprint.aspx?quickid=0907071&amp;printmode=true"> 8 Entity Framework Gotchas</a> that is worth a read. Entity Framework is just not very intuitive.</p>
<p>The final problem I want to mention is the designer itself. Entity Framework runs inside of Visual Studio. You create an Entity Data Model item within a project. You are then taken to a wizard and from there you can create a model from your database. All well and good. But every table you need is placed on a visual canvas. The small application I was building only had eight tables, but that was more than enough to look at on one screen. What is it like when you have 50 tables which is not a large number. I recently did a project which had to query a database containing 24 tables and 27 views. And this was a relatively small application. I wouild have hated to look at my model in the Entity Framework designer, it would have been virtually impossible.</p>
<p>There is a new version of Entity Framework coming out soon. Perhaps it will ship with VS 2010. And I am prepared to give the new version anothe go. But at the moment it is practically unusable.</p>
]]></content:encoded>
			<wfw:commentRss>http://midnightmuse.com.au/2009/10/01/entity-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Beginning ASP.NET</title>
		<link>http://midnightmuse.com.au/2009/09/15/beginning-asp-net/</link>
		<comments>http://midnightmuse.com.au/2009/09/15/beginning-asp-net/#comments</comments>
		<pubDate>Mon, 14 Sep 2009 14:24:53 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://midnightmuse.com.au/?p=177</guid>
		<description><![CDATA[ASP.Net is a brand new experience for me.]]></description>
			<content:encoded><![CDATA[<p>All of my .Net experience, until relatively recently, has been Winforms.  Over the past 12 to 18 months I have done a bit of WPF, but Winforms is still my bread and butter.</p>
<p>Early this year I picked up a new client. That itself was surprising. I thought in these troubled economic times that I might be struggling to find new work. But I happened to be recommended by the right person at the right time and I was asked to do a winforms project. Every developer knows that some projects go well, and some go badly. This one went well at every step. The client was pleased with the result and the application was deployed ahead of time.</p>
<p>It could have gone the other way. I could have run into unforseen problems and had an application that didn&#8217;t meet expectations delivered late. And then I wouldn&#8217;t have been asked to do any more work for them. Fortunately, that wasn&#8217;t the case, and I have now done half a dozen winforms applications for this client.</p>
<p>Last week they asked me if I could do a simple ASP.Net application. I haven&#8217;t looked at ASP.Net in the last 6 or so years. When I first moved to .NET after a number of years programming windows in Visual Basic from version 3 to version 6, and dabbling in C++ along the way, I went through qutie a few tutorials and so I got a taste of ASP.Net. I haven&#8217;t looked at it since.</p>
<p>So I said I would brush up on it and see it went. Today I received the initial specs for the application.</p>
<p>I have spent the last three of four days brushing up on ASP.Net, and I have had a close look at ASP.Net MVC. I like the idea of MVC. I have read qutie a few blog posts which have described the good, the bad and the ugly of Microsoft&#8217;s implementation of MVC. But until now I haven&#8217;t used it in anger.</p>
<p>When I do Winforms applications I often use Model View Presenter. In WPF I have been looking at MVVM, and I am currently working on a project that will use it for the first time.</p>
<p>Whether ASP.Net MVC is the right way to go, I can&#8217;t say. I don&#8217;t have enough experience. But it does look, on the face of it, a better approach than standard ASP.Net. So I think I will try that and see what happens.</p>
]]></content:encoded>
			<wfw:commentRss>http://midnightmuse.com.au/2009/09/15/beginning-asp-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Physics for fun</title>
		<link>http://midnightmuse.com.au/2009/06/06/physics-for-fun/</link>
		<comments>http://midnightmuse.com.au/2009/06/06/physics-for-fun/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 07:57:12 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://midnightmuse.com.au/?p=175</guid>
		<description><![CDATA[New physics site]]></description>
			<content:encoded><![CDATA[<p>My son has a <a href="http://www.tonywright.id.au/">new site </a>dealing with physics.</p>
<p>He is a Phd student at Wollongong University studying the theoretical aspects of nano technology. There is nothing there yet but over the coming months he will be publishing papers and useful articles related to this area of physics.</p>
]]></content:encoded>
			<wfw:commentRss>http://midnightmuse.com.au/2009/06/06/physics-for-fun/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
