Entries categorized 'Development'

Concise Code - Does it make things hard to read?

Some thoughts scribbled down on Monday 07 July 2008 at 07:50 AM

I was using Resharper 4 and noticed some nice code cleanup advise that it gives. One to note it the compression of: // Create job if quote is won if (CurrentQuote.Status == "A") { quoteView.FindControl("btnCreateJobCard").Visible = true; } else { quoteView.FindControl("btnCreateJobCard").Visible = false; } To the one liner (which I prefer) // Create job if quote is won...

Read more...

Test web pages in different versions of IE with IETester

Some thoughts scribbled down on Sunday 06 July 2008 at 11:22 PM

Designers should love this windows download. Instead submitting your design into a web site that generates images for you in different web browsers, you now have a windows app that allows you do this and interact with the site on your desktop. It's called IETester from the folks at Debug Bar...

Read more...

Visual Studio - Join the dark side

Some thoughts scribbled down on Wednesday 11 June 2008 at 07:31 PM

I've recently joined the dark side and implement a black theme on my Visual Studio IDE. It makes the code nice and easy to read because of the contrast. You can grab my settings file and import it into Visual Studio 2008 by Click the Tools Menu Select Import and Export Settings..." Select Import selected environment settings Backup if you want, then Next Browse for the settings file and Finish...

Read more...

Use TryParse instead of Parse

Some thoughts scribbled down on Friday 30 May 2008 at 07:50 AM

I noticed something in the code of the project I was currently working on. It manifested itself in a crash with exception type FormatException. The problem was caused by the developer using code like this: double percentComplete = Convert.ToDouble(tbProgress.Text); or double percentComplete = double.Parse(tbProgress.Text); The problem with this is that there are potential exceptions lurking if the...

Read more...

Tip - Run batch files from solution explorer with PowerShell

Some thoughts scribbled down on Thursday 08 May 2008 at 03:06 PM

Quick tip for those of you who use a batch file to regenerate your data access layer . You might have noticed that if you try to run (double click) a batch file from the solution explorer window it just opens the batch file in a text editor. To make it actually run you: Right click the batch file Select "Open With..." Click "Add..." In "Program name" put the path of PowerShell ("C:\Windows\System32...

Read more...

LINQ to SQL with WCF - Lazy Loading and Caveats

Some thoughts scribbled down on Wednesday 19 March 2008 at 02:52 PM

Just a quick tip for those of you working with LINQ and WCF. LINQ-to-SQL natively supports lazy loading as long as your entities are still managed by the DataContext. However, when you pass your entities across WCF your entities become detached from the DataContext so you can't lazy load on the client side - which makes perfect sense. The question is how do you then pass a LINQ entity and its child...

Read more...

.NET 3.5 Language Enhancements - Automatic Property Getters and Setters

Some thoughts scribbled down on Wednesday 19 March 2008 at 09:31 AM

Nice little time saver here, to declare a trivial property (just sets and returns a private variable) all you need to do in .NET 3.5 is: public string FirstName { get; set; } This syntax looks exactly like how you would declare an interface or abstract property. Previously you would have to write code like this: private string _firstName; public string FirstName { get { return _firstName; } set { _firstName...

Read more...

The Aggregate method in LINQ

Some thoughts scribbled down on Sunday 16 March 2008 at 10:05 PM

One little known and scarcely document feature of LINQ is its Aggregate method. This function is very useful when you want to do something to the whole collection. Lets say I have the follwoing BlogEntry class public class BlogEntry { public Tags { get; set; } } Now what do I do if I want to build a tag cloud? I can use a dictionary and loop through like so: var entries = GetBlogEntries(); Dictionary<string...

Read more...