<feed xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
    <title>Fran Hoey</title>
    <link rel="self" type="application/xml" href="http://geekswithblogs.net/FranHoey/Atom.aspx" />
    <subtitle type="html"> </subtitle>
    <id>http://geekswithblogs.net/FranHoey/Default.aspx</id>
    <author>
        <name>FranHoey</name>
        <uri>http://geekswithblogs.net/FranHoey/Default.aspx</uri>
    </author>
    <generator uri="http://subtextproject.com" version="Subtext Version 0.0.0.0">Subtext</generator>
    <updated>2011-08-15T09:48:51Z</updated>
    <entry>
        <title>How do you interview a programmer?</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/FranHoey/archive/2011/06/12/how-do-you-interview-a-programmer.aspx" />
        <id>http://geekswithblogs.net/FranHoey/archive/2011/06/12/how-do-you-interview-a-programmer.aspx</id>
        <published>2011-06-12T08:26:4601:00:00</published>
        <updated>2011-06-12T08:29:49Z</updated>
        <content type="html">&lt;h3&gt;How do you know the programmer you are interviewing is the best of the bunch?&lt;/h3&gt;

&lt;p&gt;I'm talking about natural programming talent. The best programmers will pick up new technologies fast and be using them in an innovative, imaginative and logical way. They will write clean logical code that rarely fails and is easy, even pleasing, to follow.&lt;/p&gt;

&lt;p&gt;Most interview tests can be passed by reading a textbook and having a little experience. They don't weed out the truly good programmers from the ones who learn programming parrot fashion.&lt;/p&gt;
&lt;p&gt;For me, an interviewer needs to test the interviewees problem understanding and solving techniques as this underpins any good programmer. I think a good way of doing this is via logic games.&lt;/p&gt;

&lt;h4&gt;Blocked Car/Parking Lot&lt;/h4&gt;
&lt;p&gt;The user has to move other cars out of the way to get the yellow car out of the parking lot. This exercises the programming problem solving muscle. The user has to think about many factors as the levels get harder (e.g. I need to move the red car, but to do that I have to move the blue car, but I cant because....) &lt;/p&gt;
&lt;p&gt;Here is an example - &lt;a href="http://www.funatico.com/flash-games/yellow-out-2042.html" target="_blank"&gt; http://www.funatico.com/flash-games/yellow-out-2042.html&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;River Crossing Puzzle&lt;/h4&gt;
&lt;p&gt;A classic logic puzzle. The user has to get a group of people from one side of a river to the other, but the boat cant take them all at once. There are several rules restricting who the people are happy to be with that restrict the order they can be moved. This is the sort of problem common when programming. The core task is simple, but restrictions in the environment or business rules add complications.&lt;/p&gt;
&lt;p&gt;Here is an example - &lt;a href="http://www.smart-kit.com/s888/river-crossing-puzzle-hard/" target="_blank"&gt;http://www.smart-kit.com/s888/river-crossing-puzzle-hard&lt;/a&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;I'm not suggesting this is the only test you should try, or even the best, but it at least tests something that is nearly always missed.&lt;/p&gt;&lt;img src="http://geekswithblogs.net/FranHoey/aggbug/145820.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/FranHoey/comments/145820.aspx</wfw:comment>
        <slash:comments>3</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/FranHoey/comments/commentRss/145820.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/FranHoey/services/trackbacks/145820.aspx</trackback:ping>
    </entry>
    <entry>
        <title>Compact Framework Visual Inheritance P/Invoke Designer Error</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/FranHoey/archive/2011/05/06/compact-framework-visual-inheritance-pinvoke-designer-error.aspx" />
        <id>http://geekswithblogs.net/FranHoey/archive/2011/05/06/compact-framework-visual-inheritance-pinvoke-designer-error.aspx</id>
        <published>2011-05-06T12:36:5701:00:00</published>
        <updated>2011-05-06T12:38:27Z</updated>
        <content type="html">&lt;p&gt;This is a problem I've struggled and struggled with. No workaround or fix I found on the internet worked. In fact the work around I finally got to work incorporates a combination of fixes.&lt;/p&gt;

&lt;h2&gt;Symptoms&lt;/h2&gt;
&lt;p&gt;The Form or User Control designer in Visual Studio displays the following error:&lt;/p&gt;
&lt;p style="font-family: Courier New"&gt;Visual inheritance is currently disabled because the base class references a device-specific component or contains P/Invoke&lt;/p&gt;

&lt;h2&gt;Cause&lt;/h2&gt;
&lt;p&gt;In case you didn't know P/Invoke is used to access un-managed code (com components). The designer has to compile and initialise your forms via the constructor to display them on the design pane, however, it is unable access un-managed code. If your forms inherit from a custom base form and the designer sees a P/Invoke anywhere in your code (even if it will never access it) it throws the above error. &lt;/p&gt;

&lt;p&gt;Two examples of this I've found are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The InputPanel Control&lt;/li&gt;
&lt;li&gt;The Sqlite .Net Libraries from PHX Software&lt;/li&gt;
&lt;/ul&gt;



&lt;p&gt;See here for more - &lt;a href="http://msdn.microsoft.com/en-us/library/ms228851.aspx" target="_blank"&gt;http://msdn.microsoft.com/en-us/library/ms228851.aspx&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;Solution&lt;/h2&gt;
&lt;p&gt;As hinted at before there are two parts to the solution. First you need to tell the designer “Don't worry about it, I wont let you touch P/Invoke code”, then you need to live up to your promise.&lt;/p&gt;

&lt;h3&gt;Part 1&lt;/h3&gt;
&lt;p&gt;Mark your base form with &lt;span style="font-family: Courier New"&gt;DesktopCompatible(true)&lt;/span&gt; to calm the designer.&lt;/p&gt;

&lt;ol&gt;
    &lt;li&gt;In Solution Explorer, right click your form and select "View Class Diagram".&lt;/li&gt;
    &lt;li&gt;Select the class blob.&lt;/li&gt;
    &lt;li&gt;In Properties Pane click "..." button in the "Custom Attributes"&lt;/li&gt;
    &lt;li&gt;Paste &lt;span style="font-family: Courier New"&gt;DesktopCompatible(true)&lt;/span&gt; into the text area and click ok.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;Part 2&lt;/h3&gt;
&lt;p&gt;Avoid code that references the P/Invoke code. There are many ways to do this but here is my simple method. &lt;/p&gt;
&lt;p&gt;The designer pane only initialises the forms it requires. When the program runs for real, the static class &lt;span style="font-family: Courier New"&gt;Program&lt;/span&gt; opens the first form and your code takes it from there. That little nugget of information makes my method work.&lt;/p&gt;
&lt;ol&gt;
    &lt;li&gt;Create a static class with a static property as such&lt;br /&gt;&lt;span style="font-family: Courier New"&gt;public static bool IsRuntime { get; set; }&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;In the &lt;span style="font-family: Courier New"&gt;Main&lt;/span&gt; function in the &lt;span style="font-family: Courier New"&gt;Program&lt;/span&gt; Class (Program.cs) set the above property to true before it opens the first form. This code is only run at runtime.&lt;/li&gt;
    &lt;li&gt;Use this property in &lt;span style="font-family: Courier New"&gt;if&lt;/span&gt; statements in your code to avoid P/Invoke calls when &lt;span style="font-family: Courier New"&gt;IsRuntime&lt;/span&gt; is false.&lt;br /&gt;&lt;img src="http://www.bluejumper.com/blogimages/pinvoke_runtimetest.gif" /&gt;&lt;/li&gt;
&lt;/ol&gt;


&lt;h2&gt;SQLite Solution&lt;/h2&gt;
&lt;p&gt;The above solution would work if you are using SQLite, but you would end up with very messy code as you are probably referencing your SQLite libraries quite often. This is a neater solution that keeps all the runtime checks in a central place.&lt;/p&gt;

&lt;h3&gt;Part 1&lt;/h3&gt;
&lt;p&gt;Same as above.&lt;/p&gt;

&lt;h3&gt;Part 2&lt;/h3&gt;
&lt;p&gt;Create a class that sets up your SQLite Objects and perform your checks there. Unfortunately I cant publish my class here as the source code belongs to my client, however, I can give you a few snippets to give you the general idea.&lt;/p&gt;

&lt;p&gt;1. Create an IsRuntime Property&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.bluejumper.com/blogimages/pinvoke_runtimeprop.gif" /&gt;&lt;/p&gt;

&lt;p&gt;2. Get the calling code (e.g. Form) to pass in the IsRuntime flag&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.bluejumper.com/blogimages/pinvoke_constructor.gif" /&gt;&lt;/p&gt;

&lt;p&gt;3. Use Interfaces to avoid any declaration of SQLite classes and only initialise SQLite classes when IsRuntime is true.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.bluejumper.com/blogimages/pinvoke_getcommand.gif" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.bluejumper.com/blogimages/pinvoke_execute.gif" /&gt;&lt;/p&gt;&lt;img src="http://geekswithblogs.net/FranHoey/aggbug/145213.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/FranHoey/comments/145213.aspx</wfw:comment>
        <slash:comments>2</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/FranHoey/comments/commentRss/145213.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/FranHoey/services/trackbacks/145213.aspx</trackback:ping>
    </entry>
    <entry>
        <title>Connecting an MVC project to an SQL database</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/FranHoey/archive/2011/03/29/connecting-an-mvc-project-to-an-sql-database.aspx" />
        <id>http://geekswithblogs.net/FranHoey/archive/2011/03/29/connecting-an-mvc-project-to-an-sql-database.aspx</id>
        <published>2011-03-29T22:14:5301:00:00</published>
        <updated>2011-08-15T09:48:51Z</updated>
        <content type="html">&lt;p&gt;I'm just getting to grips with MVC linq etc etc and came across what looks like a common stumbling block. For the more experienced of you reading this please refrain from shouting "Dumbass" at me.&lt;/p&gt;

&lt;p&gt;All the tutorials are either Code First examples or they create the database from scratch in the App_Data directory. All well and good for a tutorial that need to be easily portable to the readers computer, but not very helpful when setting up a full scale MVC application.&lt;/p&gt;

&lt;p&gt;My first problem was my lack of knowledge of Linq to SQL. If you fall into this category have a look at this link - it's gold dust.&lt;/p&gt;

&lt;p&gt;http://weblogs.asp.net/scottgu/archive/2007/05/19/using-linq-to-sql-part-1.aspx&lt;/p&gt;
 

&lt;p&gt;Finally, how to add an external SQL database to your MVC project:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Right click on "Models" folder, select "Add New Item"&lt;/li&gt;
  &lt;li&gt;Add a "Link to SQL Classes" item&lt;/li&gt;
  &lt;li&gt;Open your "Server Explorer" pane (if you cant see it try "View" on the menu bar and "Server Explorer"&lt;/li&gt;
  &lt;li&gt;Right click on "Data Connections" and select "Add Connection"&lt;/li&gt;
  &lt;li&gt;Follow the instructions.&lt;/li&gt;
  &lt;li&gt;Almost there....&lt;/li&gt;
  &lt;li&gt;Expand your newly added database to view the tables.&lt;/li&gt;
  &lt;li&gt;Drag the tables you want over to the main pane of the "Link to SQL Classes" item you added at the start.&lt;/li&gt;
  &lt;li&gt;Hey presto, you have a database context you can run Linq queries against.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Please bear in mind you will need to use the "Models" namespace to reference you database context objects.&lt;/p&gt;

&lt;p&gt;....&lt;/p&gt;

&lt;p&gt;And now back to highly sophisticated programming!&lt;/p&gt;&lt;img src="http://geekswithblogs.net/FranHoey/aggbug/144574.aspx" width="1" height="1" /&gt;</content>
    </entry>
</feed>
