To put some content here, go to Site Admin -> Appearance/Presentation -> Widgets -> Select "Left Sidebar" -> Click "Show" -> Click on "Add" on one of the widgets on the left side -> Click "Save changes" -> Done

Twitter is the Web now let’s get it right

So everyone loves twitter right the biggest problems with it is that it is it can’t scale, it is clunky and it is one site. What should really happen is that we should be able to distribute tweets across the web. All of my past tweets should be stored as URLs that any search engine can search and not just on twitter but on a site that I can move to different host over time.

There are 3 main architectures that internet professionals need to create.

First we need some sort of pubsub. There needs to be away for developers to add your stream to constantly updating apps. This will take something like .Net Services or a queuing system in the cloud that can get around fire walls. Every user will need to have a URL. This is how to subscribe to the user as well as a way to get the history. This idea is very much like openID. This allows twitter to scale and let many services host your tweets and aggregate your tweets. They could even handle security for you letting people get access to your tweets or not. If you need to switch hosts just move your url.

New twitter URLS
yourHost/username/subscribe/someFilter
yourHost/username/history/wall/whatever

2.) The searchable. Real time search is very important and people like google and others that are good at taking data can subscribe to all tweets and make them searchable only there is no monopoly this is true internet. The best algorithm and value add wins plus new people can get in the game with history.

3.) Reply’s go to the url of friends that have subscribed to you. something like theirHost/username/incoming

the whole point of this post is to describe a way of tweets using the current architecture of the internet to scale and finally make the “web” real time.

my .02 please let me know what you think.

I got social:
  • Facebook
  • Mixx
  • Google Bookmarks
  • DotNetKicks
  • LinkedIn
  • Reddit
  • Technorati
  • Yahoo! Buzz
  • Digg
  • TwitThis
  • del.icio.us

Using GitHub.com from Windows for .NET samples

First off this guy has a great article on it here.

I will add my 2 cents and why I am using it. The real reason I am even talking about github is that I need a place to upload sample code. What I really hate about the way that people upload code to site is that I need to download a zip to really see it. I like to browse code. I like to read and try and use the concepts in stuff I do so I looked at Codeplex and google code but decided that I liked Github.com because at some point I could use it for real enterprise SCM.

Quick comparison of all three I looked at

Google Code
– Offers some privacy
– uses SVN
– allows code browsing
– Maximum created projects (10 at the time of this writing)

Codeplex.com
– Offers some privacy
– uses SVN / TFS
– allows code browsing
FAQ

GitHub.com
– Offers privacy
– Can Upgrade to Subscription
– uses GIT
– allows code browsing
Great list of Guides

later

I got social:
  • Facebook
  • Mixx
  • Google Bookmarks
  • DotNetKicks
  • LinkedIn
  • Reddit
  • Technorati
  • Yahoo! Buzz
  • Digg
  • TwitThis
  • del.icio.us

Silverlight Virtual Control as a Bookmarklet

Silverlight Virtual Earth Contorol CTP

The Silverlight Map is great, fast and is really easy to code. You only need to know C# and not JavaScript. This is huge if like me you are a .Net guy. I have had some experience with Google maps and all that javascript is not fun. The layering on top of the map works just like you think it should and you can add complex controls to the map with ease just AddChild(complexControl, location). I really see this as being the future of mapping applications.

What I really want to be able to do is be on a web page that has an address on it and bring up a map of where that address is. This calls for a bookmarklet. A bookmarklet is a javaScript function that you can run from you bookmark bar.

Below Creates a new div and adds the div to the body of the page. This also adds jQuery and the silverlight app to the dom so that they can both be displayed.
Example Code»

If you download the SDK for the Map control you will find an example of how to load the Map in Silverlight. I will post my latest code when I am done.

later.

I got social:
  • Facebook
  • Mixx
  • Google Bookmarks
  • DotNetKicks
  • LinkedIn
  • Reddit
  • Technorati
  • Yahoo! Buzz
  • Digg
  • TwitThis
  • del.icio.us

  function Show() {

        (function() {
            if (!(typeof jQuery != 'undefined')) {
                var s = document.createElement('script');
                s.setAttribute('src', 'js/jquery-1.3.2.min.js');
                document.getElementsByTagName('head')[0].appendChild(s);
            }

            var el = document.createElement('div');
            el.id = "MapDivCreate";
            el.style.position = 'fixed';
            el.style.height = '100%';
            el.style.width = '410px';
            el.style.margin = '0 auto 0 auto';
            el.style.top = '0';
            el.style.left = '70%';
            el.style.padding = '5px 10px 5px 10px';
            el.style.backgroundColor = 'Green';
            var frame = document.createElement('iframe');
            frame.style.height = '100%';
            frame.style.width = '100%';
            frame.src = 'Content/MapFramePage.aspx';
            el.appendChild(frame);

            document.getElementsByTagName('body')[0].appendChild(el);

        })();

More Mocking with Rhino Mocks

Here is a sample of a test class I wrote. Don’t for get to use “using Rhino.Mocks;” at the top. This just shows how you record the expectation and you can playback those expectations. I will go into a much more complex scenario when you might want to know what was passed into the mocked function.


   public interface MyOriginalInterfaceType
  {
      public bool DeleteFromDB();

   } 

    public class MyObjectToTest
   {
        private MyOriginalInterfaceType _originalInterface;
        public MyObjectToTest(MyOriginalInterfaceType interface)
        {
             _originalInterface = interface;

         }

          public void Delete()
          {
               _originalInterface.Delete();
          }
   }

    [TestClass()]
    public class MyTest
    {
        MockRepository mockRepository;
        MyOriginalInterfaceType myMockedInterface;

        [TestInitialize()]
        public void MyTestInitialize()
        {
            mocks = new MockRepository();

            // create a strict Mock for my original object
             myMockedInterface= mocks.StrictMock< MyOriginalInterfaceType>();
        }

        [TestMethod()]
        public void MyTestMethod()
        {
            // Go ahead and record the expected function calls
            using (mockRepository.Record())
            {
                Expect.Call(myMockedInterface.Delete()).IgnoreArguments().Return(true);
            }

            using (mocks.Playback())
            {
               MyObjectToTest obj = new MyObjectToTest(myMockedInterface);
                obj.Delete();
                myMockedInterface.VerifyAllExpectations()
            }
        }

later.

Technorati Profile

I got social:
  • Facebook
  • Mixx
  • Google Bookmarks
  • DotNetKicks
  • LinkedIn
  • Reddit
  • Technorati
  • Yahoo! Buzz
  • Digg
  • TwitThis
  • del.icio.us

Mock Framework

Rhino Mocks

This really is a great mocking framework. There are a few things you are going to have to get used to if it is the first time using a mocking framework.

1.) Why do you need a mocking framework?
After you start to apply things like inversion of control and single responsibility you get smaller and smaller pieces of code to work with. When you decide it is time to unit test your code you will want to test the code without having to instantiate the objects that it uses. This is where the mocking frameworks comes in. Mocks allow you to test a class without actually creating instance(s) of the class that it depends on.

2.) Why rhino Mocks?
It is really are easy to use and powerful once you get used to it. Here is a link to a very helpful pdf.

3.) What was the hardest thing to get?
For me the hardest thing to get was the record / playback. What you want to do is record things while you are testing and then you can playback what happened you can actually see what values were passed to each of your mock objects. This is useful if you would like to check what exactly was passed to the mock object (pretty cool).

Just some interesting things about rhino mocks and sample code will follow.

later.

I got social:
  • Facebook
  • Mixx
  • Google Bookmarks
  • DotNetKicks
  • LinkedIn
  • Reddit
  • Technorati
  • Yahoo! Buzz
  • Digg
  • TwitThis
  • del.icio.us

Quick Property Query To C# with Attribute

Here is a quick sql 2000 select statement that takes a table name and produces a list of c# class properties. Let me know if this was worth a post.

Select
'[DataInfo("' + Name +'","' + columnname + '",' + CAST(ColumnLength  AS varchar)  + ',' + CAST(isNullable  AS varchar) + ')]'
+ ' public ' + csharpType + ' ' +  columnname + '{get;set;}' as property
from (SELECT     CASE col.xuserType
			WHEN 56 THEN 'int'
			WHEN 167 THEN 'string'
			WHEN 59 THEN 'decimal'
			WHEN 175 THEN 'char'
			WHEN 61 THEN 'DateTime'
			WHEN 35 THEN 'string'
			ELSE 'Other' END AS csharpType,
			col.length as ColumnLength,
			col.name as ColumnName,
			col.id, col.xtype,
			col.typestat,
			obj.Name,
			col.isnullable
			FROM         dbo.sysobjects AS obj INNER JOIN
                      dbo.syscolumns AS col ON obj.id = col.id
) as FinalTableView
	Where Name = @YourTableName

This is just a simple way to get this into .net ready code and then update.

later.

I got social:
  • Facebook
  • Mixx
  • Google Bookmarks
  • DotNetKicks
  • LinkedIn
  • Reddit
  • Technorati
  • Yahoo! Buzz
  • Digg
  • TwitThis
  • del.icio.us

Inversion of Control:Runtime knows best. Part 2

In part 1 of this post I talked a little about Inversion of Control and why it is useful.  Now I want to go into a situation you could use it.  Because of the distributed nature of the systems in our production environment applications are difficult to test by themselves. 

We currently have a batch process application that sends messages to service1 over MSMQ via WCF as fire and forget.  When the message is picked up by the WCF service1 it processes the message by sending multiple synchronous messages via ws-* to service2.  Even saying this makes it sound complex now try testing service1.

Example Code»

To test service1 you need to have MSMQ setup and have service2 running somewhere set up correctly.  Now in production their are multiple people to take care of this problem and multiple servers that are always up.  In Dev and some QA we do not always know the status of the entire enterprise applications. So what do we do?  Take the time to create/set up service2?

No, Hopefully we abstracted service2 so that service1 sets it up at run-time.  Since we are using IoC in our service1 what we can do is pass in our test “service2 implementation” into the classes that need to access it.  If we didn’t write a test implementation of servce2 in our service1 the change is easy and fast becuase we pass in the class to our business objects.

This saves us all the service2 set up time when just fixing a bug in service1.  It also helps us when tracking down error messages and bugs so that we know where to look.  If we take the time to look across the enterprise or narrow or focus to the run-time – application that you are changing.

 

later

I got social:
  • Facebook
  • Mixx
  • Google Bookmarks
  • DotNetKicks
  • LinkedIn
  • Reddit
  • Technorati
  • Yahoo! Buzz
  • Digg
  • TwitThis
  • del.icio.us

namespace Service1
{
     public class BusinessLogic
     {
        IService2 _service2;
        public BusinessLogic(IService2 service2)
        {
          return  _service2 = service2;
        }
        public Process()
        {
             _service2.Call();
        }
     } 

     public class Service1
     {

        public string Call()
        {
           BusinessLogic bl;
           if(QAInstance)
           bl = new BusinessLogic(IService2QaInstance);

           if(ProdInstance)
           bl = new BusinessLogic(IService2QaInstance);

          return bl.Call();
        }

     }
}

namespace Service2
{
      public interface IService2
     {
         string Call ();
      }
     public class Service2
     {
         public string Call ()
         {
           // some process
         }
      }
}

Inversion of Control:Runtime knows best. Part 1

A lot has been said about the importantce of IoC.  I guess I can add my two cents but what it really comes down to for me is change.  How easy is it for me to change my code?  Change is real as if you don’t know., IoC  is a way for us as software developers to handle change from the top-down instead of the bottom-up.  

I think this is more prevelent today becuase of the service oriented or distributed world we architected in,  which will continue to grow.  For example, When I delete a user in my application I might actually end up calling multiple things.  Calling a MSMQ service to remove the user from a mailing list, call a WCF service to cancel pending orders and call the database to delete some meta data.  

Now I used to think lets put the delete function inside the user object and then the user knows how to delete itself. But at that point does a user create a reference to 2 services and the data acces layer?   The user would then have to know how we are going to connect to those services(MSMQ, WCF) or at least the facade object that the function has to call which is going to couple the user object to multiple implementations.

What we would like to do is allow the application or runtime that is consuming our objects to hand out the current implementation of how things work.  It is like waiting till the last minute to make a descision so you know as much as possible before the descision has to be made.

What can we know at runtime?  We can know a lot more than we do during development.  QA box names. Service outages. Test runs in production.  All of theses things are runtime enabled so if our runtime can make descions for our more static class that a huge win.

In Part 2 I want to talk about how we can set up our application development teams to take advantage of this and how it might affect runtime language choices and promotion through the process.

later.

I got social:
  • Facebook
  • Mixx
  • Google Bookmarks
  • DotNetKicks
  • LinkedIn
  • Reddit
  • Technorati
  • Yahoo! Buzz
  • Digg
  • TwitThis
  • del.icio.us