Inheritence Hierarchy

Dzmitry Huba wrote the following here about Inheritence:

If two or more classes share only common data (no common behavior), then that common data should be placed in a class that will be contained by each sharing class.

If two or more classes have common data and behavior (i.e., methods), then those classes should each inherit from a common base class that captures those data and methods.

If two or more classes share only a common interface (i.e., messages, not methods), then they should inherit from a common base class only if they will be used polymorphically.

… Just something I want to ponder at some point soon.

Repository Pattern and Lazy Loading

I’ve been looking at the general problem of developing an API and the issues that result, and this is in the context of the repository pattern particularly. Though I don’t think the issues are any different when not using the repository pattern. You still need to be able to load the data you need and avoid issues like: If I Eager load I’ll have way to much data, if I load it when i need it I’ll be opening connections all over the place. With the repository pattern you break the practice of separation of concerns if you inject a reference to any required repositories or services etc. If you actually just provide somewhere on an entity to put it’s sub-entity or a collection and only load it when you need it… well that just doesn’t feel right at all…

I’ve know for a while that we were going to have to deal with this… More research!

jQuery Plugins List

Controllers in another Assembly in MVC

I was looking for information about putting controllers in a seperate assembly(dll) as a test to see whether I would be able to create some sort of plugin mechanims where the plugin assembly contains the controllers needed for that plugin.

I came across this post in a forum which simply stated says that you need to do this:

  1. Create your web application
  2. Create your class library for your controllers
    1. Reference the System.Web.Extensions.dll
    2. Reference the System.Web.MVC.dll
  3. From your web application, reference the class library

And that is it! You can create your controllers in the class library and everything will just work (Except you won’t be able to right click on an action and click “Add View…” and some of the other nice thing like that!)

It seems that the MVC framework looks in the whole appdomain for any class that implements IController…

jQuery Cookie Plugin

jQuery History Plugins

jQuery animation Example

I just created a jQuery Html Template that has 3 section.

  1. Header – Fixed size
  2. Content – Starts at the bottom of the header and stops at the top of the footer
  3. Footer – Fixed size

http://codepaste.net/ybuqrv

The template includes jquery library inline so it is fully functional.

The animation part will occur when the “Click Me” button is pressed in the top right of the page. The header will change size as will the content area. The content area is self scrolling also.

This test was done as a simple experiment to try and solve a problem with a control I’m trying to design.

Works on: IE 6-8 (though in IE6 the links are not correct), FireFox (3.5) and the latest Chrome (3.0.195.27)

jQuery toggle functions don’t work in 1.3.2

I was messing with a prototype of a page which linked to jquery 1.3.2. I used slideToggle, tested is(“:hidden”) and various other methods and I couldn’t get it to work. It was like the div I was trying to hide/show was always visible and the toggle just showed the open animation.

Firstly a simple working example:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
    <script type="text/javascript" src="jquery-1.3.2.js"></script>
</head>
<body>
    <script type="text/javascript">
        $(document).ready(function() {
            $(".container > a").click(function() {
                $(".toToggle").slideToggle();
            });
        });
    </script>
    <div class="container">
        <a href="javascript:void(0);">Toggle</a>
        <div class="toToggle">
            <p>Contents to slide in and out!</p>
        </div>
    </div>
</body>

Now assume that I want to have multiple items in the div with the toToggle class and I want to float all of them in some way or another. In the below example we only have one <p> element that will be floated left, like this:

<div class="container">
    <a href="javascript:void(0);">Toggle</a>
    <div class="toToggle">
        <p style="float: left;">Contents to slide in and out!</p>
    </div>
</div>

Now you should be seeing the same problem that I’ve had. When you click the anchor tag you will see the toToggle div’s contents going from an invisible to open state upon every click.

This doesn’t happen in jquery 1.3.1. The issue was caused by a change with how an element was considered to be hidden or visible. The details about the changes were given in the release notes here.

The issue is that the jQuery that checks whether an element is hidden checks whether offsetHeight or offsetWidth is equal to zero (0) and if so the element is considered hidden, whereas in the previous 1.3.1 release of jQuery the test was done against the “visibility” and “display” css declarations.

This becomes an issue if you have floated elements within the div in our example as the offsetHeight and offsetWidth will both be zero (0). (See http://css-tricks.com/all-about-floats/ – under “The Great Collapse”)

John Resig mentioned here that we can simply add “overflow: auto” to the div’ with the “toToggle” class and it will resolve the issues… so our code would be:

<div class="container">
    <a href="javascript:void(0);">Toggle</a>
    <div class="toToggle" style="overflow: auto;">
        <p style="float: left;">Contents to slide in and out!</p>
    </div>
</div>

This solves the issue. (albeit with people complaining that the overflow:auto should be put in a stylesheet etc.)

jQuery changes

jQuery 1.3.1 (line 2250 and following)

Sizzle.selectors.filters.hidden = function(elem){
    return "hidden" === elem.type ||
        jQuery.css(elem, "display") === "none" ||
        jQuery.css(elem, "visibility") === "hidden";
};

Sizzle.selectors.filters.visible = function(elem){
    return "hidden" !== elem.type &&
        jQuery.css(elem, "display") !== "none" &&
        jQuery.css(elem, "visibility") !== "hidden";
};

jQuery 1.3.2 (Line 2369 and following)

Sizzle.selectors.filters.hidden = function(elem){
    return elem.offsetWidth === 0 || elem.offsetHeight === 0;
};

Sizzle.selectors.filters.visible = function(elem){
    return elem.offsetWidth > 0 || elem.offsetHeight > 0;
};

Found a discussions on whether the jQuery 1.3.2 code is correct. Ticket #4374 & Ticket #4512. And there is going to be a change again it seems… This is the latest nightly code as of 2009-11-04…

2009-11-04 Nightly of jQuery

Sizzle.selectors.filters.hidden = function(elem){
    var width = elem.offsetWidth, height = elem.offsetHeight,
        force = /^tr$/i.test( elem.nodeName ); // ticket #4512
    return ( width === 0 && height === 0 && !force ) ?
        true :
            ( width !== 0 && height !== 0 && !force ) ?
                false :
                    !!( jQuery.curCSS(elem, "display") === "none" );
};

Sizzle.selectors.filters.visible = function(elem){
	return !Sizzle.selectors.filters.hidden(elem);
};

References:

Importing Templates into Sql Server Management Studio

You can add templates to the template explorer by navigating to a directory and putting the files directly into a folder.

On Vista/Windows 7 the folder is:

C:\Users\user\AppData\Roaming\Microsoft\Microsoft SQL Server\100\Tools\Shell\Templates\Sql

“user” should be replaced with your username and the 100 directory is for Sql Server Management Studio 2008 and you replace it with 90 for 2005!

On XP it is:

C:\Documents and Settings\user\Application Data\Microsoft\Microsoft SQL Server\100\Tools\Shell\Templates\Sql

“user” should be replaced with your username and the 100 directory is for Sql Server Management Studio 2008 and you replace it with 90 for 2005!

You will have to restart management studio for the templates to come up. If you have 2005 and 2008 management studio and you use both then you will have to put the templates in the folder for each version also.

EXCEPT operator in Sql Server 2005+

I came across the EXCEPT operator in Sql Server 2005 and went’ and did a little bit of searching.

Pinal Dave has a nice simple example and shows that the execution plan between EXCEPT and NOT IN is the same making it no different except in how you code it obviously.

http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/

IT seems the Except operator can work over multiple columns it seems. So it tests all of the columns in both sides of the EXCEPT which makes it somewhat of an easily avoidable keyword it seems…(That is there seems to be other ways that you can do the same things without having to learn this new keyword, even though it is rather simple)