ALT.NET Israel Autumn 2010

It is my great pleasure to invite you to the fourth ALT.NET Israel unconference, which will take place in September, Thursday-Friday (2-3/09/2010).ALT.NET Israel

About the format:
The goal of ALT.NET conferences is to have community discussions and knowledge sharing between the community members. During the first day of the conference, the planning stage, attendees will be able to offer sessions / request sessions on issues close to their heart. By the end of the planning stage we will have an agenda for the following day.

The conference day will include multiple discussions at each one of the discussion slots, discussion can take place with 2 people or with a room full of people. There is no need to stay till the end of the session… if you feel that you do not contribute to a session you can leave and attend another session of your choice.

Where?
Sears Israel (SHC ISRAEL)
Hamanofim 9
Akershtein Building A – 3rd floor
Hertzelia

When?
September 2nd and 3rd, 2010

Thursday – Planning 02.09.2010
18:00-19:00 – Registration & refreshments
19:00-20:30 – Building the schedule and list of sessions for Friday
20:30-……. – Coffee / drinks at one of the pubs around

Friday – Conference Day 03.09.2010
09:00-09:30 – Registration & Refreshments
09:30-09:40 – Opening talk
09:40-10:50 – Discussion round 1
11:00-12:10 – Discussion round 2
12:20-13:30 – Discussion round 3
13:30-14:00 – Lunch
14:10-15:20 – Discussion round 4
15:20-16:30 – Discussion round 5
16:30-17:00 – Summary
17:00- …… – Coffee / drinks at one of the pubs around

Please register for the event at the following address: http://altnetisrael.eventbrite.com/

See you there!

Summary: the 2nd Software Craftsmanship group meeting in Israel

Yesterday I attended the 2nd Software Craftsmanship meeting, led by Uri Lavi, held in the headquarters of PicScout.

Uri talks about Code Smells

The main agenda for the evening was Bad Code: identifying bad code, code smells, and using tools to identify bad code. Uri gave an in-depth presentation about most common code smells, such as huge nested switch/case statements, and explained how to refactor them into a working, beautiful code.

After the talk, the group had split into two: Java and .NET developers, and they were given a Dojo-style assignment: Create a class which displays a given integer as a Roman Numeral.

Dror Helper, together with Avi Pinto made the first pair in the Dojo, and began coding the challenge TDD-style: tests were written before the actual code. This quickly led to a heated discussion about TDD with the people in the group, many of whom had never even heard of TDD.

Overall, this was an enjoyable meeting. Uri presented his topics with passion, and promised that there were many more sessions to come!

The slides from the meeting are available here.

Making Productivity Power Tools for Visual Studio 2010 play nicely with ReSharper

Scott Guthrie wrote about VS 2010 Productivity Power Tools update, and I went to the Extensions Gallery to download it. I won’t write an overview about it – Scott has already done an excellent job on his blog. You can also find more information on the extension’s page.

If you’re a ReSharper addict (like me), you will notice that some things just do not work or interfere with the way ReSharper does things. So here’s a list of things that you can do to make ReSharper and the Productivity Power Tools work nicely together:

1. Go to the Productivity Power Tools under Tools – Options:

  • Turn off Automatic Brace Completion if you prefer ReSharper to do it for you.
  • Turn off Ctrl + Click Go To Definition. ReSharper provides this functionality.
  • Turn any other settings on or off, depending on your personal preferences.
2. Fixing Quick Access

One of the best features of the Productivity Power Tools is the Quick Access window. If you’re a ReSharper user, you’ll appreciate it if you love the Go To Class navigation (Ctrl + T [Visual Studio] or Ctrl + N [IntelliJ]). The Quick Access allows you to navigate virtually everywhere by typing the name. For example, to open the Keyboard options, simply start typing keyb:

The default shortcut for this window is Ctrl + 3, however this key binding is used by ReSharper’s Bookmarks system. If you’re not using the bookmarks:

  • Go to Tools – Options – Keyboard, find the command by typing QuickAccess. You should see it in the list as View.QuickAccess.
  • Under Use new shortcut in make sure it shows Global, then press Ctrl+3 (without the + sign) in the adjacent text box, then click Assign.
  • Select Text Editor in the Use new shortcut and repeat the above step.

There are many more cool features in these Power Tools. Together with ReSharper they really boost productivity sky high!

Happy coding!

C# Puzzle: What does this program do?

Consider the following code:

class Woot
{
    private static float PI;
    private static bool initialized = doInitialize();

    private static bool doInitialize()
    {
        if (!initialized)
        {
            var thread = new Thread(() => { PI = 3.14f; });
            thread.Start();
            thread.Join();
        }
        return true;
    }

    public static void Main(string[] args)
    {
        Console.WriteLine(PI);
    }
}

What is the output of this program? Is it:

  1. 3.14
  2. 0
  3. Throws exception
  4. None of the above

To find out the answer to this puzzle, as well as many others, watch the “C# Puzzlers” talk with Eric Lippert and Neal Gafter from NDC 2010. How many did you get right?

Ever wanted to know why you got the badge on StackOverflow? Now you can!

Badges are an integral part of the StackOverflow, which reward participants. According to Jeff Atwood, those are based on the Xbox 360 Achievement System.

Some time ago I suggested on meta that it should be possible to easily identify which question or answer (when applicable) awarded the badge. This request was met by an initial refusal, stating that the user should figure out himself why the badge was awarded. This quickly became a heated issue, as I was not the only one who wanted this feature implemented. At the time, the badge system was not designed for this.

I am happy to say that waffles (Sam Saffron) implemented the needed change, and now it is possible to view the questions/answers responsible for the badge! Just go to your profile page, and click on one of the badges. You’ll get a page with links to the answers or questions:

badges

Thanks Jeff and Sam for implementing this feature, and thanks to everyone in the SO community for making this question award me the “Great Question” badge.

Happy Hunting!

Visual Studio 2010 bug: NullReferenceException when opening any file, caused by a docked add-in tool window

Here’s an issue I’ve been struggling with: it seems that by accessing a certain property of a docked tool window of an add-in, an exception is thrown somewhere inside Visual Studio 2010. It’s caught internally, and the exception message, “Object reference is not set to an instance of an object”, is shown whenever I was trying to open any file (code or otherwise).

Here’s the offending code (this OnConnection method belongs to a C# Add-in code, it’s pre-generated when you create a new Add-in for Visual Studio):

public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
_applicationObject
= (DTE2)application;
_addInInstance
= (AddIn)addInInst;

const string guidString = "{7CAB9543-0A69-4971-B154-01BC2DAAE2ED}";

object dummy = null;
var windows
= (Windows2)_applicationObject.Windows;
var buggyWindow
= windows.CreateToolWindow2(_addInInstance, Assembly.GetExecutingAssembly().Location, typeof(WindowControl).FullName, "Buggy", guidString, ref dummy);

buggyWindow.Visible
= true;

if (buggyWindow.LinkedWindowFrame.LinkedWindows.Count == 1)
{
// does not matter what happens here.
}
}

It seems that accessing the window's LinkedWindowFrame.LinkedWindows property causes a corruption when the add-in is docked, which will manifest itself upon attempting to open a file.

I submitted this issue to Connect, including steps to reproduce.

Update: It seems that the issue was fixed! Microsoft will include the fix in the next Visual Studio 2010 update!

Want to work at Typemock? We're Hiring!

We are looking for a .NET/C++ developer to join the growing Typemock ranks. You need to:

  • Live in Israel
  • Know .NET very well (at least 3 years .NET experience – VB.NET or C#, and willing to learn the other one)
  • Have some C++ experience (recent – sometime in the past couple of years)
  • Be interested in Agile development, unit testing and TDD (you don’t have to be an expert. You’ll become one on the job!)
  • Have very good English
  • PASSION for programming
  • Advantage to C++ hardcore devs but you don’t have to be one
  • Advantage to Open source contributors   but you don’t have to be one
  • Advantage to public figures (bloggers, speakers..) but you don’t have to be one

You will be working on one of our products, or several of them along the way. Including Typemock Isolator, Test Lint, TeamMate and future products we are working on! We are counting on all our developers to be part of the design process, to take active part in support and customer meetings, and the first day of every two weeks is dedicated to pet projects – you work on anything you want (even if it’s not to do with Typemock)!

If you’re interested, please contact me at igal at typemock.com

Turning poor man’s performance profiling into awesome using Excel and Pivot Tables

As I’m writing this, Dror Helper blogged about using a “poor man’s performance profiler”. This profiling technique is useful when the tools are lacking, and we need to measure a performance of method(s) within our code. This information is usually logged, and after a run we’re left with a huge file containing hundreds (and sometimes thousands of lines). How do we make sense of this mess? How do we filter out and understand the relevant performance information?

As it happens, Microsoft Excel is a great tool to assist with this task! Excel is this part of Microsoft Office, which everyone has, but very few know how to use. I was watching as a colleague of mine, Doron, worked his magic with Excel, and now I’d like to share this information with the rest of the class:

Note: I used Excel 2010 to perform this. I believe that this is possible with earlier versions, but I can’t tell for sure.

1. We start by opening the log file, selecting all text, and pasting it into a new Excel worksheet.

2. Now we need to filter out anything not starting with the word *PERFORMANCE*.

With the first column selected, go to Data, and press Filter.

This will add a dropdown arrow on the first cell, click it, go to Text Filters, then Begins With. In the dialog type *PERFORMANCE*, and press OK. This will leave only the lines starting with *PERFORMANCE*, however, Excel will still show the original row numbers. Select the first column excluding the first line (by clicking on the 1st *PERFORMANCE* cell, then pressing Ctrl-Shift-Down Arrow), copy then paste the selected lines into a new sheet. This will reduce the number of displayed rows dramatically.

3. Split the text into columns using the Text-to-Columns feature

Tip: you can skip this step reduce the number of steps here, if you output your performance text comma-separated.

With the first column selected, in the Data pane, click Text to Columns. First, we’re going to split the string by *PERFORMANCE*, so select Fixed Width, then Next. Click and drag the arrow head one character to the right, then press Finish.

Now the first column only contains the word *PERFORMANCE*, so we can safely delete the entire first column.

Let’s repeat this step once more, this time selecting Delimited in the first page of the wizard, then Next. We want to split by the equals sign “=”, so let’s type = into the text box next to Other. We can see in the preview how it will look like. Close the wizard by pressing Finish.

4. Adding the numbers together using PivotTables

Now that we have two columns, one containing the method name, and the other the time it took the method to execute, we can summarize it using a PivotTable. But first, we need to give the columns some meaning in the pivot table, so insert a new row before the fist row, and above the first column type Method, and above the second row type Time.

SNAGHTML3e456020

Select both columns except the first row (you can select just the two cells in row 2, then pressing Ctrl-Shift-Down Arrow). Go to Insert, then PivotTable, and press OK in the new dialog.

Drag the Time field down to where it says Values. This should create a field called Sum of Time. Drag the Method field into the Row Labels.

image

On the left we should now see all the methods with the time it took to run them nicely formatted:

 

And that’s it! We can now apply Excel’s sorting to the columns and perform other analytical data with our “poor man’s performance profiling” data.

ReSharper 5.0 Hidden Gem – Patterns Catalogue

Have I mentioned that I love ReSharper? While patiently waiting for the 5.0 release to RTM, the team at JetBrains have shipped the Beta 2 release (build 1618). This is a very stable, very good improvement over the previous nightly builds.

One of the things that improved the most with this release is the SSR – Structural Search and Replace. It’s a new feature, allowing you to specify code patterns to be added as hints, errors or warnings to the ReSharper code analysis, as well as specifying a replacement pattern.

Here is an example of this feature, taken from the JetBrains .NET Tools blog:

Adding the following pattern:

Will add a new quick-fix action:

The patterns can also be imported/exported as XML files, allowing easy sharing between co-workers.

In order to create a new pattern, select Patterns Catalogue from the Tools submenu of ReSharper menu.

Press Add Pattern.

 

We can add either a search only pattern, or a search and replace pattern. Let’s add a pattern to turn NUnit Asserts into fluent NUnut Assert syntax:

  • Add Assert.AreEqual($expected$, $actual$) in the “Search Patten” window.
  • Press “Add Placeholder”, select argument, and type expected in the name. Do the same for actual.
  • In “Replace Pattern”, type Assert.That($actual$, Is.EqualTo($expected$)).
  • Choose Pattern severity, I selected “Show as suggestion”.
  • Fill in the description texts.

The final result should look like this:

Press Save and close the Pattern Catalogue dialog.

You will now be able to turn this:

into this:

Happy coding!

Visiting Islay - Part 2

Note: this is part 2. Read part 1 of the trip here.

Early Saturday morning on Islay, and we are set to go on another adventure! After eating a delicious breakfast that our lovely host prepared for us, we were set to try and explore some more distilleries. Unfortunately there were no tours at Lagavulin and Ardbeg on a Saturday, so we decided to drive to the place where one of my most favorite pictures was taken - the Carraig Fhada Lighthouse.

image It was a relatively short drive, the road eventually becomes almost undrivable. We parked our car outside the gates of the Carraig Fhada farm and continued on foot. The sea breeze blows into our faces as we walk slowly along the rocky path towards the lighthouse. It's so calm and peaceful out here&

Fully recharged by the fresh air and breathtaking scenery we went back to the car. I quickly checked the little map we had and saw that Kilchoman distillery is open on a Saturday! My GPS has no idea where Kilchoman is, but it's very hard to get lost on Islay, so I set course to Bruichladdich and we begin driving.

As we soon found out, on Islay there are two main roads, the A846 from Port Ellen to Port Askaig, passing Bowmore and Bridgend, and A867 from Bridgend to Portnahaven, passing Bruichladdich and Port Charlotte. Those have one lane at each direction. All other roads on the island are single lane roads, with passing places every couple of hundred meters. Our GPS decided that we should take the B8016 (also known as High Road), and we obeyed.

I mentioned before that driving on Islay is an experience all by itself. We had to drive slow, because stray sheep and goats tend to find their way onto the road. On a single lane road there is not much traffic, but eventually a car or a truck with a friendly tourist or Ileach (native of Islay) will come towards yours. Here is where the interesting thing happens: the driver who is the closes to a passing place on his side will flash his headlights once, signaling that he will drive off the road to let you through. And as always, you part ways with the Islay wave.

image For miles and miles, the road is surrounded by peat fields. There is enough peat on Islay for the next 1500 years. I stop the car and go outside to take a closer look at the wet boggy stuff that is the heart of the Islay whiskies. Wet peat, as I learned in the distillery tour, is harvested and then let to dry, but not too much. Dried peat burns too quickly, and therefore it needs to be a little bit wet for the perfect burning. I wanted to take a piece of it back home with me, but I wasn't sure the customs people would understand...

At Bridgend we turned to A847, towards Bruichladdich. The wet sea shore on our left was covered in birds, and in the distance there were people looking at them through huge telescopic lenses of their cameras. Another thing Islay is famous for is bird-watching, and there plenty of that going on. A young couple that was staying next to us in the B&B came to Islay for the birds, bringing a Jeep full of equipment - I've never seen camera lenses that big before.

Suddenly where was a road sign showing the way to Kilchoman. I gladly followed, and after driving for a while on a narrow farm road, passing Loch Gorm on our right, we finally reached Kilchoman farm. It is immediately showing that this is not your ordinary distillery. There are no huge warehouses, no large buildings or trucks parked outside. Kilchoman, just like the sign says, a farm distillery, small and simple, the first distillery that was built on Islay for 124 years, so it says.

We went into the distillery shop and cafe, registered for the tour (which was a bit pricier then in most distilleries), and while waiting had something to eat at the cafe. A few moments later came the folks we met yesterday at the Laphroaig tour, but they didn't stay long - they went to Bruichladdich, because there was a private tour arranged for them there. We had about an hour before the tour at Kilchoman began, so we drove to Bruichladdich as well. In the shop there were people well into tasting already. We had a choice - stay at the shop and join the tastings or try and join some of the tour. Tough choice indeed, but in the end whisky won, and we stayed at the shop. There were at least 25 different Bruichladdich expressions behind the counter, but being a peat freak I went for the King - Octomore 2, the peatiest whisky yet. It just took a few drops - the peat is overwhelming in this expression. Comes strong both on the nose and the palate, but in the background there is a distinct malty sweetness, which became more apparent after a splash of water.

image Our Kilchoman tour was starting soon, so we said goodbye to Bruichladdich for now, and went back. We got to the farm just in time for the tour to start. One of the most things I enjoyed about the Kilchoman tour is its intimacy and simplicity. The malting house was very small, so was the kiln where they burn peat; it really felt more like a farm production than a full scale distillery. In fact, there are only 2 people who operate the entire distillery from malting to rolling the filled casks into the warehouse. What's more amazing, that even a fairly large distillery, such as Laphroaig, have only 20 people working there.

Last stop on the tour was the warehouse where the whisky was sleeping. Not many distilleries let you into the warehouse, let alone photograph some of the things (Diaego owned distilleries, such as Lagavulin and Caol Ila, do not allow flash photography of the mill, because one time, the legend goes, the flash from a camera ignited the flour hovering in the air, and there was a big fire). In the warehouse there was the famous first cask filled in 2005, as well as many different types of casks lying around - from huge sherry casks, to small “blood tub” casks, filled with the young spirit.

image In the end, for me this was one of the most enjoyable tours, as it left me a little mystified. Standing there in the warehouse I remembered something a world-famous whisky writer Charles MacLean once said - the cask is not a mere container, but rather like a chrysalis in which a spirit is transformed, like a caterpillar turned into a butterfly. I was pondering on what will all those different spirits taste like in 5, 10, 15 years? What kind of beautiful butterflies will they transform into? This was history in the making, and we patiently wait to see the outcome.

After that we came back to the shop to have a sample of the spirit. Departing Kilchoman I bought a miniature bottle of the Inaugural Release of the official 3 year old whisky. The prices at Kilchoman shop were a bit high, but it's all for a great cause. Satisfied, we returned to the B&B to recharge, before going out to dinner at the Harbour Inn in Bowmore.

We arrived at Bowmore in the evening, and the sky above the port was so clear, covered in a million stars. Everything in Islay feels magical, and this was no exception. How I wished my camera would take proper pictures at night...

We entered the restaurant, and were even able to get one last table that wasn't booked. While sitting in the waiting room entered a group of well-dressed German folks, and with them a girl in full Scottish attire, with a large bagpipe under her arm. Apparently, they were celebrating something, and the girl began playing the pipes. I could not imagine that the pipes can sound so loud! We were sitting on a sofa just a few meters from the piper girl, but the sound made the walls vibrate, it was wonderful!

We were called to our table, and soon after we were seated, the folks that were following us from Laphroaig and Kilchoman came in. We greeted each other, and they were seated a few tables behind us.

After the delicious and a fairly expensive meal we went back to the B&B for a good night sleep. New adventures await us tomorrow!

To be concluded…

«September»
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789