typemismatch

just a projection of my own imagination

  • You are here: 
  • Home
  • .NET

Tools are the next programming paradigm …

Posted on November 25th, 2007

“Code Generation” tools to be more specific. Let me clarify that firstly. I’m not talking about tools that just take away programmer’s jobs – I don’t see anything that would suggest that is currently possible. I’m more interested in tools that just do what we keep repeating. If you haven’t discovered code productivity tools yet then you’ve been living under a rock! It’s time to wake up and get busy. You’re too slow these days without some good tools and so I’ve put a few posts together just for the best tools you could start with.

If you browse around the net these days you’ll find tons of “silver bullets” for the programming problems of today. Time is usually the best test of these things and pretty much all fancy styles, methodologies or techniques have failed or fail to some degree. The bottom line is, there isn’t a magic way to develop software, that will at least guarantee good quality or bug less code. So I think the next best thing is – how do we developer faster? and if we do find something that works well, how can I automate that so the next time I use it, a. I don’t have to rewrite it and b. I don’t re-create any bugs.

As a developer if you can build a library of tools, snippets and templates you’ll definately be headed down the road to more successful software. Now not all my suggestions are for code generation – I’ll talk a little about profilers and other such tools you just have to have!

http://www.typemismatch.com/2007/11/25/tools-productivity-tools-generators/

http://www.typemismatch.com/2007/11/24/tools-net-profilers/

If you do have any tool recommendations please leave a comment and I can see about adding a post for them.

-c

Tags: ,
Filed under .NET, Software | No Comments »

Tools: Productivity Tools / Generators

Posted on November 25th, 2007

There are many tools out there for developers and I’ll probably write some more later about some ORM tools I use often and that save a ton of time. This article is about a more generic tool, something that can help you no matter what kind of code you’re writing. These are productivity tools and/or code generators.

A good tool in this area does at least the following:

  • Helps identify code mistakes
  • Supports code block templates
  • Lots of refactoring support
  • A good deal of syntax high lighting, i.e. code blocks, braces, line numbers etc.

Again this isn’t a tool you’re going to find for free. They take a great deal of time and research to develop so be prepared to spend a little. I’d say anything priced from $150-$250 is about average.

Below I have listed two tools both from the same company. The first called “Refactor!Pro” is a great tool however it is included in the more advanced product called “CodeRush” both from DevExpress.

Although Refactor!Pro is only $99 it is well worth the extra $150 to get the full product. This tool is incredible and you’ll discover even in the first day of usage that it can save you a ton of time. The ability to create your own templates which change depending on the code you’re editing is awesome. I picked this over competitive products primarily for 1. Their support and other product lines and 2. Their integration with the keyboard and keyboard shortcuts was just the easiest to use.

Don’t forget, you must learn to use these tools. If you get one and don’t bother to learn the shortcuts or how the templates work then you’re just wasting your money. See some juicy screen shots belows.

As usual you can get a nice long trial, so give it a go!

-c

Tags: ,
Filed under .NET, Software | No Comments »

Tools: .NET Profilers

Posted on November 24th, 2007

This post is part of my series on development tools. There are way to many companies out there that do not offer their developers any tools what-so-ever and it is a real shame. If you’re a lone ranger then you need to get some cash and get these tools.

If you want to write high performance applications there are many things to consider and I’m not going to get into all the design aspects now. What I want to stress is that as human beings we just don’t have the capacity to predict everything our software is going to do when it runs. Using a profiler allows you to see exactly how your code is running and for web applications you can get a great idea where to optimize and also where to add caching.

Unfortunately there are no good free .NET code profilers out there but hey, very seldom is truely useful software just free :) The JetBrains and Red-Gate profilers are your best bet. I found the Ants profiler from Red-Gate to be the easiest to use and understand the output. Although JB’s profiler looks better, I went with more functional. The guys at RG are also easy to negotiate with so go bargin yourself a good price!

Here is the link for the Ants profiler, go give it a whirl. Screen shot below:

ANTS Screenshot

-c

Tags: ,
Filed under .NET, Software | No Comments »

Don’t do this: Exception Handling

Posted on November 23rd, 2007

I work with a lot of .NET developers and hey even some Java ones from time to time ;) We’ve all done some dumb things and we all write bugs but the following is a recurring issue I find and I wish I knew where people were learning this.

try

{

    // do something bad

}

catch (Exception err)

{

    throw(err);

}

If you aren’t going to do anything with an exception then why are you catching it? Make your code user friendly and actually try recover from whatever went wrong, if it’s completely unknown then log it and let the user know (if required) that something bad happened.

As for logging techniques when things do go wrong please don’t just dump it out to a log file. I’m lazy and I don’t need to go trawling around the drive looking and then searching through log files. Here is my recommended sequence to follow when trying to log application errors:

  • For critical failures send an email but as with all logging, make sure you don’t end up in loops!
  • Log next into either the server event logs (application log) or an internal log that the site/application admin can use. Of course this won’t work if you’re experiencing a database problem in which case go back to the event log.
  • As the last resort log to the disk.

Since I write a ton of ecommerce style sites I have one fail-safe for all financial related errors – all the available data gets emailed to me so I can rebuild the required data for the user.

-c

Tags: ,
Filed under .NET | No Comments »

VS 2008 is here!

Posted on November 19th, 2007

I plan to write about some things you need to know about this release but right now just know that it is hitting the MSDN servers. No one is sure yet if the new MVC framework is bundled with this but if it is get ready for some goodies.

-c

Tags:
Filed under .NET | No Comments »

Visual Studio 2005 tricks, where are they?

Posted on November 14th, 2007

I hope you’re still not using Visual Studio 2003, if you are you need to get another job :) I want to talk about the hidden powers of VS 2005. Every now and then we get a good blog posting from someone at MS with tips on how to increase performance or do this or that.

Has anyone ever seen a site or even a single book dedicated to the things we “need” to know about VS but don’t. The only books I can find are general “using vs” kind of books but nothing for the more advanced developer.

Maybe we should put our heads together and write one? I’m giving it some serious thought and might kick off a page on this blog for gathering tips and tricks and then compile that into a PDF for us all to use.

Feel free to post your best tips in the comments.

-c

Tags: ,
Filed under .NET | No Comments »

Simple programming can be hard but it’s worth it.

Posted on November 11th, 2007

I recently launched a new site off some old ideas I had. I decided that I didn’t have the time to engineer yet other typical site with logins, account management, features, features, features etc. I wanted to keep the barriers to usage extremely low – since my site was going to be radically different, why lets users leave because your site wasn’t fast enough. I guess this is more about a simple site rather than simple code – which is a whole other story!

This is a short study on what took to build Mafooku and what appears simple sometimes isn’t. Take a look at the site for reference: Mafooku – Top 10

I started off the usual way, lets get the basics done for any site. So here was the initial list of things I thought my site needed. I’ve broken each section down into the initial “bad” list and then the final “good” list.

  1. We’re posting products so we’re going to need an login to edit products.
  2. If you need a login you need registration.
  3. Now I needed password/account recovering pages.
  4. Product edit/save page.

Woah … look at that list. To post a single product the user must first register, remember yet “another” username and password, understand their account layout and finally try post a product. Many users would have given up already so I narrowed down the list to just

  1. Let the user post a product.

A single page, short sweet with limited fields and just one image. Everything you need to get a seller interested in your products. So that may have seemed easy enough but we have a problem now. How does a user edit or re-post a product or more importantly delete it if it isn’t relevant anymore?

You need some creative thinking for this. A user can remove their product because when it is posted they get an email with an encrypted link to disable the product. Since only they have that email it acts like an account. The same idea applies to editing or in my case – just re-posting with updated details.

So from my initial list, item 3 wasn’t ever needed. Item 4 was really just item 1 simplified for the user so no extra coding here. Item 2 again wasn’t needed. There are now no barriers to usage, the site will be faster and much easier to understand.

I applied the same to the actual product listings. Categories etc just get too big for users to really navigate and search, when done right, can help a lot – is it really simple? I decided for this site, no. If you can’t see what we have within 1 click (no typing!) then it isn’t simple enough. Hence the front page items and a list of the last 100 and nothing else.

The actually programming behind the scenes was a bit more complex with some advanced caching, plenty of security and encryption but still remained a small size code base because I never stuffed the site with un-needed features.

-c

Tags: , ,
Filed under .NET, Software | No Comments »

Quick performance tip for VS 2005

Posted on November 6th, 2007

As I’m sure we all know Visual Studio 2005 as great as it is isn’t the fastest application on the planet. The good news is there are a multitude of things we can change to speed it up. Now firstly let me just state that I’m not a fan of just linking to other people’s blogs or regurgitating their information however I have posted the links to Scott Guthrie’s blog below for reference.

The tip I wanted to add was a really quick and easy performance boost for Laptops. I guess you could also apply this to a desktop using the same logic. As you will see below having the OS on one hard drive and apps on another drive gives a huge performance increase in VS but what if your system is already setup? I had this issue with my laptop. The easy fix is to add a second drive to your laptop and move the OS paging file over to this drive. I also moved the SQL databases to this drive since that is easy enough. I noticed a remarkable improvement in visual studio performance and I didn’t have to go through the headache of moving source code, IIS settings or VSS settings. The paging file is the biggest one by far.

Scott’s Links for VS performance tuning:

Hard drive performance

Tags: , ,
Filed under .NET | No Comments »

ASP.NET Ajax PageMethods

Posted on October 31st, 2007

If you haven’t yet used Page Methods then you’re really missing out. These allow you to create in-page web service methods that can then be called from the client.

This is a quick tip about where these methods can be embedded. It took me awhile to figure out why my newly added methods would not appear in the client javascript. I was using ASCX (user controls) and had the code in the user control code behind file. This will not work and the required javascript won’t ever get generated.

Page Methods must always be defined in the aspx.cs file!

-c

Tags: ,
Filed under .NET | No Comments »

VS 2005 Style Sheet Tip

Posted on October 29th, 2007

Some of you may already know this little asp.net secret but if you don’t enjoy :)

It appears that when an asp.net page renders due to the fact that the header element is actually being generated on the server before it is sent to the client some nifty things happen. I hope you already know that any style sheets placed in a theme folder will get added to the header automatically. This is really great but what if you want a style to be conditional?

Well, normally you’d put the css into another folder so it isn’t automatically added – for example you might use /css/ie_hacks.css or something like that. In the header you’d probably specify the css source as /css/ie_hacks.css but you can take a short cut. You can just use the style sheet name, ie_hacks.css and when the page is rendered the full path will be found.

I use this a lot with conditional IE hacks where I want a path rendered that I do not know during development since many of my site projects run mutiple clients under one site.

-c

Tags: ,
Filed under .NET | No Comments »