Tuesday, August 9, 2011

Filtered Search Sample (part 1 - clientside)

I think we did a pretty nice implementation of site search on a recent project. It made effective use of jQuery, AJAX calls and a flexible service and data layer.

Search1

Filtering allows the user to quickly widdle down the number of assets on a site to a more manageable result set. The Filter/Search area can be shown or hidden by the user and allows the user to quickly view documents and assets that are located on the site that fit the user's criteria. The area is available throughout the site and persists state so the user can quickly view their last result

Search2

Above is the view of the filter search when adding criteria and clicking "View Results"

Search Form

The html is presenting a set of checkboxes grouped by their parent category. The values of each tag is the corresponding GUID that exists in the data layer. The parent category check-box simply checks or unchecks it's children when selected or unselected.

Screen1

View Results Click

Our Javascript will leverage jQuery and iterate through the checkboxes and use the keyword value to build a url to call through Ajax and and get a JSON result set to populate the result div.

Screen2

AJAX Call / Response

Using Firebug we see what we are getting back from the Ajax call. You can see that we passed in 1 tag for the 2nd category and 1 tag for the 3rd category, the user did not enter in a keyword (searchString) and the results we want per page is 8. The results we get back will be a JSON collection. For performance reasons we have paging occur on the serverside so although there are 35 items that match our criteria we only get back 8 (based off of the perPage parameter). Each JSON object contains what we need to show the results - the link, the icon, the name and the snippet (if exists).

Screen3

Display the results

Screen4

 

Our jQuery.getJSON function will iterate through the result set and create a div resultBlock for each item. One little tricky thing you will see above is that our results are actually split across 2 columns so we have a check to see if the current item in the for loop is equal to the perPage / 2 and creating a new column if that is the case.

Next Up

So we just went over the clientside of the fence for calling and displaying the results, tomorrow I will go over how this was handled on the serverside using C# and Sitecore as our datalayer.

Saturday, August 6, 2011

My Marriage can drive today

License
16 years ago today, Pamela and I got picked up outside the Hard Rock Hotel in Las Vegas around 10 o'clock in the morning. The limo was compliments of the Silver Bell Wedding Chapel although our driver felt the urge to remind us quite often that he only works off of gratuity. We picked the chapel out of the phone book because it said it had a nice bridge and river which was a perfect setting for pictures. Although we weren't taking any pictures it sounded like a nice spot. After we went to get our registration we arrived at the Chapel. The river and bridge was akin to something you would see at a put-put golf course with a small water hazard. The cheesiness was great and we got back to the hotel by 11:30 that morning.

Vegas is probably not for everybody, but there sure was something special about that day. We were just two young kids figuring out what all this 'growing-up' and 'parenting' stuff was, but during the cheesy little ceremony it was like we were officially saying: no matter what, we will figure this 'life' thing out together. 16 years later and I wouldn't have changed a thing.

Friday, August 5, 2011

Mouse?!... We Don't Need No Stinkin' Mouse!

Back when I was put on my first Agile (with a capital A) project at VW Credit we did paired programming. We had 3 pairing sessions a day except for the days we had our IPM, Showcase and Retrospective. I was one of the stronger developers on the team and thought our code quality would be up a bit and our knowledge sharing (or Bus Count) would be up as well but I really didn't think I would learn a heck of a lot from pairing with some of the less experienced developers. I was proven wrong the first pairing session I had with Steve.

Although I knew more about the code and the API and development in general, I started to realize when Steve was driving that when I explained what we wanted to do with a piece of code how fast Steve was at coding. It wasn't just the typing, for I could type as fast as him, it was beyond that. It was the way that he would open his tool windows and the way he jumped around the code. He would also make crazy use of shortcut keys and used temporary macros like they were going out of style.

It got to the point where I was actually the one feeling a little self-conscious when I was coding; when you would think it would be the other way around. I would start coding something and in my head I would think, "Steve must be thinking I am coding this so slow" and this would cause me to go even slower. I finally realized that Steve was very rarely using his mouse. I brought it up to him and he said that he used to use the mouse quite a bit but he had a co-worker that swore by using the keyboard as much as possible to speed up productivity. Steve said it was quite difficult at first and it was probably a good two weeks of forcing himself to be less dependent on the mouse and then it just became second nature.

Our entire development team ended up embracing Steve's Anti-Mouse mantra. In fact we ended up installing an application on all our workstations that would keep track of how many yards our mouse moved for the day and would announce at our Daily Stand-up when someone broke the Shortest Distance Record.

So try it out for 2 weeks and see what you think. I would start with:

  • Getting to know the shortcut keys to the 2 or 3 applications you use most
    • Outlook
    • Word
    • Visual Studio - you can also create your own shortcut keys to be more efficient. If you are doing something over and over again, think about recording a macro and assigning it to a key combination. For example if you are in my environment and you hit CTRL-SHIFT-W the current word where the cursor is would get highlighted and copied to the clip board. The Watch window would then take focus and the word would get pasted into the Watch window.
  • Mouse Tracker - for those that want to make a game out of it or to visually see how well they are improving
  • AutoHotKey - If there isn't a shortcut key, then make your own. AHK is a great scripting language that allows you to easily assign text and/or mouse activity to a hot key or key combination. Back before Windows 7 came out I actually used AHK to easily "snap" my windows to the right or left side of my monitor. I will do another post just on AutoHotKey with some of the ways I use this application.

Thursday, August 4, 2011

Ektron Content Types and AutoMapper

If you are working with Ektron you are probably already aware of Ektron SmartForms and the ability to turn them into strongly typed Content Types. If you are not familiar and want to get up to speed I recommend taking a gander at Bill Cava's webinar on the subject located here. This is a great step in making it a bit easier to do some CRUD operations on SmartForm content but depending on what your SmartForm looks like, you might get a weird looking Content Type class when just relying on the class creation from using the xsd.exe tool.

Taking the transformation a step farther and turning the Content Type class into a true Domain Object can make your code a bit cleaner and further separate your business layer from your data layer which is always nice. Jimmy Bogard has a nice AutoMapper project located over at CodePlex that you can leverage to move between your domain objects and your SmartForm content types.
Automapper does a nice job of figuring out which field should be mapped to which field and it has the flexibility for you to take control of the mapping at a field or type level. If you have a Rich Text field in your SmartForm you will probably want to do something similar to the sample code below which introduces a custom resolver that makes it easier to map from a string field on the domain object to the corresponding rich text field on the SmartForm.

Automapper

Wednesday, August 3, 2011

Defending against "Summer Vacation Brain Mush"

Summer Vacation is great for the kids but after a couple of weeks their brain really starts to turn to mush from not thinking as much as they do when school is in session. My daughter has always been a book worm so during the summer she would zip through her summer reading list and then continue on to her Twilight type books. My son Jake on the other hand, who is 13, does not enjoy reading and is more of a math and science guy. I got him to read a little bit by getting him into the math and statistics behind poker and getting him some Poker books but that only lasted a little while before his days were once again filled up with too much XBox and WoW.

Another attempt to engage Jake's brain this summer was to start teaching him some web development. I was going to go down the Microsoft route and maybe I will at some point but I decided to do Ruby on Rails instead. If I teach him with Microsoft centric technologies it will be more of a Master/Student dynamic. If we go with Ruby on Rails, a technology I am only vaguely familiar with, it will be more of a Student/Student dynamic.

Think back growing up, did you have more fun playing just playing a game of catch with your dad or your dad going over the proper technique to throw a curve ball? I think teaching Jake how to build an MVC3 web application will be a lot like me being the Coach instead of a fellow Student which should be more enjoyable.

rails for zombies

To make things even more enjoyable, I found a really great learning resource from Code School, called Rails for Zombies. For those that are familiar with the Head First development books you would like this course a lot. There is just a nice balance between learning, doing and entertainment.

 

Tuesday, August 2, 2011

Run Forrest!!!

It is no secret, I really hate running. It is merely convenient. I would much rather play a game of basketball or better yet a game of lacrosse with some friends but doing so would require a lot of coordination with other people’s schedule and getting a court or field available. Not to mention you would then have to drive to the location. With running, I am only dependent on me, I choose the day and time and then it is just the matter of opening up the front door and making my legs alternate steps in a faster than a walk pattern. It is this convenience that actually makes running even less enjoyable. Only having to worry about your schedule and running by yourself is one of the reasons running is such a bore. The motivation isn’t there. If your body tells you that today is just too hectic and “tomorrow” fits into your schedule better, you will usually listen because you are only competing with yourself.

When you are playing a team sport or even an individual sport against an opponent such as tennis, you usually tune out your whiny body about how tired it is until after the play is over and then you tell it to be quiet because another play is starting. With running, it is just you and your body and your body is really loud and persistent about how much better it would be to cut this run in half and go home and watch SportsCenter.

Enter Nike+
Nike Plus

Nike+ allows you to turn running into more of a team and social activity while still maintaining the convenience. It has some cool things in terms of setting goals and tracking your runs but the nice thing that adds a bit more motivation are the Challenges. You can join hundreds of public challenges or you can create your own and try to build up some friendly competition and interaction with some friends and co-workers. Being in a fairly large company with multiple offices can make it difficult to connect with co-workers, especially if they work in a different state or country.

I setup a few challenges on Nike+ and invited my co-workers to run with me. I had a novice entry for those new to running or just wanted to get out there and walk for a bit a few times a week. I created a little more of a competitive challenge that has participants race to 75 miles within a month and then to foster some inter-office pride, I created the iCrossing Office Challenge. The Office Challenge had members represent their office in which every run contributes to the office they belong to and the office with the most miles at the end of every month wins.

Nike Plus Challenge

There is a nice Twitter like feed that shows the latest runs and by whom as well as a spot to do some Trash Talk or some friendly words of encouragement. I still hate running and my body still tries to make excuses to prevent me from running or to end my run early, but having Nike+ and the social aspect of the challenges allows me to yell back at my body “we need to de-thrown the Dallas Office once and for all”.

So get out there and try it. It works with a number of devices and if you have no friends you can always request me and I will run with you. My Nike+ ID is TeckChavez.

Monday, August 1, 2011

LaxCraft CodeProject Article

I posted an article at CodeProject that goes into a little more detail about the code and technologies used with LaxCraft. You can find the article here: http://www.codeproject.com/KB/aspnet/laxcraft_sample.aspx and as a reminder you can download the entire code at http://laxcraft.codeplex.com/