Are extension methods and "var" considered bad? And, can I use Moq?

Topics: Developer Thread
Developer
Aug 30, 2008 at 7:11 PM
Edited Aug 30, 2008 at 7:12 PM
Updated due to some weird text munging.

Hi All,

Is there any recent thread, or note anywhere about development guidelines for dasBlog?  Specifically, I am working on another patch and find myself using var (where the type is obvious) and (an) extension method (still targeting 2.0 but using this technique http://www.danielmoth.com/Blog/2007/05/using-extension-methods-in-fx-20.html).

Also, I was going to use Moq in a new test project for the newtelligence.DasBlog.Web.Services project.  Moq needs .NET 3.5 so the test project would need to target that.  Obviously, I could use a mocking framework that targets 2.0- but I thought I would ask the question first.  I guess I am asking, are we staying on 2.0 or can we start using 3.5 bits?  If we are still targeting 2.0 for production, can we use 3.5 bits in the unit test projects?  Are all the dasBlog devs on VS 2008?

FYI - I am using the extension method to replace the method noNull in BloggerAPI.cs.  I wanted to avoid adding another method to SiteUtilities (the horror).  Actually, the extension method I wrote (NotNulll) looks funky to me, but it is legit.  An example test usage is:

        [Fact]
        public void NotNull_CalledOnNullString_ReturnsEmptyString()
        {
            string x = null;
            string y = x.NotNull(); //looks funky and the carried over name is bad
            Assert.True(y == "");
        }

Does anyone object to this?  Would you prefer the following everywhere instead (I think I might)?

string y = x ?? "";

Or stick SiteUtilities XYZUtils (please no)?

Ben



Developer
Sep 2, 2008 at 9:21 PM
Hi All,

<gentle prod>Please can someone tell me if submitted patches should be backwards compatible with VS 2005?  (i.e. no "var", no extension methods etc).  I know they should be 2.0 compatible.  I just want to know if it is OK to assume that all dasBlog devs are now on VS 2008?</gentle prod>

I have some time right now, to enhance the dasBlog Live Writer support and submit a few other new features and fixes.

Ben
Coordinator
Sep 3, 2008 at 8:41 AM
I think we should stay with 2005 right now, atleast untill the 2.1 final is released... I believe there are no outstanding bugs, so as far as I'm concerned it could be released soon.
Developer
Sep 3, 2008 at 9:58 AM
Hi Paul,

Thanks for the response. Do you think you will move to VS 2008 with 2.2+? I ask, because I don't have 2005 on my dev box anymore. If 2.2+ will be on 2008 I will hold my patches until then (or perhaps there would be some value in a branch we could patch against now to prevent integration problems later?).

Ben
Coordinator
Sep 3, 2008 at 10:02 AM
I don't have 2005 either, but you can develop using the 2008 solutions, just be carefull not to use any 2008 stuff (var and extension methods, all others should be blocked by compiling the projects agains 2.0)$0$0$0$0I expect the 3.x version to be 2008... since 2.1 will be the last .NET 2.0 version$0
Developer
Sep 3, 2008 at 10:07 AM
Thanks for clarifying the plan for me.  I will press on with the patches!
Coordinator
Sep 19, 2008 at 6:04 AM
Just agreeing with Paul 100%.

On Wed, Sep 3, 2008 at 2:07 AM, BenTaylor <notifications@codeplex.com> wrote:

From: BenTaylor

Thanks for clarifying the plan for me. I will press on with the patches!

Read the full discussion online.

To add a post to this discussion, reply to this email (dasBlog@discussions.codeplex.com)

To start a new discussion for this project, email dasBlog@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com




--
Scott Hanselman
http://www.hanselman.com
Developer
Sep 19, 2008 at 4:35 PM
Edited Sep 19, 2008 at 4:36 PM
Thanks Scott (at 6.04 AM!).

I have already reverted my "var" usage and hacked out my hacked in extension methods.  So far, I have uploaded 3 patches over here http://www.codeplex.com/dasBlog/SourceControl/PatchList.aspx.  They are:

1.  Do not ping any services when a non-public post is saved (bug fix?)
2.  Enhanced Windows Live Writer support so you can author post descriptions (excerpts in WLW parlance).  Screenshot of it in action.  Was change to WLW manifest and WS API fix.
3.  Choice of - as URL spacer as well + http://bentaylor.org/dasBlog-Patch-Add-Choice-Of-Dash-For-Post-Title-URL-Spaces.aspx

I may have slightly overreached in the last one.  I created a new interface ITitledEntry which is (already) implemented by Entry & EntryIdCacheEntry.  This was done so that I could remove some code dupe in SiteUtils.  I think it makes sense, but perhaps it should be in it's own patch.  Don't worry, I did not delete any methods from SiteUtils.  I just marked them obsolete.

What is the process with regards to updating the resource translations?

--
Ben Taylor
http://bentaylor.org/