Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 573469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:43:37+00:00 2026-05-13T13:43:37+00:00

I just read this post and it makes the case against implicit typing using

  • 0

I just read this post and it makes the case against implicit typing using when starting out with Test driven development/design.

His post says that TDD can be “slowed down” when using implicit typing for the return type when unit testing a method. Also, he seems to want the return type specified by the test in order to drive development (which makes sense to me).

A given unit test with implicit typing might look like this:

public void Test_SomeMethod()
{
    MyClass myClass = new MyClass();

    var result = myClass.MethodUnderTest();
    Assert.AreEqual(someCondition, result);
}

So my questions are:

Does using implicit typing help or hinder writing unit tests for TDD? Is there anyone out there that can share their experience using this technique when writing unit tests?

I ask this because soon I have not done TDD and want to know if there is a way to write generic or semi-generic unit tests that would work a return type might change.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T13:43:37+00:00Added an answer on May 13, 2026 at 1:43 pm

    I see his point but I don’t really think it’s the right reason to not use var here. Remember, TDD works roughly according to the following:

    1. Write a new test.
    2. If test fails to compile (and it should fail!), write enough code until the test compiles.
    3. Run all tests.
    4. If a test fails, write enough code until all tests pass.
    5. Refactor.

    Whether or not we use var the test will fail to compile either way because the method under test won’t exist yet!. Once we start coding up NewMethod his points are rather moot.

    Rather, the right reason to not use var here is because the code gives no indication what the type of result is. This is a matter of opinion but var is okay here

    var dict = new Dictionary<Foo, List<Bar>>();
    

    and for anonymous types but not here

    var m = M();
    

    because it’s completely unclear without going to the declaration of M (or using IntelliSense) what the return type of M is.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 317k
  • Answers 317k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Automatic ~ expansion is a feature of the shell. If… May 13, 2026 at 11:39 pm
  • Editorial Team
    Editorial Team added an answer JNICALL is probably #define JNICALL __stdcall. Changing the calling convention… May 13, 2026 at 11:39 pm
  • Editorial Team
    Editorial Team added an answer The SPSite object's RootWeb (SPWeb) has a Created property. May 13, 2026 at 11:39 pm

Related Questions

I just read this post about why new-line warnings exist, but to be honest
Question can also be: What is your preferred way of invoking stored procedures to
I've read a lot of times that one should never blindly catch exceptions. Some
I'm trying do to a basic bash with the use of system calls but
In my C# application, I have a large struct (176 bytes) that is passed

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.