Wednesday, 26 October 2011

Some things I didn't know about Notepad++

Notepad++ has been my text editor of choice for a number of years now. It's got a lot more features now than when I first started using it. I've not really kept track of the additions so I thought it was about time had a good look to see what's available that I've missed. A quick Google search found a lot of useful tips. I stole a few tips from various blogs which I've linked to at the bottom of this post. 

Regular expression search and replace with groups

Okay, this isn't new to me, but it's definitely worth mentioning. Search and replace using regular expressions is extremely useful, even more so when using groups. Different regular expression engines use different syntax for groups, in Notepad++ it's slash and a number.

Here's a stupid example. Say I wanted to add a full stop at the end of each line:

Find what: ^(.*)$
Replace with: \1.

TextFX and Plugins menus

There's all kinds of wonder hidden in these menus. A few of my favourites are:
  • Plugins -> Compare (Alt + D) - Compares two files
  • TextFX Convert -> HTML Encode
  • TextFX Characters -> Proper Case - E.g. "cloud moon goat" becomes "Cloud Moon Goat". Also has upper and lower case options (which are more easily available if you right click in a document)
  • TextFX Tools -> Delete line number or first word
  • TextFX Settings -> Auto close XML/HTML tags

Custom file extensions

Notepad++ provides highlighting for many different types of file, but misses common file types that I use such as .build and .config. Turns out it's very easy to map custom file extensions. Select Settings -> Style Configurator, then choose the required language and add a space separated list of extensions in the "User ext" box.

Box selection

I was surprised to find out this is exactly the same as Visual Studio. Hold Alt, click and drag to select a column. 

Macros

Macros are something I've never bothered to look into. I assumed they just recorded basic text manipulation (typing, copy, paste, etc.), but turns out they can record more than that. For example you can save search and replace actions which is great for saving any common search and replace operations with complex regular expressions.

Misc

Here's a few other bits and pieces that I thought were worth mentioning:
  • Edit -> Clipboard history
  • View -> Fold and Unfold all
  • Run -> Open containing folder
  • Run -> Launch in browser

 

Tuesday, 11 October 2011

Teesside basketball league


What?


The Teesside basketball league (TBL) site stores all the information vital to the smooth running of the Teesside basketball league. It records team information (including match day, tip off time, venue and contact details), league standings, news, fixtures, match results, team statistics, player statistics and generally makes the world a better place.

Why?

I originally created the TBL site in 2009 because I wanted to learn some new skills and apply those skills to a real life project. Primarily I was interested in getting more experience of .NET MVC and unit testing, neither of which I was using at work.

How?

The first version of the site was created in 2009. I was unfortunately forced to use ASP.NET MVC 1, which wasn't the best framework around, but it was considerably better than .NET forms. At some point I stumbled across a something called Sharp Architecture. It is described as a "solid architectural foundation for rapidly building maintainable web applications leveraging the ASP.NET MVC framework with NHibernate". In short it provided me with functionality that, if I had to write myself, would have increased the length of the project by about ten times. Some of the functionality provided included ORM setup, visual studio project templates, easy controller based transaction support and an automatically created in memory database for unit testing queries. In additions it detailed a test driven way of working which was extremely helpful.  

The first version of the site was a lot of hard work, but a very rewarding experience. I got want I wanted, I learned a considerable amount about ASP.NET MVC, SQL Server, jQuery, NUnit and RhinoMocks. Even better I still had a girlfriend (now the wife) at the end of it, which considering the number of evenings I spent with my head buried in my laptop, was a very good thing.

For some reason in 2011 I decided that I was no longer satisfied with MVC 1. I wanted all the new and whizzy features offered by MVC 3. It turned out that Sharp Architecture was a pain in the ass to upgrade to MVC 3 so I'd decided I'd had enough of it. Fortunately I wanted to have a go at implementing some of the features provided by Sharp Architecture so it wasn't a big problem.

The technologies I used in the rewrite included ASP.NET MVC 3, Razor, jQuery, Entity Framework, NUnit, NSubstitute, Ninject, T4 and Chirpy.

In hindsight I would have dropped the Entity Framework and NSubstitute. I now believe the Entity Framework was overkill for this project and something simpler would have sufficed. Unfortunately NSubstitute is missing quite a few features offered by other mocking frameworks so something like Moq or RhinoMocks would have better.


Update - April 2015

Sadly the Teesside basketball league is no more so I've shut down the website. Here are a few pictures of the desktop site, mobile site and app.