8 Tips To Be A More Efficient Asp Net Developer
8 Tips To Be A More Efficient Asp Net Developer
Page 1 of 6
Introduction
This is really just a list of things (in no particular order) that I regard as good or useful practices,
all of which in some way contribute to your efficiency. Efficiency is a pointy- haired boss' word that
they like to throw around whenever they feel more is required from you. Here, anyway, in no
particular order, are some things then I regard as being conducive to personal efficiency,
particularly for developers, and even more so for .NET. If you find something on the list that you
don't do, then think about doing it. A lot of them are intertwined, and really, the whole drive is
self- learning and self- improvement. On the technical side the move is from engineering (building
everything from scratch everytime) to production (attached together pre- engineered pieces). This
is really the way things are moving from the developers perspective, and more functionality has
to be built in less time. For that to happen, we need to be smarter developers doing less actual
coding and more re- using of existing code. You need to leverage as much as you can. All these
things do tend to tesselate into each other, reinforcing each other, which is a good thing. I could
make some funky flow diagram to illustrate, but I will restrain myself, I think you get the idea.
Also, research time becomes self- supporting, as the savings made further free time to do more
research. If you are doing it right, you should be spending a significant proportion of your time
doing research.
Background
1. Application Blocks
These are the free, open- source collections of best- practice code written to cover specific areas.
There are ones to cover Enterprise applications, Data Access, Application Updates, etc. The list
goes on, and it is possible to write your own. I spent a lot of time building my own Data Access
class to speed things along, then took a look at the Data Accessor block to find it amazingly
similar. I now kind of wish I had invested that time in learning how to use the existing Data
Application block, then I would have been able to take that knowledge with me anywhere. As it
stands, I can't take the proprietary code with me, so I must settle for finally getting round to do
http://www.codeproject.com/aspnet/8thingsefficient.asp?print=true 6/28/2007
Eight tips to make you more efficient as an ASP.NET developer - The Code Project - AS... Page 2 of 6
what I should have done in the first place. So my advice is learn how to use them, and leverage
what is out there, and the long term benefits will be yours. I recently watched a webcast on using
the updater block, and it is really cool if you are writing Windows apps (really blurring the lines
between the web and Windows worlds). Check out the links in the reference section. There is a
webcast on creating your own too (another reason to get into the webcasts).
2. MSDN Webcasts
Educate yourself for free! In my opinion, these are an absolutely brilliant resource. Go and have a
look, great for learning about a new area, free online seminars for learning whenever suits you. I
try and watch a couple a week. It's got me really excited about Whidbey. MS also has free
assessments for ASP.NET, to help you on the road to certification.
You are not alone. There is a huge community of developers out there, producing great tools to
help. I am a huge fan of codesmith and it has made generating Web Forms and Business objects
a breeze. A good rule of thumb is anything that changes only depending on the database can be
automated with codesmith. I made a whole bunch of templates and they've paid the company
back 100 times over in time savings. This is the bridge you can use to go from coding solutions
from scratch, to generating solutions against databases automatically. Try it. There will be no
going back. This is a big step forward from engineering to production.
There are other great tools too, I use mainly Nunit, The Regulator and NDoc. For a full list, see
the reference list at the end.
Full list : Ten Must- Have Tools Every Developer Should Download Now
Code Smith website
4. Custom Errors
If it breaks, don't show a server error. Please. CodeProject itself has a good page for when
something breaks.
Placing the settings below in the web.config will specify a page to redirect to if an unhandled
exception occurs. The remoteonly setting means you will only be redirected if you are not
running on the local server (i.e. debuggers will see the real error). This is the minimum you
should do if you do not want your users to see server errors when something breaks (which may
or may not be the fault of your application - so expect things to break!). You can also specify
pages to use for each HTTP error status code, and I put some example there too. By the way, in
the code below I took out all the angle brackets, otherwise it gets interpreted as invalid html.
http://www.codeproject.com/aspnet/8thingsefficient.asp?print=true 6/28/2007
Eight tips to make you more efficient as an ASP.NET developer - The Code Project - AS... Page 3 of 6
Additionally, it is important to be notified when errors occur, and have a log to refer to when
debugging difficult problems. My applications send me an email when an error occurs, and I can
diagnose in seconds, then contact the person who saw the error whilst they are wondering what
went wrong, then explain what happens. Now that is good customer service. Often it is "Request
detected a dangerous value" when they type HTML into text boxes where they shouldn't. The
code below goes in global.asax, and logs the error to the event log, and fires off an email when
an unhandled application error occurs. Here I use the standard "Application" event log, but you
can create your own, it just means you have to create a new category on the server. Whilst it is
possible to code that, your code should not have sufficient permissions to make such a change. It
is a straightforward implementation of the concept, which works. There is an Application Block for
logging as well if you need some heavy duty logging.
Collapse
Function WriteError()
Dim HeaderInfo As String = "MyApp ERROR, "
Dim Message As String = HeaderInfo
Try
Try
Dim ex As Exception = Server.GetLastError().GetBaseException()
Message = Message & "MESSAGE: " & ex.Message &
ControlChars.Lf & "SOURCE: " & ex.Source & ControlChars.Lf
& "FORM: " & Request.Form.ToString() & ControlChars.Lf
& "QUERYSTRING: " & Request.QueryString.ToString() &
ControlChars.Lf & "TARGETSITE: " & ex.TargetSite.ToString &
ControlChars.Lf & "STACKTRACE: " & ex.StackTrace &
ControlChars.Lf & EventLogEntryType.Error
Message = Message & ControlChars.Lf & "Server : " & _
Request.ServerVariables("SERVER_NAME")
' Insert into event log
WriteToErrorLog(Message)
Catch
End Try
Finally
WriteError = Message
End Try
End Function
If anEventLog.SourceExists("Application") Then
anEventLog.WriteEntry(Message, _
System.Diagnostics.EventLogEntryType.Error)
End If
Catch ex As Exception
End Try
End Sub
http://www.codeproject.com/aspnet/8thingsefficient.asp?print=true 6/28/2007
Eight tips to make you more efficient as an ASP.NET developer - The Code Project - AS... Page 4 of 6
ConfigurationSettings.AppSettings("ErrorReceiverEmailName").ToString
aMM.Subject = "Error in MyApp at " & Now.ToString
aMM.From = _
ConfigurationSettings.AppSettings("ApplicationEmailName").ToString
SmtpMail.SmtpServer = _
ConfigurationSettings.AppSettings("MailServerName").ToString
Try
SmtpMail.Send(aMM)
Catch ex As Exception
' Couldnt send a email - things are going from bad to worse.
'At least the log entry will be there
End Try
End Sub
If anEventLog.SourceExists("Application") Then
anEventLog.WriteEntry(Message, _
System.Diagnostics.EventLogEntryType.Information)
End If
End Sub
RSS readers are great. It is a quick way of browsing lots of sites very quickly and finding out if
anything useful has been posted. Get an RSS Reader, set up MSDN and CodeProject for a start.
Make it part of your daily routine. Also, there is a Webcast on building your own (this is one of
those cross- reference synergistic things).
An RSS Reader
6. Use Skype
Talk to your clients and other developers, as often as you like, for free! You can have conference
too, which is good for brainstorming lots with other developers, or having meetings. I don't get
any commission for this, but I am an avid user. I have saved a fortune on the company's and my
own phone bill. You will need broadband, but it will probably more than pay for the broadband
connection itself. This also really opens up the option of working from home as you can have
conference meetings and brainstorming sessions through the day.
Skype
7. Automate deployment
I use batch files for deployment, to strip code out, have an update package for clients, and have
a log of changes. The batch file below copies everything from your designated directory to
another location, with a date and time stamp. It also removes any unnecessary files. A complete
setup project is great first time, but when you maintain your own web applications and are
updating frequently without overwriting settings, becomes a headache. The approach below
works very well for me. Include it with the source for your project so that it becomes part of
source control. This is because, every time you use it, you should set the date to today, so next
time you run it, it picks up the correct files.
Collapse
http://www.codeproject.com/aspnet/8thingsefficient.asp?print=true 6/28/2007
Eight tips to make you more efficient as an ASP.NET developer - The Code Project - AS... Page 5 of 6
set time1=%TIME:~0,2%
set time2=%TIME:~3,2%
set DatePart=%newdate2%-%newdate1%-%newdate3%at%time1%%time2%Hr
SET deploypath=D:\deployments\MyApp\%DatePart%
@echo lets clean the deployment path - ONLY FOR LOCAL DEPLOYMENTS
rem del %deploypath%\*.* /s /q /f
SET sourcepath=C:\Inetpub\wwwroot\MyApp
del %deploypath%\batch /s /q /f
del %deploypath%\class /s /q /f
del %deploypath%\*.vb /s /q /f
del %deploypath%\*.aspx.resx /s /q /f
del %deploypath%\*.aspx.vb /s /q /f
del %deploypath%\*.scc /s /q /f
del %deploypath%\*.vbproj /s /q /f
del %deploypath%\*.vbproj.vspscc /s /q /f
del %deploypath%\*.ascx.resx /s /q /f
del %deploypath%\*.sln /s /q /f
del %deploypath%\*.vspcc /s /q /f
del %deploypath%\*.vssscc /s /q /f
del %deploypath%\styles.css /s /q /f
del %deploypath%\*.vsdisco /s /q /f
del %deploypath%\*.resx /s /q /f
del %deploypath%\*.pdb /s /q /f
del %deploypath%\*.webinfo /s /q /f
8. Use WebControls
Lots of great free web controls are out there. Use them! I don't want to get into web control
development, but here are some more useful online resources to leverage.
http://www.codeproject.com/aspnet/8thingsefficient.asp?print=true 6/28/2007
Eight tips to make you more efficient as an ASP.NET developer - The Code Project - AS... Page 6 of 6
Need a better calendar control than the standard ASP.NET control? Try eworld.
Need a text editor? Use freetextbox.
Need a spell checker? Go no further than NetSpell.
Many many more resources out there, these are just ones that I've come across recently. Really
just wanted to emphasize the point that, it is good to check whether some already in existence
can be leveraged before you start coding.
References
History
Spent my whole life developing, having worked in C++, Delphi, ASP, then finally settling
down to working solely in ASP.Net. Also a forex day trader.
http://www.codeproject.com/aspnet/8thingsefficient.asp?print=true 6/28/2007