Posts

Showing posts from 2015

A view of windows 10 new devices

Here is a link where you'll find windows 10 designed devices: http://blogs.windows.com/windowsexperience/2015/10/06/a-new-era-of-windows-10-devices-from-microsoft/?WT.mc_id=DX_MVP4025064

Building a windows 10 application

Here is the "how to" for beginners, but useful to anyone who starts on building a windows 10 application. It is a good way to start with good practices. http://blogs.windows.com/buildingapps/2015/09/30/windows-10-development-for-absolute-beginners/?WT.mc_id=DX_MVP4025064

Unit tests

A funny way of having a view of unit tests: http://blog.apterainc.com/custom-software/if-unit-tests-were-seinfeld-characters

IT Challenges

Sometime, you want to do more than your day work. This kind of website looks perfect for that: https://www.topcoder.com/ Take a challenge, and win prizes, or just learn new things!

Typescript and Angular 2

Using angular is a very popular way of building websites, webapplications. You probably know that the version 2 is coming, with breaking changes. Visual studio 2015 seems to be welcoming this new version. Take a quick look at this video: https://channel9.msdn.com/Events/Visual-Studio/Visual-Studio-2015-Final-Release-Event/TypeScript-and-Angular-2-in-Visual-Studio-2015

Visual Studio 2015

Did you ever wonder how Visual Studio is made? Look at this video, and see the changes that happened since older versions of VS. https://www.microsoft.com/france/visual-studio/evenements/visual-studio2015.aspx

KISS is my philosophy

How much time lost trying to understand what an other developper is trying to achieve? How much time lost trying to understand a x-line lambda? How muc time lost trying to review a spaghetti code? Well the answer is... to much. Sorry guys, but my brain is too small for too complicated things. One of my favovite principle is KISS: Keep It Simple, Stupid. Applying this philisophy, your code will be more readable, more comprehensive. Read this blog post to learn more.

Windows 10 - Getting started

Windows 10 is here! I hope it will be better than Windows 8 - 8.1... From what I can hear, it will be. Let's start a tour of this fresh new OS: http://www.hanselman.com/blog/GettingStartedWithWindows10.aspx .

Xamarin.forms.Maps - Tap to get a position on the map...

Image
Xamarin.Forms.Map component Xamarin.Forms.Maps is a great component. It gives you the possibility to deal with maps and geolocation problematics in a few lines of code. This "Map" component internally use native map controls for iOS, Android and Windows Phone: You can display and locate "Pins" with custom information on the map. I suggest you to read the reference links above. Display pins with custom information The problem But actually, in my mind, the Map control miss a very important feature: --> Tap  on the map to get the relative location (to put a new pin, to get the relative address...) The workaround Use renderers Actually, to solve this problem, we need to implement custom renderers for iOS and Android. Maybe this feature will be implemented later by Xamarin... So here is my solution (3 code files below): - ExtMap.cs : overloaded map control that will contain our "Tapped" event to get the tapped location

Microservices architecture

Building a monolithic app, even subdivided in different layers is not the only path... Recently, I discovered the Microservices architecture. This allow to separate the whole application itself in autonomous part of sub application. It has pros & cons. You can see this website for an advanced comparison. Martin fowler speaks about it: http://martinfowler.com/articles/microservices.html . Paul Mooney has also started an interesting series on this kind of architecture. Here are the first two parts: http://insidethecpu.com/2015/07/17/microservices-in-c-part-1-building-and-testing/ . http://insidethecpu.com/2015/07/31/microservices-in-c-part-2-consistent-message-delivery/ .

AOP through Unity interceptors - Conclusion

We have seen how pleasant could be the programmation with Unity and interceptors. Of course, you can use another IoC framework to achieve what we have done in this series. A good advice would be to use Autofac . This framework has more capabilities than Unity. An other point of attention is performance. Enabling interception is not cost free. You should take care of it: I would advice to measure the impact of enabling/disabling interception.

VS2013 Xamarin's incompatible plugin when installing VS2015...

Image
As a good .NET developer, yesterday I installed the new Visual Studio 2015 IDE to discover all its new features... VS2015 installed ! I was previously developping mobile apps with Xamarin on VS2013. So as I am impatient I installed VS2015 without thinking of all the modifications it can bring to my environment... And bingo ! When I started back VS2013 to edit my Xamarin's projects, I had a bad surprise: iOS & Android projects no more compatible... But, fortunately, I find a really quick solution to restore Xamarin compatibility with VS2013. In fact in the windows programs / functionnalities menu, I  changed the Xamarin app components configuration like above: Xamarin, change installation Xamarin for Visual Studio 2013 is disabled ! Re-enable it and it s all good :) And go you can continue to develop Xamarin projects with VS2013 !

AOP through Unity interceptors - Cryptography

Today, in our AOP serie, we will use Unity to encrypt/decrypt our data. Let's imagine that you have a repo that stores personal information about users. You may want some of this data to be encrypted, in case your database is stolen, or accessed illegaly. Once again, AOP helps us in this situation. Let's build our sample. We will need an interface & an implementation representing the user repository. public interface IUserRepo     {         bool IsUserAuthenticated(string login, [Encrypt] string password);          [Decrypt]         string GetPasswordForUser(string login);     } public class UserRepoImpl : IUserRepo     {         public bool IsUserAuthenticated(string login, string password)         {             if (password == "1234")                 return false;             return true;         }         public string GetPasswordForUser(string login)         {             return "wOSHX/n2NyWWn53YXVvJIg==";         }     } Using t

AOP through Unity interceptors - Compression

Today we are going to compress our data. We will still use AOP through Unity. The scenario is the following: we have a class generating a huge set of data (in our example, data structure is string). we don't want it to be kept in memory, because we will use it later, or not often. So one solution could be to compress this data & uncompress it once we will really need it. public interface IBigDataRepo     {         string GetData();     }  public class BigDataRepo : IBigDataRepo     {         public string GetData()         {             return new string('X', 100000);         }     } We are going to use is this way: static void Main(string[] args)         {             using (var container = new UnityContainer())             {                 container.AddNewExtension<Interception>();                 // Register                 container.RegisterType<IBigDataRepo, BigDataRepo>(                     new Interceptor<InterfaceInterceptor>(),       

AOP through Unity interceptors - Performance monitoring

Today we continue the serie on AOP with Performance monitoring. The principle is very simple: we want to monitor the time a method took to execute. Here is the code of the class. public class PerformanceMonitoringInterceptionBehavior : IInterceptionBehavior     {         public IEnumerable<Type> GetRequiredInterfaces()         {             return Type.EmptyTypes;         }         public IMethodReturn Invoke(IMethodInvocation input, GetNextInterceptionBehaviorDelegate getNext)         {             Stopwatch sw = Stopwatch.StartNew();             var result = getNext()(input, getNext);             sw.Stop();              WriteLog(String.Format("Method {0} took {1} ms", input.MethodBase, sw.ElapsedMilliseconds));             return result;         }         public bool WillExecute         {             get { return true; }         }         private void WriteLog(string message, string args = null)         {             var utcNow = DateTime.UtcNow;            

AOP through Unity interceptors - Caching

Image
Let's continue our serie on AOP with another popular usage of interception: caching. Let's use the previously created project and add this class: public class CachingInterceptionBehavior : IInterceptionBehavior     {         private static IDictionary<string, MemoryCache> Cache = new Dictionary<string, MemoryCache>();         private static IList<string> SyncLock = new List<string>();         private static object SyncRoot = new object();         public IMethodReturn Invoke(IMethodInvocation input, GetNextInterceptionBehaviorDelegate getNext)         {             if (input.MethodBase.GetCustomAttribute<IgnoreCacheAttribute>() != null)             {                 return getNext()(input, getNext);             }             var arguments = JsonConvert.SerializeObject(input.Arguments);             string key = string.Concat(input.MethodBase.DeclaringType.FullName, "|", input.MethodBase.ToString(), "|", arguments); if (IsInCa

AOP through Unity interceptors - Logging

The first thing we think when talking about interception is logging. Let's see an implementation of a Logger. But before introducing the Logger implementation, let us scaffold a console sample project. public interface IFoo { FooItem GetItem(string name); } public interface IStore { StoreItem Get(int id); IEnumerable<StoreItem> GetAll(); void Save(StoreItem item); void ThrowException(); } public class FooImpl : IFoo { public FooItem GetItem(string name) { return new FooItem { Name = name }; } } public class StoreImpl : IStore { public StoreItem Get(int id) { Thread.Sleep(1000); return new StoreItem { Id = id, Name = "Fake name" }; } public IEnumerables<StoreItem> GetAll() { Thread.Sleep(2000); return new List&ltStoreItem>()

[Xamarin Forms] Button text alignment issue in Android

Image
Recently, I had to deal with custom Buttons in my Android application. So I designed custom renderers to render it. Unfortunately, I encountered a strange behavior with the text alignment of my buttons. This happens when the button changes of state : - Originally the button's text is centered - When you click it, the text moves to the left See images below:   Before / after the button click After investigating, I found a solution to my problem. In my Android custom button renderer, I had to overwrite a specific method:  ChildDrawableStateChanged public class ExtButtonRenderer : ViewRenderer<Extbutton, global::android.widget.button> { ... public override void ChildDrawableStateChanged(Android.Views.View child) { base.ChildDrawableStateChanged(child); if (Control != null) Control.Text = Control.Text; } ... } That's all ! Related links: Custom renderers: http://developer.xamarin.com/guides

[Fast&Furious guide] Get ready to build a Xamarin iOS app

Image
In order to build, test and deploy an iOS application using the Xamarin SDK, you will need to setup your environement first. As you know, it's necessary to have a Mac computer that will be at least your build host... This post is just a quick guide to help you to setup your environment ! So let's go ! Setup your environnement (2 possibilities) The hardware needed: A- First choice: A MAC (MacBook Pro for instance) with a Virtual Machine (VmWare / Parallels) running Windows and Visual Studio with Xamarin. B- Second choice A MAC (will be used only as a build host) A PC (with Windows / Visual Studio / Xamarin SDK) on the same network Requirements: Minimum MAC OS versions : OS X Mountain Lion, iOS Xamarin SDK, XCode IDE Minimum Windows versions : Windows 7, Visual Studio 2010, latest Xamarin tools C-  You will also need an iOS developer account You need to have an iOS developer account in order to: - test / deploy your app on a device - publish your app

AOP through Unity interceptors - Introduction

Image
Hello, Today we will start a serie of blog posts concerning Aspect Oriented Programming (formely AOP ). This technic is used to have a better separation of concerns in the application you write. Let's take a basic example. When you are writing the implementation of a class that is specialized on a task, you could write someting like this: public class Calculator { public decimal Add(decimal num1, decimal num2) { Console.WriteLine("Entering Add Method"); var result = num1 + num2; Console.WriteLine("Exiting Add Method"); return result; } } The issue with this code is that the logging is part of the method. What will happen if you have a huge quantity of code? You will probably duplicate the logging code across te different class & methods you will write. Moreover, the Add method we wrote is not specialized on a single task: it has two different purpose: it effectly performs an adds operation and it lo

[Xamarin Forms] Embed custom fonts in your apps

Image
Recently I had some difficulties to embed custom fonts in my applications. Specially with the iOS application that was crashing with no message (while it was working for the Android version). In fact, it was a font issue. So in this post I will show you some tips to embed quickly custom fonts in both your Android & iOS apps. 1- Select your fonts The first step is to get some cool fonts you want to use. You'll maybe use (free) fonts from various websites like: www.1001freefonts.com www.dafont.com 2- Set font files properties In your solution, include your fonts files: iOS:  Create a subfolder (in the the 'Resources' directory) where to embed the fonts Build Action = BundleResource & "Copy Always" Android : Create a subfolder in the 'Assets' directory where to embed the fonts: Build Action = "AndroidAsset" & "Copy Always" 3- iOS application: edit your plist file With iOS you need to specify the e

C# Clean code book

Remember last week, I presented the website https://leanpub.com/ One interesting & free book recently published is https://leanpub.com/cleancsharp/ . You will find in there a lot of good tips to write clean C# code. Some tips are really useful. If the professional applications I work on would have be written by people who have read this book, my life would be easier! It is only question of "good sense" in my opinion, plus a set of established rules, like proven efficiency stuff. But I have to say that most of them are not applied, even in "top" french companies.

Publishing and/or Reading books

I would like to share with you a platform I found few weeks ago. I've already mentionned SyncFusion ebooks in an earlier post ( http://kampeki-factory.blogspot.fr/2015/03/syncfusion-free-eboks.html) . Notice that they still add free books regulary. The platform I discovered is called Leanpub ( https://leanpub.com/ ). As an author, you can propose your book, writen using your favorite tool. They are doing the publication in different formats (pdf, iPad, kindle...) on their side. An other interesting thing is that you set the price. In fact, you set two prices: the first one the is minimum price, and the second one is a suggested price. As a reader, you are informed of those two prices. You can pay the minimum price (which can be 0$). Or you can follow the author advice and give him the price he thinks his book is really.

Create a startup with DotNet tools?

Here is a pretty good article if you plan to create your startup. Will you choose Microsoft tools? http://rlacovara.blogspot.fr/2012/03/should-you-use-net-for-your-statup.html

Swagger IO

If you are building a WebAPI, I recommend the usage of swagger IO to document your API. It is incredibly simple to setup & provide you (and your clients) a very good way to expose and describe your data. The website: http://swagger.io/ To see a demo: http://petstore.swagger.io/

Visual Studio Code: a new IDE is born!

One important announcement at the Build conference is the release of a new IDE. It is called Visual Studio Code and it is a cross platform editor. It runs on Mac Linux and... Windows ;). It has Intellisense, supports multiple languages, has debugging and git built-in. Visit https://code.visualstudio.com/ to get more information & download.

[Fast&Furious guide] Setup a continuous integration process with TFS2013

Image
The goal of this post is to present you ( very quickly ) how to set up a TFS server (give you the steps) in order to get a continuous build integration environment. We will also talk about continuous deployement. For all the details, please take a look at the bottom of this post for the reference links... To summarize, the continuous integration process will help your team to merge their working copies  of your application code and to discover faster when a build fails. The reasons why a build fail can be multiple: - errors in code - a test fails - code analysis fails... We will take a look at the following points: - Configure the TFS Server - Create a new build definition - Insert tests in your build process - Manage team project's check-in policies - Deal with NuGet packages - Automatically deploy your project with MsDeploy. Setup your TFS 2013 server First you need to have a server that will manage and build your code. Install a TFS server and configu