By BoLOBOOLNE payday loans

The jQuery Party – I’m really late

Posted: December 18th, 2010 | Filed under: Javascript/jQuery, Programming
Author:
No Comments →

So I’ve known about jQuery for quite a while. But I haven’t taken the time on my own to experiment with it nor was I really getting much chance to use it at work. Being an ASP shop, most of the out of the box functionality we get doesn’t play nice with extensive amounts of custom javascript.

So jQuery sat undiscovered, unexplored and therefore unloved. I have recently however undertaken an effort to experiment more, and I have been. I’ve been experimenting more with C, C#, .net 4, patterns like IoC (in fact I’m currently writing my own flavor of IoC container that I plan to release – assuming I don’t find one that’s already targeting the same thing I am).

Anyway, my experiments with jQuery have been a total blast. Not that I’ve gotten too complicated yet. I’ve done a lot with some of the simpler ui pieces and gotten relatively comfortable with the core. There is a lot left in the UI to explore and plenty of other plugins when I’m ready.

I was talking to a friend who is more of a designer than a programmer and he was asking what I liked about jQuery. I tried to explain some of the really nice features but wasn’t really getting far. For sure, my favorite piece of the core is the flexibility of the selector.

Specifically the ability to select collections based on a context or not.

    $("a","#nav");
    $("a");

Will select all anchor elements under the element with the id “nav”. Or like in the second section you can just select all of the anchor elements anywhere on the page. From there you can perform… well just about anything.

To my friend who is a designer this didn’t in itself open up the world of possibility like it did to me. So I hacked up this quick little script for him:

Read the rest of this entry »

Tags: , , , ,

AutoMapper prefill

Posted: December 16th, 2010 | Filed under: .NET, Libraries, Programming
Author:
No Comments →

I wrote a series of posts about AutoMapper and where I found it useful several months ago. In some cases I think I was trying to fit it into something it wasn’t entirely intended for, which by the way is pretty much the comment I got from Jimmy Bogard the developer behind AutoMapper.

Anyway having integrated AutoMapper deeper into the application I work on I’ve found another great use. It’s a little strange perhaps, but it works out really well. I use it to handle prefills on extended objects. So if I have a base object that I extend and add a few fills I create a map for this with AutoMapper, ignoring the new fields. Then on construction I’m passing the base object and letting AutoMapper handle the prefill for me.

It’s not a complex idea but it’s simple and effective. I’ll give you a quick example of how we’re accomplishing that.

public class BaseClass { 
    public string MyProp { get; set; }
}

public class ExtendedClass : BaseClass {
    // a lot of my maps are created in a bootstrapper but for this situation
    // this works pretty well, though I admit it might be a little questionable architecturally
    static ExtendedClass() {
        Mapper.CreateMap<BaseClass, ExtendedClass>()
            .ForMember(dest => dest.MyNewProp, opt => opt.Ignore());
    }

    public ExtendedClass(BaseClass prefill) {
        Mapper.Map(prefill, this, typeof(BaseClass), typeof(ExtendedClass));
    }

   public string MyNewProp { get; set; }    
}

We’ve been doing this for a few months now and while we don’t need it frequently, when we do need it, it’s been great.

Tags: , , ,

Fibonacci’s Sequence

Posted: December 14th, 2010 | Filed under: Programming
Author:
No Comments →

Someone asked me today how I would write a function for Fibonacci’s Sequence. I was taken entirely off guard so I gave a bad answer that I know wouldn’t work but was at least the right general idea… sort of. Then I thought about it for a minute and thought of a simple solution. Too bad the moment was passed.

int seq(int x)
{
    return (x < 2) ? x : seq(x - 1) + seq(x - 2);
}

Looking at it now, it’s got to be one of the simplest things I can imagine, it’s going to drive me crazy that I didn’t think of it quickly enough. And yes, I realize there are probably 1000 websites that give this same answer, but I haven’t looked at them yet. Not to mention that’s just not the point. The point is I had to figure it out for myself.

This is of course only the simplest solution, not the most efficient or best.

Tags: , ,