All posts by Gigi

Roslyn moves to GitHub

For the past several weeks I’ve been writing about the new features in C# 6 and Visual Studio 2015, which are facilitated by the .NET Compiler Platform, known as Roslyn.

Roslyn’s Codeplex homepage has hosted the project’s source code and information for a while.

However, over the past few days, the following announcement was posted on Roslyn’s Codeplex homepage:

This coming week (Wednesday is the target, Thursday at the latest) we will be moving the Roslyn Project to live under GitHub, joining the rest of the .NET team over there.

Details:

  • This will be a simple switch – turn off CodePlex, turn on GitHub. You’ll be able to see our checkins on GitHub that same day, for example.
  • Any of your pull requests to our project in GitHub will pile up for a couple of weeks, because we are going to take the opportunity to also streamline our (currently very complex) pull request process – yeah! We’ll reopen in a couple weeks with a much easier process. That, combined with us switching to use Git internally as well at the same time (!), means many fewer moving parts and gets us much closer to the same environment you’ll be using on Roslyn code. It will be so worth it.
    • At this point, I’d advise holding off on any requests sent to CodePlex, and save them for GitHub instead.
  • We’ll be using GitHub Issues for both discussions and bugs after the switch.
  • We will try to move over outstanding bugs from CodePlex, but this is the trickier part of the plan. Stay tuned.
  • We will also do our best to preserve check-in history.
  • We will be under the .NET Foundation over there, as the “Compilers” project.

We will update this page with the forwarding information when the switch is complete mid-week. I’ll also be blogging about some of the additional OSS work we’re about to embark on in a week or two.

–Matt Gertz–*
Group Software Engineering Manager, “Roslyn”

It appears that the move is now complete, and you can find all the latest on Roslyn at its new home on GitHub.

VS2015 Preview: Inline Temporary Variable

Visual Studio 2015 brings two new refactorings: Introduce Local Variable, and Inline Temporary Variable.

Inline Temporary Variable is actually the exact opposite of Introduce Local Variable. At times you’ll be using a variable for something so simple that it actually clutters the code. For example:

var firstArgument = args[0];
Console.WriteLine(firstArgument);

We can get rid of the firstArgument variable by using the Inline Temporary Variable refactoring.

To do this, we first need to select the firstArgument variable on the first line (where it is being declared), and then press Ctrl+. (Control Dot) or select “Quick Actions…” from the context menu after right-clicking the selection. This brings up the refactorings menu, from which we can select the refactoring we want:

vs2015-inline-temporary-variable

After selecting the Inline Temporary Variable refactoring from the menu, the code gets cleaned up pretty nicely:

Console.WriteLine(args[0]);

 

VS2015 Preview: Introduce Local Variable

There are two new refactorings introduced in Visual Studio 2015. The first of these allows you to introduce a local variable to simplify your code. Let’s see this at work on some source code from ImapTalk.

After selecting some code, press Ctrl+. (Control Dot) or select “Quick Actions…” after right-clicking on the selected code. You’ll get a list of refactorings that you can apply to your code, along with a nifty preview of what your code will look like after it is applied:

vs2015-introduce-variable-preview

In this code I’ve got this Color object that I’m passing directly into the constructor of a SolidColorBrush, which looks a bit messy. With this refactoring, I’ll introduce a local variable to hold that Color, and then pass the new variable into the SolidColorBrush:

vs2015-introduce-variable-renameOnce you select this refactoring, Visual Studio goes into inline rename mode, so that you can choose the name of the new variable.

Take a look at the refactored code above. Much better! 🙂

On Cooking Software and Waterfalls

I’ve recently been following a discussion about Agile software development on LinkedIn. While there were some interesting points raised and also many pointless posts, there was one entry in particular that I found particularly interesting.

I am reproducing the post by Peter Wennerholm below with his permission, and have added my own commentary in between block quotes.

“Several contributors seem to see only two alternatives to how to produce software: Agile and Waterfall.

“That is not a fair view of the situation: waterfall was presented as a process that should NOT be used for software development. So far I have never heard of any shop that uses it, and that’s a good thing too.

“Let us chew on that for a while. The waterfall process was never intended to be used for software development. It was put forward as a process that should be avoided. So unless you really have found yourself in a pure waterfall team (and then you have my sympathies) please stop putting it forward as an alternative to Agile. The Agile “procedure” must be judged on its own merits, not as a contrast to an absurdity.”

Some interesting insight on the Waterfall model here! The paper [PDF] linked by Mr. Wennerholm, which dates back to 1970, describing what we now know as the waterfall model while clearly indicating (a) why it is not suitable for large software development projects, and (b) a number of improvements that make the Waterfall model a lot more reasonable to use. If you’re too lazy to read the paper itself, this blog post contains some pretty decent commentary about it.

“I have always made software in much the same way as how I cook: you add some ingredients, then taste, then add some more, taste again, etc. If you want to give it a fancy name, be my guest, but it seems more like common sense to me. Oh well… If someone can make money teaching common sense to programmers, who am I to deprive him of his living?”

I think that the cooking metaphor used by Mr. Wennerholm is pretty spot on. It is in the spirit of prototyping (which is at the heart of many agile practices) to create something small, see that you’re going in the right direction, and then continue with the next iteration, as opposed to building the whole thing and then realising you’re totally off track. The simplicity of the process is also worth noting. While software development may be as simple as a feedback loop, today there are many different methodologies involving piles of documents, meetings and ceremonies. While these are often useful if done right, it is not hard to realise that they are well hyped up by the people making a living from promoting them (e.g. by writing books) and by those who religiously think they’re a panacea.

“The problems seem to arise when people trained in managing non-programmers are put to manage programmers. The “common sense” is a double-edged sword: your life experience will dictate what is common sense to you, and it may differ very much from what is common sense to me. A non-software person tends to see a project as a collection of known problems with known solutions: it takes X seconds to lay one brick, the wall is Y long, so it will take Z days to finish the wall. A programmer knows that there are many unknown variables in his project: it is a collection of problems out of which some may be completely new, or handled by new tools, or in an unknown environment, or with unknown people. We cannot say how long it will take to finish the wall; when we start we do not even know if we should use bricks. Therefore, common sense dictates to make tiny waterfalls, or cycles, where each cycle takes us one step further towards completion and gives us more knowledge about the problems ahead of us. Agile and Scrum to you, perhaps.”

In this paragraph we recognise the fact that there are many unknowns in software development. When undertaking something new, we are often unfamiliar with the business, the technology, and many other aspects which can seriously affect the outcome of the project.

In my opinion it is pure madness to commit to strict deadlines on something that is very poorly understood. Therefore, the first thing that should be done is to make the effort to investigate the unknown factors so that they are at least fairly understood. This should be done as early as possible.

Aside from learning by communicating with the client, prototyping also helps a lot with understanding the problem domain. I believe this is what Mr. Wennerholm means when he mentions making tiny waterfalls. This is also reflected in the aforementioned paper, where Dr. Royce suggests creating the software twice: once as a small-scale throwaway prototype to capture the problem domain without wasting too much effort, and the second time as the actual deliverable.

“When we talk about what is the best way of programming, let us all be very humble. Our profession is so young that some of the very first programmers are still alive today. Look at house building: after thousands of years of experience we still have houses that burn or collapse or rot – we cannot claim to have all the answers on how to build software.”

I don’t think this paragraph requires much commentary: I think it is a pretty awesome message that we have so much to learn. Let’s try not to be religious about anything in software development; tomorrow someone may demonstrate that the awesome technique we touted so valiantly is actually a pretty bad practice. And when that happens, I hope we are open-minded enough to learn from our mistakes and grow in our beloved profession.

VS2015 Preview: Inline Rename

Another IDE experience that has been revamped in Visual Studio 2015 Preview is that of renaming stuff. You can rename a variable by right-clicking it and selecting “Rename…” from the context menu, or instead by simply hitting F2 on your keyboard:

vs2015-inline-rename-menu

When you do this, Visual Studio goes into Inline Rename mode. It finds all the instances of that variable and highlights them for you, while providing some other options on the side:

vs2015-inline-rename-renaming

As you type a new name, all instances are instantly updated:

vs2015-inline-rename-renamed

What’s really cool about this is that the IDE actually warns you if the new name conflicts with some other variable:

vs2015-inline-rename-conflict

Just press Enter to accept the changes.

Although I have demonstrated how to rename a variable, this also works for other things such as methods and classes. In case of conflicts, Inline Rename will attempt to resolve them using fully-qualified names if possible, as demonstrated in the video with Beth Massi and Dustin Campbell.