Category

C#

Windows Phone 8.1 and Windows 8.1 developer

Recently I’ve had a little change in my carrer. From being a .NET Web Developer I’ve become (at least trying to become) Windows Phone & Windows 8 Developer. Almost everything is different, minor change ;]

Right now on regular basis I’m dealing with XAML, MVVM concept, MVVM libraries, Blend, Animations, VisualStates and much more stuff that comes with creating applications for Windows Phone (WP) and Windows 8 (W8) platform. Although I had some, none professional, experience with Windows Phone and all that I’ve mentioned above – I’ve made 3 really simple applications – it was a drop of knowledge in the sea of stuff that you have to know as a decent WP and W8 programmer.

With that being said, I’m trying to catch up, bacause of the obvious lack of knowledge, and in my spare time I’m doing some easy projects that hopefully will let me understand better the concepts, best practices, syntax, libraries and everything that hovers around the WP and W8 development. Keep your fingers crossed.

Universal Apps

Lately Microsoft presented new way of building apps for WP & W8. Universal apps, that’s the name of the idea, allows you, as a developer, to create only ‘one’ application for both earlier mentioned platforms. That’s truly great, like a special offer in the shop, 2 for 1, more for less. What’s even better, it’s a new thing in a .NET world and I’m new to this particular part of a .NET world. Everybody knows that two negatives gives plus. Isn’t it great ;] ? So! Besides reading about it

I figured out that theory isn’t enough and it would be good to do some practical exercises. Brilliant idea! I wasn’t thinking more and just started coding. Not really…Firstly you have to download and install Visual Studio 2013 Update 2*. Read what’s new in it here and download it from here.

Visual Studio 2013 Update 2

After a while you can create your first Universal Application. Just choose a template, pick a name for a project and you’re ready to go.

Universal_Template_in_Visual_Studio

First Universal App project – Favorite Time Zones

The application that I’m going to create is really simple one, and you can find a lot similar ones already in the store, but that’s not the case here. The deal is to learn about WP8 and WP platform, API, possibilities, limitations, behaviour etc.

Idea came from a need. Right now I live in Australia but originally I’m from Poland and sometimes I want to call my family and I don’t know what exact time is in Poland, same thing goes for my family but in the opposite way. It’s 8h difference, which can be easily calculated but if there was a tile on my phone or laptop screen with my Favorite Time Zone(s) that would be great. No more calculations, just a quick glimpse and I know if I can make a call or not. Let’s get to work then.

To be continued…

 * Apparently there was another package of updates. Now you can download Update 3 for Visual Studio.

Starting a project with Visual Studio is really easy process. There are just few steps, how many depends on the project template, to get going with new idea. You just go to File -> New -> Project…

Create_New_Project_Context_menu

then choose the best template that suites your needs, put desired name to it, click OK and you have got yourself a brand new project that is ready to use. You can start coding, right ? There’s always a but, isn’t it ? Yes you can, but you should bear in mind one thing, a project naming convention which determines your project directory tree and has an impact on a C# namespaces.

Examples are the best way to explain a point. I, myself, am a Web Developer so I’ll use a MVC project template as an instance. Let’s create a empty ASP.NET MVC 4 Web Application project and I’ll try to get you through my thinking.

Imagine that we are creating some kind of application for heater company. I’m a little bit cold right now so this is why heaters company, nothing in particular. Let’s say that the company name that we are doing the project for is HeatItUp. They want for themselves a nice website. We already know the first step, File -> New -> Project… and then we choose template and name, easy.

Project_Creation_Template_Window

Although project is perfectly fine, in the end the Microsoft shiped the template, you should be aware of the way Visual Studio creates for you project directories. Notice the two input fields for Solution Name and Name (Project Name) in the New Project Window. After creating it like on the above screenshot you will end up with situation like that:

Combined

 

You can see that you’ve got Solution named HeatItUp and Web Application Project (website) named the same way. This is bad from the logic and good practices point of view. Logic, because project named like that does’t say anything to anyone besides you, the creator, about itself. Nobody knows if it is a WPF, WinForms, just a library or as it really is a Web Application unless they open it and look closely. Good practices because of the mentioned above and everything that corelates with it, generated directory tree and namespaces in your code. Little advice, always keep your namespaces clear and tidy because in large projects you can get really confused and even lost when they are poorly designed and when it comes to namespace refactoring…pure evil.

Ok, but even when I made a mistake with the Web Application project name I can easly change it in the Soultion Explorer. Yes, but don’t, because it changes nothing but the *.csproj file name, directories tree and namespaces are still the same. Obviously you can change folder names by yourslef and edit *.csproj file and change RootNamespace tag, refactor all the namespaces and it’s done. Sure, you can, but the price is really high, a lot of effort.

CSProj_File_RootNamespace

Solution to this issue is just to keep in mind these two input fileds on the New Project window while creating new project, Solution Name and a Name aka Project Name. Or you can do it my way, start with the Blank Soultion

Blank_Soultion

and add systematically projects that you need, always thinking about others who will work, inspect and try to understand the project solution.

Project_Creation_Good_Way