DCSIMG
Stiller's Blog

Stiller's Blog

Software Challenges - Arise!

Come and Learn XNA!

Microsoft XNA is a set of tools with a managed runtime environment provided by Microsoft that facilitates computer game development and management. XNA attempts to free game developers from writing "repetitive boilerplate code"[1] and to bring different aspects of game production into a single system.” (Wikipedia)

If you ever thought about developing a computer game, if you think 3D is cool or if you’d like to develop 3D applications that can be run on the PC, XBOX360 and on a Windows Phone – you should definitely learn about XNA.

Want to learn more?

Well, there are 2 steps you can take. First, you can go to Josh’s blog and read some more. Second, you can register to Josh’s Expert Days session on XNA where he’ll teach you quite a lot of what it takes to develop games using XNA.

image

Excited? I am. See you there…

Expert Days 2011 – Here I Come!

Expert Days

Expert Days is an annual software development conference held by E4D in Israel. This year, for the first time, some of CodeValue’s experts have joined forces with E4D and are participating in order to give you, the attendee, the best possible value. If you are a software developer, software architect, team leader or somehow interested in the hottest available Microsoft technologies – this is definitely the conference you want to be at.

The conference is held on 10/07/2011-14/07/2011, and there are dozens of one-day workshops, which are packed with practical knowledge which you can immediately use. Investing your time in these workshops will certainly payoff immediately!

For more information regarding the available workshops, feel free to click the banner below.

Workshops

Among all of the conference’s experts, you can also find me there this year and I gladly invite you to participate in my workshop – Windows Workflow Foundation 4.0. Note that if you specify that you arrived through me and specify my instructor code (116) you can get a 20% discount to the workshop!

Except for my workshop, I personally recommend arriving at workshops performed by some of the other CodeValue experts – Alon Fliess, Amir Zuker, Eli Arbel, Josh Reuben & Shay Friedman.

But wait – there’s more!

This year, Expert Days has a free opening event on 10/07/2011. This event includes a cocktail party, mingling and a series of professional lectures all of which are absolutely free. During the opening event, an XBOX+Kinnect set will be given to one of the attendees. That’s right – an XBOX+Kinnect set shall be given away to one of you! All you have to do is register and show up…

Opening Event

See you there,
Eran

Architect’s Master Class – Impressions so far

Luckily for me, starting yesterday I had the privilege to attend Juval Lowy’s 5-day Architect’s Master Class which is held in Israel and organized by Gadi Meir’s IDAG. In this Master Class, Juval, a recognized software legend by Microsoft and one of the most well known Software Architects in the world, explains the role of the Software Architect in the Software Development industry and his position in the organization.

Listening to Juval is, as always, a pleasure. I am personally happy to find out that many issues I have contemplated about in the past as a solution Architect are not unique, and that my solutions and beliefs are usually on par with what Juval teaches. Juval certainly has an ability to take a point and graphically drive it all the way home and that is why listening to him is so enjoyable.

The first two days of the Master Class were devoted mainly to the Software Crisis and the lack of industrialization in the software industry, and a thorough explanation of the appropriate process for managing the development of a Service-Oriented System. I can’t even count the number of times in which Juval demonstrated a situation which I could project into real life. The material is very practical and I believe that this is the key to the success of the master class – real life instructions for the real life architects.

These two days were definitely a blast and I learned a lot, and I am looking forward for the remaining three days. Hopefully I’ll be able to share my insights once the master class finishes. I know I can’t wait to implement the material on our CloudoscopeSmile

CLR Profiling API Lecture Materials

Thank you to all those who attended Alon’s, Pavel’s and mine sessions yesterday at the Windows User-Group at Microsoft Israel.

My session focused on an introduction to the CLR Profiling API, and I had a great time presenting it, with interesting questions from the crowd and hardcore C++ and even some inline Assembly (!!).

I hope all those who attended enjoyed the session. Feel free to download the source code and lecture slides and have one more look at what we’ve learned yesterday.

Go ahead – Profile away!

Upcoming Lecture: The .NET Profiling API & Hosting the .NET CLR

As a veteran software developer, you must have already heard that the CLR can be hosted inside any application. You probably also heard that you can host it yourself, opening the door for many exciting customizations you can perform in the process. However, you might have been a little wary to try and implement it yourself…

You also probably used a couple or more code profilers during your professional lifetime, including profilers which handle managed code. These profilers showed you exactly how much CPU you are using and which method is using it, and ultimately directed you towards optimization heaven. Have you ever thought about how these profilers are written? Have you ever tried to write one yourself?

Join Alon Fliess, Pavel Yosifovich and myself at Microsoft Israel’s Windows Platform User-Group as we show you exactly how to achieve the above. Attendance is free, but you should register here.

The lectures will take place at Microsoft Ra’anana on Wednesday October 6th, at 17:00-20:30. Additional details can be found here.

A New Journey Begins

Time to Say Goodbye

It's been more than a year since I joined Sela, and I've arrived to a point where I felt that it's time to move on. I had a great time since I joined Sela, as I had the opportunity to deep-dive into some interesting technologies and meet some exceptional people. I would like to take this opportunity to thank some of them:

  • Erez Fliess - My manager at Sela, and the person who (together with Alon) is responsible for me being there in the first place. From Erez I learned that the most important thing, before being a technology expert, is to be a person and a friend. Erez speaks with everyone at eye level and with respect and for that I am truly grateful.
  • Alon Fliess - One of the greatest professionals I have ever met, and most importantly, a very good friend. With Erez, he convinced me to come to Sela. I've had many opportunities to work with Alon, both at Sela and beforehand, and it has always been a pleasure.
  • Sasha Goldshtein - A gifted lecturer, writer and professional, and a person I truly enjoy working with. The only person with whom it is actually mind-blowing to watch him type on a keyboard.
  • Ishai Ram - Ishai taught me a lot of what I know about lecturing and giving guidance, and I thank him for that. Without a doubt, when Ishai sets his mind on something it'll be done in the best possible way. Thank you.

There are obviously tons of gifted professionals I worked with at Sela, and I would like to thank each and every one of you personally. I'll still be giving lectures and teaching at Sela on various topics, so don't be surprised to see me there!

Something of My Own

So what's next, you might ask. Well, those who know me knew that I've been thinking to start something of my own for a while. As it turns out, good things come to those who wait as I had the opportunity to join a group of very talented people and form something new and interesting. These include Erez Fliess, Alon Fliess, Shay Friedman, Bernie Almosni, Ariel Ben-Horesh, Eli Arbel, Amir Zuker, Josh Reuben and Michael Kanevsky.

Bring on CodeValue

Ok, so you're going to start your own company - how are you going to name it? While this may seem a trivial issue, it is one of the most difficult, time-consuming and important questions one should answer when starting a company, as a company with no name doesn't actually exist.

But can you guess what is the #1 factor in choosing a name for your company? Well, if you guessed "an available domain name" you're the lucky winner! Try it out. Think of good, short, catchy name and check for a ".com" or ".net" domain availability. Any success?

Well, after much thought CodeValue was eventually born. If you're interested to learn more and keep in touch, check out our new website at http://codevalue.net and follow us via RSS, Twitter and Facebook.

Go ahead now, check it out...

Invoking the Static Constructor via Reflection

-- Warning! --
This post may cause the reader a slight feeling of nausea. However, remember that tough situations call for some tough actions!

The Situation

Imagine that you have to write some-unit tests for a class which uses an existing infrastructure, involving calls to static methods on a static class. To make things worse, this static class also holds some state which, unfortunately, gets carried around between tests without no actual ability to clear it.

    public static class MyInfrastructureClass
    {
        private static Dictionary<int, string> _someState =
new Dictionary<int, string>();
        private static List<double> _someOtherState = new List<double>();

        public static void SomeOperation1()
        {
            // ...
        }

        public static void SomeOperation2()
        {
            // ...
        }
    }

After a unit-test is run, the state of the above class is not fresh, and as a result unit-tests can influence each-other and their success is dependant on the order in which they are run. This is obviously a very bad situation to be in.

Possible Solution

If there is no inherent built-in way to clear the state of the static class, then one can think of two possible solutions:

  1. Add a “Reset()”-like static method especially for unit-tests which is responsible of reinitializing the class’ state. While this solution is feasible, it involves writing special code for unit-tests which has to be maintained, and if the static class’ code is not yours this is not possible in the first place.
  2. Dynamically invoke the static constructor via reflection – this is the solution I would like to demonstrate.

Invoking the Static Constructor

Not many people know this, but it is possible to invoke the static constructor via reflection, much like the way you dynamically invoke any other method.

    ConstructorInfo constructor = typeof (MyInfrastructureClass)
.GetConstructor(BindingFlags.Static | BindingFlags.NonPublic,
null, new Type[0], null);

    constructor.Invoke(null, null);

The above code can be placed at the initialization or teardown stage of each unit-test, resulting in a clean-up of the static class’ state. This looks nice, however when using this solution you should be very careful – dynamically invoking the static constructor breaks the CLR’s promise that the static constructor would be called exactly once. This might break up the class’ implementation if it does not expect it and should be thoroughly inspected. With the above being said and kept in mind, if the static constructor only initializes and clears up the class’ state this might be an easy solution for unit-testing when infrastructure code refactoring is not possible.

My Two Cents

Static classes are a possible .NET implementation for the Singleton Pattern. This implementation has it strengths, however in my opinion it should be avoided as much as possible. The reason for this is mainly Unit-Test unfriendliness – static classes encapsulate state which cannot be easily reinitialized and implementation which cannot be easily replaced with mocks using standard, open mocking libraries.

When required to implement the Singleton Pattern, I usually prefer using a singleton instance accessed via an interface. For example:

    public class MySingletonClass : IMySingletonClass
    {
        private static readonly MySingletonClass _instance =
new MySingletonClass();
       
        public static IMySingletonClass Instance
        {
            get { return _instance; }
        }

        private MySingletonClass()
        {
            // Singleton initialization
        }

        // IMySingletonClass implementation
        // ...
    }

This way clearing the state between unit-tests is very easy (just replace the singleton instance used), and replacing the implementation with a mock is also relatively easy but requires a degree of cooperation for the tested client class which should allow injecting the instance used from the outside.

Conclusion

I wouldn’t usually recommend dynamically invoking the static constructor, however the technique is sometimes useful for unit-tests and should be kept in your toolbox. Just remember – use it with caution!

In addition, when possible, try to avoid using static classes. Singleton instances are, in my opinion, a better way to go.

WF 3.0/3.5 Design Time Performance Boost

Kushal Shah, from the WF designer team at Microsoft, has recently posted a series of posts on WF 3.0/3.5 design time performance. As some of you might know, the WF 3.0/3.5 designer’s performance decreases drastically as the number of activities in the WF rises and Kushal addresses this exact issue with some tips & tricks (Part I & Part II).

Tips & tricks are nice, but part III of Kushal’s posts really got me going. Besides the fact that work has been done to improve WF 3.0/3.5 designer performance under VS2010 (remember that WF 3.0/3.5 still ships in VS2010 side-by-side with WF 4.0), Microsoft has released two hotfixes which apply these fixes onto VS2008 SP1.

Thus, even if you are using WF 3.0/3.5 and are unable to upgrade to VS2010 for some reason – go ahead and try the hotfixes (here and here). They just might make your experience a little better!

Some Links for my WCF Students

Among the many things I do at Sela, I teach several courses including C#, .NET Framework, LINQ and WCF, and this post is intended mainly for my WCF students. Of course, feel free to browse the links even if you are not one of my current students – I promise they include some interesting WCF material. :)

Enjoy!

Posted: Mar 14 2010, 07:34 PM by Eran Stiller | with no comments
תגים:

Visual Studio 2010 RC Now Available

To all of you out there who are already playing with the VS2010 and .NET 4.0 Beta 2 bits, it was announced today that the Release Candidate version is now available for download for MSDN subscribers and would be made available to the general public on Wednesday.

The RC version contains many performance improvements and bug fixes, and should be more mature than Beta 2. I can’t wait to download & install it already!

WCF in Real Life with Juval Lowy

This Thursday I had the pleasure to attend a one day seminar on “WCF in Real Life” with Juval Lowy. The day was organized by Gadi Meir and sponsored by Sela, and was composed of discussions on many issues in WCF including:

  • Hosting WCF Services
  • Handling Faults and Errors
  • Extending the WCF Extensions
  • Queued Services
  • WCF 4.0
  • Windows Azure AppFabric Service Bus (aka .NET Services Bus)
  • And more…

As always it was very interesting to hear Juval speak and explain his ideas and knowledge, and even though I was already aware of most of what Juval spoke about I still felt I learned a few new tricks.

Discovery Based Pub/Sub Service

The one thing I would like to point out here is Juval’s design of a Publish/Subscribe service based entirely on WCF 4.0 Discovery, creating an entire Pub/Sub service which does not require any explicit Subscribe or Unsubscribe operation.

The basic idea is that the subscribe and unsubscribe operations are performed by the WCF discovery and announcement mechanisms automatically for us, so that all you have to in order to register for notifications is to expose the appropriate service – resulting in a very simple look & feel for users of the framework. Look for an article by Juval on this issue on the next MSDN magazine.

Sela Developer Practice – Demos & Slides

The Sela Developer Practice (SDP) took place this week at the Crown-Plaza hotel in Tel-Aviv with many presentations on various topics, all of which given by Sela’s experts.

SDP

Sasha and I gave two presentations on Tuesday – one on “Parallel Programming with .NET 4.0 and Visual Studio 2010” and an additional one on “Building Workflow Services with WF 4.0 and WCF 4.0”.

Parallel Programming in .NET 4.0 and Visual Studio 2010

In this presentation Sasha and I presented the new Parallel Programming paradigms available in .NET 4.0 and Visual Studio 2010, including the Task Parallel Library (TPL), the Parallel class, Parallel LINQ and concurrency debugging and profiling support in VS 2010.

Feel free to download the presentation and demos and experience it yourself. The session’s recording will be available from the conference site to those who attended.

Building Workflow Services in .NET 4.0

In this presentation Sasha and I presented how to integrate the new features of WF 4.0 and WCF 4.0 to create a workflow application that orchestrates the execution of multiple WCF services. During this session we reviewed what’s new in WCF 4.0 and WF 4.0, demonstrated the authoring of a WCF Workflow Service and showcased the new Windows Server AppFabric host.

Feel free to download the presentation and demos and experience it yourself. The session’s recording will be available from the conference site to those who attended.

How Fanboys See Operating Systems

I usually don’t like blog posts which simply reference some other site, but this one is just too good. I can definitely sympathize with that one.

Thanks to Elad Hanania who pointed me at the direction.

WAS Listener Adapter Hang

This post was written after I wasted invested several hours in getting a non-HTTP WCF 4.0 workflow service hosted in the Windows Process Activation Service (WAS), in hope that the next person who stumbles upon this would find it in Google Bing or something…

Assume you want to host a WCF 4.0 service in WAS on a Windows 7 environment. Lets further assume that this WCF service is non-HTTP activated, meaning that it uses TCP, MSMQ or named pipe bindings. One of the steps required for accomplishing the above is starting an appropriate listener adapter service for the binding we want the use. So for an MSMQ binding we need to start the “Net.Msmq Listener Adapter Service”.

Service List

If we assume that you already have IIS and MSMQ properly installed on your machine, starting the service might hang and the following message might appear in your Windows application log:

Listener Adapter protocol 'msmq.formatname' is waiting to connect to Windows Process Activation Service.  This event will only be logged once.  Cause: This could be caused by either Windows Process Activation Service not being started, the protocol not being configured in <listenerAdapters> section, or another process already connected as Listener Adapter for that protocol.  Fix: Ensure that Windows Process Activation Service is running, the protocol is configured in the <listenerAdapters> section, and that another process has not already connected as the Listener Adapter for that protocol.

Application Log

After checking that the WAS service is running and assuming that no other process has connected as a Listener Adapter for MSMQ, you reach the conclusion that MSMQ (or any other non-HTTP protocol for that matter) doesn’t appear in the <listenerAdapters> section of applicationHost.config. At this point you might try searching how to configure this section, leading you to this .NET 3.5 sample page which explains pretty much what you want to do (even though you’re interested in .NET 4.0), but it doesn’t refer to the <listenerAdapters> section at all. You’ll also find these pages but they don’t help much either.

The solution, and even though you’re using .NET 4.0 over the latest Windows 7 you should not skip this important step – Go to “Control Panel –>  Turn Windows features on or off” and there under “Microsoft .NET Framework 3.5.1” (yes, yes, even though you want .NET 4.0) select “Windows Communication Foundation Non-HTTP Activation”. That’s it.

 Feature Selection

I think the naming and organization of features could have been a little better…

As an extra - if you install Windows Server AppFabric it does this for you.

WF 4.0: Déjà-Vu? Not So Far!

I’ve worked a lot with WF 3.0 and WF 3.5 in the past, and I almost always ended up with some mixed feelings. On the one hand, WF is an amazing technology which allows you to do some pretty incredible things when you think about it – easily create a Domain-Specific Language (DSL) and allow domain experts to accurately model the business logic as they see fit in a graphic manner, just dragging-and-dropping some cubes around. Along with accompanying abilities to host the WF and allow it to communicate with the outer world it should be a definite winner.

On the other hand, when you start implementing your way around WF 3.5 – that’s exactly when all those annoying little problems start to come to life:

  1. Want to have a large WF with lots of activities? Better prepare for some sluggish WF designer experience.
  2. Want to flow a transaction into your WF? You can’t.
  3. Want to send a One-Way message over a One-Way WCF contract? That’s strange.
  4. Want to send a message and receive a reply? Prepare for some weird results.
  5. You get the point…

Examples are easily available, and it was of no surprise to me when I learned that Microsoft are preparing to rewrite the WF engine for .NET 4.0. The promises were loud, and the motivation was clear. However, as I attended this year’s PDC session on WF 4.0, I had this weird feeling of Déjà-Vu. Is history repeating itself? Are we getting the exact same product again? Have the issues been truly fixed? I had this uncomfortable feeling for a couple of weeks, until I finally had a chance to really dive deep into WF 4.0 – and the feeling just went away!

WF 4.0 brings many improvements over WF 3.0/3.5 (including deep WCF integration, enhanced performance and many more), however as far as I am concerned, the main improvement in WF 4.0 is the general feeling when using it – it is just easier and more streamlined to use with a lot less quirks and annoying behaviors. When combined with the hosting and management capabilities of Windows Server AppFabric Beta 1, this is definitely a winning technology.

How do I start with WF 4.0?

In the near future I plan to blog about some of my experiences with WF 4.0, WF services and AppFabric. Till than, I concentrated a list of resources I found useful for getting started with WF 4.0:

Anxious to know more?

Want to learn more on WF 4.0? Wish to see an AppFabric hosting demo live? Find out for yourself how easy it can be! Join Sasha’s and mine session on “Building Workflow Services with WF 4.0 and WCF 4.0” at the Sela Developer Practice (SDP).

image

Besides this session, Sela’s team of experts will bring you the latest and most up to date information on various Microsoft technologies, directly from the PDC which was held just a couple of weeks ago. What are you waiting for? Check out the various presentations and tutorials and sign up!

More Posts Next page »