Category Archives: .NET Platform

What the heck is Xamarin?

Xamarin on the Rise

By mid-2014 Xamarin is starting to pick up some traction in the market. There are more Xamarin jobs (paying very well) then there are programmers to do the work. So I get a lot of questions from recruiters and students about “What the Heck is Xamarin”?

xam-x-plat

So What the Heck Is Xamarin?

If you are a Microsoft shop C# is likely your language of choice. And Visual Studio your choice of IDE. Xamarin is two things:

  • a Visual Studio add-on so you can program Windows, Mac, Android or iOS apps* in C#.
  • a IDE for the Macintosh and Linux so you can Windows, Mac, Android or iOS apps in C#. (Visual Studio does not run on Mac or Linux)
  • an alternative to learning Objective-C and XCode on Mac or Eclipse and Java on Mac or Linux or Windows to program Android apps.

* even if you only use Visual Studio on Windows to build iOS Apps, you will need a Mac that will be used to compile your iOS code.

so-why-choose-us

So Why Choose Xamarin?

There are several compelling reasons

  • You are a Microsoft shop and a C# Zealot you have to build Android and/or Mac and/or iOS apps.
  • Learning Eclipse, Objective-C, Swift, XCode scares you to death. A Mac or Linux machine is not your cup of tea.
  • You did not like the price tag of my favorite tool  Rad Studio from Embarcadero Technologies  to do this although it’s C++ orientation (Delphi is available too, a language invented by the C# creator Anders Hejlsberg).
  • Because Microsoft told you too! (don’t laugh that has worked for them for decades with developers).

So these are all legit reasons, and they are why Xamarin’s star is rising.

why-not-hey-archiekeep-calm-and-choose-wisely-33

So Why Not Xamarin?

There are good reasons to not use Xamarin as well.

Rad Studio from Embarcadero Technologies may be more expensive (almost 5 x the cost fully loaded) but ITS MORE EXPENSIVE FOR A REASON.

  • XCode and SWIFT rock for iOS programming.
    • If you are a C# programmer get out of your comfort zone and try an Angel you don’t know, and don’t waste too much time griping its not the devil you know.
    • Even Objective C is nice compared to C++. So while it is a bit dated it is a nice superset of C and C++.
    • More frameworks and 3rd party libraries and open source libraries available than with Xamarin.
  • Eclipse and Java is multi-platform (and while it is worse than VStudio with the right add-ins it can be quite nice) and learning new stuff is always fun unless you are stubborn.
    • Its not THAT hard its just difference. Hard is macro-assembler or VI. Eclipse is easy.
    • More frameworks and 3rd party libraries and open source libraries available than with Xamarin.
  • You have Simpler Cloud and iOS and Android needs that can be met with
    • PhoneGap
    • Icenium

The above frameworks and code-generation tools do a LOT of the work for you and are built on HTML 5 and JavaScript instead of low-level code with all that implies good and bad.

 

xamarincodesharing-500x297

How do I learn it? What does it cost?

Well the good news is there are not many books, so you won’t go broke buying every Xamarin book. The bad news is since there are not many books you better be great at Googling and teaching yourself. As for the cost at the time of this writing the Xamarin IDE for Linux or Mac costs about $83/month (about $1,000 a year).

  • Renowned author Charles Petzold wrote a book that you can get a free preview edition of here @
    Petzold-Book-232x300
  • The Xamarin cookbook by Dimitris Tavlikos focusing on iOS is good @
    ios-Cookbook

If you have any favorite Xamarin books or learning resources, please share it in a comment so we can add it here.

My Xamarin predictions

crystal-ball-future-quote

Xamarin is young and with 30+ years in the computer field and business/marketing prediction field I can safely give you a roadmap of Xamarin’s future:

  • Microsoft will buy it or clone/steal it.
  • If MS clones it, it will take the form of a Mac and Linux VStudio first with a FREE Xamarin add-in before they ditch it for a “built in house” replacement.
  • The cross platform Framework may catch up to Rad Studio from Embarcadero Technologies in a few years.
  • Basically the need for a MAC will go away because they will invent a Virtual Cloud Mac that transparently compiles it for you via WebService.

These predictions were made on November 2014 and will be updated as they occur, or something happens that proves they will never occur.

Great LinQ Bloggers

linq-logo

Want to read some great LinQ blogs?

Draft – .NET Code Generation

What the heck is code generation?

Code generation is an old idea, that people hobbled together solutions to make it happen. Lets start by showing a few examples of it:

  • Lets say you are writing a class in .NET but many of its properties are based on fields in a database table. For example if the database has 25 fields the class will have 25 properties that map to the database fields. Sure you could type out the property names and types once and have the 25 properties in your class and be done. That is until they add or remove table fields or rename them, and you must go back to your editor and add/delete/rename ad nauseum.  If you have 30 tables that you are wrapping into corresponding objects DBMS changes mean a lot of tedious work to keep them in sync. A code generator could just loop through field names and types dynamically and generate corresponding properties. Update the database tables, then regenerate the code and dozens or hundreds of classes are updated.
  • Now for a simpler example. Let us say you know that the query SELECT * from Location is slower than the query SELECT id,city,state,zip from location.  This could be streamlined by creating a code generating function inline i.e. SELECT <%FieldNames(“Location”)%> from location which expands before compilation to the latter SELECT with an explicit field list.

CodeSmith and FREE T4 – The Coke and Pepsi of Code Generation

In all marketing wars there ends up being 2 leader once the market becomes mature. A strong #1 can “suck the oxygen out of the room” and delay 1 #2 rising, at the risk of the category dying entirely.

Code Generation for .NET there are 2 players

CodeSmith is fairly neutral and can generate any code for any language or platform. T4 is coupled to .NET and visual Studio. Most ORMs for .NET use one of  these two to generate their classes.

Another Approach or 2 or 3

These are just one approach to Code Generation, a simple and easy one.

  • the Roslyn project is yet another focused on the more compiler writer type of person. Read more about the Roslyn project @
    http://msdn.microsoft.com/en-us/vstudio/roslyn.aspx
  • CodeDom allows one to write .NET code dynamically, and combined with Reflection to read the code entities at runtime it is an approach that many used who do not know these tools or just prefer this approach and the runtime checking it provides.
  • All this often dovetails with use of attributes.

What about code generation on other platforms?

  • Linux
  • Mac
  • iOS
  • Android

 

DRAFT – VSNetCodePrint – an amazing Product

I Refactor code a lot. But refactoring code requires sometimes reading lots of code on paper or PDF, and Microsoft Visual Studio has the worse printing support on the planet.

VSnetcodePrint to the rescue. It is a great product. Well supported. Inexpensive.

I have some things I would like them to improve:

  • method visibility in the TOC
  • minification support for JavaScript
  • Data for SQL Tables in their printouts (with a few options)

DRAFT Asp.net MVC: Getting Started The Right Way DRAFT

aspnetMVC

DRAFT MVC and ASP.net – a Match Made in Heaven! DRAFT

asp-net-mvc-debate asp-net-mvc-thin

How is it better than WebForms?

ASP.net MVC is in many ways better than WebForms for example:

  • Testability (i.e. Unit Testing) is much easier by design in MVC
  • Separation of Concerns (see ??) is much easier by design in MVC
  • HTML 5 and JavaScript and CSS and Mobile Development is less encumbered by gotchas
  • It is much easier to have a page interact with a fairly sophisticated back-end code base
  • Postback is NOT its central model. Ajax and partial refreshes are first class citizens here.
  • It pays more if you negotiate right.

There are other benefits but hopefully these will be enticing.

aspnetMVC-architecture Zombie-Bad-Fire-Worse

How is it worse than WebForms?

xxxxx

xxxxx

xxxxx

canada-oil-sands-threatened-by-spiralling-costs-300x250 cost-calculator1

What must I buy? (Asp.net MVC is free, learning it may not be)

Here are the sums of the expenses:

  • ASP.net MVC is free so that part is the best thing.
  • If you don’t have Visual Studio, you will need the Community Edition which is FREE, a much better choice than the express edition.
  • If you are on a Mac or Linux you will need Xamarin (not free), or just setup a VM there and run Windows on them.
  • You can read online tutorials like:
    • xxxx
    • xxxx
    • xxxx
    • But I recommend supplementing them with some books that will go into the whys and high end concepts that quick tutorials cannot cover.
  • If your HTML 5 and Javascript and Juery and JS frameworks are rusty, or you don’t know it you will need to invest time in learning that (see my recommendations here).
adam-freeman-bookThis book will answer all your intermediate and advanced questions better than most books. It does not handle the many beginner questions you will have that online tutorials handle better. It has a better architecture focus than most of the competing books so lots of wisdom – although sometimes short on knowledge. CsharpinanutshellThe C# Bible. A must own for every .NET programmer. Tremendous bang for the buck and years of material crammed into a dense easy to understand book.
adam-freeman-bookRefactoring is the BIBLE for Separation of Concerns. CsharpinanutshellDesign Patterns are vital, but the mainstream books are too hard to understand. This book will make Design Patterns much clearer to you.

 

Those downloads, tutorials and books will make your sword very sharp in slaying the MVC dragon!

mvc-high-point

What the heck is MVC? MVP? MVVM?

xxxxx

  • MVVM
  • xxxxx
  • xxxxx

Some other terms that may be helpful to you we will define here are:

  • Route —
  • Partial View –
  • Attributes –
  • Areas –
  • Web API –

shortcut shortcut-2

Are there any shortcuts?

xxxxx

  • DevExpress is awesome. I prefer it to Telerik, Infragistics and Kendo. They all are good, but DevExpress is the best I have used.

 

How do I know when I am doing it right?

A tough question but the right one.  Give yourself time to get it right. Plenty of people are doing it wrong and half assed and shipping code. Shipping code and meeting boss deadlines and project budgets does matter more than the wisest approach on your first project if you have no mentors or leaders who are veterans.

I have questions. Where do I ask them?

xxxxxxx

  • xxxx
  • xxxx
  • xxxx

Get out there and code your first ASP.net MVC project!
I (and many others) will answer your questions on [AspNetAnyQuestionIsOK] when you do code!