August 19, 2008 by
ryan
Tonight I have the privilege to be giving a talk on the ASP.NET MVC Framework at the
Northwest Ohio .NET User Group!
(6PM, at the HCR Manor Care building downtown)! If you interested in
learning about some of the reasons for using the MVC framework along
with creating a basic MVC application you might want to check it out :)
August 18, 2008 by
ryan
Wow, the theme generator that my brother and I made is on Channel 9.
It's in the video at about 11:30. Thanks to Dan and team for mentioning it! View the channel 9 site here.
August 18, 2008 by
ryan
I like to have business cards so I can easily give people my contact information. My amazing wife designed this for me to kind of keep the cards with a programming look and feel.

Let me know what you think!
August 7, 2008 by
ryan
This is a really short post but I wanted to pass the word along. I just finished a fun little ASP.NET MVC Application to generate Visual Studio
themes based off of 3 given colors. I have always felt that selecting
every color to make a coherent theme is way too repetitive. This web
application automatically chooses complements / contrasts based off
your initial color selections (and uses jQuery to let you preview your
theme before creating). I will be making another, more detailed post later that will explain how it all works but for now, check it out and let me know what you think.
View the application
July 25, 2008 by
ryan
This is probably another thing that many people know but it's new to me. In the Modify table window, you can generate a script to show the ALTER TABLE that Management Studio creates.
Make your change (add column / delete column / change a columns data type, etc.)
Click the 'Generate Change Script' button (this option is not at all hidden but was something I didn't take the time to use because I never needed it before).
View the dialog with the change script
Thanks to my friend Ross for pointing this out to me. He really needs to start blogging these tips :)
July 22, 2008 by
ryan
I really wish Visual Studio / SQL Server Management Studio had column editing support similar to text editors like Crimson Edit. I find myself using the column edit alot when running quick, one off SQL Queries or making the same change to multiple lines in VS. I know a lot of this functionality can be replicated with macros but it seems to be a lot faster to just hit column editing mode and type away.
View my demo of Crimson Editor's Column Edit Mode. (Wink seems to slow down and speed up certain parts of the recording -- especially when a dialog window is open.)
July 8, 2008 by
ryan
Justin Etheredge recently tagged me to write up how I got started in software development (you are probably familiar with the meme started by Michael Eaton). Without any further explanation, here goes:
How old were you when you first started programming?
I first started programming when I was 10 or 11 (I don't remember exactly).
How did you get started in programming?
My interest in programming initially began as a general interest in computer games. My dad showed me how to get around in DOS and pulled up some games in QBasic. It wasn't long after that I started messing with the code to see what would happen if I changed things. From there, I tried writing some stuff on my own spending a lot of time in the syntax help.
What was your first language?
BASIC
What was the first real program you wrote?
Depending on the definition, the first real program I wrote was a game that worked in an AOL chat room. When I was 13, one of my friends showed me this thing called a scrambler. The scrambler would let you enter a word, send the scrambled word to the chat and keep score of who got the word right first, etc. I don't know why but I thought it would be an interesting thing to try and replicate. About a month later, I had finished writing one using the VB and the Windows API. It was not very useful but I learned a lot that way I guess.
What languages have you used since you started programming?
C#, VB.NET, Java, JavaScript, Ruby, Perl, PHP, BASIC, C, C++, F# (and others)
What was your first professional programming gig?
When I was in Highschool/College I did some freelance websites/applications mainly for construction and contracting companies. After college my first full-time programming job was working at Franklin University on the development team (websites / web applications).
If you knew then what you know now, would you have started programming?
Absolutely.
If there is one thing you learned along the way that you would tell new developers, what would it be?
Be continuously learning.
What's the most fun you've ever had programming?
I honestly couldn't tell you -- there are a lot of projects that have been really fun. I especially like when there's some new kind of challenge I haven't encountered before.
Who are you calling out?
Matt Braun
Scott Sanzenbacher
Rob Conery
Jurgen Appelo
Danny Douglass
Oren Eini
June 11, 2008 by
ryan
Whether you're creating a project for fun or freelancing (etc.),
working remotely as part of a team is becoming more and more common.
Communication is still key to a successful project, however, it's much
more difficult when your working with people in different locations and
on different schedules. Although, you will not be able to achieve the same
level of communication as face-to-face, there are some tools beyond
E-mail, IMs and Remote Desktop that could make your life a little
easier. Here are some of the tools I use when I'm not in the vicinity of as the team I'm working with.
Source Control
Obviously,
source control is a must-have. This is a given for development
projects; even if you're working by yourself. I use Subversion for all
of my code because it's relatively easy to set up and, for the most part,
pretty intuitive for newer users. When creating a source repository you
need to choose to:
- Host your own
- Go through a third party
- Assembla
-Although there are many options in this arena, this is the host that I
use for remote collaboration so it's the one I'm going to focus on. You
can set up a Subversion repository simply by adding a new project to
your workspace and specifying that you want to use subversion (in the
setup configuration). From there you can add users or make your project
open to the public. Apart from Subversion, there are many other features
that may make Assembla a worthwhile site to check into.
Finally when running Subversion, you're either going to need
an IDE that supports SVN, use the command line or download a client. I
use
Tortoise SVN and the command prompt, however,
Visual SVN for Visual
Studio looks nice (and when I'm using Eclipse, the SubVersion plugin is
wonderful).
Screen capture software
It
can be confusing trying to fix an issue based on a text description.
Having a screenshot or video that explains how to reproduce a bug can
be invaluable. Coupled with a bug tracking application, this can be an
extremely effective way to quickly resolve issues. Camtasia is
probably the ideal application for creating screen casts of a bug but
for the price tag it might be overkill (especially if it's just for fun
/ open source). Currently, I usually use Wink by Debug mode for this
sort of functionality. Although it's definitely not as feature rich as
Camtasia, it gets the job done.
Also see: Jing
Real-Time Collaboration
Some
situations require an extra level of involvement from team members.
Vyew has been an awesome addition to the tool belt. With it, I can
collaborate / share desktop / share files real time with someone else
anywhere in the world in. Similar to the screen capture application, it
really helps to communicate something that otherwise may be difficult to
explain. Earlier in the week, for example, I was having some trouble
with an Eclipse setting for a project I'm working on. Rather than sending e-mails back and forth trying to explain the issue, I used Vyew to
share my desktop with a friend half way across the country. In a
matter of minutes, he was able to diagnosis the problem and I was back in business. Vyew is free if you don't mind having ads on the page. Otherwise, it's $6.95/month for the Plus Package and $13.95/month the Professional version. For more information, vist the Vyew site or check-out Guy Kawasaki's synopsis of Vyew.
What tools do you use to stay connected with your team?
June 5, 2008 by
ryan
This may be common knowledge but it was new to me. If you're ever hand mangling control position in a winforms designer you can setup keybindings for Bring to Front Send to Back options that are normally available on the controls context menu. This is really useful if you have layers of controls and you can't always get to the Context.
- Click on Tools -> Options
- Under Environment, Select the Keyboard menu
- Type "Format.BringtoFront" (or "Format.SendtoBack") in the "Show Commands Containing" box
- Choose your shortcut keys
- Press Assign
Thanks to my friend Ross for pointing this out.
June 3, 2008 by
ryan
Settings
Up until now, we've been using NHibernate Query Generator for all of our data access. Although this is a great way to retrieve our data, there is another option we can play around with -- LINQ for NHibernate. To set this up in our existing application (see Part 1, Part 2, Part 3 and Part 4 on creating the ASP.NET MVC Application) we'll first need to grab the code out of subversion https://rhino-tools.svn.sourceforge.net/svnroot/rhino-tools/experiments/NHibernate.Linq/ and build it using MSBuild or Visual Studio. After that we want to add a reference to it in our application.
Simple Code
Next we'll want to update our controller to use Linq for NHibernate instead of NHQG (Service layer would be better place for this type of code but since this is a demo it'll be okay -- for more on using a service layer to handle all the repository code check out Michael Hanney's post on ActiveRecord, NHibernate and ASP.NET MVC). The initial NHGQ code is:
var p = Repository<Product>.FindOne(Where.Product.Title == ID);
Our LINQ for NHibernate query will look like this:
var p = (from item in UnitOfWork.CurrentSession.Linq<Product>()
where item.Title == ID
select item).First();
It's pretty obvious that the Linq code is a bit longer than the NHQG code. Although that in itself is not a bad thing, it may turn some people away. Momentarily, we'll see some scenarios where Linq for NH is very useful.
Paging and Sorting
One nice thing we can easily do with Linq for NHibernate is page and sort our data. If we simply want to get a list of all products it would look like this.
var p = (from item in UnitOfWork.CurrentSession.Linq<Product>()
select item
).ToList()
To page/sort the data it's just a slight addition to the list all code.
int itemsPerPage = 5;
int startIndex = (ID.Value - 1)* itemsPerPage;
var p = (from item in UnitOfWork.CurrentSession.Linq<Product>()
orderby item.Title ascending
select item
).Skip(startIndex).Take(itemsPerPage).ToList();
More Advanced Usage
Kyle Baley's article on Linq for Nhibernate shows a more interesting use for Linq for NHibernate; we can create a generic method that adds query criteria on the fly. This would make our code much more reusable so we're going to go ahead and make a demo class heavily based on these concepts.
public class QueryHandler<T>
{
private IList<linqExpression.Expression<Func<T, bool>>> _criteria;
public QueryHandler()
{
_criteria = new List<linqExpression.Expression<Func<T, bool>>>();
}
public void AddCriteria(linqExpression.Expression<Func<T, bool>> LambdaFunc)
{
_criteria.Add(LambdaFunc);
}
public IList<T> GetList()
{
var query = from item in UnitOfWork.CurrentSession.Linq<T>()
select item;
//Tack on our query Criteria
foreach (var criterion in _criteria)
{
query = query.Where<T>(criterion);
}
return query.ToList();
}
}
Here, we've created a class that has a private list of criteria, a method to add criteria to the list and a method to get the list based on the given criteria. I realize it may be a little intimidating but we can perfom most of our select queries through this method due to the use of Generics.
Updating the controllers to use this functionality is not too difficult. For pages that simply retrieve lists we call the GetList method without specifying any criteria:
var queryHandler = new QueryHandler<Product>();
var p = queryHandler.GetList().Skip(startIndex).Take(itemsPerPage).ToList();
Pass in new lambda expressions to add query criteria
var queryHandler = new QueryHandler<Product>();
queryHandler.AddCriteria(item => item.Title == ID);
var p = queryHandler.GetList().First();
Now we see there are multiple options for interacting with our ActiveRecord Repository. Please let me know of any changes that you would make. I've updated the demo code in Assembla -- http://svn2.assembla.com/svn/NHibernateTest - Standard disclaimer does apply (some of the code is less than ideal but for learning it should be okay).