Posts
70
Comments
66
Trackbacks
0
Wednesday, June 25, 2008
Hint for today - Install SQL Server 2008

Even if your databases are from prior versions of SQL Server, you should download the new CTP for SQL Server 2008.

https://connect.microsoft.com/SQLServer/content/content.aspx?ContentID=5395

The new version's SQL Server Management Studio will connect to older versions of SQL Server databases and give you intellisense (almost as good as Red Gate's Sql Prompt!).

Hope this saves you some time,

Jonathan

posted @ Wednesday, June 25, 2008 12:07 PM | Feedback (0)
Monday, June 23, 2008
Code Redundancy is NOT Bad - Part 2

I got some responses from a post I made on Saturday, that troubled me.  I really think it is important to code to an interface whenever possible - not only to give your application to flexibilty, but to give it testability as well.  So I thought I might give you an example.

Say I have a class that depends on two other classes I have.  In this example, Partitioner depends on SystemIOAdapter and MerchantRecordCounter.                                                                                                                                                                

                                                                                                                                                                                                                    

using Interfaces;

namespace Program

{

    public class Partitioner : IPartitioner

    {

        public void PartitionMerchants(ISystemIOAdapter io, IMerchantRecordCounter counter, string mappedPath, string partitionPath, int maximumCount)

        {

           // implementation details.

        }

    }

}

If the method PartitionMerchants had been written using class declarations instead of interfaces, than any test I would write for this method would be an integration test, not a unit test...  Because the failure could be in one of the dependent classes, not in the class that is under test in my unit test! 

Integration tests are useful as smoke tests to identify that a problem exists.  But they don't help me quickly identify the root cause of problems when they arise.

The following shows a unit test for a Partitioner class that depends on a SystemIOAdapter (so dependencies on a specific IO is removed),  and a MerchantrecordCounter class.  You may notice that the only way to mock these out are by creating classes that implement the same interfaces used in the PartitionMerchants method.  (In this case I am using Rhono Mocks to do this quickly).

using Project.Interfaces;

using NUnit.Framework;

using Rhino.Mocks;

namespace Tests

{

    [TestFixture]

    public class Partitioner_UT

    {

        private MockRepository mocks;

        private string mappedpath = "mappedpath";

        private string partitionedpath = "partitionedPath";

        private ISystemIOAdapter io;

        [SetUp]

        public void SetUp()

        {

            mocks = new MockRepository();

            io = mocks.CreateMock<ISystemIOAdapter>();

        }

         [Test]

        public void PartitionDirectory_OnlyOneMerchantFound()

        {

            IMerchantRecordCounter counter = mocks.CreateMock<IMerchantRecordCounter>();

            using (mocks.Record())

            {

                // set up call expectations here

            }

            using (mocks.Playback())

            {

                IPartitioner partitioner = new Partitioner();

                partitioner.PartitionMerchants(io, counter, mappedpath, partitionedpath, 0);

                // Add assertions here

            }

        }

    }

}

I hope this clears up why it is so important to write code using interfaces whenever possible!

Jonathan Starr

posted @ Monday, June 23, 2008 6:26 PM | Feedback (3)
Saturday, June 21, 2008
Code Redundancy Is NOT Necessarily Bad
I was just reading Jeff Atwood's recent blog article Department of Declaration Redundancy Department

He makes the case that writing code without static typing is easier to read, and "Anything that removes redundancy from our code should be aggressively pursued -- up to and including switching languages."

My take is "maybe".

Say I have a class named Example that implements two interfaces, IFoo and IBar.  When I instantiate I have several options when dong so statically.

Example example1 = new Example();
IFoo example2 = new Example();
IBar example3 = new Example();

In the second case I am ensuring that example2 implements a certain interface, and I can swap this out with an instantiation of a different object that implements IFoo.  This strategy pattern is fundamental to object oriented programming, and 'getting in the habit of writing code using var' can provide inflexible suboptimal design.  Additionally, if you are coding using TDD (Test Driven Development) you won't be able to write unit tests that remove all dependencies for your class unless you write your dependencies as interfaces.

The way the compiler in C# 3.5 automatically converts LINQ queries to IEnumerable objects is nice.  But the following statement

var reader = new StreamReader(fileName);

is cast to the child static type, not to the its abstract parent (as I think it should be).

Interested in your thoughts.


Jonathan


posted @ Saturday, June 21, 2008 5:43 PM | Feedback (10)
Sunday, May 04, 2008
Hillary as Darth
I try not to get too political in this blog, but I could not resist the Star Wars references!



Enjoy,

Jon
posted @ Sunday, May 04, 2008 1:14 PM | Feedback (0)
Friday, May 02, 2008
Who Is An Average Developer?

Every blogger I read claims to have superior coding skills, and every place I have worked claims only to hire superior developers.  In my current position and in my prior one, my employers say they interviewed more than twenty candidates to fill each position.

If that's so, where are the average coders?

I heard one theory - they are all unemployed!  And they keep trying to get jobs but they can't.  So interviewers have a skewed sampling of coders.

I will confirm that in my current and previous position i have worked with much better developers than I had previously.

But I wonder.  I have learned so much in the last year (WCF, TDD, LINQ, PLINQ, Ruby, statistical modeling techniques with third party tools, Dundas charting, advanced NAnt builds, Webparts development, Appistry fabric development, Map-Reduce algorithms, etc.) - perhaps if I were to meet my former self from a year ago I would consider myself an average programmer. 

My sense is that all coders are improving by leaps and bounds each year.

And that most of us have an inflated opinion of our own coding skills.

What do you think?

Interested in your thoughts,

 

Jonathan

posted @ Friday, May 02, 2008 7:24 PM | Feedback (3)
Saturday, April 12, 2008
Cats - From An Engineer's Perspective
Admittedly I don't own any cats - I personally favor parrots. 

But this video tickled my fancy anyway (loved the corporal cuddling - as if there were more than one kind!)



Enjoy

Jonathan
posted @ Saturday, April 12, 2008 11:02 PM | Feedback (1)
Friday, April 11, 2008
See the music

From the Zurich Chamber Orchestra

 

posted @ Friday, April 11, 2008 8:37 PM | Feedback (0)
Quantum Mental Health Break

It's better than MC Rove (but not by much)

posted @ Friday, April 11, 2008 7:59 PM | Feedback (1)
Friday, March 28, 2008
Beta Risk

A friend at work recently asked me to look at some of the equities he holds in his portfolio.  While I am a developer, I also have an MBA in Finance; I enjoy evaluating stocks and readily agreed. 

One of my friend's holdings is  Wal-Mart (WMT), and I was a bit surprised to see that finance.yahoo.com listed WMT's Beta, which is a measure of a stock's risk relative to the market, as -0.14.  It is uncommon to find stocks with negative Betas.  Generally this means that the stock moves in the opposite direction as the market.  And the low Beta value, i.e. | Beta | < 1, indicates that the stock is less risky than the S&P500.

So I performed a few calculations, and measured the Beta for WMT using closing month prices for WMT and the S&P500  for the last five years, and reproduced the number listed on Yahoo!  But I retried the calculation going all the way back to 1972, and got a Beta measurement of 1.23.  And then again i measured beta for WMT only using the last 24 months of data and got a measurement of -0.31.  (See graphs below for details).

WMT Calculation Beta - Last 60 Months (through March 2008)

WMT Calculation Beta - Data 1972 through March, 2008

WMT Calculation Beta - Last Two Years 

 

So, given all of the variation in Beta measurements, what is a good way for estimating future Beta for a stock?  This really is an important question, as Beta dominates the function to determine the Weighted Cost of Capital for a stock.  (WACC = D/C ( Kd) + E/C ( Beta x Market Rate of Return).  And if  you are doing Beta arbitrage (buying baskets of low Beta stocks and short selling Beta stocks), this would be crucial.  (Here's an interesting article on the subject... )

I suspect that modelers should make adjustments for changing legal environments, capital structurres, dynamics between companies and their customers, suppliers, and competitors...  But which changes dominate Beta changes.  Can the past Beta measurements be used at all to forecast future Beta?

Any ideas out there?

Interested in your thoughts,

Jonathan Starr

posted @ Friday, March 28, 2008 7:29 PM | Feedback (0)
Monday, March 24, 2008
Flood

Some friends and relatives have been asking about the flood conditions in Fenton, MO (outside Saint Louis) so I thought I should post some pics of the affected areas.  My home has not been harmed (knock on wood!), but the area around me certainly has been.

I think this is a pic of a trailer park about three miles from my house.

Another pic..

There are a few bars, a public swimming pool and a soccer field affected by the rains as well.

Tueday, Wednesday and Thursday we are expecting more rain as well (Today is Monday...)

Local stations are saying the water levels should go down fast, however.

Jonathan

 

 

posted @ Monday, March 24, 2008 6:49 PM | Feedback (1)
Tuesday, March 04, 2008
HttpModule Question
I recently implemented an HttpModule in a web project (.NET 2.0 Framework on Windows XP), and noticed some anomolous behavior... The Init method for the HttpModule does not always fire (sometimes it did however) after the web application started.  I used an obvious workaround, and took advantage of the event model exposed in global.asax.  But I am disturbed from what I saw.

Has anyone else noticed this anomaly?  Is this something that can be fixed?

Thanks for the help!

Jonathan Starr
posted @ Tuesday, March 04, 2008 9:21 PM | Feedback (0)
Sunday, March 02, 2008
Saint Louis Microsoft Technology Calendar Updated...

improve my => 'code' Add to Google

I have updated the unified Saint Louis Microsoft Technology calendar here.

Here is a quick summary:

St. Louis C# User Group   3/10/2008 6:00pm
Our guest, live from France, will be Patrick Smacchia, creator of NDepend and author of Practical C# 2 and .NET 2.

Sharepoint meeting  3/11/2008  8:30am

St Louis Sql Server User Group 3/11/2008  1:00pm
Writing better T-SQL Queries, Avoid Cursors and Dynamic SQL

CRM User Group Meeting 3/27/2008 8:30am

NET User Group Meeting 3/31/2008 5:30pm
Denny Boynton “Software as a Service”

All events take place at Three City Place Drive, Suite 1100, Creve Coeur, MO 63141

Hope to see you there!

Jonathan

posted @ Sunday, March 02, 2008 11:19 PM | Feedback (0)
Thursday, February 28, 2008
Buddhabrot

I apologize for not writing into the blog for some time.

A few weeks ago, I attended the wedding of my good friend, Michael Bittel.  His blog on Africa, while it is updated infrequently, certainly certainly helps me keep things in perspective.

Also, I have continued to do some work for www.1CCN.com .  Please check out this web site/ phone application for project management if you, or someone you know, is in the construction industry.  We recently added the ability to add pictures to status updates.  Hopefully this will be useful to someone.

I started a new job recently for a startup company here in Saint Louis, MO.  One of my new co-workers showed me this interesting rendition of the Mandelbrot Set (yeah, I'm a big fan).  Basically, instead of using real numbers to create the set, the renderer used complex numbers...  And the results are pretty eerie... Looks like a buddha!

 

Hope everyone reading this entry is doing well,

Jonathan

 

Undergoing MyBlogLog Verification
posted @ Thursday, February 28, 2008 8:14 PM | Feedback (1)
Friday, January 25, 2008
LINQ and Financial Simulation

improve my => 'code' Add to Google

I just started playing around with LINQ seriously, and I really love some of the features incorporated, like the Enumerable.Range() function and how it can be used for integer programming.

Here's a simple function for generating lognormal distributions (could be useful for financial engineering).

Hope you're enjoying the samples,

Jonathan Starr

 public List<double> GenerateLogNormalDistribution(int numberOfTimes, double mean, double standardDeviation)

{

    Random randomGenerator = new Random();

    var randomNumbers = from theNumbers in Enumerable.Range(1,

        numberOfTimes).Select(x => randomGenerator.Next(1,

  1000)/1000.0)

        select theNumbers;

 

    List<double> results = new List<double>();

    randomNumbers.ToList().ForEach

        (x => results.Add(mean + (standardDeviation * (Math.Sqrt(-2 * Math.Log(x)) * Math.Cos(6.28 * x)))));

 

    return results;

}

posted @ Friday, January 25, 2008 8:00 PM | Feedback (3)
Surprising CLR Behavior

improve my => 'code' Add to Google

The following code (surprise, surprise) compiles.  But it does not work as intended  (you won't be able to "doSomethingElse()!

Can any of you figure out why?  (I have my suspicions.)

Jonathan Starr

using System;

namespace test

{

    internal class BaseTest

    {

        private int _prop1;

        public virtual int prop1

        {

            get { return _prop1; }

            set { _prop1 = value; }

        }

    }

 

    internal class DerivedTest : BaseTest

    {

        public override int prop1

        {

            set { base.prop1 = value; doSomethingElse(); }

        }

    }

}

 

posted @ Friday, January 25, 2008 4:45 PM | Feedback (0)
Response to Brainteaser #11?

I have been pretty excited about LINQ, because it seems to do all of the optimization for me for free (kinda like T-SQL). 

Yow Han-Lee asks in his blog, Brainteaser #11, Given any two large List, what is the quickest way to find the mutual intersection of the two? Now take into consideration memory constraints?

 Well, the answer that only takes a minute or two for me is the following...

Comments welcome!

Jonathan Starr


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace orderlisttest
{

    internal class Number
    {
        private int _Num1;
        public int Num1
        {
            get { return _Num1; }
            set { _Num1 = value; }
        }

        public Number(int theNumber)
        {
            this._Num1 = theNumber;
        }

    }
    public class start
    {

        public static void Main(string[] args)
        {
            var bigList1 = new List<Number>();
            var bigList2 = new List<Number>();

            for (int counter = 0; counter < 100000; counter++)
            {
                Random randomGenerator = new Random();
                int number = randomGenerator.Next(10000000);
                bigList1.Add(new Number(number));

                int number2 = randomGenerator.Next(10000000);
                bigList2.Add(new Number(number2));
            }

            var Found = from o1 in bigList1
                        join o2 in bigList2 on o1.Num1 equals o2.Num1
                        select new { o1.Num1 };

            Console.WriteLine(Found.Count().ToString() + " items were found in common.");
        }

     }
   
}

posted @ Friday, January 25, 2008 3:23 PM | Feedback (0)
Tuesday, January 22, 2008
Beauty.Equals(Truth) ?

improve my => 'code' Add to Google

I noticed an entry on Wikipedia that made me smile.

SPL or the Shakespeare Programming Language is, in the words of Wikipedia, "designed to make programs appear to be something other than programs; in this case, Shakespearean plays. "

Variables in code are treated like characters in a Shakespearean play.  Variables must "enter" to be useable (allocated?) and "exit" to be declare out of scope...   And variables speak their mind to output to the console.  For instance,

[Enter Juliet]
[Enter Romeo and Juliet]

Hamlet:
Thou art as sweet as the sum of the sum of Romeo and his horse and his black cat! Speak thy mind!

[Exit Romeo]
[Exeunt Romeo and Juliet] [Exeunt]

My only point is - Do you write your code pleasing to the eye?  Or is it a jumble of symbols barely comprehensible? 

I am all for bringing a sense of beauty to our coding, and am open to suggestions.

Interested in your comments,

Jonathan Starr

posted @ Tuesday, January 22, 2008 1:58 PM | Feedback (0)
Monday, January 21, 2008
The Sesame Street Presentation Rule - Not #1

I just read through Jeff Atwood's recent post - The Sesame Street Presentation Rule - and it warrants a reaction.

The most important feature of a presentation is that it communicates how you can benefit your audience.  People are not actively trying to fund cartoons or quips as much as they are looking out for their own very personal needs (whatever that is).  So, it is vital that we analyze our audience for their needs - as needs differ.

Employees are generally interested in security, and possibilities for advancement.  Investors generally look for quick and sizable returns on investment. If you focus on the particular interests of your audience, there is very little need to be funny. 

Humor can help - I will concede.  But it is so difficult to be funny.

Hey, Jeff Atwoods' blog is a case in point.  Really not very funny, but he satisfies the needs of his readers to explore quirky topics.

Interested in your thoughts,

Jonathan

posted @ Monday, January 21, 2008 2:53 PM | Feedback (0)
Wednesday, January 16, 2008
Thought Experiment: Reforming Meetings

I just read an excellent article posted on XKCD on how to create a better IRC chat.

Basically, to keep chats interesting, the server boots out users who enter things already entered before.

Wouldn't that be good for corporate meetings? The rule could be amended: If someone says anything said before (even using different words), the person cannot speak again for the duration of the meeting. 

Imagine how much shorter meetings would be with this rule.  No more endless repetitions.  No more wasted time.

Another nice side effect is that meeting attendees might pay more attention to what is said - because they are enforcing the rule!

Interested in you thoughts,

Jonathan Starr

posted @ Wednesday, January 16, 2008 5:31 PM | Feedback (0)
Tuesday, January 15, 2008
Automatic Properties in C# - A Critique

improve my => 'code' Add to Google

In the latest release of Orcas, one of the new features provided is "Automatic Properties" which allows developers to use a shorthand like the following:

    public class Person {
    
        
public string FirstName {
            
get; set;
        
}

        
public string LastName {
            
get; set;
        
}        
        
        
public int Age {
            
get; set;
        
}
    }

and the compiler knows to interpret this as

    public class Person {

        
private string _firstName;
        private string 
_lastName;
        private int 
_age;
        
        public string 
FirstName {

            
get {
                
return _firstName;
            
}
            
set {
                _firstName 
= value;
            
}
        }

        
public string LastName {

            
get {
                
return _lastName;
            
}
            
set {
                _lastName 
= value;
            
}
        }        
        
        
public int Age {

            
get {
                
return _age;
            
}
            
set {
                _age 
= value;
            
}
        }
    }


Prima facie, this looks like a good thing.  The developer is typing less code, and still has hooks in property accessors to perform validation, or needed side effects from value changes.

But I have a few problems with this shorthand.

Criticism 1

Why is this shorthand needed when there is a snippet (prop) that provides full property accessors, with better hooks for inserting custom actions like validation?

Criticism 2

I think that the shorthand looks too much like the signature of a method normally found in an interface, not a class.  The only difference appears to be an access modifier. So I find the shorthand syntax is confusing...


What do you think?

Jonathan Starr
posted @ Tuesday, January 15, 2008 8:00 PM | Feedback (3)
Sunday, January 13, 2008
Instructional Video #3 for Mobile Phone Project management

I did one more video with a friend today for 1CCN.COM - which is a mobile phone project management toolset custom designed for the construction industry.

The video below shows you how a user can add time entries via mobile phone to a project.

I am very interested in your comments!  Is the video easy to understand?

Jonathan

 

posted @ Sunday, January 13, 2008 8:17 PM | Feedback (0)
Saturday, January 12, 2008
Reminder

improve my => 'code' Add to Google

Just a quick reminder to the Saint Louis developers out there.  There is another Saint Louis .NET User Group meeting on Monday, January 14th at 2 City Place.

Details are here in the updated Saint Louis Microsoft Technology calendar.

Hope to see you there!

Jonathan

posted @ Saturday, January 12, 2008 9:46 PM | Feedback (0)
1st Instructional Video
I have been helping a friend finish a mobile web application for his new business (www.1CCN.com), and posted below are my first attempts for making instructional videos.  Windows Movie Maker (which comes with Vista) was a blast - really easy to use.

Any comments are appreciated - btw, we will be adding Ajax to the budget entries tomorrow.

Thanks!

Jonathan



Adding a contact to the Contractors' Collaborative Network



Creating a Project in the Contractors' Collaborative Network
posted @ Saturday, January 12, 2008 8:55 PM | Feedback (0)
Friday, January 11, 2008
Critique of Richard Bookstaber's, “A Demon of Our Own Design”

I just finished Richard Bookstaber's new book, A Demon of Our Own Design: Markets, Hedge Funds, and the Perils of Financial Innovation, and he makes some fair points.

He asks a very important question in the book, in my opinion, “Why have economic cycles become less extreme while financial cycles have become more extreme?”. 

After all, our knowledge of financial instruments has increased over time, we use computer applications to help us hedge risk in better ways today, and we have better and more reliable streams of information for traders to navigate today's financial waters.

His answer, which I find intriguing, is that liquidity is the most important determinant of short term price swings (which is very different from the conventional answer - fear and greed).  He points out that financial instruments with different risk profiles quickly became correlated with each other because they were packaged together.  (Perhaps traders now have better means of smelling blood in the waters as well?)

I suppose this may be the reason we see Bank of America purchasing Countrywide today.  Bank of America had a lot of information about Countrywide because of their $2 Bn in the company over the summer, and they probably realized that providing liquidity to Countrywide's positions would not only enhance the value of today's $4Bn takeover, but also the existing $2 Bn investment made earlier.

Interested in your thoughts,

Jonathan

 

posted @ Friday, January 11, 2008 6:27 PM | Feedback (0)
Re-Adding Service References
improve my => 'code' Add to Google

While using Visual Studio 2008, I made the mistake today of dropping and re-adding a WCF service reference.  If you do this, not all of the service operations and exposed proxy types are recreated in the References.cs file.

If you made my mistake, cleaning the solution (right click on the solution and choose -> Clean Solution) will clear out the problem.

And in the future, I will be updating service references instead.

Hope this helps you out!

Jonathan

posted @ Friday, January 11, 2008 5:30 PM | Feedback (0)
News
Jonathan Starr is a developer in Saint Louis, MO. He holds an MBA in Finance from Columbia Business School and earned his MCSD from Microsoft.


All statements in this blog are personal opinions and do not reflect the opinions of his employer.





Related Sites
Join My Community at MyBloglog!

Tag Cloud