Thursday, August 21, 2008

Google Maps Mobile Rocks!

I am using GoogleMaps on my blackberry curve. I don't have a GPS, however, I find the tower based location pretty usefull. Now I am in Paris, and for kicks I tried to use the future here. Well, to my surprise, Google Maps correctly found me in the middle of Paris with accuracy of 1700 meters. That's pretty damn close. This app rocks!!! If you still don't have it, get it at http://maps.google.com/mobile/

Tuesday, July 15, 2008

Simple EntityMapperTranslator

CAB defines a very clean way of defining a translator for converting objects from one type to another. A typical use for this is to convert from an "wire" object a business object and back. This is done by creating an EntityMapperTranslator. Defining two methods: BusinessToService and ServiceToBusiness. And then registering the translator in the IEntityTranslatorService.

Often, the business object identical or  nearly identical to the wire object. The code below will copy every property from the SourceType to the TargetType. Of course, this can be used outside of the EntityMapperTranslator as well for the same purpose.

 

class TypeTranslator : EntityMapperTranslator<SourceType, TargetType>
{
    protected override TargetType BusinessToService(IEntityTranslatorService service, SourceType value)
    {
        TargetType target = new TargetType();
        foreach (PropertyInfo pi in value.GetType().GetProperties())
        {
           PropertyInfo newPi = target.GetType().GetProperty(pi.Name);
           if (newPi != null)
           {
              if (service.CanTranslate(newPi.PropertyType, pi.PropertyType))
                 newPi.SetValue(target, service.Translate(newPi.PropertyType, pi.GetValue(value, null)), null);
              else
                 newPi.SetValue(target, pi.GetValue(value, null), null);
           }
        }
        return target;
    }
}

Thursday, June 26, 2008

Dropping Visual Studio Unit Testing for NUnit

Continuing with my adventures in porting java code to .Net, I am dealing with moving JUnit unit tests to .NET. My first move thought was to convert to Microsoft Unit Testing framework. However, after spending quite a bit of time to get it to work, I gave up and switched to NUnit.

Two things that are NOT supported by the Microsoft framework and forced me to switch

    • Per-Test StartUp/TearDown functions. [TestInitialize] and [TestCleanup] are not called for every [Test]. They are called when the Test class is initialized. That means its very hard to have a good Initialization and Cleanup routines for every test.
    • Lack of Test Inheritance. I a set of unit tests that test different implementations of an interface. The core test of the interface must be the same to make sure that all implementations handle the core identically. However, There might be special additional tests to validate extended functionality. Currently, you can not accomplish that with Inheritance.

Both are fully supported by NUnit.

Technorati Tags: , ,

Saturday, May 31, 2008

1st Java annoyance

For the last month I've spent as much time writing Java code as C# code. And its definitely been a great learning experiences. Even though the core languages are very much alike, and you can usually find a function in .NET that corresponds to Java and the other way around, I've spent quite a bit of time yesterday trying something that should have been completely trivial.

The Problem:

having a Date variable loadDate that includes Date and Time, create two variables startDate and endDate where StartDate is the portion of the loadDate, and endDate is the startDate + 1 day

C# Code:

DateTime loadDate = DateTime.Now; DateTime startDate = loadDate.Date; DateTime endDate = startDate.AddDays(1);

Java Code#

GregorianCalendar cal = new GregorianCalendar( loadDate.getYear() + 1900, loadDate.getMonth(), loadDate.getDate()); Date startDate = cal.getTime(); cal.add(Calendar.DATE, 1); Date endDate = cal.getTime();

Why is the Date.getYear() function returning 108 for a year 2008? What is the logic behind that? Are the Java developers afraid of running out of integer values?

Why the Calendar class supplies the clearDate() function, but no clearTime() function?

Why I can't dd Dates the way I can other classes?

Why the Calendar.add() function doesn't return a result instead of replacing the internal value, the way other classes do?

Why is this not documented in the Date class?

Wednesday, April 09, 2008

SQL ROW_NUMBER() function and Audit tables

I had to search through an audit table to find times when the value changes in a specific field. Considering an audit table

DateModified DateTime
ID varchar()
Quantity decimal
Price decimal

I wanted to find the rows when Quantity changed for the same ID.

I've been able to accomplish that using the ROW_NUMBER function of SQL 2005

Here's the query:

select Row_Number() OVER (PARTITION BY ID Order BY ID, DateModified) as RowID, DateModified, Quantity, ID INTO #TempData from AuditTable select a.ID, b.DateModified, a.Quantity as FromValue, b.Quantity as ToValue from #TempData a inner join #TempData b on a.ID = b.ID and a.RowID = b.RowID-1 and a.Quantity != b.Quantity order by 1, 2 drop table #TempData

Technorati Tags: ,

Tuesday, April 08, 2008

Yuneta's Blog

A friend of mine started a blog and started posting nice support entries.

http://yunetasblog.blogspot.com

Technorati Tags: ,

Saturday, February 16, 2008

Windows Server 2008 will have an SP1 label

I came cross an interesting blog entry that said that Windows Server 2008 will have SP1 label already applied to it. Take a look at http://blogs.msdn.com/iainmcdonald/archive/2008/02/15/windows-server-2008-is-called-sp1-adventures-in-doing-things-right.aspx

Now, how will this effect people's rule not to install a Microsoft server, until SP1 is released (or did the rule implement this version scheme due to that rule :)

Technorati Tags: , ,

Thursday, February 14, 2008

Firefox 3 Beta 3

Firefox team released a public Beta 3 of the new version of Firefox 3 browser. Here are some first impressions

  • Pretty stable, didn't have any stability issues yet. Beta 2 would crash on some very basic pages
  • It is FAST. As in like really, noticeably faster then Firefox 2 and IE. Complex pages like iGoogle, MSDN, etc... show up instantly
  • The URL dialog is nicely improved. You now get a dropdown with recommended URLs based on both URL and page title.
  • It passes the acid2 test

Some minor annoyances

  • Old add-ins and themes do not work

Technorati Tags: , ,

Friday, February 01, 2008

Sara Ford's WebLog : Did you know... You can use Shift+ESC to close a tool window - #142

Sara Ford's Tips Blog is an excellent source of tips. This one especially helpful for me.

Sara Ford's WebLog : Did you know... You can use Shift+ESC to close a tool window - #142

Technorati Tags: , , ,

Friday, January 25, 2008

WCFTestClient - a testing utility from Visual Studio 2008

I stumbled upon an excellent utility for WCF Testing that comes with Visual Studio 2008 - WCFTestClient.

The tool is an simple way to test WCF clients HTTP and TCP bindings. Some things are not supported, however, for basic WCF Testing, this definitely beats the old ASMX test page.

Note: Also check out the WCFSvcHost utility from Visual Studio to host an arbitrary WCF Service.

Thursday, January 17, 2008

.NET 3.5 Source is now available

Everyone's talking about it. The source for .NET 3.5 framework is available for debugging. Read full instructions on how to set it up here

http://blogs.msdn.com/sburke/archive/2008/01/16/configuring-visual-studio-to-debug-net-framework-source-code.aspx

Technorati Tags: , ,

Saturday, January 12, 2008

Query ExPlus 2.0.2.8 is released

I finally got a chance to release a binary of the latest Query ExPlus v.2.0.2.8

I didn't put time into the project for a while, however, some developers in the community did, and I'd like to extend my appreciation to those guys.

The new functionality since last version is:

  • Handle result sets with NULL primary keys
  • Select All for the grid
  • MRU implemented using Genghis library
  • OleDB Support
  • Fixing Order by in Oracle Browser

The project is still a one executable 172KB in size. The only prerequisite is the .NET 2.0 framework

You can access the project homepage on Source Forge

http://sourceforge.net/projects/queryexplus

The direct download link for the release is

http://sourceforge.net/project/showfiles.php?group_id=176790&package_id=206668&release_id=567994

The download is available as either compressed executable or compressed source

 

Technorati Tags: , ,

Thursday, January 10, 2008

Customizing SCSF Guidance Package for Modular Development

One of the requests that I've received from other developers is the ability to use SCSF for developing a module without including the shell in the solution. We develop a large number of modules independently in different groups and having the shell be a part of every module was getting to be a problem.

The only issue that I was getting with getting this to work was that SCSF guidance package would fail in ViewTemplateCS when I would right click on a folder and tried to add a new view to the project.

To solve the issue, I was made a small tweak to the source in the ViewTemplateReferenceCS.cs. (The code comes with the SCSF, however, you will have to install it separately after the SCSF is installed) The culprit is the function
    ContainsRequiredReferences(Project project)
Specifically the call to ContainsReference(project, prjCommon.Name)

Since the common project is not in the solution, the call failed with Null Reference exception. All I had to do was to change the last line of the function to be
   ContainsReference(project, "Infrastructure.Interface");
Then recompile the GuidancePackage solution and place the
Microsoft.Practices.SmartClientFactory.GuidancePackage.dll
into the
C:\Program Files\Microsoft Smart Client Factory\Guidance Package
folder.

Monday, January 07, 2008

Fixing WCF/WPF VS 2005 Extensions installation after installing VS 2008 or .NET 3.0 SP1

I've encountered a problem trying fix the WCF / WPF Visual Studio 2005 Integration components after I've installed Visual Studio 2008.

Installing a VS 2008 will install .NET 3.0 SP1 and remove the installation of .NET 3.0. When trying to install the WCF / WPF Extension, installation display's a message

Setup has detected that a prerequisite is missing. To use Visual Studio 2005 extensions for .NET Framework 3.0 (WCF & WPF), November 2006 CTP you must have the .NET Framework 3.0 runtime installed. Please install the .NET Framework 3.0 runtime and restart setup

You really can't install .NET 3.0 since a newer version (.NET 3.0 SP1) is already installed.

I found a solution on the MS Forums http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2550726&SiteID=1

It involves either going creating a registry key to full the installers into thinking that SP1 is installed. To fix the issue, add the following value to the registry:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{15095BF3-A3D7-4DDF-B193-3A496881E003}] "DisplayName"="Microsoft .NET Framework 3.0"

Thanks Erich for the solution.

Note: I got a comment that this can also be forced using command line: msiexec /i vsextwfx.msi WRC_INSTALLED_OVERRIDE=1

Thanks

Friday, December 21, 2007

Closing and Terminating views in SCSF

There is a bug in the SCSF implementation that views even though closed, will not terminate the workitems. This was described on codeplex in the following thread: http://www.codeplex.com/smartclient/Thread/View.aspx?ThreadId=4370

Here is my workaround:

In the View.Designer.cs

protected override void Dispose(bool disposing) { if (disposing) { if (_presenter != null) { _presenter.OnCloseView(); // <<<<<<<<======= Workaround _presenter.Dispose(); } if (components != null) components.Dispose(); } base.Dispose(disposing); }

In the ViewPresenter.cs

bool Closing = false; public void OnCloseView() { if (!Closing) { Closing = true; if (WorkItem.Status != WorkItemStatus.Terminated) WorkItem.Terminate(); base.CloseView(); } }

The code will force the workitem to be terminated after the view is closed

Technorati Tags: , ,