Friday, May 17, 2013

Windows Phone App Design Principles

Hope most of you might have heard DOUGLAS MARTIN's quote:
         "Questions about whether design is  necessary or affordable are quite beside the point: Design is inevitable. The alternative to good design is bad design, not no design at all."

And  VICTOR PAPANEK says: 
       "Design is the conscious effort to impose meaningful order"

So, if designing is that much important then one has to be very much stern about it. Going forward, today I am pointing out some design principles for Windows Phone App. So, let's gear up.

  • Clutter free UI - Information should be well organized and user should not get congestion like feel. Make best use of typography
  • Focus should be on content and it should be in a way that it attracts the user's attention from the beginning itself
  • Try to keep only the most pertinent content on the screen because when it comes to WP design, content matters more than a chrome
  • Try to provide seamless UX from dedicated device buttons
  • Tiles should be soulful and alive, in order to achieve the better responsiveness
  • Accentuate more on enhanced touch and gesture information
  • Try to keep the smart screen updated with only the latest and germane information
  • Use proper icon/text to introduce your app
  • Always create UI mockups, before proceeding towards actual implementation
  • Once mockups are ready, never hesitate to do usability testing
  • Provide app uniformity by providing similar meaning to similar images, color, symbols, etc
  • Do spend time in branding your app - it includes logo, color, copyright info, etc.
Hope above tips were useful :)

Wednesday, May 15, 2013

Windows Phone App' s Tip - Image consideration


Images play a very significant role in any Windows Phone application. So, one should be very careful while dealing with images. As of now, Windows Phone supports only two image formats named JPG/JPEG and PNG. Now before concluding on which image format to choose, let's get into bit more depth of it.

PNG format images are non-lossy and need very little CPU effort to display because those are pixel perfect. But at the same time, huge PNG images take too much longer to read from storage and ultimately lead to slower display.
On the other hand, JPEG format images are lossy, smaller to store  and based on the compression level much more complicated decoding algorithm is required to display them.

Another point regarding image is about opacity and transparency - All the images that use transparency should be stored as PNG format because JPEG doesn’t support transparency and JPEG format should be used for all the images that are fully opaque.

Now when coming to Windows Phone apps, performance matters a lot...Isn’t it?
Well, now some best tips to make our Windows Phone app much more performant:
  • Choosing proper image format: Use JPEG for anything large and PNG for anything small, i.e. use PNG for small icons. If image transparency is not a concern then it is always recommended to use JPEG.
  • Compiling images with Build Action=Content: Whenever a new image is added to the project, the default "Build Action" is set to Resource. It is always recommended to change this "Build Action" property to Content as it will reduce the size of our DLL, resulting in speedy image and app loading.

Note: Resources are included in an assembly whereas content is included in deployment package.
  • Image size: One of the limitations of Windows Phone is the limited screen resolution. So one has to consider proper image size, in order to gain better performance

 I'll keep updating this post as and when I'll get to know about more interesting facts. I would be very happy, if you can add more on to it.


Thursday, March 21, 2013

Silly but useful stuff - Part 3 (UI)

Importance of UI in performance
Simple UI tricks, such as progress bars, redirecting user's attention using animation, or placing slower loading sections at the bottom of a page or off-screen, can often ‘fix’ a performance problem without the need to tune the underlying code.
These UI tricks are an important tool to have in your performance tuning toolbox and can be much quicker and easier than addressing the underlying issue. They can act as a holdover until you have the time to devote to the core problem. So, one should never underestimate the UI while tackling performance issues.

Isn't it interesting :)

Saturday, March 2, 2013

StringBuilder is NOT the answer for all string concatenation scenarios; String.Join could be

Yes, if you are in a loop and adding to a string, then a StringBuilder *could* be most appropriate. However, the overhead of spinning up a StringBuilder instance makes the following pretty dumb:     


var sb = new StringBuilder(); 
sb.Append("This is ");
sb.Append("not more efficient");
sb.Append(" solution.");
var str= sb.ToString();
 Instead, use String.Join, which is typically more performant than spinning up a StringBuilder instance for a limited number of strings. It’s my go-to concat option:  

        string myString = String.Join(" ", new String[] { "This", "is", "a", "much", "better", solution, "."}); 


The first variable of " " can just be set to "" when you don’t want a delimiter.
For loops that do a lot of looping, sure, use a StringBuilder. But just don’t assume it’s the de facto solution in all, or even the majority of cases. My rule of thumb is to add strings together when I’ve got one to five of them (likewise with String.Format if it helps with legibility). For most other cases, I tend towards String.Join. Only when dealing with a loop that isn’t limited to about 10 iterations, especially one that really lets rip, I do spin up a StringBuilder.

Thursday, February 21, 2013

Starting with Prism - Part 3 of n

Continuing to my Prism 2 of n series, in this article I am going to talk about how a communication happens between various application components, following Prism framework. Here mainly I'll be discussing about Commanding, Event Aggregator, Shared Services and Region Context. To now more on this, let's jump here.

Thursday, January 31, 2013

Const and Readonly keyword

Both these words play a very important role in defining constants in an application (C#). At one sight, it seems like, both are same but exactly it is not he case. Let's understand one by one to get the clear picture.

The word const itself means, it will never change. If you are specifying any variable as a const that means the value of the variable is never going to change inside the application.

How we declare a constant is, by using a const keyword. Basically, one can define const only on the primitive types, like int, double, etc. One should make sure that the value should be assigned at the time of declaration itself and another important thing is whatever value is set for const variable, that value will be set at the compile time itself and this value will get stored inside a .dll or an .exe. In later part, I'll show u on how we can see this value inside a dll or an exe using an Ildasm. Sample code to define const variable is as:












Another keyword is the readonly. The readonly word also sounds like a const but for the readonly variable you cannot change the value, once it is assigned. Means it is restricting us to a value assignment. Sample code to define readonly is as follows:











Please note, readonly  variables can be assigned either at the time of declaration or can be assigned value inside a constructor. These two are the only places, where one can assign the value of a readonly ariable. For readonly alue assignment is done at run-time and there is no difference between a regular variable and a readonly variable in terms of memory allocation.

Combined sample code with bit more depth:











In above code, let’s change value PI and age variable inside the Main function as:













Here one can notice that, reassigning both the variables named age and PI is giving an error and on mouse hover, we can get the complete description of error as:








Now question is, if both are having the same qualities then what’s the point in creating two different things. Well, this is not the case because const is a compile time constant and readonly is a run-time constant. Most of us might be aware that the value of compile-time constants are set at the time of declaration itself and this can be seen in ildasm also. Coming to the run-time constants, these are set at run-time and that’s the reason that it is not mandatory to assign readonly variables at the time of declaration itself as one can assign them in a constructor also as:















Now question is when to use what:
If the value is going to fix throughout the program and is never going to change in any circumstances, then one should choose const.
But on the other hand, if assignment of initial value depends on some parameter/conditions and value needs to be decide at run-time, then one can opt for readonly and based on that initial value of a readonly variable can be set. But please note, once the value is assigned, further modification is not at all possible till the lifetime of the application.

ILDASM and constants:
Now, let's jump quickly on ildasm to prove the value assignment for both of these.










As I told earlier, that const are compile time constants and are assigned at the time of declaration itself. So, same can be proved via ildasm using IL code. In ildasm, one can see the value of const variable in hexa but for readonly variable, there is no such value assigned in PI variable in ildasm.

Hope above article was useful :) 

Wednesday, January 23, 2013

Silly but useful stuff - Part 2 (ASP.Net)

Using StartMode Attribute
Every time we update our site, IIS must recompile it during the first request, so the initial request takes significantly longer than subsequent ones. An easy solution for this is to tell IIS to automatically recompile our site as part of the update process. And this can be achieved using the startMode attribute in the ApplicationHost.config file.

In essence, we can say, by using startMode attribe, one can reduce the initial load time of an ASP.Net site. Hope it helps :)

Sunday, December 23, 2012

Silly but useful stuff - Part 1 (.Net)


Collection and List
Let's have a look at this snippet:























In first sight, most of you might feel that both List and Collection will contain print numbers from 1 to 6. Am I right?

But Alas! There is a hidden gotcha in it ;)
Because the actual output is:







What happen surprised???

If you have ever tried to get in depth of Collection and List, then you might know the answer. Well, the answer is pretty simple. MSDNdocumentation clearly states that "Initializes a new instance of the Collection class as a wrapper for the specified list".

And on the other hand, MSDN documentation states that "Initializes a new instance of the List<T> class that contains elements copied from the specified collection and has sufficient capacity to accommodate the number of elements copied."

Hope now it is clear to you.

So, the moral of the story is, one should be very cautious while using List and Collection else it can bite you really very-very hard.

Saturday, November 3, 2012

Converting a given string to Title Case

To convert string in title case is bit tedious and may require lot of code as there is no direct method available in C#.Net  in String class. So, here I am sharing a method, which will be the extension method for String class and can be used to convert given string to title case.
Here I am using CultureInfo from Globalization and ToTitleCase method of TextInfo class.


public static class StringExtensions
{
    public static string ConvertToTitleCase(this string input)
    {
        System.Globalization.CultureInfo cultureInfo =
        System.Threading.Thread.CurrentThread.CurrentCulture;
        System.Globalization.TextInfo textInfo = cultureInfo.TextInfo;
        return textInfo.ToTitleCase(input.ToLower());
    }
}

Hope reusing this will save lot of your time :)

Wednesday, October 24, 2012

Changes in Visual Studio 2012

Introduction

Nowadays, we see that software development process is shifting from enterprise-driven process to consumer-focused approach, in which applications are fully based on the taste of consumer market and the devices they want to use. And the speed at which these devices and platform are emerging, it is becoming more and more challenging for developers. Earlier applications were used to run on a server or a desktop but today many more devices like smartphones, tablets are becoming ubiquitous. So, in this case developer must either create applications that work on multiple platforms or make applications tailored to each platform with similar logic and the most important thing is, there should be a connected experience that allow user to seamlessly move among all these devices and platforms.
But as long as Microsoft is with developers, developers need not worry. Agree ??? 

Visual Studio 2012 

Launch of Visual Studio 2012 solved a lot of problems. Now instead of the developer worrying about platform and devices, Visual Studio will take care of it. Isn't it good? Visual Studio 2012 makes it easy to develop apps for multiple platforms including Windows Smartphones, slates, Xbox and of course traditional desktops. With the birth of Portable Libraries, developer can write and compile the code once and then deploy the assembly anywhere. Enhanced version of Team Foundation Server is another major addition. Continuing to all these, one major change are App Store which help consumer to quickly search and acquire the required application software. In App Store, Applications can be monetized also either by charging or including advertisements in the application. Visual Studio 2012 provides integrated tools to publish our applications in this app store.

Major changes done in Visual Studio 2012
  • Interface of Visual Studio is redesigned in order to remove significant clutter from the screen, while still providing a fast access to major features.
  • Visual Studio 2012 is not only for developers, but many other people like stakeholders, architects, project managers, designers, testers etc.
  • Visual Studio 2012 helps developer create applications that span device boundaries. Project templates, debugging tools and portable class libraries all help to make this process easier 
  • Visual Studio 2012 supports developers by enabling them to create solutions that are highly scalable, supporting a range of models from durable full duplex synchronous services to high-throughput asynchronous services.
  • Developing a scalable solution is only half the challenge: You must also provide a suitable environment to act as a host. With Visual Studio you can develop for a range of infrastructure choices. Whether you choose to target a physical server, a virtual server, or a private or public cloud, Visual Studio 2012 is your solution. If you decide to use the Windows Azure™ public cloud offering, you can deploy directly from Visual Studio to the cloud. Visual Studio also includes IIS Express (lightweight IIS), which is suitable for testing the apps.

Visual Studio Team Foundation Server 2012

  • It enables stakeholders to participate as equally as developers throughout the application life cycle and help developers in faster delivery with more business value.
  • As earlier version, Visual Studio TFS can be installed on local server but in Visual Studio 2012, Team Foundation Server is available as an online SaaS version.
  • Sometimes, some teams may be using a different development environment, such as Eclipse™. Visual Studio Team Foundation Server 2012 provides adapters to connect to supported IDEs so that developers can work in their preferred development environment. 

Blend

  • It enables developer to create more stunning applications using XAML.
  • Portability between Visual Studio 2012 and Blend has been improved, and the design surface in Visual Studio has been upgraded to more closely match the experience in Blend.

Visual Studio Test Professional 2012

  • This helps testing process to fully integrate into Software Development Life Cycle (SDLC).
  • Using this test cases and testing can be performed more quicker using the same tools as developers.
  • It allows Exploratory Testing, which enables testing without creating any formal test plans. It allows Test Manager to record, attach screenshots, and create a test case
  • Testing on remote devices without installing Visual Studio 2012 or Test Manager on the device itself (only a small test agent need to be installed on the device). 
There are lots of interesting facts, which are associated with Visual Studio 2012, which I'll be posting as and when I'll get time.