How often you feel that your code is suddenly slow compared to couple of days before after some code is being added? After a while do you feel a need of cleaning up code because of lot of trial and errors, and don’t know which code is safe to delete? Do you feel some functions are too big to manage? Are you feeling overwhelmed by number of data model classes you have added and need a way to visualize the dependencies between these models quite often? Answer to many questions like these and more is a simple and very efficient tool call NDepend. I have been using NDepend from its version 2 in early 2005, and with every release they never seize to surprise me! Latest version 5 is one of the best one so far Some cool features include more than 150 code rules that check your code quality, can scan up to 10000 lines of code per second, adds no code to your code, integrated with Visual Studio, provides some beautiful actionable metrics, reports and graphs that will make it easy to fix the code quickly. It can also compare builds, do code diffs, detect cyclic dependencies. It can give you metrics based on application, assembly, namespaces, types, methods and fields. If you haven’t tried it yet, you should head over to NDepend website and start a trial and get amazed how you code can be analyzed:)
On 19th April, we conducted a Hands on Labs for Xamarin iOS. Most of the attendees were from ASP.Net or WPF background. So, we decided to take a simple application of calculating Auto Fare in Bangalore which we did during 5th April Hands on Labs for Xamarin Android and use the same PCL in iOS app.
Attendees were able to follow through the lab, and reproduced the results and won some cool goodies. Due to complex publishing cycle, we demoed the procedure to publish the app to iTunes store.
On 21st June, on the month of Xamarin turning 3, we will be having an event showcasing new features and demos with lots of food and food for thought. Don’t miss this event, as we are giving away a book, couple of T Shirts and some goodies.
Way to go XHackers
On 5th April, we conducted a Hands on Labs for Xamarin Android. Most of the attendees were from ASP.Net or WPF background. So, we decided to take a simple application of calculating Auto Fare in Bangalore.
We first did a WPF application that does the calculation. Later we discussed how to extract the business logic and use PCL [Portable Class Library] to host it. Later, we started an Android project and used PCL to demonstrate code reuse. Code built during the event is uploaded to XHackers GitHub a/c for reference.
Attendees were able to follow through the lab, and reproduced the results and won some cool goodies. Few people were able to publish the app to stores.
On 19th April, we will be conducting Hands on Labs for Xamarin iOS. Don’t miss this event, as we are giving away a book, couple of T Shirts and some goodies.
Way to go XHackers
Lets assume app needs an external database, either hosted on cloud or on premise.
Build 2 sets of REST APIs, one for Authentication and another for actual app logic talking to your database. Also host them on different server instances if possible. If attacker is trying to break the authentication server and creates DDOS attack, your app logic server is not compromised. Also make sure every REST call for the app logic is validated by a token generated after authentication
Your client side UI can be very simple. If it is web application, you can go with simple HTML, jQuery with extensive use of Templates, and client side validations. No server side code cris-crossing your HTML and jQuery calls to REST APIs for data. This also helps in packaging the same HTML, JS, CSS in phonegap apps for any targeted mobile platform.
Your client can also be a native Windows app, Web app, Windows Phone App, iOS app or Android App. All of them will just have UI related code and all of them talk to REST APIs for data. This makes the UI/UX designers to actually work without worrying too much about server side coding.
If you architecture is based on Microsoft .Net platform, you can use Portable Class Library [PCL] to encompass your REST calls to easily usable function calls. And your Windows app, Web app, Windows Phone App, iOS using Xamarin and Android using Xamarin can all call the same PCL library for data access.
Do let me know if there are better alternatives.
Hope it helps
In most of the Windows / ASP.Net applications, if we have to send a parameter from master page to detail page, we have several ways of doing it, like Query string, POST parameters, session state, database, static class with static variable etc. In Xamarin, we can still do database and static class approach. Most commonly used approach is using PutExtra
var detailActivity= new Intent (this, typeof(DetailActivity)); detailActivity.PutExtra ("MyData", "Data from MasterActivity"); StartActivity (detailActivity);
On the receiving detail page you can access the Value as below
string text = Intent.GetStringExtra ("MyData") ?? "Data not available";
Hope that helps Watch out for more soon!
[amazon_carousel widget_type="SearchAndAdd" width="500" height="200" title="" market_place="US" shuffle_products="False" show_border="False" keywords="xamarin" browse_node="" search_index="Books" /]
We are conducting first XHackers event in Kolkata on March 27th 2014. We will be introducing Xamarin, how to write simple Android apps using Xamarin. Seeing the response of this meetup, we will conduct level 100, 200, 300 sessions, hands on labs, hackathons in near future.
If you are in Kolkata, don’t miss this event.
On the first day of World’s First Windows Azure Conference, 20th March, I presented a webcast on ‘Enrich your Windows 8 apps: Sensors and Media’
Essence of the talk was how to use Media like webcam and mic for capturing photos, audio and video and playing them back, Playing DRM enabled PlayReady content. Also quick demo of using sensors like Accelerometer, Compass, Gyrometer, LightSensor, Inclinometer and GPS. Also a concept called Sensor Fusion which showcases how using more than one sensor to build some cool new apps.
Most of the Windows RT enabled devices cannot run Visual Studio and if we have to test the sensors of them, Microsoft has released a set of Remote Debugging tools. You can find them at here and how to setup and debug here.
You can find the presentation at here .
All the code samples used in the demo are available at here
Continuing the series, lets understand how controls are created and used
- Just like in WPF, ASP.Net, Windows Forms, in Xamarin based android layout designer, we drag and drop controls on to the controls on to the layout screen. The code it generates is XML which can also be typed manually or controls can also be instantiated and referred completely in activity. However, the key difference lies in how we get to access the controls.
- In WPF, ASP.Net, Windows Forms, where the UI and the related code behind, double clicking on a button in UI, it automatically wires a event handler and all controls are accessible by the names you gave.
In Android, we have to refer to controls first by searching and assigning it to local variables using
ControlType localVariable = FindViewById<ControlType>(Resource.Id.ControlName);
Sounds pretty lame if you see from Windows developer’s view. But it is true decoupling of UI and Code behind. Makes sense?
Hope that helps you get started further Watch out for more soon.
For someone who starts with Xamarin without Android knowledge, it will be a tough nut to crack. Being a .Net developer for more than 13 years, I was wondering why someone would build an Android app the way it is built. But then there are some good reasons for why it is built that way. If you are a Windows Forms/WPF/ASP.Net developer, you might find this post easy to understand the differences.
For starters, lets look at Designer and Code behind files that we know very well
- UI designer files like .xaml for WPF, .aspx for ASP.Net , .cshtml for MVC windows form designer files are equivalent to .axml files which are usually found in /Resources/Layout/ folder. Sometimes .xml files are also used to define the UI. Xamarin provides a UI designer for .axml and .xml files
- Code behind files like .xaml.cs WPF, .aspx.cs for ASP.Net, controller for MVC, windows form code behind files are equivalent to activity.cs files that are usually inherit from Android.App.Activity class. Unlike the Designer and code behind are usually linked and easily identifiable in Microsoft world, Activity in Android usually links the Layouts by setting them manually in code using SetContentView like
Hope that helps you get started Watch out for more soon.
XHackers is a Gloal group of Xamarin Enthusiasts who want to share their love for Xamarin to all those who want to learn how to put Xamarin to best use.
We had our first meetup on Feb 1st 2014, group of 7 guys and 1 lady to form XHackers. We were so excited to talk about Xamarin, we forgot to take a picture :D. On March 1st 2014, we did an another meetup for introducing iOS and Android programming to bunch of enthusiasts. Started with programs on how to write ‘Hello World’ for each platform. It was a decent turn out for first public meeting. Post this event we have pushed hard to grow this community and we have crossed 100 members as of today.
Very soon, we want to conduct hands on sessions, weekend hackathons, iOS and Android App porting hackathons. Watch out for more at our Meetup page.
Now is the time for you to speak up and say what you want to hear from us. We want to hear your stories of your Xamarin Experience at our next meetup. Also let us know, how we should do our next meetup? Hands on classes? More hello world sessions? do send a mail to reachus at xhackers dot co
Also XHackers was meant to be a global group. Currently our first two meetups happened in Bangalore, India. If you want us to come to your city, do send a mail to reachus at xhackers dot co. One of core members will be visting your city for first meetup and help that city chapter started in your city.