Archive | Personal Projects RSS for this section

SQL Server Management Objects – An Update

So, after previous post called “Adventures with SQL Server Management Objects“, I decided to take a step back and see if I could improve my code. I wasn’t happy with the while(true) loop, as if the developer stars align in a certain way this could potentially mean an infinite loop.

This is Bad™.

Originally I had the idea of using Tasks (from the Task Parallelism Library) to monitor the status of switching from Idle to Executing and then Executing to anything else (signifying failure), and so I plugged away at my code briefly, while also coming to grips with the TPL. However, as time went on, I realised this code was getting messier and messier because a) I didn’t really know what I was doing, and b) as I got more familiar with Tasks and when/where to use them I realised I technically didn’t need them (as it being a console app, I didn’t really care about blocking the main thread). Not only that, but monitoring the status changes of the Job in this way was fraught with danger because sometimes (yay consistency) the time between the initial job.Start() and job.Refresh(), the job can execute and fail, making the status monitoring a bit flaky at best. So I threw away my changeset and started again (from my previous commit), this time without any usage of Tasks.

This is what I ended up with, edited for brevity;

    /* snip */
    var lastRunDate = job.LastRunDate;

    job.Start();
    job.Refresh();

    // The job.LastRunDate will only change once the job finishes executing, providing a way of monitoring the job
    while (job.LastRunDate == lastRunDate)
    {
        Thread.Sleep(_interval);
        job.Refresh();
    }

    if (job.LastRunOutcome == CompletionResult.Succeeded)
        WriteInfo("Hooray! Job Successful");
    else
    {
        WriteError("Oh Noes! Job failed!");
        WriteError("Job failed with message: " + job.GetLastFailedMessageFromJob());
    }
    /* snip */

By monitoring when the LastRunDate property of the Job object changed, I was able to accurately determine when the job had actually stopped executing from the current attempt. Thankfully, the LastRunDate property only gets changed when the Job finishes executing (whether it fails or succeeds).

If you want to look at the full changeset, the details are here.

Technically though, this still blocks the main thread. I realised after I finished this, that you could wrap that entire chunk of code above inside a Task, using –


Task.Factory.StartNew( () => {

/* monitoring code here */

});

Unfortunately, this doesn’t have any of the CancellationToken stuff implemented in it. And honestly, I’m not entirely sure where it would go, or if its even necessary. That’s for another post though 🙂

Thanks for reading folks, have a great night/day.

Advertisements

JavaScript: My Journey

So I finally jumped on the bandwagon. Two bandwagons, actually, but I’ll get to that soon.

I have a somewhat troubled history with JavaScript. You know those horror stories you hear from devs sometimes, the ones that make you shiver with fear? I lived through one of those, and it tainted my view of JavaScript from early on in my career. I saw JavaScript used (or more accurately, abused) in such a way that I was completely turned off from JavaScript, with an almost irrational hatred of the language.

I was encouraged to read “JavaScript: The Good Parts” to try and overcome my fears regarding JavaScript, and thankfully I managed to put my anger (and yes – it was genuine anger; that’s how bad this project scarred me) aside and plunged in headfirst. Very quickly I realised that JavaScript is actually pretty amazing. Prototyping languages are something I’d never really encountered before (I come from a .Net background). The JavaScript in my past was most definitely not how to use JavaScript, so it was fascinating to see JavaScript demonstrated in such a way that had me nodding my head and thinking “damn, that’s pretty cool”.

So bit by bit (ha, geddit?), I started to appreciate JavaScript… Not that I’d actually used it for anything else at that point, but my anger towards anything JavaScript was fading, so it was nice to come back to a slightly more balanced standpoint. Then, I discovered JQuery. Wow… just wow. JQuery is probably the single most important thing to ever happen to JavaScript… So many things that were previously tedious and terrible were single line, small character set calls. So my attitude towards JavaScript improved again.

Then, most recently, I had the pleasure of attending a presentation by a mate at work who was doing a live coding demo app (oh yes, live coding. Ballsy, right!?) to demonstrate some Windows 8, HTML5 and JavaScript goodness. I came away not only impressed (it was a good presentation), but inspired.

Which brings me to the second bandwagon; Windows 8 development. I’d tinkered with it a bit in the past, but nothing more than a bit of light reading. This was the first time I’ve actually spent any decent amount of time looking into it, and jumping straight into the Windows 8 JavaScript apps has been an absolute blast. So far, I’ve done the venerable “Hello World” tutorial, HW with navigation, and am currently working my way through the photo viewer sample application. And I’ve gotta say, using JavaScript is actually kind of fun especially with all the functionality exposed by the WinJS library. It’s been a while since I’ve picked up a completely new technology (no, I don’t count the previous experience I’ve had with JavaScript), and I can see some pretty awesome potential with JavaScript in Windows 8 development.

Come to think of it, its been a long time since I’ve coded for myself and actually enjoyed it this much. With my current job, I don’t get much time to play around with the new Shiny and now that I’m currently on holidays I think I’ll be spending some more time hacking away at JavaScript and Windows 8 in general. Once I’ve completed the tutorials I might try my hand at something small, maybe a blog engine or something to really solidify the knowledge in my head.

While I like what I’ve done so far in the WinJS world, I would be very curious to see what people have used for things like navigation and layout outside the WinJS realm. A lot of the stuff I’ve seen in Windows 8 Land, WinJS makes ridiculously easy (which is a good comment on the guys who developed the WinJS libraries), so once I’m done with the Windows 8 side of things, I’m going to delve into the other areas and see whats out there in terms of APIs and the like.

So this is my journey so far, and I hope you enjoyed the post. I think this might be Part 1 of a series… Not quite sure yet. Maybe a follow up post on my concerns with JavaScript development in general (because even with my new-found positive attitude, there are still a few!), and touching on some gotchas in the Windows 8 landscape.

Expect a follow-up post very soon with the resources I’ve used so far in my Windows 8 JavaScript learning journey.

Progress!

So its actually been a productive week. Even though it did strictly take longer (by 1 day) than I was hoping in my previous post, I still managed to get my main goals accomplished.

I now have a shiny new VM with the following:

  • Windows Server 2012
  • SQL Server 2012
  • Visual Studio 2012
  • BizTalk 2010 R2.

Oh whats that you say? “But Adam, you said BizTalk 2013 you sly devil!”. Why yes… yes I did. Little did I realise by attempting to go as bleeding edge as I possibly could I would cut myself… In that BizTalk 2013 hasnt actually been released yet, on MSDN or retail. Silly me 😉 I did have a rather amusing head-scratching moment at that point.

Last night I started my own personal development again, which felt absolutely awesome. I’m going to be creating some sort of Windows 8 Metro app, will all the trimmings; snap-bar functionality, charms and the whole shebang! I  began the Intro to Windows 8 App Development on the Pluralsight Website to wet my feet in the Windows 8 world, and I am actually kind of excited… Its been a while since Ive learnt an interesting new technology. On a side note, you are even remotely interested in software development, and you dont have a subscription to PluralSight, GO GET ONE RIGHT NOW. NOW, I SAY! Heck, I’ll even wait for you.

Ok good, glad we got that sorted out. Trust me, you’ll thank me later 😀

So overall this week I think I’ve accomplished the minor goals I set out to do, plus even a bonus goal (that of starting my personal developement) on top! Its beginning to look alot like Christmas… (I even gave you the karaoke version of that song! Gosh I’m nice).

My goal for the following week will be to get through the PluralSight vid I’m currently watching, and write a really basic ‘Hello World’ style application.

Night all 🙂

Of Projects and Hobbies

On the whole, I enjoy writing as an honest to goodness hobby. Once I start writing my brain goes into the zone and I’m madly typing a thousand words or so in a very short time, and usually its fairly coherent. Lately I’ve been taking notes on potential future personal projects, but I’ve been seriously struggling to find the motivation to start just the initial investigations required for these projects. And dont even get me started on my technical blogging :\

So, with that in mind I’ve decided to start accelerating things a little bit but using an alternate approach to ‘CODECODECODE’. Firstly, as a mixture of hobby and personal development I’ve started a gaming blog. I am a HUGE gamer… my passion for gaming quite often overrides my common sense so its definitely a subject I know a lot about, and have a lot to say. The point of this is to try and get into the habit of writing. I’m a firm believer in that writing is a really useful skill as a developer, as we are required to be coherent in a number of different aspects (writing specs, talking to clients etc) and a blog is a good way to hone those communication skills a lot of developers seem to lack. So while its not really technical as such, at the very least its giving me practice in making my thoughts about various subjects clear and focused.

The second of my two-prong attack is these personal projects I’m talking about. I’m going to start setting REALLY small goals for these, as I tend to get overwhelmed by the scope of my ideas, killing it before it begins. For instance… by the end of this week I plan to have a new dev VM set up, with Windows Server 2012, VS2012, SQL2012 and BizTalk Server 2013. If I can have that accomplished, I will be a very happy camper. And next week perhaps some initial investigation into the simpler projects I’ve thought of. Next week is a long way away, so I’ll leave that up in the air for now (you’re on the edge of your seat right now, aren’t you? 😉 ).

Feel free to share your experiences in tackling your own personal development below, I’d be happy to hear someone else’s approach to this.

%d bloggers like this: