Skip to main content

Posts

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

In my last pos t 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: Added Initialized 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 ...

How many fingers point can be tracked by Windows 8

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...

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

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 t...

Day 4 of Software Architecture 2012 & Agile and OO design

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...

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

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. Th...

How to NOT expose a read only collection in C#

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...

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

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 t...