Code Highlighters For Your Blog

31. October 2008

I recently tweeted that I thought the SyntaxHighlighter is the best way to display code on your blog. In response, I had some who were a little confused how to get started with the tool. The tool isn't as straight forward as some other tools. There are several steps you will need to take in order for it to work on your blog.

Since my tweet, I have reconsidered my initial recommendation for new users. The look and features of SyntaxHighlighter are nice, but it does take some setup on your blog, some manual manipulation of your code, and presents a slight delay during render time (since it is dynamically manipulated via JavaScript).

I plan to start using SyntaxHighligher from now on and I would recommend it for bloggers that post a lot of code, but if you an occasional code poster, then one of the following Windows Live Writer plug-ins might be a better solution for you (they are much simpler and faster to render and takes no setup on your blog). All that said, you might even like the plug-ins better than SyntaxHighlighter... and hey, that's fine by me :)

The Windows Live Writer plug-ins that I recommend are...

[More]


How to use SyntaxHighlighter

31. October 2008
I recently tweeted that I thought the SyntaxHighlighter is the best way to display code on your website. In response, I had some who were a little confused how to get started with the tool.

The intent of this blog entry is to show you, step by step, how to integration SyntaxHighlighter into your website.
  1. Download SyntaxHighlighter
  2. Unzip the contents with your favorite unzipping tool (personally I used 7-Zip Portable)
  3. ... some code here ...
    Language Aliases
    C++ cpp, c, c++
    C# c#, c-sharp, csharp
    CSS css
    Delphi delphi, pascal
    Java java
    Java Script js, jscript, javascript
    PHP php
    Python py, python
    Ruby rb, ruby, rails, ror
    Sql sql
    VB vb, vb.net
    XML/HTML xml, html, xhtml, xslt



1. The solution above is found here: http://yehhou.blogspot.com/2007/06/blogger-dpsyntaxhighlighter.html. That blog was written in Chinese. I made some minor changes and posted here. The reason for the Javascript code to remove
tags is because BLOGGER has a setting to automatically add
where there is line break. It is very convenient feature for blog posters, but somehow syntax highlighter will display the
tag in plain text;
2. Clipboard for the SyntaxHighlither does not work well here. It tends to give you the text without line breaks, so I commented out the Javascript that setup the clipboard function;
3. When posting HTML code, remember to replace < with <, and replace > with >;
1. Download and find a place to host the library files for SyntaxHighlighter. A free choice is, of course, Google Page Creator;
2. Login to BLOGGER, go to: "Settings > Template > Edit HTML", make the following changes (credit goes to yehyeh's blog):
http://yehhou.blogspot.com/2007/06/blogger-dpsyntaxhighlighter.html [More]

Tools


An NDepth Look @ NDepend

31. October 2008
Synpopsis - I've been wanting to review NDepend for quite some time, but I figured it was bad form to run it against my production code from work. So, instead of running the tool against my work code, I thought I'd use the PetShop ASP.NET MVC project that I created for the .NET User's Group.

NDepend provides many ways to visualize the architecture of any particular project.  To create the following pictures and diagrams all I did was point NDepend to my Visual Studio solution file.

Dependency Graph

A useful way to get an understanding of how your application architecture is to generate a Dependency Graph based off your code. The following graph shows show the PetShop pieces relate to one another.

 

Dependency Matrix

For those of you who are graphically challenged, there is a Dependency Matrix that does a nice job of showing how many dependencies there are between 2 particular areas of your design.

  

Code Metrics

The next diagram has always impressed me. Even if you didn't know what it meant... it is pretty impressive to just look at :) The following diagram is actually showing the Code Metrics for your project. The following image represents the number of lines of code (LOC) in your project.  


CQL Queries

In addition to all these cool graphs, matrices, and images, there are some hard core queries that you can perform against your assemblies. NDepend has something called Code Query Language (CQL) that allows you to write custom queries to identify numerous statistics such as:
  • Which public methods have more than 30 lines of code?
  • Which classes implement System.IDisposable?
  • Which methods have been refactored recently and is not thoroughly covered by tests?
  • etc...

 

The following is an example of what a CQL query looks like. This query identifies the methods that are too big in your assembly. NDepend comes with a library of already created queries, such as this one, but you are able to add to or customize these quieres as well. 


Conclusion

There is so many more features that I haven't covered that NDepend provides, but I wanted to highlight some of the features that I thought are very useful and could help you in your current projects.

I think this tools adds some great functionality that dovetails nicely with the features of from the various Visual Studio suites.

Don't just take my word for it, I encourage you to download a trial version of NDepend and check it out for yourself.

Then if you like it, make a list of the features that are useful for your project, show it to your boss, and see if your work will pay for it :)
[More]

Tools


Nashville .NET User's Group Presentation

10. October 2008

Yesterday I gave my first User's Group (UG) presentation at the Nashville .NET UG entitled... "A Crash Course in ASP.NET MVC".

In the presentation I gave an overview of what MVC is, explained some pros & cons of using it, answered some common questions, presented a demo application that I developed (Pet Shop 5), and then I dived into the demo's code.

You can download the content that I presented at the User's Group below... *Note: There is some additional slides at the end of the slide show that you might find interesting.

You also might want to check out a blog post I created a month or so ago intended for ASP.NET Web Form developers to quickly get up to speed on the concepts of ASP.NET MVC. A lot of the material is about pre-Preview 5 releases of ASP.NET MVC, but I still think it would be beneficial for most developers. If you so choose, you can directly link to the document hosted on Google Documents.

You might be interested in keeping up with me via:

Emailelijah.manor@gmail.com
Twitterhttp://twitter.com/elijahmanor
.NET Tech bloghttp://webdevdotnet.blogspot.com
Stack Overflowhttp://stackoverflow.com/.../elijah-manor
Tech Riddle bloghttp://manorisms.blogspot.com
Personal bloghttp://elijahmanor.blogpot.com

Thanks for everyone who came... there was an awesome crowd!

[More]

.NET User's Group, ASP.NET MVC ,