It’s going to be one of those days…

14 07 2008

VS2008 has crashed 20+ times today.  Reboots aren’t helping.  I’m slowly uninstalling plug-ins at the moment.  Ugh.

Obviously a Monday

I broke'd it...

Tags: ,




AnkhSVN 2.0 Released - How’s it look?

11 07 2008

When I first started using Subversion full time for all of my personal projects, I stuck with the VisualSVN server and AnkhSVN as a Visual Studio client.  Both were free, easy to install, and easy to use.

However, after a few weeks, the AnkhSVN client could almost be called “annoying.”  It trampled over the existing SCC plugins for SourceSafe (for work) and made a mess out of several of my project uploads.  I ended up going back to using TortioiseSVN and doing everything through Explorer.

When AnkhSVN 2.0 was released, I figured I’d give it another shot.

The site claims quite a bit—including several unique additions:

  • Pending changes window; subversion status and commands available in one place
  • Full support for Visual Studio 2005 and 2008; AnkhSVN is now a SCC package instead of just an addin
  • Better log viewer
  • Merge support
  • Property editor
  • AnkhSVN now supports most project types previously unsupported via the SCC api
  • All solution explorer actions (rename, copy&paste, drag&drop) keep subversion history now
  • Enhanced build process and setup
  • Automatic check for updates
  • And last but certainly not least end user documentation

All of those look great—especially the SCC package and changes window.  But how does it compare once installed?

After installation and starting up VS2008, everything looks normal.

Brief Look

Pending Changes Window

The new pending changes window is FANTASTIC—much improved over the old 1.x versions.  I did run into a snafu when trying to resize the window where the scrollbars didn’t update on the screen; however, I’m not sure if it’s a VSS or AnkhSVN issue.

SCC Package

Under Options > Source Control, AnkhSVN shows up just like it should.

What does boggle me is that all of the Subversion commands and menus are available no matter what—even when the VSS SCC is enabled.  It still has the stink of VSS and SVN trying to step on one another (“pick me! control your project with me! no, I’m better! pick me!”).

Log/History Viewer

I really like the new history viewer.  It’s clean and easy to read; however, if you change the options at the top—there doesn’t appear to be a way to “change it back” and see the history again, close the view and review.

Annoyances

  • Opening a project from Subversion (File > Subversion > Open from Subversion) will open a project just fine, copy it down, but never opens it.  You have to go back and open the solution after it’s created the local structure.  Not huge, but annoying.
  • When viewing history; you cannot view the history of a single file (that I’ve found) in the Repository Explorer. 

I’m still planning to give it a whirl for the next couple of weeks and see what happens.  Hopefully over a couple weeks I’ll have more time to code—it’s been a busy July so far!





Ready for ReSharper 4.0.1 Nightly Builds?

8 07 2008

I swear that they don’t sleep at JetBrains.  Sleep is good!  :)

Fresh off of ReSharper 4.0’s great EAP and full release, they’re hard at work for ReSharper 4.0.1.  According to Confluence, there’s already been almost 220 bug fixes (as per build 907). 

As usual, caution should be used when evaluating an EAP product (e.g. not on your one-and-only production workstation), but it looks like another great opportunity to kick in some feedback for ReSharper.

You can find the nightly builds here.





ReSharper 4.0 is now RC!

5 06 2008

The first RC for ReSharper 4.0 is out—pick it up! Nice!





ReSharper 4.0 Beta Released!

22 05 2008

The EAP from Monday (19 May) was elevated from Beta candidate to Beta status later this week—a tremendous step for the tool.  The JetBrains team has been cranking out build after build and the latest few have been great!

If you have been putting off checking out the new ReSharper—don’t wait!  The builds are extremely solid and if you do happen across an issue, submit it up and help the community!





Adding Multiple System Monitors ala Perfmon

22 05 2008

I use Perfmon a LOT. 

The logging and diagnostic software provided to us is, well, it’s just not that great.  Very slow to use and get around and every time I want a specific counter, I have to go ask for it because it’s someone’s “job” to add those. Ugh.  That’s no way to live.

Until now, I typically have a Perfmon console for each of my major application and SQL servers.  Why?  Because I was never smart enough to figure out how to add additional System Monitor controls into a single performance console.

Well, now I figured it out!

  • File > Add/Remove Snap-in
  • Click Add…
  • Select the ActiveX Control

ActiveX Control

  • A Wizard will start; scroll down and select System Monitor Control

System Monitor ActiveX Control

  • Give your new counter a name!
  • Repeat this until you’ve added your servers.  From there, configure each System Monitor control as needed.

Perfmon with all the servers!

From here, you can either add counters manually or use this brilliant PowerShell script.





MoQ Mocks - Use virtual method or interfaces?

6 05 2008

I’ve switched over and am using MoQ full time now on my projects and LOVE it.  The lambda expressions may seem strange to others, but I like that I can read my code, left to right, and it’s almost verbatium to what I want to do.

The one snafu that really bugs me is when testing classes that are based off of a base class rather than an interface.  For example, my LINQ business layers fall back onto a prototype over on the MSFT Code Gallery and the Microsoft Dynamic Query libraries (which is part of the VS2008 samples, just add the class file into your project).

Unfortunately, the base class library has everything has static methods.  That’s no good for testing.  However, that’s not enough.  I kept getting the following error:

System.ArgumentException: Invalid expectation on a non-overridable member.

Say huh?  Non-overridable?  Why’s it trying to override the method?

I finally found the answer over on the MoQ Google Groups—”[Castle] DynamicProxy can not intercept methods calls to non virtual, non abstract methods”.

Daniel Cazzulino goes on to explain:

it’s a limitation of the CLR since its inception: there’s no built-in
interception mechanism.

so, the interception mechanism we use is auto-generated classes that inherit from the types to mock, and override all members to provide the interception. that’s why they need to be virtual.

we’re reusing the interception library from Castle DynamicProxy for doing that.

Well, that explains that, but I’m not sure I like decorating my classes simply to enable mocking. 

public virtual bool Add(int studentId, string enteredBy) { }

The mock and test then look like:

[TestMethod]

public void Reports_AddReport()

{

       var mock = new Mock<ReportsController>();

       mock.Expect(x => x.Add(studentId, enteredBy)).Returns(true);

      

       Assert.IsTrue(mock.Object.Add(studentId, enteredBy));

}

What would be a better solution? 

In my opinion, taking the base class and pushing the members up into an interface, then mocking the interface would be best.

With the methods nicely tucked into a new IReportsController interface and the virtuals banished from our base class, our test only changes slightly, but without opening up the methods in the base class to override.

[TestMethod]

public void Reports_AddReport()

{

       var mock = new Mock<IReportsController>();

       mock.Expect(x => x.Add(studentId, enteredBy)).Returns(true);

      

       Assert.IsTrue(mock.Object.Add(studentId, enteredBy));

}

Are there times where virtual methods would be a better idea?





Test Coverage Tools in VS2008

2 05 2008

Perhaps I spend a bit too much time “working” and not enough time learning the ins and outs of my tools.  I stumbled across the Code Coverage Results tab this morning and was quite pleased.

The Code Coverage metrics count what lines of code are not tested in your project.  I’ve seen 3rd party tools that so this, but never found this inside of Visual Studio.  To use these tools, I believe you must use the Visual Studio testing framework (which I do).

Here’s how to get it working.

1. Enable Code Coverage in the local test run configuration for your test project.

Test > Edit Test Run Configurations > Your Test Configuration

Enabling Code Coverage

Click on Code Coverage and check the libraries to include in the code coverage routines.

2. Execute your Test Project.  After the tests are complete, right-click one of the tests and select “Code Coverage Results”.

Select Code Coverage Results

3. Use the Code Coverage Results window to analyze the coverage of your unit tests.

The Code Coverage Results window (with the default columns) tell you your:

  • Not Covered Blocks
  • Not Covered Blocks %
  • Covered Blocks
  • Covered Blocks %

Code Coverage Results

In the image above, you can see that ERC.Models has VERY poor coverage.  That’s a LINQ library that, quite honestly, DOES have poor coverage as all of the code is automatically generated.  The implementation of the Model (in ERC.Controllers) has quite good coverage, but has room for improvement.

I can further drill down into the ERC.Controllers namespace and see that I left out the ReportsController.  I remember creating the tests for the controller, but I added a quick method to it and forgot to update the test. 

For this controller, with only a few lines, it’s easy to spot the problem but what about a namespace or class with thousands of lines of code?  This is where the code highlighting comes in handy.

4. Use Code Highlighting to pick out the missed lines of code.  Click on the Code Highlighting button to toggle highlighting on and off.

Code highlighting toggle button.The code highlighting button, seen to the left, toggles red highlights on and off in your code.  This only works for code that is included in your code coverage metrics, but helps the developer find those little code blocks that may have been overlooked.

In my ReportsController, I remember adding a quick method, but forgetting to update the test.  I can open up that controller and see that the untested code is now highlighted.

Untested code is highlighted red.

From here, I can go back, add or update the approprate tests, and rerun.

It’s a simple feature, but GREAT to see it built in—especially now that I know it’s there!  The only caveat is that I wish you could (or wish I knew how to) exclude  pre-generated code, such as LINQ code.





My experience creating my first Mobile 6 application

27 04 2008

The past few months, I’ve been busied with looking for a new home.  Unfortunately, with home buying comes specials, taxes, financing rates, and a myriad of other calculations—the house price means nothing.

For example, if a home was 150,000$ with no specials, chances are the payment would be less than a home that’s 135,000$ with 15 years of specials left (~15,000$, or 1000$ per year), at least until that 15 year period is over.

But, walking through models and with an agent—how can you calculate that right off the bat?  My agent has a spiffy little calculator that does it, but can’t figure in Homeowner’s Dues or Specials, just PITI.  Well, I’m a developer—I just needed to develop something!

So began my first venture into creating a Windows Mobile 6 application.  I’ve had my T-Mobile HTC Wing.  It’s not a super fancy “all in one,” but I really like it.  What I liked most, when I purchased it, was that I could develop .NET apps for it—I just never (until now) had a good reason.

Mobile Calculator for WM6

Lessons Learned:

  1. The experience of developing for the Mobile platform (e.g. compact framework) is nearly identical to developing for Windows forms—the only difference is being limited to screen size.
  2. The screen resolution (inspite of what shows up on the emulator) does not mirror how it appears on the PDA—even when using the correct emulator and skin in Visual Studio.  This may be a caveat to my Wing, who knows.

Beyond that, at least for this basic application, everything’s the same.  Drag your text boxes, labels, and other controls onto the form, then add logic into the events.

Things I Need To Work On:

  1. Using multi-form “forms”—how can I popup a box for more information?
  2. How can I add a .config file with the application and read/write to it?
  3. How can I save information and settings?
  4. How do I get applications to show up on the Programs menu?

Easy things to research—just haven’t had time.

Also, for those interested, here’s the mortgage forumla based on the Excel PMT formula and rehashed to be used in .NET.  This calculates PITI, then adds in specials, homeowner’s dues, etc. based on the term of the loan etc.  I’ve bolded the important part.  Spacing and usage of the Math.Pow method is required (since C# doesn’t support the ^ operator).

The 20% check mark calculates a downpayment that ensures avoiding mortgage insurance (which is a TOTAL waste of money since it simply ensures the lender, not you).  CalculateDownPayment() returns 20% of the entered value.

NOTE: I’m sure I could refactor and get fancy—but for something this simple, there’s not a lot of value.  As I add (if I am house shopping THAT long to NEED to) features, I may split things up.

private const int monthsPerYear = 12;

private const int term = 30;

 

private void Calculate_Click(object sender, EventArgs e)

{

if (PmiCheckbox.Checked)

                     Down.Text = CalculateDownPayment();

 

var rate = Convert.ToDouble(Rate.Text);

var monthlyRate = rate / monthsPerYear;

var value = Convert.ToDouble(Value.Text);

var down = Convert.ToDouble(Down.Text);

var taxes = Convert.ToDouble(Taxes.Text);

var insurance = Convert.ToDouble(Insurance.Text);

 

var principal = value - down;

 

var principalAndInterest =

(principal * monthlyRate) /

(1 - Math.Pow((monthlyRate + 1),

-(term * monthsPerYear)));

 

var taxesAndInsurance =

(taxes / monthsPerYear) + (insurance / monthsPerYear);

 

var subTotal =

principalAndInterest + taxesAndInsurance;

 

var specials = Convert.ToDouble(Specials.Text);

var homeOwners = Convert.ToDouble(Homeowners.Text);

 

var additionalCharges =

(specials / monthsPerYear) + (homeOwners / monthsPerYear);

 

var total =

subTotal + additionalCharges;

 

Total.Text = string.Format(“T: {0:C}”, total);

}

To conserve real estate, I put the “Total” down near the Calculate button.

The finished product for the Mortgage Calculator.

The application itself is probably directly out of a CS100 course—basic mathematics, but the fact that it’s on my mobile phone rocks.

To me, getting paid at work to create something is great and fufilling, but having a need, even one as simple as this, and being able to create it from scratch is truly rewarding and reminds me why I love being a developer.

 





So far, a total loss…

23 04 2008

This past week, so far, has been a total loss on the technical front.  I can’t articulate how much documentation I’ve written or whiteboard sketches for new applications—but for projects that are either on hold or vaporware at the customer’s request.  Ugh.

I do have a few posts in the works from various projects, including some of my first tinkerings with creating Windows Mobile 6 software.  More on those later this week.

Tags: