Wednesday, August 24, 2011

Book Review: Introducing HTML5 by Bruce Lawson and Remy Sharp

IntroducingHtml5The buzz in the development world these days has changed. Cloud Computing? That’s so 2010. Multi-core CPU’s? Ho-hum. Tablet computing? Whatever.

But when Microsoft announced that the next version of Windows would allow for development in HTML5 and JavaScript, the world took notice, and a lot of us are scrambling to get up to speed. Okay, so some developers have been playing with HTML5 for a while now, and JavaScript has been around for years. I’ve worked in HTML4 for quite a while, and JavaScript has never really floated my boat. I’m a traditionalist. Code compiles. Scripts are what I use to run back in college before I had a real IDE.

I say that with only a little bit of sarcasm. I’ve never liked Web UI coding. Working with the infinite number of browsers and their individual peculiarities frustrated the crap out of me. The web was for signing people up for things, watching videos and browsing news and sports. You would never write a real application in this environment. Would you? What masochistic developer would want to build a core business system in something you could never truly test, and would behave differently on every computer? What sadistic system designer would expect users who have jobs to do to wait for a page to refresh every time they wanted to know if their data was valid?

When I heard about Microsoft’s intentions, my initial reaction was to think it was a joke. After hearing it a few times, and learning it really was true, my heart skipped a beat. I was worried that I was about to be left behind again technically, and in a few years, I’d be one of those back-end developers that couldn’t change with the time. I’d be branded as a ‘.NET Developer’, something akin to the 2011 version of a COBOL programmer. It didn’t take long for that fear to turn to anger. I’d just invested the last five years working my way deep into the Microsoft .NET Stack, building my skills and my reputation, and… and it just wasn’t fair! This whole process was very similar to the seven stages of grief. I went through the depression of realizing that I was again going to have to rebrand myself and rebuild my skills, and then the realization that doing it the last time really hadn’t been that bad. I started to look at the opportunities this would present – things that I had never before been able to do, that I could now do. I started to research what HTML5 really was, and what it was that made the world so sure this was the way to go.

After doing some piecemeal research on the web, I realized I needed a book. I’m a book learning. Reading a book primes my brain. Books are generally better organized than the snippets you might find on line. I wanted to start with the basics, and form a solid base with which I could talk intelligently with my coworkers and my bosses. I wanted a book that would explain it from the beginning.

Introducing HTML5 (First Edition) by Bruce Lawson and Remy Sharp was the book I chose to get me there, and I highly recommend it. It starts by covering the Structural Elements of HTML5, how pages are organized, the new elements and the expanded role of JavaScript in HTML5 applications. It then dives into some of the more advanced features of HTML, including Audio and Video, Canvas, Data Storage, Offline mode, Drag and Drop, Geo-Location and Messaging. I skimmed the Audio and Video and the Canvas sections since I am usually designing business apps, and haven’t had the need to build an app that draws lines since I was in college. I did, however, build a Silverlight Video player on Windows Azure for Microsoft Demo Showcase back in 2009/2010, so I expect that sooner or later, I’ll be doing something similar to that in HTML5. It’s good to know it’s there.

I was fascinated by the offline storage possibilities and the future of messaging and sockets. I can see a day coming very soon where I build an HTML5 app with messaging tied to the service bus on Windows Azure that handles Windows Workflow Processes and notifies users that some long running, multiple streamed process has completed. There’s power there. A lot of it.

I do find it a little bit funny that this is the second technical book in a row I’ve read where the authors are constantly taking shots at Microsoft and Internet Explorer. I guess I’ve been buried so deep in the mother-ship for so long, that I don’t have the same level of animosity. Of course, I have worked my career around not having to do a lot of browser work. Perhaps that has insulated me far more than I thought.

This book is short and to the point, and a great introduction to HTML5. You won’t come out a world class expert on HTML5, but you will understand the basic concepts, enough to be able to talk about it, and to begin the honest discussion of whether or not that next project you are starting should target HTML5. I’m at least willing to consider it at this point, as long as we don’t implement any features that can’t be made backwards compatible by implementing modernizr.js which is covered by Scott Guthrie here.

The biggest advantage I see to HTML5 is that in the ideal world going forward, we can build an app once, and as long as it is HTML5 compliant, it should just work on all browsers. I really like that. I want to do the work once, and move on the next project. HTML5 brings the Web UI development out of the dark ages, and makes it a real possibility for someone like me. This is a good book to get up and running inside of a week, and I’ve already recommended it to my team.

Saturday, July 30, 2011

Book Review: jQuery in Action

JQueryInAction

A few years ago, when I first got into ASP.NET development, I worked on a project that used the Ajax Controls Toolkit. I was not a JavaScript person, and my experience with the Toolkit and all its idiosyncrasies left a very bitter taste in my mouth for ‘client-side’ web development. For many of the projects after that, I worked on the back end of the system – the database, data model and business logic, and eventually the controllers and web services. We had a UI guy who tackled the JavaScript stuff and worked ‘magic’ there.

A couple of months ago, I got involved in a project which had a very large existing code base, with a lot of jQuery and my UI guy was nowhere to be found. Before I knew it, I was neck deep in it, and drowning fast. I muddled through the project and got it out the door, but I realized that I could no longer have this gap in my education. I also realized, by working on that existing code base, that jQuery was nothing like the JavaScript and Toolkit I once struggled with, and it was really freaking powerful.

It turns out that back in early 2010, I had ordered jQuery In Action by Bear Bibeault and Yehuda Katz during some book buying binge, but never read it. It got loaned out to a couple of people at work, and I didn’t see it for the longest time. It wasn’t until I finished working on that big jQuery project that I even remembered that I still had it. I tracked it down, and it flew to the top of my reading list.

I wish I had read this book a three years ago. jQuery is really powerful. And it’s really big.  jQuery in Action did a great job of introducing me to the core concepts, and giving me a refresher on basic JavaScript. Ok, not a refresher – an introduction. The unfortunate part is that I ordered this book in early 2010, which meant the version I have is the first edition published in 2008. The second edition came out in May 2010. The first edition covered up to jQuery 1.2. The second edition covers jQuery 1.4.  As I recall, there are some fairly major differences in jQuery between 1.2 and 1.4, but more importantly, there have been major changes in browsers. Internet Explorer was just on Version 7 when the book was written, and a lot of time had to be spent by developers to account for the way IE6 worked, and to a slightly lesser extent, IE7. With IE9 now out and promising “It just works”, I would like to think that jQuery will have gotten even easier in the last few years. The first edition of jQuery in Action has quite a few asides that detail the frustrations developers had with IE6 & 7, and I get the impression that the authors would have little good to say about Internet Explorer in conversation.

The book is well organized and the coverage of the core concepts appropriate for a beginning jQuery developer as long as you have a solid background in web development. It even has a very good appendix on JavaScript, which was invaluable to someone like me with a large gap in their knowledge of the subject. They build a large number of exercises into the book as well. Since I was reading the book whilst commuting, I didn’t get a chance to try them, but I think I understood them well enough from the written copy. At the very least, I know they are out there and I can download them when I get a chance to give them a try.

What I find amazing about this book (and jQuery), is how many times I thought back to projects I already have in production, and said “Wow, the UI could be so much better”, or “If I had only known about jQuery, the whole architecture would have changed.” The former makes me happy that I can now say “Yes, we can do that.” more often to clients. The latter makes me question my skills as a software architect. I had never even considered some of the approaches presented in the book, and not only would the UI have been more user friendly, it would have been faster and more reliable. I’m disappointed in myself for not taking the time to learn about jQuery before now. I can rationalize all I want about being busy with other things (like learning Windows Azure, MVC, WPF, writing 4 books, etc.) but the truth is that I considered the UI side to be the ‘poofy’ stuff and let other people handle it. The UI, I thought, was just for displaying the results of all the ‘hard work’ done on the back end.

No longer. Reading jQuery in Action has opened my eyes to the fact that I have to know all the layers, at least well enough to know what is possible. I have no doubt that there will be aspects (especially in CSS) that require an artist’s touch (which no amount of reading is going to give me), but I will now treat jQuery as a first class language in solving client problems. I still have qualms about jQuery, mainly from the testability standpoint, but I do like the idea of unobtrusive JavaScript which will allow me to keep a separation of concerns and allow me to build up a personal collection of functions that I trust just work.

I will, at some point, go out and get the second edition of this book to see what has changed in the last few years, and to reinforce my basic knowledge of JavaScript and jQuery. With HTML 5 and JavaScript coming at developers like an out of control freight train, jQuery in Action is a great way to get started and to get up to speed.

Tuesday, July 19, 2011

Using etc/Hosts to Assist in Testing

A coworker and I were in the process of migrating a client’s web server from old hardware to new hardware last week, and we needed to be able to test the system before turning it on to live traffic. The web applications called web services, and the configuration of the web app included the URL for the web services.

We needed to be careful what we were doing here, because the web services were also migrating to a new server, and on this new server, were pointing to a new database server as well. We didn’t want to change all the configuration settings on the new servers, and we couldn’t change the public DNS entry.

I’ve done this before, but not everyone knows about the following trick, so here it is:

On Windows, if you go into your %WinDir%\System32\drivers\etc directory, you’ll find a file called hosts, often referred to as “etc\hosts” or “Etsy Hosts”. Open this file with notepad running as administrator on your machine. The instructions for changing this file are right in there, and it’s pretty easy. We added a new line to file on the new server, (and on the test client) like:

127.0.0.1       www.palador.com

We saved our changes, and then restarted IIS on the box. And presto…

But it didn’t work.

We reset IIS again, and did an ipconfig /flushdns from the command prompt.

And it still pointed to the old domain.

We went back to the Hosts file and everything looked fine. I scratched my head. Then I realized that we had forgotten to put a carriage return after the new line. We added the hard-return, restarted IIS and flushed DNS, and now everything worked.

I’m pretty sure I had run into this exact same issue a few years ago, and that’s why I knew to look for it. Hopefully this will help someone else avoid this issue.

Sunday, July 17, 2011

Book Review: The Nomadic Developer by Aaron Erickson

NomadicDeveloperI don’t actually remember how I found this book. It somehow got onto my Amazon wish list one day, and it was one of those things I bought because I needed to top up an order above $25 to qualify for free shipping. I don’t remember what it was that I bought with this book, but I doubt it was as impressive as The Nomadic Developer.

It’s funny, because I tell people that I got into the consulting world back in 2008. After reading this book, I realized that I actually started in consulting back in 1994. My very first job in IT was technically at a consulting firm, albeit a very large one, (the one started by Ross Perot back in the sixties and famous for making everyone wear blue suits everywhere they went). I worked on a couple of very large accounts, so it seemed like I was just a developer in Corporate IT, but in reality, I was a consultant. I left that company in 1999, and moved on to real Corporate IT, working for an airline maintaining their revenue management systems, and later on to building and maintaining the fight operations systems. We owned those systems from cradle to grave, twenty four hours a day, seven days a week. They were horribly difficult to change. There was a tremendous amount of tribal knowledge in every subsystem, and many were already five or six years old when I started, and rewrites were impossible. By the end of my 8.5 years there, my technological skills were atrophied to the point where another year or two, and I would have been completely unmarketable outside of that industry vertical.

I jumped (back) into consulting in 2008 with little idea of what true consulting was. I wish I had had this book at my disposal back then. Not that I would change my decision – the leap into consulting has done wonders for my skills and my career. I have no doubt that making the move, when I did, was absolutely the right decision for both me and my family, and I’d like to think it was the right decision for the company I work for as well.

But in The Nomadic Developer, Aaron Erickson goes into wonderful detail of what to really expect from technology consulting, how to identify good (and bad) companies, how to survive, and how to thrive in the consulting world. He talks about how to maintain both your position and your passion during both good and bad times in the economy, and how to avoid career limiting moves. At the very least, had I read this book while still working for the airline, I could have avoided a couple of interviews that would have led to positions that I was not right for. My trouble-radar kicked in on those before I accepted, and I count myself lucky. By the time I had finished chapter two of The Nomadic Developer, I had already identified those firms as being one of the ‘Seven Deadly Firms’, and hiring on there likely would have tainted my consulting experience for the rest of my career.

The Nomadic Developer is not only for people who are thinking of becoming consultants. It’s also for consultants who are fairly new to the game, and will help you to stay out of trouble as the economy changes. I think it should also be read by owners/senior management of consulting firms, if only to avoid uncomfortable moments brought on during interviews by people who have read the book and are asking some of the hard questions Erickson suggests. Most of those questions I would be a little uncomfortable asking during a interview, but I see the value in at least trying to ask them. It’s not always the response that is important, it’s the way the response is said that will tell you if the employer is going to treat you as a partner / investment or a warm body / cost.

Here are some of the questions he suggests:

  • What is your annual revenue?
  • What is your (target) profit margin?
  • What is your exit strategy?
  • What’s the value of the sales pipeline?
  • What is the sales process?

I’ve done a lot of interviews of candidates in the last few years, and even though I have been on the technical side, I’ve never been asked questions like that. I’m actually pretty horrible at technical interviews because I hate trivia questions. I prefer to ask about experiences and expectations and to evaluate the personality of the interviewee. If someone was to ask questions like that, and I hadn’t read Erickson’s book, I would perceive them as intelligent but aggressive. But after reading his book, I would think that the candidate truly is trying to find the right fit. If I’m a consulting company senior management, I’m reading this book to make sure I’ve got my crap together so I don’t lose out on good consultants because I look like an amateur. I’m also doing an honest assessment of my company to see if I am making any of the mistakes Erikson lists in the Deadly Firms chapter. Unless my goal is to build an unsuccessful company, I want to be active in fixing these situations, even if it is just an employee perception. I don’t think too many people want to be unsuccessful at running their own company.

Another point Erickson makes is about passion for work, and how to maintain that during hard times, especially when the client you are working for is not in an industry you find appealing. I spent three years working for a client that did direct marketing… sending out junk mail and running those annoying call centers that call you during dinner. I slept on my office floor multiple nights while doing system upgrades, and let me tell you, that was really hard to justify to myself after a while. That experience left me quite cynical when it comes to working on projects I don’t fully believe have societal value. In the long run, that cynicism can be a career killer in consulting. It can kill your passion for software development, and once you’ve lost that, it can be very difficult to get it back. Employers, and especially co-workers, notice when your passion withers. In tough markets, not every job will be life-fulfilling, but Erickson suggests that taking pride in the work you do on each project will preserve the passion, and from there, passion will generate positive results and better  opportunities in the future. It takes a while to build up the resume, and there is something to learn on just about every project.

I’m giving this book a big, big thumbs up, and making sure that my wife, who is a project management consultant, also reads  this book. Very little of the book is specific to programming, and those bits can be read and parallels drawn with most other industries and job types.

Do yourself a favor, and read this book, and then get your coworkers, and your boss to read it too. If the suggestion is negatively received, you may already be working at one of the ‘Seven Deadly Firms’, and its time to find your exit strategy.

Tuesday, April 12, 2011

Where did I go?

Judging by the activity on this blog (or lack thereof), you'd think I was either dead or retired. I am not dead.

I am still actively developing software, and am constantly hanging out on the bleeding edge.  To that end, I do occasionally post blog entries on the web site of the company I work for (www.Palador.com).  But most of the stuff I work on I cannot discuss in public, or is so well covered by other blogs that I don't see the need to cover.  In the best case I’d just be repeating what someone else has said, or in the worst case, I’d be plagiarizing it.

So if you have a question or a comment, feel free to leave it.  But I only swing by this blog once in a blue moon, so if you are in a hurry, you might want to try another search.

If you really need to get ahold of me, you can try my writing blog at www.joebeernink.com.  It’s not technical in the least, but it is monitored much more frequently.

Thanks for stopping by.

Tuesday, September 28, 2010

MVC Abstract Controller

It’s been a while since I’ve posted anything here.  I’ve been busy, and most of the stuff I am working on I either can’t blog about or isn’t worth blogging about as it’s pretty much already covered in a dozen other blogs.  But I have been doing a lot of very basic ASP.NET MVC coding lately on a couple of sites.  I’ve stepped step back from my architect role to do some heads down coding to fill a personnel gap.  I don’t get to do that a lot, and I rather enjoy it when I get the chance. 

But I did come across a very interesting ASP.NET MVC situation this week that required more than a little thought.  And since my monthly blog entry was due for work, I put a long entry about an ASP.NET MVC Abstract Controller on the Palador web site blog.

Feel free to leave me a note here or there.  I’m always afraid of putting a big ‘code’ blog up because it’s just asking for someone to come along and rip the snot out of it and show me a better way to do it. But in this case, I’ll take the chance, as the solution was simple and saved me a lot of time and frustration.

Thursday, August 5, 2010

Book Review: Microsoft SharePoint 2010 – Building Solutions

 sp2010 The full title of this book by Sahil Malik is Microsoft SharePoint 2010 – Building Solutions for SharePoint 2010, and it was recently published by Apress.  I love Apress books, and have 6 others on various .NET related topics on my shelf.  SharePoint 2010 is something I needed to get up to speed on really quickly for a new project at work, as in I had less than a week to make sure I knew what I was talking about.

The book is 367 pages, and covers a wide variety of topics in SharePoint 2010.  It demos a few techniques and tools, and identifies some of the differences between SharePoint 2007 and SharePoint 2010, so even if you know SharePoint 2007, it will really help you to identify what is different about 2010. 

I’ve barely worked in SharePoint in the past.  I tried a little bit of SharePoint 2003, and dabbled in 2007, but frankly, after seeing how painful it was to work in either of those environments, I wanted nothing to do with it.  SharePoint was where good developers went to watch their career die.  Once you knew it, you were guaranteed to get every crappy job out there, and because you were so valuable to the execs and their TPS reports, there was no way you were ever going to get out without quitting your job.  And then, of course, you were so pigeonholed as a SharePoint developer, you could never get out from under it.  Even if I knew SharePoint 2007, I would never put it on my resume.  Career suicide.

SharePoint 2010 seems to be a little different.  With the advent of Windows Identity Foundation and the advanced made in PowerPivot Services, there are definitely things that can be done in 2010 that would take forever in a typical ASP.NET application.  And Linq to SharePoint is a godsend.

Malik covers all these topics with a few quick examples so that at least you know what is there, and how to use it.  Each topic is probably worthy of a book of its own.  I don’t have that kind of spare time, so I needed something at this level so I at least can speak the language and help to architect where these features can be used.  Some features I will deep dive into in the future.  Some features I will leave for others on my team to get familiar with.  You can’t know them all.

I do have a very big gripe with this book.  It does not appear as if it was ever professionally edited by a real copy editor.  There are grammar and spelling mistakes on just about every page.  As a fellow author, I know how hard it is to produce clean copy by yourself.  A second or third set of eyes is always necessary.  So I don’t blame the author for this, I blame the publishing company, Apress.  I really hope this is not a sign of things to come.  I know things are changing in the publishing world, and time to market on these books is critical and compressed.  But in the two or three dozen technical books I’ve read in the last few years, and the dozens of fiction books I’ve read, I can only remember a few typos.  This book had hundreds, and it drove me batty.  I had to reread entire sentences to try to make sense out of them because words were transposed, missing or extras added in and never removed.

Also, the print on this book, and the line spacing is small.  It really felt like they were trying to save paper by eliminating paragraph breaks.  If the book was a fast action thriller, that may not be a problem, but in a technical book, I expect proper formatting.  It helps to convey information and give your brain a break; an indication that the topic or idea is changing.  Without a break, it gets really hard to read. A lot of the graphics are blurry or too dark to read, though that could have been my eyes as I was reading late in the evening.  At one point, it was so bad, I wanted to hurl the book across the room.

I’m going to recommend this book, but I really hope they do another edit on it.  Architects should read it.  SharePoint 2007 devs should read it to get up to speed on the changes.  New devs for SharePoint 2010?  Not sure.  It does give a good introduction to SharePoint Development, but you’ll probably end up buying another book as well to get into the nitty-gritty.

SharePoint 2010 seems to have come a very long way from it predecessors, but it still feels like it is behind the times, and a little kludgy.  I’m worried that there are difficulties hidden in the practicalities of working with it that are glossed over by this book – things that you could spend a week trying to figure out, only to be frustrated by some weird case where you have to use I before E except after C when the word is in French and followed by an apostrophe.  SharePoint 2010 is to SharePoint 2007 as .NET 2.0 was to .NET 1.1.  The next version should be like .NET 3.5, infinitely better and more stable.  2010 is usable, but just not quite there yet.

But it no longer seems like career suicide to know it.  You’ll probably just need to make sure it is not the first item you list on your resume.

Wednesday, August 4, 2010

Book Review: Programming Windows Azure

I meant to review Sriram Krishnan’s Programming Windows Azure book a few weeks ago, but I have been slacking.  It wasn’t until last night, when I was halfway through my next technical book (which I will review soon), that I realized that I had neglected to do the obligatory blog post.

I’ve been working with Windows Azure since the day after the CTP Launch.  I was in the Early Adopter program.  I corresponded regularly via email or via the forums with various members of the Azure Team for about 8 months between December 2008 and July 2009.  I’ve led three major projects in the Azure world, and at PDC last year, members of the Azure team were finally able to put a face to the name of the guy that kept asking the questions that kept them working a lot of hours.  Most of them didn’t hold that against me.

I give that background because when I bought this book I didn’t think I, of all people, would get much out of it.  It was going to be another trophy on my shelf, a book read, a subject I thought I knew well enough to make this what I would consider a ‘light read’.

I was in for a shock.  A refreshing one.  This book taught me something new, or closed a gap in my knowledge base, on just about every page.  While I had worked with Windows Azure, it was in the context of delivering a specific product, and my focus was on using Windows Azure as a tool to allow the product to launch, and a lot of the details had be bypassed.

This is a great book – one of the top 3 or 4 technical books I’ve read in the past 3 years.  Every developer working on Azure must read this book.  Must.  Nothing beats the experience of working on a new platform, but this book will sure make it easier, and teach you the benefits and the pitfalls of this environment.

The biggest downfall of this book is that Chapters 1 (Cloud Computing) and 2 (Under The Hood) will lose a lot of developers who have no interest in the internals of Azure or the history of cloud computing.  These are both necessary and interesting chapters, but for the non-architect or truly technical geek, most will skim them or skip them.

Also, the scope of the book is limited to the Azure Platform itself, and it does not cover things like the AppFabric or the role of Windows Identity Foundation in Azure.  I’m looking for a good book on those as well, since I have yet to deep dive into the Service Bus, and haven’t worked with WIF since it was still called Geneva.

The rest of the book is superb, and like I said, I learned something on every page.  Every Azure developer should have this trophy on their shelf.

Microsoft Word 2010 Bug

I spend a lot of time in Microsoft Word 2010 writing my novels.  I most often am working on my ACER 1420P laptop while doing it, and honestly, this is the only place I have seen this bug, but it annoys the crap out of me.

Here’s what happens:

  1. Open a new or existing document
  2. Start typing
  3. Let you mouse cursor drift up over the tool bar (like the one for text formatting). 
  4. Keep typing.
  5. Eventually, characters will start repeating.  First you’ll see three ‘c’ characters (or whatever character that falls victim to this bug on that given day).  If you see this start to happen, sometimes moving the mouse will stop the next phase from happening, but if you miss it because you watch your fingers and not the screen (which I am prone to do), phase 2 of the bug will soon kick in.
  6. Phase 2 involves Satan taking over your computer.  If you just happen to hit the backspace key or a cursor key, it will start repeating indefinitely.  Next thing you know, your whole document is gone or you are sitting at the top or bottom of your document, and you still can’t get control back.

The only thing that I have ever found that works is to pull up task manager, and kill Word.  But at least it will ask you if you want to save your changes before it closes.  If the repeating character is a cursor movement, no problem.  If it was the backspace key, you are SOL.

I find that the bug shows up most often if the cursor seems caught between tool bar buttons.  It looks like a Windows event has gotten into an infinite loop, and as a developer, I would not want to be the one who has to try to figure this one out.

That said, I really hope this gets fixed soon.  It happens to me at least once a week, and more than once has cost me work.  I save early and save often because this one could strike at any moment.

Monday, July 5, 2010

Gradients, CSS and Overflow

Last year, I built a website (http://www.joebeernink.com) to handle aspect of my burgeoning writing career.  I also used it to learn ASP.NET MVC.

I had a designer do the styles and the graphics, but I did all the HTML work.  When I originally laid everything out, the content all fit nicely on a single 800px long div which exactly matched the length of the repeating vertical gradient the designer put together for me for the outer background. 

Once the content got too long, the repeating style left a lot to be desired.  It not only repeated across the X axis, but the Y axis as well, which meant starting at pixel 801, I had this nasty black line across the bottom of the screen, and then the gradient began again.  Yuck.

So instead of that, I set overflow = auto on all my inner divs, which for a while meant that the one page that had too much content had an inner scroll bar.  I was kind of okay with that (I shouldn’t have been), but CSS has never been something I’ve worked with a lot, so I ignored it.

Lately, as I’ve been upgrading my site for an upcoming conference, every page began to have the scroll bar, and it was killing me.  I talked to my designer at work and they shook their heads and said, “Dude, that’s like one line of CSS to fix.  Don’t be such a loser.”  Okay they didn’t say that, but they should have.  They said it was pretty easy, and could be done in a single line of CSS.  They were going to send me that line of CSS, but must have forgot.  So yesterday, knowing that a single line solution existed, I got ready to do some CSS spelunking, and eventually came up with the solution.

Out with the old CSS Classes

.page
{
    background-image: url("../../Content/beernink_pagebkgd.jpg");
    margin-left: auto;
    margin-right: auto;
    background-repeat: repeat;
}

#main
{
    margin-left: auto;
    margin-right: auto;
    padding: 20px 30px 20px 30px;
    background-image: url("../../Content/beernink_insideBkgd.jpg");
    background-repeat: repeat;
    margin-bottom: 5px;
    width: 740px;
    _height: 1px; /* only IE6 applies CSS properties starting with an underscrore */
    overflow: auto;
    height: 500px;
}

And in with the new

.page
{
    background: #252E33 url("../../Content/beernink_pagebkgd.jpg");
    margin-left: auto;
    margin-right: auto;
    background-repeat: repeat-x;
}

#main
{
    margin-left: auto;
    margin-right: auto;
    padding: 20px 30px 20px 30px;
    background-image: url("../../Content/beernink_insideBkgd.jpg");
    background-repeat: repeat;
    margin-bottom: 5px;
    width: 740px;
    _height: 1px; /* only IE6 applies CSS properties starting with an underscrore */
    /* overflow: auto;
    height: 500px; */
}

The #252E33 is the color at the bottom of the gradient. The color nicely fills the page beyond the 800px line, and looks great. 

There are probably better ways to do this, but this was simple and allowed me to say the site was ‘done-done’ for the conference later this month.

Of course, now I want to find a real blogging engine in ASP.NET MVC that I can deploy with my site.  Any recommendations?

Friday, May 7, 2010

Silverlight + Azure Shared Access Policy Issue

We’ve been working with Shared Access Policies in Azure for the last week or so, and for the most part it was working.  But it would only work for a while, then it would stop.  Then it would start working again.   It took some help from Steve Marx and Jai Haridas on the Azure Team to figure out what was going on.

This first piece of code is part of our storage manager that retrieves the Uri for the blob from Azure Blob Storage, and creates a Shared Access Policy for that blob so that our Silverlight Video Player can directly access the blob without going through a very slow web service call.

   1: /// <summary>



   2:         /// Get the Uri for a specified video blob



   3:         /// </summary>



   4:         /// <param name="videoId">The unique identifier of the video</param>



   5:         /// <returns>A Uri ponting to the Video</returns>



   6:         public Uri GetVideoBlobUri(Guid videoId)



   7:         {



   8:             var log = Log4NetHelper.GetLogger();



   9:             log.DebugFormat("Getting Video for video id {0}", videoId);



  10:  



  11:             try



  12:             {



  13:                 CloudBlobContainer container = GetContainer("VideoContainerName");



  14:  



  15:                 CloudBlockBlob cloudBlockBlob = container.GetBlockBlobReference(string.Format(CultureInfo.InvariantCulture, "{0}", videoId));



  16:                 



  17:                 var readPolicy = new SharedAccessPolicy



  18:                 {



  19:                     Permissions = SharedAccessPermissions.Read,



  20:                     SharedAccessExpiryTime = DateTime.UtcNow + TimeSpan.FromMinutes(10)



  21:                 };



  22:  



  23:                 var blobUri = new Uri(cloudBlockBlob.Uri.AbsoluteUri + cloudBlockBlob.GetSharedAccessSignature(readPolicy));



  24:  



  25:                 log.DebugFormat("GetVideoBlobUri successfully retrieved for video id {0}", videoId);



  26:  



  27:                 return blobUri;



  28:             }



  29:             catch (StorageClientException ex)



  30:             {



  31:                 // If the blob was not found, return null



  32:                 if (ex.ErrorCode == StorageErrorCode.BlobNotFound)



  33:                     return null;



  34:                 // Rethrow the exception in all other cases



  35:                 throw;



  36:             }



  37:             catch (Exception ex)



  38:             {



  39:                 log.ErrorFormat("Error while retrieving video blob {0}", ex.Message);



  40:                 throw;



  41:             }            



  42:         }




In our Silverlight Web Service, we call this manager class and return the Uri embedded in an XElement.  Originally we did this to allow us to return other information with the Uri, but at this point, the Uri is all we are passing through.





   1: /// <summary>



   2: /// Get video URI.



   3: /// </summary>



   4: /// <param name="videoId">ID of the given video.</param>



   5: /// <returns>Status</returns>



   6: public XElement DemoVideoUri(string videoId)



   7: {



   8:     var blobManager = UnityFactory.Current.Resolve<IBlobManager>();



   9:     var blobUri = blobManager.GetVideoBlobUri(new Guid(videoId));



  10:  



  11:     string xml = string.Format("<VideoUri>{0}</VideoUri>", HttpUtility.HtmlEncode(blobUri.AbsoluteUri));



  12:     var sr = new StringReader(xml);



  13:     return XElement.Load(sr);



  14: }




On the Silverlight side, we take make a call to this web service, extract the Url from the XElement, and pass the Url into the MediaPlayer like so





   1: var client = new WebClient();



   2:  



   3: var videoUri = GetVideoUri();



   4:  



   5: client.DownloadStringCompleted += (x, y) =>



   6:                                Dispatcher.BeginInvoke(



   7:                                    () =>



   8:                                    {



   9:                                        var xdoc = XDocument.Parse(y.Result);



  10:                                        var query = from b in xdoc.Descendants()



  11:                                                    select b.Value;



  12:                                        HostedVideoUri = new Uri(HttpUtility.HtmlDecode(query.First()), UriKind.Absolute);



  13:                                        mediaPlayer.Source = HostedVideoUri;



  14:                                        Log(string.Format("HostedVideoUrl = {0}", HostedVideoUri.AbsoluteUri));



  15:                                    }



  16:                                    );



  17:  



  18: client.DownloadStringAsync(new Uri(videoUri, UriKind.Absolute));



  19:  



  20:  



  21: private static string GetDemoVideoUri()



  22: {



  23:     var host = HtmlPage.Window.Eval("window.location.hostname;") as string;



  24:     var path = HtmlPage.Window.Eval("window.location.pathname;") as string;



  25:     var refererUri = host + path;



  26:     var url = string.Format("http://{0}/xxxx.Svc/DemoVideoUri/{1}", GetHost(), VideoId);



  27:     return url;



  28: }






This is all pretty simple code (and the above code works, by the way).



Where we ran into problems was in the Web Service, when populating the xml string.  Originally, we used blobUri.ToString() instead of blobUri.AbsoluteUri.   This caused big issues (403 errors returned from the Azure Storage Service), when the Video Player tried to retrieve the blob because the Url returned from the Shared Access Policy generator can have spaces in it.  And Uri.ToString and Uri.AbsoluteUri work very differently when handling spaces.  I did not know this until last night.  Uri.ToString unescapes the Uri before returning it.







So why did it work sometimes, and not all the time?  Simple.  Sometimes the Uri from the Shared Access Policy Generator has spaces, and sometimes it does not.  The former did not work, while the latter did.  We were looking for a pattern in the number of times we called the web service, or the interval between calls, and the size of the video blob.  But it was as simple as a single space.



I think we spent at least 8 hours over the last two days trying to track down this bug.  Hopefully this saves someone else some grief.



This post is cross posted on http://www.palador.com/blog/Blog/Silverlight--Azure-Shared-Access-Policy-Issue intentionally.

Monday, April 26, 2010

Book Review: Professional Application Life Cycle Management with Visual Studio 2010

We’re jumping into Visual Studio 2010 this week, and beginning the migration to TFS 2010 as well.  I wanted to get familiar with TFS 2010 and try to standardize our practices a little more before we mis-configured everything, so I bought the first book I saw that seemed to cover TFS 2010.  Professional Application Lifecycle Management with Visual Studio 2010 by Mickey Gousset, Brian Keller, Ajoy Krishnomoorthy and MArtin Woodward fit the bill for what I was looking for and more.

The book is broken into 5 Parts:

  • Architect
    • This was a little basic, and highlighted a few new features in VS 2010 that I once used Visio to accomplish.  But it also clarified for me a few basic UML constructs that I rarely used or may have been using incorrectly.  I’m not sure I’ll use all of the available UML diagrams very frequently, mainly because not everyone on the team will be able to use them or understand them, but I’ll see how it goes.  Ironically, this may be the last section that is truly useful for me.
  • Developer
    • I’m going to make sure all my developers are familiar with the new capabilities of VS2010, and this is a fantastic guide to what is possible.  It make take a little effort to get to add these tools to the dev tool belt, but I think these time savers make the difference between a professional development shop, and a place that is just throwing code over the fence.
  • Tester
    • A great section about brand new functionality in 2010, and an area both testers and devs should be reading.  I’m hoping that I can really alter our expectations of the relationship between dev and QA through the use of these tools, and that by the end of the year, our QA process can be much more thorough than it is now, and not cost any more time than it already does.  It’s definitely been the neglected child of the development process, and my goal for the rest of 2010 is to bring it up to speed.
  • Team Foundation Server
    • A solid primer on TFS and some good guidance on branching and merging.  A must read for dev leads, architects and build engineers
  • Project / Process Management
    • This is the section that really got my attention at first, and the one I would like everyone here to read, even the execs, and especially the solution managers.  Half the battle of good project execution is getting everyone on the same page of terminology and process.  This is definitely worth a read for a shop that is will to make changes, not for the sake of making changes, but to fix issues and bring themselves into compliance with the rest of the development world to eliminate the vocabulary barrier.

I found all the sections useful as a starting point to either make slight improvements to the processes we use, or as a guideline to make wholesale changes to how we are working to improve our output. 

What I really liked about this book was that while I could have figured this stuff out on my own over the next year or so, it gave me a good primer to get started, so hopefully that will result in fewer wrong steps, and let me know about hidden features that I may have never discovered. 

I powered through this book in about a week, and I’m sure I remember less than 50% of it.  But at least I know where to go to look things up, and can begin to plot out direct for the configuration of our TFS servers and our processes.

Tuesday, March 2, 2010

Book Review: Introducing .NET 4.0

I recently finished reading Alex Mackey’s book, “Introducing .NET 4.0 With Visual Studio 2010”.  VS2010 won’t be launched until April 12, 2010, which is still just over a month away, but I’ve been champing at the bit, ready to dive into .NET 4.0 for months now.  Mackey does a great job of whetting my appetite without drowning me in the minutiae of each new or improved feature. 

.NET 4.0 is all about improvements to pieces that have been slowly coming together over the past few years.  There have been a number of out of band releases to the .NET Framework since .NET 3.5 launched.  .NET 4.0 enhances a lot of those releases, and, in some cases, completely goes back to the drawing board.  There are a few new features that will make developers happy, but for me, the money is in the things Microsoft made better. 

Mackey assumes you have a good knowledge of .NET, as this book targets what is new since 3.5.  He includes things which were included in .NET 3.5. SP1, since not everyone may have gotten into that yet.  I was pleasantly surprised at how much of the SP1 functionality we have actually put to use here, and was able to skim those chapters.

There are parts of the book that were finished before the actual functionality of VS2010 or .NET 4 were finalized, but that’s what you’ll get when you buy a book on a product before the product is released. Caveat Emptor.

By the end of the book, I was able to make some decisions on what functionality to target for further research.  My bets are on three areas that will have the biggest payoffs for my team and my customers:

  • MEF (Managed Extensibility Framework)
  • Entity Framework 4.0
  • Windows Workflow 4

With MEF being such an integral part of Office 2010, a good working knowledge of it is essential to provide process enhancements for our customers.

We use Entity Framework 1.0 in just about every project we work on, and the leap to 4.0 should resolve a number of significant issues and code costs that we have encountered in the past year.  I expect to see a large effort reduction in application development costs due to this upgrade.

If the improvements to Windows Workflow are as good as advertised, then I believe WF will go from shunned cousin to an accepted member of the development family.  There’s a lot of power in WF, but the previous implementation was lacking.  I stopped considering the previous releases as viable last year after a few false starts, but I have much higher hopes for it going forward with V4.

I recommended Introducing .NET 4 to my colleagues as a good getting started guide, and directed some to target certain chapters to match up with the type of work they typically do, or areas where they have yet to become involved in to give them a 40,000 foot view. 

I will probably go out and buy other .NET 4 books as they become available, but will focus on the three areas above as they will have the biggest impact to my architecture choices in the coming months. 

Mackey helps to give that guidance, and gets me excited for the new features.  That’s what I want in an introductory level book.

Cross Site Blogging

Today, I’m proud to announce the launch of a revamped Palador.com web site.  Palador is the consulting company that I work for, and as the Senior Application Architect there, I will be doing my part to blog there, as well as here, and my personal blog as well.  That’s a whole lot of blogging, but I actually get paid to blog there, so hey, I’m okay with taking that on.

Occasionally, I will cross post blogs here and there.  Sometimes things will be posted there and not here, depending on the topic. We’ll see how it goes.

We’ll have five or six of us posting entries on a variety of topics, which is cool as it just goes to show how diverse our skill set is here. 

Anyway, take a spin over to the new site and let us know what you think.  I wrote or edited a lot of the copy there, so if you find issues, let me know.