I was wondering if Angular is going to release TypeScript definition for their framework. So I post a comment, few minutes later I got reply from Rob.
I recently pushing and dragging myself to learn Java script and Angular framework at the same time. I have to admitted that, as a C# developer for so long I was spoiled by strong type world, great IDE Visual Studio and XAML. Angular is a great framework to built a SPA (Single Page Application), but in term of UI designer tool, it kind of put me back at least 3 years to the past comparing to Expression Blend XAML designer. On other side, maintenance a hugs Java script source code can be a big challenge for C# developer, if we don't follow best practice and avoid shoot our self in the foot. Please read "Java script: the good parts" by Douglas Crockford. Yesterday, I listened to .Net Rock podcast # 1006 about Angular, an interview with Rob Eisenberg. It was a great talk and give me a big confident that future of Angular 2.0 will be a great tool to developer SPA for Mobile browser. I was wondering if Angular is going to release TypeScript definition for their framework. So I post a comment, few minutes later I got reply from Rob. I am glad that Angular team really like TypeScript, and releasing definition file is at least in the discussion too.
0 Comments
I recently played with Azure Cloud Service aka Web or Worker Role. I notice that it toke long time to deploy my package. In the package I had:
Then I run 20 client app simultaneously from my home, and run another 20 client app from another Internet end point (external IP address). I keep it running for 1 hour without any error. I was expecting
How come it take so long to deploy?Turn out that I have wrong expectation with it. ACS does what it suppose to do. To me ACS is in a blur line between Platform as a Service (PaaS) and Infrastructure as a Service (IaaS).
Here are what I'll use ACS for:
Download source code from: GitHub. It is hard to ignore Dependency Injection in software development these days, since all the cool kids are bragging about it. In this article I use Ninject, because it has better support from developer community due to its large adoption. So I can seek out for help quickly. However when it come to dealing with Generic Interface, we need to tell Ninject what Generic Interface bind to what Concrete Class. Just like the following syntax: this.kernel = new StandardKernel(); The problem is when you add more Message type and its Message Handler, you need to add extra code to configure the new messages and it handlers. I am a lazy developer, I want to write the code that is agnostic enough and will always work without code changing. Here is what you need to do: Install these 2 NuGet Packages:
this.kernel.Bind(x => x.FromThisAssembly() .SelectAllClasses().InheritedFrom(typeof(IMessageHandler<>)) .BindAllInterfaces()); Basically it tell Ninject's configuration to find all Class that inherited from Generic Interface IMessageHandler<> then register all of them. Let take one step back and look what I am trying to do with this small project. I need to process a collection of different type of message. Each type has it own handler class. Here are two types of message: PersonMessage and CoffeeMessage, that both are inherited from BaseMessage class. public class BaseMessage public class PersonMessage : BaseMessage public class CoffeeMessage : BaseMessage Here are the two message handlers: PersonMessageHandler and CoffeeMessageHandler, that both are implements Generic Interface IMessageHandler<T> public interface IMessageHandler<T> where T : BaseMessage public class PersonMessageHandler : IMessageHandler<PersonMessage> public class CoffeeMessageHandler : IMessageHandler<CoffeeMessage> This is where system process the message. The code work fine, but it just fall into the same problem as mentioned above. Every time I add another message type I need to change the code that invoke the Handle method for each message. var messageList = new List<BaseMessage>(); messageList.Add(new PersonMessage() { Name = "Jame", Age = 20 }); messageList.Add(new CoffeeMessage() { Name = "Mocha", Volume = 1 }); messageList.Add(new PersonMessage() { Name = "Ken", Age = 15 }); messageList.Add(new CoffeeMessage() { Name = "Cappuccino", Volume = 1 }); messageList.Add(new PersonMessage() { Name = "Tim", Age = 35 }); messageList.Add(new CoffeeMessage() { Name = "Late", Volume = 1 }); foreach (var message in messageList) Here is the agnostic code to process what ever message I will add in the future. this.ProcessMessage(message); |
AuthorEnjoy my day working as a software developer, love writing code, landscaping photography and hiking. Archives
April 2015
Categories
All
|