Windows Mobile Support

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Tuesday, 30 October 2012

Windows Azure Tools - Error 0x80070643: Failed to install MSI package

Posted on 13:29 by Unknown
Today I had to install Visual Studio 2012 and Windows Azure 1.8 SDK for a new project. Everything went as a charm; I didn’t have any kind of problems. But after a while I realized that I had a project that is written in .NET 4.0 and use Windows Azure 1.6 SDK and an update to 1.8 is in this moment is not possible.
After installing Visual Studio 2012 and Windows Azure 1.8 SDK I tried to run my old project, but without success. In that moment I realize that I have a big problem, because I will not be able to provide support for that project. I uninstall Windows Azure 1.8 SDK, installed 1.6 but without success. I tried to uninstall Visual Studio 2012 with success. After that I accessed Windows Azure web site and download Windows Azure 1.6 SDK and Windows Azure Tools 1.6 but I received an error when I tried to install Windows Azure Tools 1.6.
Error 0x80070643: Failed to install MSI package
I tried to repair Visual Studio 2010, uninstall and reinstall all the kits related to Windows Azure but with the same result when trying to install Windows Azure Tools 1.6.
Error 0x80070643: Failed to install MSI package
I could not use Last Good Know Configuration because installing Visual Studio 2012 and other tools created a lot of restoring points and all of them were from today. I started to think at the “black magic solution”. Clean install of Windows on the current machine or on a virtual machine. But before this I had a great idea.
What about trying to install Windows Azure Tools 1.6 using Microsoft Web Platform Installer. And surprise. I was able to install with success all my tools. In this moment I have the machine in the state that was in this morning.
About Visual Studio 2012 and Windows Azure 1.8 SDK. For now I will create a virtual machine with a cool configuration W8 + VS2012 + Windows Azure 1.8. In the future, I will install as default machine Windows 8 with VS2012, but in this moment my first priority is to offer support to my clients.
Read More
Posted in Azure, Windows Azure | No comments

Visual Studio - How to see the source code of .NET framework

Posted on 07:00 by Unknown


Every time when I’m installing Visual Studio one a clean computer I have problems remembering the steps that need to be done on Visual Studio to see the source code of the .NET framework.
In the next lines we will look over the steps that need to be done. Next time when I will need to make this configuration I will come back to this post.
We need to go in Visual Studio menu, under Tool->Options and select the Debugging tab. In the general node we will need to check/uncheck the following options:

  • Uncheck the “Enable Just My Code (Managed only)”
  • Uncheck “Require source files to exactly math the original version”
  • Check “Enable source server support”

In this moment we are almost done, the only think that we need to do is to double check under Symbols node that “All modules, unless excluded” is checked. In general I prefer to create a custom path where the symbols are downloaded.
While you are debugging, if you have any kind of problems loading this symbols, go on the call stack, right click on the stack and check if “Symbol Path” is selected in the “Load Symbols From”.
First time when you will debug after these changes, you will notify the application will run slower, because pdb files are downloaded.
Good luck!
Read More
Posted in visual studio | No comments

Monday, 29 October 2012

Design a state machine mechanism using Windows Azure Service Bus (part 2)

Posted on 08:32 by Unknown
In my last post I presented how we can implement a state machine using Windows Azure Service Bus Topics. In this post we will see the real code that we need to write to make this possible.
We will start from a simple example. Let’s imagine that we have 3 states machines:
  1. Added
  2. Initialized
  3. Processed
Each state change will required a custom action to be executed. When changing the state from Added to Initialized we will need to calculate some values. Changing the state from Initialized to Processed will required to store the sum value in a repository. Messages in state Processed will be logged.
We will implement this using Windows Azure Service Bus Topics. For each state we will have a different subscription that will process messages with the given state. Each action that needs to be done at each step will be made by the process (machine) that receives the given message from subscription.
In the next part of the post we will cover all the steps that need to be done to be able to implement this.
First of all we need to create a new Service Bus Topic. Before creating a Service Bus Topic you should always check if a topic with the specific name was already created.
var namespaceManager =
NamespaceManager
.CreateFromConnectionString(CloudConfigurationManager.GetSetting("ServiceBusConnectionString"));

if (!namespaceManager.TopicExists("myFooTopic"))
{
namespaceManager.CreateTopic("myFooTopic");
}
After this step, we will need to create a subscription for each state. For the first step, the sum that needs to be computed can be done directly from subscription. We can specify in the action of the subscription the sum calculation.
RuleDescription ruleDescription = new RuleDescription()
{
Action = new SqlRuleAction("set sum = value1 + value2"),
Filter = new SqlFilter("state = added");
}

namespaceManager.CreateSubscription(
"myFooTopic",
"addedSubscription ",
ruleDescription);
Even if the calculation is made automatically, by Service Bus Topic, we will need to take the message from the current subscription, change the state and add it back to the topic:
TopicClient topicClient = TopicClient.CreateFromConnectionString(
CloudConfigurationManager.GetSetting("ServiceBusConnectionString"),
"myFooTopic");

SubscriptionClient subscriptionClient = SubscriptionClient.CreateFromConnectionString(
CloudConfigurationManager.GetSetting("ServiceBusConnectionString"),
"myFooTopic",
"addedSubscription");

BrokeredMessage brokeredMessage = subscriptionClient.Receive();
if(message != null)
{
try
{
BrokeredMessage newMessage = new BrokeredMessage();
newMessage.Properties["sum"] = message.Properties["sum"];
newMessage.Properties["state"] = "initialized";
topicClient.Send(newMessage);
message.Complete();
}
catch (Exception)
{
message.Abandon();
}
}
In this moment we have a mechanism that process messages that are in the first state. A similar code need to be implemented for the next 2 states. For the next state we will need to create the subscription:
RuleDescription ruleDescription = new RuleDescription()
{
Filter = new SqlFilter("state = processed");
}

namespaceManager.CreateSubscription(
"myFooTopic",
" processedSubscription ",
ruleDescription);
After this we will need to implement the action that need to be done for messages with the given state:
TopicClient topicClient = TopicClient.CreateFromConnectionString(
CloudConfigurationManager.GetSetting("ServiceBusConnectionString"),
"myFooTopic");

SubscriptionClient subscriptionClient = SubscriptionClient.CreateFromConnectionString(
CloudConfigurationManager.GetSetting("ServiceBusConnectionString"),
"myFooTopic ",
"processedSubscription");

BrokeredMessage brokeredMessage = subscriptionClient.Receive();
if(message != null)
{
try
{
var sum = message.Properties["sum"];
// Save the sum in the repository.
BrokeredMessage newMessage = new BrokeredMessage();
newMessage.Properties["sum"] = sum;
newMessage.Properties["state"] = "processed";
topicClient.Send(newMessage);
message.Complete();
}
catch (Exception)
{
message.Abandon();
}
}
For the next step, the code is very similar; I will not describe the code again. For the last state action we don’t need to add the message again to the topic, because the message is in the last state. We need only to write the data to the log.
TopicClient topicClient = TopicClient.CreateFromConnectionString(
CloudConfigurationManager.GetSetting("ServiceBusConnectionString"),
"myFooTopic");

SubscriptionClient subscriptionClient = SubscriptionClient.CreateFromConnectionString(
CloudConfigurationManager.GetSetting("ServiceBusConnectionString"),
"initialized",
"processedSubscription");

BrokeredMessage brokeredMessage = subscriptionClient.Receive();
if(message != null)
{
try
{
Trace.Write(message.Properties["[PropertyName]"]);
Trace.Write("The ABC was processed");
message.Complete();
}
catch (Exception)
{
message.Abandon();
}
}
The last step is to write a message on the Service Bus Topic that has the first state.
TopicClient topicClient = TopicClient.CreateFromConnectionString(
CloudConfigurationManager.GetSetting("ServiceBusConnectionString"),
"myFooTopic");

BrokeredMessage message = new BrokeredMessage();
message.Properties["value1"] = 10;
message.Properties["value2"] = 40;
topicClient.Send(message);


After the message will be added to the topic, based on the status property, each subscription will process it. Each subscription will process only messages that have their specific status.
 In this post we saw how we can implement in Windows Azure Service Bus Topics a simple workflow that is based on the states.
Read More
Posted in Azure, Cloud, service bus, Windows Azure | No comments

How many fingers point can be tracked by Windows 8

Posted on 02:49 by Unknown
Windows 8 brought to us a native support for touch screens. This is a great feature that opens the tablets world for us.
For touch support, we have a lot of gestures that are built in. We need only to subscribe to the event that we want to listen. This can be very useful, because we don’t need any more to implement our custom gestures.
  • Tap - one finger touches the screen and lifts up.
  • Press and hold - one finger touches the screen and stays in place.
  • Slide - one or more fingers touch the screen and move in the same direction.
  • Swipe - one or more fingers touch the screen and move a short distance in the same direction.
  • Turn - two or more fingers touch the screen and move in a clockwise or counter-clockwise arc.
  • Pinch - two or more fingers touch the screen and move closer together.
  • Stretch - two or more fingers touch the screen and move farther apart.
If we need a custom gesture we can implement it without any kind of problem. This is not recommended because the user will need to learn new gestures for each application.
I received some question about how many fingers can be tracked in the same time by Windows 8. It seems that this is direct dependent to the hardware. WinRT API gives as the possibility to track each touch point separately with a unique id when the track point enters in our component. We can store these items in a collection (dictionary with the pointer ID as key). When a new pointer appears in our component we can add it to our collection and when the pointer exits our control we will need to remove it from our collection. In this way we will know how many finger points are in our controller.
The event that we need to use to track these actions is PointerMoved event of a container. The event will contains a method named “GetCurrentPoint”, that will return the current point that was moved. Each object of this type contains two properties that are very useful for us:
  • PointerId – The unique id of the pointer (each time when we touch the screen a new point with a new id will be generated).
  • IsInContact – Will tell us if the current pointer is still in contact (eq. when you remove the finger from the screen this method will be called with this property set to false – at this step we need to remove the pointer id from the collection).
Our code should look like something like this:
private void container_PointerMoved(object sender, PointerRoutedEventArgs e)
{
PointerPoint currentPointerPoint = e.GetCurrentPoint(myContainer);
var pointerId = currentPointerPoint.PointerId;
if (!currentPointerPoint.IsInContact
&& collection.Contains(pointerId))
{
collection.Remove(pointerId);
return;
}
if (currentPointerPoint.IsInContact)
{
// Check the pointer location - Position.X and Position.X properties
collection[pointerId] = ...;
}
}
It seems that the number of maxim fingers that are supported by Windows 8 is directly dependent by the hardware.
Read More
Posted in Metro App, windows 8, windows store application | No comments

Tuesday, 23 October 2012

Design a state machine mechanism using Windows Azure Service Bus (part 1)

Posted on 14:53 by Unknown
In this post we try to see a possible solution to implement a simple state machine (with a simple workflow) over Windows Azure Service Bus.
Let’s imagine a system that needs to process over 1 million requests per day. Each request that enter in the system will pass through different statutes until the process will be finished. If we have simple rules, it will be very easily for us to implement a system that will process each request and change the state of our request.
This can be imagined as a simple workflow, where a request flows from one state to another. At each step, we are making executing a small action. The big question here is how we can design a solution in a way where we will don’t have any kind of scalability problems.
The biggest problem that can appear at this step is related to scalability and distribution the logic over machines. This can become a nightmare when death-locks appears or when the system will reach his limits. The costs of hardware’s that will help us to survey another day can be enormous. 
We will see a simple solution that uses Windows Azure Service Bus to resolve our problem. In the next post we see how easily we can scale this solution.
Let’s assume that each request will go through 4 states before it will process completely. Each action that need to be done implicate an external system or an internal system that was already implemented.
For this case we can use Windows Azure Service Bus with success to implement a mechanism that will send a request from one state to another. In this way we will have reliability on our site. Not only this, we will not have any kind of problem with losing the requests that has a specific state if something happens with the system.
In this first solution, we will use Windows Azure Service Bus Topic. As we already know, Windows Azure Service Bus Topic permit give us the possibility to send the same message to more than one listener. From some perspective it is very similar to message broadcast. Each listener need to listen the topic through a subscription.
What is very useful at this is what we can with a subscription. We have the possibility to have not only more than one client to our subscription, but we can define custom rules. Using these rules we will be able to define what type of messages will be accepted by our subscription.
If a subscription will accept only messages that has a property with a specific value, than we will be able to process only messages with a specific state by our subscription. After the message is processes, we can change create a new message with the new state and send it back to the Windows Azure Service Bus Topic.
The system would look something like this:

As we can see, we use the same topic to add messages that are in a new state. Each subscription will process messages on the given state. In this current implementation, we are using Windows Azure Service Bus Topics because we don’t want to use a different place to store each message that has a different state. In the same time, for each subscriber we can have more than one listener. For the states where we know that computing power is more expensive, than we can allocate more listeners.
In the next post we will see how we can make this system more scalable using Windows Azure Service Bus features.
Read More
Posted in Azure, Cloud, service bus, Windows Azure | No comments

Friday, 19 October 2012

Day 4 of Software Architecture 2012 & Agile and OO design

Posted on 16:18 by Unknown
Today was the last day of Software Architect 2012. Last day was dedicated to workshops and I decided to join Allen Holub session: “Agile/OO design from start to finish”. After these days I become a fan of A. Holub and I hope that I will be able to implement a correct OO design. It is pretty challenging, but I promise that I will try to write about this in future.
Here are some notes from the presentation that I considered important. A part of them are well known by all of you:
Agile is based on communication, but there are people that will not be able to integrate in a team environment. Even if they are great on technical side and have a lot of knowledge, they are not able to communicate and to share data. Sharing is one of the most important things in Agile. The biggest enemy for Agile is EGO. Because of this people will not be able to communicate and different roles will appear – “I am the MASTER and the team need to do as I say.” – WRONG.
When we are talking about user-stories, management should understand the concept of points and the relations between points and duration – there is no relationship. Also when the team say, there are 50% percent chances to not be able to finish at time, than the chances are pretty high.
If you have a bunch of user-stories, start with the one that are the most risky. You will need time to clarify and resolve them. Also if you have a complicate or a user story that is very big than you should slit him? One good solution here is for the first sprint to consider only one happy flow, after that another, or an exceptional flow and so on. In this way we will be able to make it more and more complex at each iteration. Your scope is to have something that is fully functional at the end of every iteration.
Be strong and in the moment when someone wants to take off a man from the team say “NO!” This action can affect the project velocity; because of this there are chances not to finish all the user stories at the end of the iteration.
I didn’t use the SCRUM and SPRINT terminology.  Why? SCRUM is not the only way to be AGILE. From some perspective SCRUM is not agile, in the current “implementation”.
I will finish this post blogs about this conference with two cited that I heard today and I like:
“A ‘bug’ is not a logic error; it is a missing unit test.”
“Each team member is responsible for his own word and the team is responsible for the entire project (all the code and artifacts that are generated).”

Day 1
Day 2
Day 3
Day 4 
Read More
Posted in | No comments

Thursday, 18 October 2012

Day 3 of Software Architecture 2012 & Basic Principles of an Object

Posted on 16:39 by Unknown


Day 3 of Software Architect 2012 from London has passed. Today was a great day for science also. I went at 3 sessions sustained by Allen Holub. This man is not only a great speaker, but also knows the programing art extremely good.
Like in the other post about conferences where I participate, I will present in some words the things that I consider important.
Now we are living in a world that where OOP is everywhere. We are trying to create a model for each object from this world, but there are times when we forget base things. An object should expose a set of functionalities and not information. Sounds odd in our days, where everything is a POCO or a service, but this is how we should write our classes.
A world that is formed from POCO and services is not more than a procedural programing. In this case let’s change the name from OO to Procedural Programing. An object should be defined by what can do, what actions contain – public methods; and not by data that he contains. The content is not important; the functions that are exposed are the most important.
This is easy to say, but trust me, it is very hard to implement. For example when we have a class that want to calculate the price with VAD and deduction of a product we create a separate class for this. This calculator class will access the price property of our product. But we don’t need something like this. It is not wrong to have a method that returns the final price of the product in our product class. Yes, of course, as input parameter or in constructor we can specify an instance of an object that knows how to calculate (the final formula).
 There are lot more thing to talk about this subject. I promise that every week I will have a dedicated post related to OOP and design. Until than I will buy this book and start reading.
Day 1
Day 2
Day 3
Day 4 
Read More
Posted in eveniment | No comments

How to NOT expose a read only collection in C#

Posted on 01:01 by Unknown
These days I had the opportunity to make a review over an ecommerce application. They tried to use CQRS and they almost succeeded. 
I notified a problem on their queries classes that can become a big problem in time, if you want to sell this solution as a platform. Also, from some perspective, these problems also violate the CQRS principle.
Let’s see some code now:
public class Order
{
Collection<OrderItem> _items;

public IEnumerable<OrderItem> Items
{
get
{
return _items;
}
}
...
}
What do you see here strange?  We want to expose the OrderItem collection as a read only collection. To do this, we convert it to IEnumerable.
Hmmm… sounds good? Nope. Big mistake! Nobody stop us to convert the Items back to an ICollection and Add/Remove items from it.
Order order = new Order();
…
var orderItems = (Collection<OrderItem>)oder.Items;
What should we do? .NET framework has specials collections that can be used in these situations. I this case we should use IReadOnlyCollection<T>. This class will let the user to access items but he will not be able to modify the list (add or remove items from the collection).
To obtain the list as a read only collection we will need to use the AsReadOnly() method:
public class Order
{
Collection<OrderItem> _items;

public IReadOnlyCollection<OrderItem> Items
{
get
{
return _items. AsReadOnly();
}
}

...
}
Under the hood, this method will create a new collection that point to our original items.
When expose items as “read-only”, you should always double check. There are many methods that permit us to cast items.
Read More
Posted in C#, list | No comments

Wednesday, 17 October 2012

Day 2 of Software Architecture 2012 & How an architect should be

Posted on 14:44 by Unknown
This week I attended to Software Architecture 2012 conference from London. This was the second day of conference with 4 sessions per day on six tracks simultaneous. Here is the blog post of day one.
There were great sessions about how software design and architecture. I really enjoyed the keynote, where Simon Brown talked about how software architecture should be. One thing that he mentioned and I thing that is very important is what an architecture should do. I think that we know a lot of architecture that don’t write code anymore and don’t learn new technologies. They climb on the Ivory Tower and when we have a question throw a response like: “Implementation detail”. How you can define a solution when you don’t know the technology? Yep, that type of “guru” is only a PowerPoint architected and nothing more.
He is the perfect person that can draw components on a white paper and the first person that will run when a project will have problems. In that moment he will show the SAD (Software Architecture Documentation) but without giving you a real solution.
A pretty nice solution here (because you cannot be master of all technologies) is to let your ego at home and talk with technologies specialists. Design a good solution means making a team with this guys and with the rest of the developing team. They know the real problems that technologies have and what is the real limitation of a framework. On paper everything looks good.
As software architecture you should be able to share your knowledge, to couch and be mentor for other peoples. If you share your knowledge no one will come and steal your position. In reality, your value will increase because the team level will be higher and they will like working with you.
Don’t let people learn from their own experience. Try to share your experience with others, because we don’t want to reinvent the wheel again and again.
Day 1
Day 2
Day 3
Day 4 
Read More
Posted in design patterns, eveniment | No comments

Different methods to implement Message Aggregator pattern using Service Bus Topic – CorrelationId

Posted on 01:08 by Unknown
In one of my last post I presented the Aggregator Pattern. The main purpose of this pattern is the ability of the consumer to combine (aggregate) messages. This pattern can be implemented in Windows Azure using Windows Azure Service Bus Queues or Topics.
There are two different implementation for this pattern. The implementations are extremely different and also can affect our performance.
The first implementation requires using the Session support from BrokeredMessage. What this means from the code perspective? We need to set the Session each time when we want to send a message. The consumer will start to consume the messages with the specific session id. This solution is simple and it works great when we don’t have a lot of messages. For example if we have only 9-10 messages.
The first advantage of this implementation is on the consumer side. We don’t need to create the consume before messages are added to the Service Bus. The messages will be persisted in the Service Bus infrastructure. One of the downside of this implementation is the numbers of the consumers that we can have for the same session. We can have only one consumer. Because of this, if we want to broadcast a message to more than one consumer … we will have a problem. Also, the current implementation of session doesn’t use any kind of hashing for the id field. Because of this, if we want to process thousands of messages per second, maybe we will have a problem.
Producer
Stream messageStream = message.GetBody<Stream>();
for (int offset = 0;
offset < length;
offset += 255)
{
long messageLength = (length - offset) > 255
? 255
: length - offset;
byte[] currentMessageContent = new byte[messageLength];
int result = messageStream.Read(currentMessageContent, 0, (int)messageLength);
BrokeredMessage currentMessage = new BrokeredMessage(
new MemoryStream(currentMessageContent),
true);
subMessage.SessionId = currentContentId;
qc.Send(currentMessage);
}

Consumer

MemoryStream finalStream = new MemoryStream();
MessageSession messageSession = qc.AcceptMessageSession(mySessionId);
while(true)
{
BrokeredMessage message = messageSession.Receive(TimeSpan.FromSeconds(20));
if(message != null)
{
message.GetBody<Stream>().CopyTo(finalStream);
message.Complete();
continue;
}
break;
}
In the above example we are spitting a stream in small parts and sending it on the Service Bus.
But, what should we do if we want more than this. For example if we want to send messages to more than one consumer. In this case, if we need a way to group messages, like session we will need to think twice. We have some options for this situation. We can use the CorrelationId for this purpose of to add a custom property to the BrokeredMessage. CorrelationId use hashing, because of this is faster than the first option.
Both solutions will work, but we will encounter the same problem in both of them. How we can create a subscription for the given CorrelationId of property before starting receiving messages. This is the biggest problem that we need to resolve.
Before talking about this problem, I would like to talk a little about CorrelationId. This fields that can be set for each BrokeredMessage that is send on the wire. The advantage using is how we can define the filter. We have a pre-define filter for the CorrelationId that can be use when we want to create a subscription. Also each id is hashed; because of this the check is not made using string comparison.
But what is our problem using CorrelationId. We can broadcast a message to more than one subscriber, but… Yes, there is a but. We need to know the correlation id in the moment when we create the subscription. Why? Because the correlation id need to specify in the moment when we are creating the subscriber. Correlation id need to be specified for a subscriber as a CorrelationFilterExpression.
This is not the end of the road. We can find solutions for this problem. The trick is to notify the consumers before adding messages to the Service Bus Topic about the new group of messages that will be added to the system. For this purpose we can use the same Service Bus Topic, or another topic for this. We can have some special messages that have some custom property that describe what will be content of the next flow of messages with the given correlation id. Based on this information, each consumer will be able to decide if we want to receive the given messages.
The trick here is to register the subscribers before the moment when you start broadcast the messages with a given correlation id. The messages will be sending only to the subscribers that are already listening. Because of this, if you are not register from the beginning, there are chances to lose some of the messages.
You need some kind of callback or a timer. Because in a Service Bus pattern, the producer doesn’t know the numbers of subscribers, we cannot create a mechanism where each subscriber notifies the producer using another topic. We could have a waiting time (5s) on the producer side, after he sends the message that notify about the new correlation id.

Here is the code that we should have on the producer and on the consumer side.
-on the producer side, we need to create and send the message that contains the new correlation id. After this we will need to wait a period of time, until the consumers will be able to register to it.
BrokeredMessage message = new BrokeredMessage();
message.Properties["NewCorrelationId"] = 1;
message.Properties["Content"] = "new available cars for rent";
topicClient.Send(message);
Thread.Sleep(10000);
-creating the subscription that check if the message contains the property that specify the correlation id.
namespaceManager.CreateSubscription(
“myTopic”,
“listenToNewCorrelationIds”,
new SqlFilterExpression("EXISTS(NewCorrelationId”));
-create the consumer that processes the message, by creating a new subscription.
SubscriptionClient client =
SubscriptionClient.CreateFromConnectionString(
connectionString,
"myTopic",
“listenToNewCorrelationIds”);
BrokeredMessage correlationIdMessage = client.Receive();
namespaceManager.CreateSubscription(
“myTopic”,
“listenToMyCorrelationId”,
new CorrelationFilterExpression(correlationIdMessage.Properties["NewCorrelationId"]));
SubscriptionClient client =
SubscriptionClient.CreateFromConnectionString(
connectionString,
"myTopic",
“listenToMyCorrelationId);

... client.Receive() …
From performance perspective is would be better to use a different topic to send the messages that contains the new correlation id.
We can imagine a lot of implementation. What we need to remember when using correlation id that we need to create a subscription for the given correlation id before starting sending the messages to it. This waiting period that I described in the above paragraphs is the most challenging part. 
In conclusion, we should use session when we need to have only one consumer. If we need more than one consumer, than we should use correlation id.
Read More
Posted in Azure, design patterns, service bus, Windows Azure | No comments

Tuesday, 16 October 2012

Day 1 of Software Architecture 2012 & Unit Test Patterns

Posted on 15:29 by Unknown
This week I attended to Software Architecture 2012 conference from London. This was the first day of the conference and I decided to participate to a full day workshop about design patterns that was held by Andrew Clymer and Richard Blewett.
After this day I made a clearer image in my mind about some design pattern and how we can use it. There are a lot of new things that I discovered today. A part of them will be covered in future blog posts.
I looked over my today notes and I’m trying to extract some information for this blog post, but there are a lot of great things, that I feel the need to dedicate an entire post about it.
I will make only a small introduction into Unit Test Patterns. Any programmer should write unit tests. As we study design patterns in general we should learn also about unit test patterns.
In the last period of time the software industry become mature from many perspectives. The testing area, especially unit testing has reached his maturity. With this maturity, some pattern for unit testing appeared and guys don’t thing if you are a developer you should not know about this. This things are not for testers, are for you, for developers. Developers write unit test and not testers. Also understanding unit testing and pattern that are related to unit testing will improve our production code.
The simplest pattern is “Simple-Test”. This is the most basic unit test pattern that validate that for a valid input the expected outcome is obtained. In the case if our code contains an error trap, than we need to create a test for this case.
Suppose that we have a class Calculate that calculate the sum of two numbers. We will need to write a test that validate that the sum for two numbers is calculated correctly. This test will not guarantee that our code is valid and will work for any kind of input data. It only validate the most simple and basic happy flow.
public class Calculator
{
public int Sum(int a, int b)
{
if (a == 0)
{
return b;
}
if (b == 0)
{
return a;
}

return a + b;
}
}

[TestClass]
public class CalculatorTests
{
Calculator calculator=new Calculator();

[TestMethod]
public void SumOfTwoSimpleNumbersReturnsTheSumOfNumbers()
{
Assert.AreEqual(10,calculator.Sum(2,8));
}
}
Another well know pattern is “Code Path”. In the first pattern we didn’t look over the code. We tested it with the happy flow. The Code Path Pattern is used to test all the paths from our code. In this way, we will be more confident about out code quality. When we are writing this kind of unit tests we don’t look over the requirements, because we could miss some paths from our code. Code Path Pattern requires looking through the code in a “white box” method and covering all the possible paths. When we are using this pattern over legacy code you may be shocked about the number of lines of codes that are not used anymore.
[TestClass]
public class CalculatorTests
{
Calculator calculator=new Calculator();

[TestMethod]
public void SumOfTwoSimpleNumbersReturnsTheSumOfNumbers()
{
Assert.AreEqual(10,calculator.Sum(2,8));
}

[TestMethod]
public void SumWhenFirstNumberIsZeroReturnsSecondNumber()
{
Assert.AreEqual(5,calculator.Sum(0,5));
}

[TestMethod]
public void SumWhenSecondNumberIsZeroReturnsFirstNumber()
{
Assert.AreEqual(3, calculator.Sum(3, 0));
}

}
The last pattern that I will describe now is “Parameter Range”. When we are writing unit test, we should test our code with more than one input data. Even if we tested all the paths of our code this will not guarantee that our code is perfect.
For example in the previous example we should test what is happening if we calculate the sum of two big numbers that will generate a value that exceed the maximum value.
    [TestMethod]
public void SumOfTwoSmallNumbersReturnsTheSumOfNumbers()
{
Assert.AreEqual(7, calculator.Sum(3, 4));
}

[TestMethod]
public void SumOfTwoBigNumbersReturnsTheSumOfNumbers()
{
Assert.AreEqual(180, calculator.Sum(100, 80));
}

[TestMethod]
public void SumOfTwoPrimeNumbersReturnsTheSumOfNumbers()
{
Assert.AreEqual(24, calculator.Sum(11, 13));
}
I would like to congratulate the speakers of this workshop. I think that you made us thinking and see the design patterns from other perspectives.

Day 1
Day 2
Day 3
Day 4 
Read More
Posted in design patterns, eveniment, unit test | No comments

Monday, 15 October 2012

Windows Azure Service Bus Patterns - a comprehensive look at patterns that can be used in combination with Windows Azure Service Bus

Posted on 13:50 by Unknown


In the last period of time I posted a lot about pattern that can be used in combination with Windows Azure Service Bus. This is the list of all the patterns that I presented until now:
  1. Message Splitter Pattern
  2. Message Filter Pattern 
  3. Message Aggregator Pattern
  4. Recipient List Pattern  
  5. Resequencer Pattern
  6. Content-Based Router Pattern
  7. Scatter-Gather Pattern 
  8. Dynamic Router Pattern 
If you want to find more information about Windows Azure Service Bus Topic, please follow this LINK.
For more information about Windows Azure Serbice Bus Queue please follow this LINK.
Read More
Posted in Azure, design patterns, service bus, Windows Azure | No comments
Newer Posts Older Posts Home
Subscribe to: Comments (Atom)

Popular Posts

  • Service Bus Topic - Automatic forward messages from a subscription to a topic
    Windows Azure Service Bus Topic is a service that enables us to distribute the same messages to different consumers without having to know e...
  • CDN is not the only solution to improve the page speed - Reverse Caching Proxy
    I heard more and more often think like this: “If your website is to slow, you should use a CDN.” Great, CDN is THE solution for any kind of ...
  • Content Types - Level 6: Rich Media
    Level 6: Rich Media NOTE: This is part 7 of 7 and the conclusion of this continuing series; please see earlier posts for more background inf...
  • Publishing our CellCast Widget for iPad
    The rush has been on this week as our development team worked to design a new version of our CellCast Widget specifically for Apple's up...
  • Patterns in Windows Azure Service Bus - Message Splitter Pattern
    In one of my post about Service Bus Topics from Windows Azure I told you that I will write about a post that describe how we can design an a...
  • E-Learning Vendors Attempt to Morph Mobile
    The sign should read: " Don't touch! Wet Paint !" I had a good chuckle today after receiving my latest emailed copy of the eLe...
  • SQL - UNION and UNION ALL
    I think that all of us used until now UNION in a SQLstatement. Using this operator we can combine the result of 2 queries. For example we wa...
  • Cum sa salvezi un stream direct intr-un fisier
    Cred ca este a 2-a oara când întâlnesc aceasta cerința in decurs de câteva săptămâni. Se da un stream și o locație unde trebuie salvat, se c...
  • Task.Yield(...), Task.Delay(...)
    I think that a lot of person already heard about these new methods. In this post I want to clarify some things about these new methods that ...
  • Content Types - Level 4: Reference
    Level 4: Reference Materials & Static Content NOTE: This is part 5 of 7 in a continuing series; please see earlier posts for more backgr...

Categories

  • .NET
  • .NET nice to have
  • #if DEBUG
  • 15 iunie 2011
  • 15 octombrie 2011
  • 2011
  • abstracta
  • action
  • adaugare
  • ajax
  • Amsterdam
  • Android
  • aplicatii
  • App Fabric
  • Apple iSlate
  • array
  • as
  • ASP.NET
  • AsReadOnly
  • Assembly comun
  • async
  • Asynchronous programming
  • asyncron
  • Autofac
  • AutoMapper
  • az
  • Azure
  • Azure AppFabric Cache
  • Azure backup solution
  • Azure Storage Explorer
  • azure. cloud
  • backup
  • BCP utility
  • bing maps v7
  • BitArray
  • BlackBerry
  • blob
  • BlobContainerPublicAccessType
  • breakpoint
  • bucuresti
  • C#
  • cache
  • CallerMemberName
  • CellCast
  • Certificate
  • CES
  • change
  • ChannelFactory
  • clasa
  • classinitialize
  • clean code
  • click event
  • close
  • Cloud
  • Cluj
  • cluj-napoca
  • Code contracts
  • code retrat
  • codecamp
  • CollectionAssert
  • Compact Edition
  • compara
  • Comparer T .Default
  • CompareTo
  • comparison
  • comunitate
  • concurs
  • Conditional attribute
  • configurare
  • connection string
  • container
  • content type
  • control
  • Convert
  • convertAll
  • convertor
  • cross platform
  • CRUD
  • css
  • custom properties
  • custom request
  • DACPAC
  • Daniel Andres
  • data sync service
  • database
  • date time
  • datetime
  • debug
  • default
  • delegate
  • dependency injection
  • deploy
  • DeploymentItem
  • design patterns
  • Dev de Amsterdam
  • development stoage
  • dictionary
  • diferente
  • digging
  • director
  • Directory.Exist
  • disable
  • dispatcher
  • dispose
  • dropdown
  • dynamic
  • EF
  • email
  • encoding
  • entity framework
  • enum
  • enumerable
  • Environment.NewLine
  • error
  • error 404
  • error handling
  • eveniment
  • event
  • ews
  • excel
  • exception
  • exchange
  • exita
  • explicit
  • export
  • extension
  • field
  • File.Exist
  • finalize
  • fire and forget
  • Fluent interface pattern
  • format
  • func
  • GC.SuppressFinalize
  • generic
  • getdirectoryname
  • globalization
  • gmail
  • hackathon
  • Hadoop
  • handle
  • HTML
  • html 5
  • Html.ActionLink
  • http://www.blogger.com/img/blank.gif
  • HttpModule
  • IComparable
  • IE
  • ienumerable
  • IIS
  • image
  • implicit
  • import
  • int
  • internationalization
  • Internet Explorer
  • interop
  • Ioc
  • IP Filter
  • iPhone
  • iQuest
  • IStructuralEquatable
  • ITCamp
  • itspark
  • java script
  • javascript
  • July 2012
  • KeyedByTypeCollection
  • KeyNotFoundException
  • Kinect SDK
  • lambda expression
  • LightSwitch Microsoft Silverlight
  • linq
  • list
  • lista
  • lista servicii
  • liste
  • Live Connect
  • Live ID
  • load
  • localization
  • lock
  • m-learning
  • MAC
  • Mango
  • map
  • mapare
  • mapare propietati
  • messagequeue
  • meta properties
  • method
  • MethodImpl
  • Metro App
  • Microsoft
  • Microsoft Sync Framework
  • mlearning
  • mlearning devices
  • Mobile Apps
  • mobile in the cloud
  • mobile learning
  • mobile services
  • Mobile Web
  • mongoDb
  • monitorizare
  • msmq
  • multitasking
  • MVC
  • MVC 3
  • MVVM
  • namespace
  • nextpartitionkey
  • nextrowkey
  • Ninject
  • nivel acces
  • no result
  • normalize
  • nosql
  • null expcetion
  • null object pattern
  • NullReferenceException
  • OAuth API
  • office
  • offline
  • Open ID
  • openhackeu2011
  • operations
  • operator
  • optimization
  • option
  • outputcache
  • OutputCacheProvider
  • override
  • paginare
  • pagination
  • path
  • persistare
  • Portable Library tool
  • Post event – CodeCamp Cluj-Napoca
  • predicate
  • predictions
  • prezentare
  • process
  • proiect
  • property
  • propietati
  • query
  • ReadOnlyCollection
  • ReadOnlyDictionary
  • referinta
  • reflection
  • remote
  • reply command
  • request
  • request response
  • resouce
  • REST
  • REST Client
  • RESTSharp
  • ronua
  • rss
  • rulare
  • salvare in fisier
  • sc
  • schimbare timp
  • select
  • select nodes
  • send
  • serializare
  • serialization
  • Server.Transfer. Resposen.Redirect
  • service bus
  • ServiceBase
  • servicecontroller
  • sesiune
  • session
  • Session_End
  • Session_Start
  • setup
  • Sibiu
  • signalR
  • Silverlight
  • sincronizare
  • Single Responsibility Principle
  • SkyDrive
  • skype
  • smartphones
  • smtp
  • Snapguide
  • sniffer
  • socket
  • solid
  • spec#
  • sql
  • Sql Azure
  • SQL CE
  • sql server 2008 RC
  • SRP
  • startuptype
  • stateful
  • stateless
  • static
  • stergere
  • store
  • store procedure
  • stream
  • string
  • string.join
  • struct
  • StructuralEqualityComparer
  • submit
  • switch
  • Symbian
  • Synchronized
  • system
  • tabele
  • table
  • techEd 2012
  • tempdata
  • test
  • testcleanup
  • testinitialize
  • testmethod
  • thread
  • timer
  • ToLower
  • tool
  • tostring
  • Total Cost Calculator
  • trace ASP.NET
  • transcoding
  • tuplu
  • tutorial
  • TWmLearning
  • type
  • unit test
  • unittest
  • UrlParameter.Optional
  • Validate
  • validation
  • verificare
  • video
  • view
  • ViewBag
  • virtual
  • visual studio
  • VM role
  • Vunvulea Radu
  • wallpaper
  • WCF
  • WebBrower
  • WebRequest
  • where clause
  • Windows
  • windows 8
  • Windows Azure
  • Windows Azure Service Management CmdLets
  • windows live messenger
  • Windows Mobile
  • Windows Phone
  • windows service
  • windows store application
  • Windows Task
  • WinRT
  • word
  • workaround
  • XBox
  • xml
  • xmlns
  • XNA
  • xpath
  • YMesseger
  • Yonder
  • Zip

Blog Archive

  • ►  2013 (139)
    • ►  November (17)
    • ►  October (12)
    • ►  September (10)
    • ►  August (7)
    • ►  July (8)
    • ►  June (15)
    • ►  May (12)
    • ►  April (17)
    • ►  March (16)
    • ►  February (9)
    • ►  January (16)
  • ▼  2012 (251)
    • ►  December (9)
    • ►  November (19)
    • ▼  October (26)
      • Windows Azure Tools - Error 0x80070643: Failed to ...
      • Visual Studio - How to see the source code of .NET...
      • Design a state machine mechanism using Windows Azu...
      • How many fingers point can be tracked by Windows 8
      • Design a state machine mechanism using Windows Azu...
      • Day 4 of Software Architecture 2012 & Agile and OO...
      • Day 3 of Software Architecture 2012 & Basic Princi...
      • How to NOT expose a read only collection in C#
      • Day 2 of Software Architecture 2012 & How an archi...
      • Different methods to implement Message Aggregator ...
      • Day 1 of Software Architecture 2012 & Unit Test Pa...
      • Windows Azure Service Bus Patterns - a comprehensi...
      • How to force browser to updated the Silverlight pa...
      • What should I do when I receive "4.1 Your app must...
      • WOWZAPP 2012: Worldwide Global Hackathon for Windo...
      • Patterns in Windows Azure Service Bus - Dynamic Ro...
      • Configuration settings from Windows Azure Service ...
      • New Unit Tests features of Visual Studio 2012
      • Windows Azure Service Bus - Adding properties to t...
      • Custom configuration files for each developer machine
      • Patterns in Windows Azure Service Bus - Scatter-Ga...
      • How to write unit tests in JavaScript for a Window...
      • Patterns in Windows Azure Service Bus - Content-Ba...
      • Mixing UI controllers in a Windows Store App (Metr...
      • Microsoft MVP
      • [Post Event] Windows 8 Dev Camp, Cluj-Napoca - Sep...
    • ►  September (13)
    • ►  August (35)
    • ►  July (28)
    • ►  June (27)
    • ►  May (24)
    • ►  April (18)
    • ►  March (17)
    • ►  February (20)
    • ►  January (15)
  • ►  2011 (127)
    • ►  December (11)
    • ►  November (20)
    • ►  October (8)
    • ►  September (8)
    • ►  August (8)
    • ►  July (10)
    • ►  June (5)
    • ►  May (8)
    • ►  April (9)
    • ►  March (14)
    • ►  February (20)
    • ►  January (6)
  • ►  2010 (26)
    • ►  December (1)
    • ►  November (1)
    • ►  October (1)
    • ►  June (2)
    • ►  May (1)
    • ►  April (4)
    • ►  March (1)
    • ►  February (1)
    • ►  January (14)
Powered by Blogger.

About Me

Unknown
View my complete profile