If you have been reading my blog for the last couple weeks, you might have noticed that I have been using Xamarin to develop two mobile applications. When I wrote my initial impressions, I ran into multiple issues with getting the Android SDK to work and I also didn’t know how to use Xamarin Forms, and how to use the build in layouts, such as a StackLayout. Fast Forward a couple of weeks later, I got used to working with Android, working with the layout system and other features. In fact, I originally wrote a quick tutorial on how to use the ListView Control.
As many of you know, I like to stay busy. At any given time I have about two or three software projects going at the same time. Currently, I have 4 projects going right now. These projects include 2 mobile apps and 2 web-based projects. In addition to all of that, I work full time and attend college at night. However, I love being busy with my software projects because it helps me learn new skills and helps me get new client work. With that being said, I still find room in my day to taking care of myself, spend time with my family and to enjoy a good show on Netflix. To achieve a decent work-life balance, I had to develop a system in order to manage my time better in order to make room for my projects. The result is a four-step plan that anyone can follow in order to improve your efficiency.
If your new to mobile application development, one topic you should learn early on, is the concept of threading. Threading is a computer science term that handles the order of execution of tasks on the CPU. Threads are usually handled by the operating system. However there might be some tasks that can only be carried out on specialized threads created by the OS. To put things in context, consider the following example. Lets say I create an iOS application that uses a REST API to fetch data about upcoming concerts using location data. When you launch this application, the app freezes, takes a long time to load, and you see a white screen for more than 3 seconds. This is a common example of an app thats not optimized for the use of threads. As a result, you might receive complaints from your users saying that the app is slow or they delete your application all together. After a while, you decide to make some changes.
Upon inspection of your code, you find that your REST call is causing this slow down inside the
ViewDidLoad method. you have to remember that in this case your code is being executed line by line. This means when your REST call is carried out, the CPU must finish getting your data before displaying it on screen. After reading this, you may be asking why does this happen? This happens because by default your application business logic and UI are loaded on the same thread called the main thread. Quick operations like simple math and string manipulation are perfectly fine on the main thread, but time consuming tasks like REST calls are not the best option. So how do we fix this? The simplest thing we could do is move this time consuming task to what is called the Background Thread. The Background Thread is a thread designed for complex operations. In return you leave the Main Thread open for UI changes. Here is some example code on how to make this happen.
For those who know me personally you might be aware that I’m learning VB.Net for use at my day job. Up until a month ago, I was using my C# skills to create applications and API’s for my employer. However, this caused a problem and management told me I had to learn VB.Net ASAP. To be honest I had no problem with this because, I could probably find some good online resources that could teach me the language rather quickly, since I already knew the .Net Framework. However, things went down hill really fast. Most if not all the resources for learning VB.Net are either very out dated or very poor. With not having any luck, I decided to find a Microsoft Virtual Academy course on VB. However all the offerings Microsoft had were considered retired, and recommended that I learn C# instead or try this VB for Absolute Beginners course.
That course didn’t satisfy me. I didn’t need to learn how to use Visual Studio or how to use certain data structures. I knew all that from C#. Since VB and C# use the same .Net Framework and CLR. I can easily move my existing coding skills to the older language. I eventually found this course on Udemy. I took the course shortly before Christmas and found it to be very helpful. But still didn’t have the content I was looking for but, it seemed to teach what I wanted to know. Soon I began to practice my VB skills. I made a handful of small apps but nothing major. After feeling pretty good about myself, I decided to try some common CRUD actions using Entity Framework (EF), a popular ORM for .Net, and one of my favorite tools. I ran into the same issue with the initial VB learning. All example code was in C# not VB. I eventually figured it out but getting EF to work in VB is not straight forward and its very ugly with the syntax. For those that are curious here is a sample incase your wondering how it looks:
Comparing it to the C# syntax its very messy and verbose. In addition if your using Pogo classes in a MVC project You need to import them one at at time instead of importing the models namespace. Even though I’m sill learning VB its very clear that it is a afterthought at Microsoft and all development efforts are still focused on C#, as it should be. However, if your just starting out do not learn VB. You are more likely to see a C based language like C# rather than a language based on BASIC. Its only a matter of time before VB is retired. Please feel free to comment or reach out to me on Twitter with your thoughts.