win8dev

Dev Story Series (Part 1 of many): Creating a data class for both Windows 8 and Windows Phone app

Dev Story Series (Part 1 of many): Creating a data class for both Windows 8 and Windows Phone app

As I promised earlier on my application for the Intel App Innovation Contest on codeproject.com, I will do a series of blog posts for my application MSicc´s Blog for Windows 8 and Windows Phone.

This is the first article in my new Dev Story Series, where I describe the development process of the app. I am starting with the very first steps that you have to do if you plan such an application. To make the application useful, we first have to decide how we want to get the data from our blog/website into our application.

One hint that will make some of you crying out loud: At the moment I am not using the MVVM pattern. I am aware of the fact that most devs for Silverlight/C# swear on it, but I still decided to go without it – as well on Windows Phone as on Windows 8. I will continue to learn it in one of my future project, but for the moment I just want to get things done – also if that means that I have to create some – well, let us call it “compromises”.

Which way to choose?

If you consider to create a “blog reader”, you have to think about how you want to get the data from your blog into your app. There are different ways:

  • via a RSS/Atom feed (that was in the old version of my Windows Phone app for msicc.net)
  • via XMLRPC (if your blog supports that)
  • via JSON

I decided to go with JSON for the new version. There were several reasons to do so:

  • there is an app err… an plugin for that on WordPress
  • JSON is fast
  • JSON is set to be the new standard for data consumption
  • With JSON.NET you can deserialize your data with only one line(!) of code

How do we get the data in our app?

Of course, we will download it. But if you only download your JSON data, the only thing you will get is a very weird looking string that looks like this:

json_string_unserialized

That´s pretty ugly, right? Of course we could work us through all arrays and objects there. That would take hours and hours until we would have covered all data we need for our apps. Luckily, there are two tools that make the whole thing a lot easier.

Two handy tools to make a dev´s life easier

The first tool I want to show you is “Beautify JSON”. It is a web based tool that makes strings like the one above readable for a human. Find it here.

Just paste the string of your JSON API in there, and you will get a readable version of your JSON string:

beautify_json

If you want to use only some of the data that your API provides, you can now easily search the string for the objects and arrays that you need.

If you quickly want to create a data class for all data that is provided, you can do this by using json2charp.  It provides a ready-to-use code that can easily be copied and pasted into your class file in Visual Studio:

json2charp

Now let´s have a look to the class itself:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace WordPressDataClass
{
 public class Posts
    {
        [DataMember]
        public string status { get; set; }
        [DataMember]
        public int count { get; set; }
        [DataMember]
        public int count_total { get; set; }
        [DataMember]
        public int pages { get; set; }
        [DataMember]
        public List<Post> posts { get; set; }
    }
}

As you can see, I created a DataContract and DataMember based class by using System.Runtime.Serialization. If you want to know more about DataContracts and DataMembers I recommend you to read MSDN: using Data Contracts.

I am not posting the whole class, only the key DataContract Posts, which will get us our List of posts. You can download the whole class at the end of the post. It will be very helpful if you want to create an app for your WordPress based blog.

I use the class in both my Windows 8 and my Windows Phone app without any differences. As you can see, If you are familiar with Windows Phone Development, there is only a small step to Windows 8 development.

I hope this article is helpful for some of you. In my next post I will show you how easily you can use the provided JSON Data in your app/s.

source code: JsonDataClass

Posted by msicc in Archive, 4 comments

Smart little helper to clean HTML based strings for [WPDEV] and [WIN8DEV]

I thought I would share this small little class I created to clean out HTML based strings into readable strings. The class is both usable for your Windows Phone app as well as your Windows 8 app.

If you use cloud based or internet data, often strings contain “&ndash;” or “&#8211;” instead of their intended letter, like you can see on this image:

htmlstringuncleaned

The method uses Regex to replace all the wrong signs and clean out all of the unwanted signs. You can also add more to that if you need to replace wrong letters.

class CleanHTML
    {      
        public static string RemoveEncoding(string text)
        {
            try
            {
                string temp="";

                temp = 
                    Regex.Replace
                    (text.
                    Replace("&ndash;", "-").
                    Replace("&nbsp;", " ").
                    Replace("&rsquo;", "'").
                    Replace("&amp;", "&").
                    Replace("&#038;", "&").
                    Replace("&quot;", """).
                    Replace("&#039;", "'").
                    Replace("&#8230;", "...").
                    Replace("&#8212;", "—").
                    Replace("&#8211;", "-").
                    Replace("&#8220;", "“").
                    Replace("&#8221;", "”").
                    Replace("&#8217;", "'").
                    Replace("&#160;", " ").
                    Replace("&gt;", ">").
                    Replace("&rdquo;", """).
                    Replace("&ldquo;", """).
                    Replace("&lt;", "<").
                    Replace("&#215;", "×").
                    Replace("&#8242;", "′").
                    Replace("&#8243;", "″").
                    Replace("&#8216;", "'"),
                    "<[^<>]+>", "");

                return temp;
            }
            catch
            {
                return "";
            }
        }

        }

As we created a class for this little helper, you can call it from everywhere within you app to clean out the string. Here is one example I am using:

 item.title = CleanHTML.RemoveEncoding(item.title);

After calling this method, your string is plain text:

Screenshot (17)

I hope this post will be helpful for some of you.

Happy coding!

Posted by msicc in Archive, 0 comments
Editorial – the relationship between developers and users

Editorial – the relationship between developers and users

I did not plan this post, but as I received an email yesterday from another developer, this changed. This post will be an Editorial about the relationship between developers and users.

Users and developers do have a problem. Users have expectations for our apps. We developers have to fulfill these expectations. Here is an image I found on the web, that describes the situation quite well:

Of course, this is a funny Picture. But in the last few weeks sadly this image turned out to be kind of  true. I talked also to other developers, and they made similar experiences. I will try to explain why feedback is important to us developers.

It all starts with an idea. The idea can come from a friend, a family member or from a situation your life. For my very first app the situation was simply the app I searched was not out there in the marketplace and it is no pleasure to use the mobile web in some situation (e.g. while fishing). For another app a discussion on my primary work was the reason.

If you are an app developer, you now sit down and create a concept. You have to think about a lot of things:

  • which features do I want in my application?
  • do I already know all to get this features into my app?
  • where can I learn about features that I want but do not know how to code them?
  • How does the UI have to look?
  • How much time will it cost to create a first running application?
  • what are the limitations of the OS I am coding for?
  • how can I promote my apps?
  • and certainly a few other things

Until now, we do not have written one line of code, but already spent a few hours if not days only in planning phase. At some point, of course we start coding. The coding and designing process is followed by ups and downs, where you have to reconsider features, sometimes even have to rethink your whole attempt on how to create the app.

I have a very good example for that. Initially I tried to use animated gifs in my app “fishing knots +” . It turned out that Windows Phone does not support this image format natively. So I searched a way to achieve my goal and let Windows Phone learn it within my app. There are some solutions out there, but I was not satisfied with the result. So I started to search for alternatives and found one that suites it very well: a storyboard for each animation. But then I had another problem: For a storyboard animation, you need single images, not a finished gif animation. Luckily one of my co-workers could help me out and created the images for me, so I was able to use it. But it took also some time for him to create the images (12 knots with at least 10 images). I created the basic images, and he did his magic. The result was great.

Now we have a very basic version of our app that runs, and can also be shown to some people. And of course, friends, coworkers and family are your first “customers” that give you some feedback. You should be grateful for the feedback they provide, as it often offers you sights on which you do not think while developing the app. Also if that means you have to rewrite a bunch of your code. They are no developers (in most cases). They are just users. Let them play around with your app (best on a real device!), and do write down every single point they tell you. Feedback is good, and helps you to evolve.

Now that we have done this, our app at some point reaches the state of being submitted to the Marketplace/Store. You should never start with a final version number like 1.0 for that. 1.0 suggests a user that it is a finished product with nearly no error. And they errors will come. I did not see a single app that was without issues on the first release, neither on the following updates. This counts for my apps as well as for apps of other developers. But that is not a bad thing. Once you have published your app, you have the possibility to obtain more feedback. This time from real end users.

To achieve this, you should offer a way to give feedback within your application. Here is my attempt that I have in every of my apps:

 

 

As you can see, I integrated a few ways to obtain feedback. I created a twitter handle, where users can give feedback and follow for actual announcements for my apps. Nowadays a Facebook page is also an advantage, and then users have the ability to send me an email to provide more detailed feedback. And one thing you never should miss: a direct link from your app to the review section of your app in Marketplace.

So from our part, we did all to get some feedback. Now to you, user of our app! We want you to give us some feedback! What we want is feedback that helps us to understand what you expect.

Sadly a lot of users are rating an app with less stars, providing no feedback or only harsh words for the app. A rating for an app was delivered with less than 5 stars because the app is not free. Another one gave me 1 start and as comment: “great”. That is not feedback that can be used to improve the app.

Another example is glƏƏk! for Windows 8. It is an really fast and fantastic twitter app. I use also their Windows Phone version, and I am absolutely happy with it.

The first versions of the Windows 8 app had some problems and was crashing a lot. Users, of course, wrote that into their reviews. But how many of them did give them feedback to improve the app? As I am in contact with the developers, I know that they did not get a lot of feedback to iron out all those issues. Feedback is important to us developers. We need to know in which cases you, the users, have the issues. We have to reproduce the error, but that is nearly impossible without your feedback.

I understand that you give a bad rating to an app if it crashes a lot or if you are constantly facing other problems. And we developers try to iron out every single point you tell us. If you see that the experience has improved, you also should honor the work we do for you and update your rating and review. glƏƏk! had some issues like all other twitter clients on Windows 8, too. In the meantime, glƏƏk! was updated nearly every day to iron out other issues, and finally we have a non crashing version.  But no one updated their reviews and ratings. Sure, some may have uninstalled the app, others are having it  still but do not updated their rating/review. This is frustrating for developers who do not get a lot of feedback via email or other channels but only via the ratings.

Please, do not take this as advice to not rate our apps. We want your ratings. But be fair. If something is wrong with one of our apps, please tell us! But I beg you to understand that we only can work with quality feedback, so please use twitter/Facebook/email, whatever we offer you. Give us as much information as you can, answer to our questions if we have them to you.  And please update your ratings after we have ironed out your issues.

Please not also that we are no aliens. We are humans like you after all. And we are  also users.

Posted by msicc in Editorials, 0 comments
Post #200 or what exiting times we have with Microsoft

Post #200 or what exiting times we have with Microsoft

microsoft_logoI struggled with myself very long on what topic I dedicate this post with the anniversary number 200 and ended up with this article.

We all had already a very exiting year with Microsoft. Microsoft is fully in his “reimagine” phase, and the winners of this are we – as users, and as developers.

Windows 8

The year was starting for me with a key milestone: Windows 8 CP. A more fluid and fast alternative to the DP Microsoft released last year. And we finally had a good amount of apps (for a beta build). I felt really in Love with Windows 8 after using it only a few hours. Windows 8 is totally different. The Metro start screen will change the way how users will interact with their PC – also if it is non touchable.

I am currently running the final version of Windows  (RTM), and I love it to use more and more apps instead of visiting websites. It is way more fun to use a twitter app than to use their website, for example.

It is a change in the daily use of your PC, but most of the users that I personally know are exited about how easy it is to use a PC with apps. Sure, there are some people who will not be satisfied. That is not a bad thing. We all like different kind of things. But I am convinced that the majority of people will accept the Metro screen as part of their PC. Period.

For Developers it is amazing: no matter what language you are using right now, almost everyone can do Windows 8 apps. No matter if you are a Web Designer, used to Java, C# or C++, your app can be there on Windows 8! And you can even use more than one programming languages in one app.

In March this year I visited the CeBit, a trade fair that is for technology news here in Germany. I was amazed about the things I saw from Microsoft, but Germany is not a big target for the mobile/IT-industry- at least not shortly after the MWC. You can read my report about the CeBit here.

Windows Phone

Windows Phone is also an important point on our list. Microsoft´s mobile OS may not be blown up as iOS or Android – but we are satisfied with what we have! The OS is fast, does Average Joe´s daily doings way faster than the other two OS – without Multicore-CPUs!!! Microsoft demonstrated this with their “Smoked by Windows Phone” campaign, which was happening in several countries around the globe.

The best thing is: The OS will be getting even better! The existing devices will get an update with new functions, that will further enhance the user experience. And there will be the next generation: Windows Phone 8!  Windows Phone 8 will get a whole new core compared to 7, that will bring a lot more features, and for all that spec-driven users out there also multi-core support. Soon we will know more about it (I guess in September).

Xbox 360 and Xbox Live/Zune

Microsoft is also evolving the Xbox/Zune services as well as the Xbox OS itself. If you were one of the lucky one´s like me to enter the Fall 2012 beta update program, you know that it is getting better and better.  I am not allowed to go to deep into detail, but a few things have been announced, like IE for Xbox.

Xbox Live and Zune services will be merged together to further enhance our experience. Hopefully Microsoft will be providing more features to all countries, not only US. Best example is Zune Pass, which is still not available here in Germany. I don´t know what issues Microsoft has with the Germany system, but others like Deezer and Spotify were also able to solve those problems. Let us hope all the best for this.

And then there will be SmartGlass. Your Xbox companion – regardless which device you use. SmartGlass will be used to extend the experience you with your Xbox. Additional info for Movies, extensions for Games, and many many more.

Office 2013

I am also exited about the free-to-test-for-everybody Office 2013 Preview. Microsoft changed the programs into streamed applications. And they are performing very well (even with my slow 2 MBit/s connection). On top Microsoft released One Note MX, a Metro app for Windows 8 for those who use a WinRT tablet only. Get it today via the official Office 2013 website (for up to 5 PCs!). Skype integration is coming later this year via an “Office app”.  There are also further apps in the Office Beta Store.

Microsoft Account and connected Websites

Microsoft changed the formerly known “Live-ID” into “Microsoft Account”. You still have all service like before, with a new name. But there is more. Hotmail will be replaced with outlook.com (in Metro Style). outlook.com has also a “People” app, “Calendar” and of course your “Mail”. On top we now have a Metro “Messenger”. SkyDrive is the last one in this round. Also SkyDrive has been Metro overhauled an got new functions, like a url-shortening service, using skdrv.ms.

MSiccDev goes BizSpark

As some of you know, I am also developing for Windows Phone and will start with Windows 8 soon. I started to learn creating apps because there was no app for fishermen, and I needed a fishing knots app in the marketplace. I am currently planning on a big service for fishermen that targets Windows, Windows Phone and the Web. To get things done with a little help from Microsoft, I applied for Microsoft´s BizSpark program – an got approved last week! Stay tuned, soon I will reveal more information about the project. But it is great that Microsoft support startups. A special thanks goes to @AWSOMEDEVSIGNER (follow him!).

Final thoughts

I don’t know how you feel, but that was a pretty awesome year until now. Windows 8 is around the corner, and will bring new device factors like Microsoft´s surface. All big vendors announced at least one Tablet/PC-convertible. Windows Phone 8 will be the booster rocket for the phone OS version, the codename “Apollo” fits really nice in here.  Microsoft´s vision of “three screens, once experience” is getting closer and closer. And the best thing: we all can participate right now!

Posted by msicc in Archive, 0 comments