In this series of post I will share my experience using Ubuntu Desktop for software development. I plan to experiment with many different tools, languages, editors, development environments, SDKs, etc., so the posts will include various installation and setup steps which I plan to keep short and mostly independent of each other.
Installation And Configuration
If you’ve read blog posts or even MSDN articles explaining new features in C# 6.0 – I’m sure you’ve learned that the null-conditional operator in C# 6.0 will help you to greatly reduce the number of hard-to-debug and hard-to-reproduce NullReferenceException-s.
When I first read about this operator, the only thing that registered in my mind was that it helped you to chain null checks, especially for descending into data structures, and short-circuit the rest of the checks as soon as you hit null somewhere in the chain. So, I thought it was just a mere convenient syntactic sugar.
But I still did not completely understood the true power of this operator. I’m usually pretty meticulous about null checks and have a lot of C# 5.0 code like this:
private static int GetCurrentSpeed(Car car)
if (car != null && car.Engine != null && car.Engine.ControlUnit != null)
And I was debating whether it was worth it to go through the code base and refactor it to use null-conditional operator. Would I gain anything? Was it worth it just to have the code to look like this:
private static int GetCurrentSpeed(Car car)
return car?.Engine?.ControlUnit?.CurrentSpeed ?? 0;
Okay, I cut 5 lines of code, what’s the big deal?
Continue reading “Null-Conditional Operator in C# 6.0”
In my previous post Better Functional Programming Support Is Coming In C# 7 I argued that by the time you get a chance to write in C# 7 you should already be familiar with Functional Programming paradigm. But since you cannot use C# 7 at the time of writing – you should definitely consider F# for learning the concepts of Functional Programming. I hope we’ll be able to write elegant declarative-style code in C# as we do in F#.
It is hard to convince somebody to spend their time on something new without showing immediate benefits. But the benefits usually come in the form of idiomatic language features which can be overwhelming at first. I hope this post will show you immediate benefits of Functional Programming by looking at real code example and understanding the features one-by-one. I do not intend to present all of the features of F# – just enough to get you interested in Functional Programming.
Recently I have been watching Pluralsight course F# Fundamentals by Liam McLennan and stumbled upon this elegantly crafted code (fast forward to 0:46):
let rec quicksort = function
|  -> 
| x :: xs ->
let smaller = List.filter ((>) x) xs
let larger = List.filter ((<=) x) xs
quicksort smaller @ [x] @ quicksort larger
I was just amazed how much functionality was packed into these 6 lines of code! If you are new to Functional Programming and F# in particular, it could be hard to appreciate this code, so let’s review feature-by-feature what makes this piece of code so elegant and powerful.
If you are curious to see how quicksort implementation looks in C# – scroll to the bottom of the post.
Continue reading “The Elegant Code I Wish I Can Write In C# 7”
I have recently listened to .NET Rocks! episode #1272 Looking into C# 7 with Kathleen Dollard where she mentioned that the next version of C# will have better support for tuples, immutability, records and pattern matching. You can download the episode and fast forward to 27:04 and 30:04 respectively. If you are interested, you can review the C# 7 Work List of Features (revision circa March 24 2016). You can familiarize yourself with support for these features in C# 7 right now, but since it is pretty much still work in progress, by the time it hits CTP or even release – there is a big chance it will look different.
So, what can you do in the meantime? Fortunately, Visual Studio ships with F# and you can start learning above mentioned Functional Programming concepts right now. Remember, F# is just another CLR language as C# is and many features like Generics and support for async/await came to C# from F#. When it comes to Functional Programming I hope this trend will continue.
Continue reading “Better Functional Programming Support Is Coming In C# 7”
Today I attended Microsoft Azure Tour in Washington, DC and I’m glad I did because there was a number of pretty interesting sessions. It’s impossible to rehash everything, but my favorite four sessions were:
Continue reading “#AzureTour Washington DC”
Approximately 6 months ago I needed to upgrade my development notebook and faced a dilemma which one to buy. As a for a long time developer working primarily with Microsoft operating systems, frameworks and development environments the obvious choice was “a Windows notebook”. But which one? I really like Lenovo’s W Series, but they moved a touchpad off center in the latest 15″ models and it was a huge turn off for me. And then a friend of mine recommended to get a MacBook Pro. What? A Mac?
After few more conversations I finally decided to buy one. After developing on it for almost half-a-year I’m ready to share my experience with it.
Continue reading “My Experience Developing on MacBook Pro”
The source code for this post can be found at https://github.com/DmitryZinchenko/blog-WrappedHttpActionResult .
So, you are in the middle of your iteration or heavy refactoring. The API documentation is not ready yet but you deployed your ASP.NET Web API application (Release build) to remote server for dev testing. Your UX teammates started using it periodically checking browser’s Developer Tools Network tab.
As long as they see 200 OK or 404 Not Found – everything is clear and fine. But once in a while you get 400 Bad Request and 500 Internal Server Error and you wish you could get a hint what have caused it.
Continue reading “Custom Reason Phrase in ASP.NET Web API Controller Action”
I have recently finished watching excellent Pluralsight course Getting Started with CloudFlare™ Security by Troy Hunt and got so intrigued by it that I wanted to get more familiar with it. Fortunately I already had Web App running on Azure that was configured with custom domain name and SSL certificate. It turned out to be a perfect continuation from the previous post.
So, what is so special about CloudFlare? Here’s a short list of fascinating features that were of particular interest to me that are available in free and paid plans.
CloudFlare makes site safer by:
CloudFlare makes site faster by:
As a side benefit, making your site faster improves its web search ranking.
These are just few awesome features provided by CloudFlare. The full list can be found on Overview page.
Continue reading “Protecting and Accelerating Azure Web App with CloudFlare”
I’m reading Learning Windows Azure by Geoff Webber-Cross, following the examples and got to the chapter where I need to configure a custom domain name for the Azure Web App and upload SSL Certificate. I have not done it before, so it turned out to be an interesting experience.
The author did not mention what domain name registrar he used but he mentioned that he got SSL Certificate from GlobalSign. Since I already had an account with GoDaddy, I decided to buy a domain name and SSL Certificate from it. Another difference from author’s experience is that I’m doing the development in Windows 8 Pro virtual machine (Parallels) on MacBook Pro.
Continue reading “Configure Custom Domain Name and SSL Certificate in Azure Web App”