Wednesday 27 February 2013

WCF : An introduction



  1. What is WCF?
ü  WCF stands for Windows Communication Foundation (WCF).
ü  This is considered as the Microsoft Service-Oriented Architecture (SOA) platform for building distributed and interoperable applications. 
ü  WCF unifies ASMX, Remoting, and Enterprise Services stacks and provides a single programming model.
ü  WCF services are interoperable and supports all the core Web services standards. 
ü  A WCF service also provide extension points to quickly adapt to new protocols and updates and integrates very easily with the earlier Microsoft technologies like Enterprise Services, COM and MSMQ.


  1. Why should I use WCF?
ü  WCF is interoperable with other services when compared to .Net Remoting, where the client and service have to be .Net.
ü  WCF services provide better reliability and security in compared to ASMX web services.
ü  In WCF, there is no need to make much change in code for implementing the security model and changing the binding. Small changes in the configuration will make your requirements.
ü  WCF has integrated logging mechanism, changing the configuration file settings will provide this functionality. In other technology developer has to write the code.
3.    What is difference between WCF and Web Services?
ü  Protocol: Web services can only be invoked by HTTP (traditional web service with .asmx). While WCF Service or a WCF component can be invoked by any protocol (like http, tcp etc.) and any transport type. 
ü  Flexibility: web services are not flexible. However, WCF Services are flexible. If you make a new version of the service then you need to just expose a new end. Therefore, services are agile and which is a very practical approach looking at the current business trends. 
ü  Ease of Development: We develop WCF as contracts, interface, operations, and data contracts. As the developer we are more focused on the business logic services and need not worry about channel stack. WCF is a unified programming API for any kind of services so we create the service and use configuration information to set up the communication mechanism like HTTP/TCP/MSMQ etc 
ü  XmlSerializer and DataContractSerializer
That Web Services Use XmlSerializer But WCF Uses
DataContractSerializer which is better in Performance as Compared to XmlSerializer.
Key issues with XmlSerializer to serialize .NET types to XML

* Only Public fields or Properties of .NET types can be translated into XML.
* Only the classes which implement IEnumerable interface.
* Classes that implement the IDictionary interface, such as Hash table can not be serialized.

The DataContractAttribute can be applied to the class or a structure. DataMemberAttribute can be applied to field or a property and theses fields or properties can be either public or private. A practical benefit of the design of the DataContractSerializer is better performance over XmlSerializer. 




  1. What is service and client in perspective of data communication?
ü  A service is a unit of functionality exposed to the world.
The client of a service is merely the party consuming the service.
  1. What is SOA Service?
ü  SOA is Service Oriented Architecture. SOA service is the encapsulation of a high level business concept. A SOA service is composed of three parts.
Any Service that fulfills above three requirements is SOA
  1. What are the core components of WCF?
ü  Like any other SOA Service the three core components of WCF are:
a.       A service class
b.       A hosting service
c.       Endpoints to expose the service

  1. What is ABC in WCF?



8.    What is an endpoint?
ü  WCF Service is a program that exposes a collection of Endpoints. Each Endpoint is a portal for communicating with the world.
ü  All the WCF communications are take place through end point. End point consists of three components.
a.       Address
b.       Binding
c.       Contract
ü  The Endpoint is the fusion of Address, Contract and Binding.









Silverlight Deployment


1.       What is the single unit for deploying Silverlight applications?


Silverlight applications are downloaded by the browser in XAP files.

2.       What are xap files?


                XAP files are essentially .zip files that contain an assembly manifest file and one or more assemblies.

3.       Can an APACHE server host a Silverlight application?


              Silverlight applications can be hosted on most types of Web servers, like Internet Information Server (IIS) or Apache. However, most Web servers are usually configured to serve only a short list of wellknown file extensions.

4.       What are the MIME types your web server should support to host Silverlight application?


Extension
MIME type
.xaml
application/xaml+xml
.xap
application/x-silverlight-app



IIS 7, included in Windows Server 2008, already includes all the relevant MIME types for both WPF and Silverlight, including both .xap and .xaml extensions, so if you're using Windows Server 2008, you're all set.
5.       How can you optimize xap file size for increasing download speed?

a.       Set CopyToLocal as false

By default, any non-system assemblies that you reference will be added to the XAP file generated by Silverlight applications. If you want to optimize your XAP files for download speed, this behavior may not be efficient for some of your modules' references.

Consider the following example. You have created an application with several remote modules. Each module gets its own XAP file. You have also created a shared Common assembly that contains shared services, common interfaces, and so on. Each module references that common assembly. By default, each XAP file will now also contain the Common assembly; this makes the XAP files larger than they need to be.

b.      To solve this, change the references to the Common assembly in all of the modules by setting Copy Local to false. This ensures that the Common assembly is not added to the XAP files.

When deploying Silverlight applications created with the Composite Application Library, some common assemblies that can typically be excluded from the XAP files include Composite and Composite.Presentation assemblies and infrastructure assemblies, among others.


6.       How can you deploy Silverlight app.

c.       You can do it using a SMS server.

d.      Manually

e.      Group policy

Group policy is ideal to deploy Silverlight in small to medium sized organizations or when it is not being deployed to a large number of users simultaneously.  For large organizations, Silverlight is best deployed using SMS or another third-party software distribution tool.  A limitation of the group policy deployment method is that it applies only to Microsoft operating systems, ignoring Apple operating system clients. 


7.       How do you know if the problem which has occurred is a web browser problem and not a Silverlight issue?


To isolate browser issues that might be related to the Silverlight add-on, you can selectively disable the add-on in Internet Explorer 7.

To disable a browser add-on

a.       Click the Tools menu, click Manage Add-ons, and then click Enable or Disable Add-ons.
b.      Change the “Show” Drop-down box to “Add-ons that have been used by Internet Explorer”
c.       Click AgControl Class, click Disable, and then click OK.

Alternatively, you can turn off all add-ons temporarily in Internet Explorer 7 by starting in No add-ons mode.

To start Internet Explorer 7 in No add-ons mode

a.       1.    Click Start, click All Programs, and then click Accessories.
b.      2.    Click System Tools, and then click Internet Explorer (No Add-ons).

You can also start Internet Explorer without add-ons by right-clicking the Internet Explorer icon on the desktop and then clicking Start Without Add-ons. Or start Internet Explorer with no add-ons or toolbars by running the command iexplore.exe -extoff.


8.        What is difference between asp.net application hosting and Silverlight hosting?

Deploying Silverlight applications is as easy as deploying ASP.NET applications, because Silverlight is normally embedded in a site.


9.       To install a Silverlight RIA Services application, do we need RIA services installed in the server machine?

To run Silverlight RIA services application we need .NET 4 installed on the server machine. RIA Services must also be available on the Web server.



The RIA Services assemblies must be available on the Web server. It is recommended that RIA Services be installed on the Web server that will host your application. If this is not an option, due to lack of permissions or some other issue, you can also make them available on the Web server by either including them in the bin folder of your project when it is published or by installing them in the global assembly cache (GAC).

 To install RIA Service RC on your server, download the MSI locally and then run it as such -

msiexec /i RIAServices.msi /SERVER=true

 If you have access to a .NET 4 RC server but do not have permissions to install RIA Services on it, you can choose to carry the RIA Services bits in the Web Applications BIN folder.

 10.   What all should you consider while preparing a WCF RIA Service application for deployment?

Following is what is needed:

·         System.ServiceModel.DomainServices.Server.dll

·         System.ServiceModel.DomainServices.Hosting.dll

·         If you are using Entity Framework to access a database, then you will also need to add a reference to the System.ServiceModel.DomainServices.EntityFramework.dll assembly.

·         If you are using LINQ to SQL to access data, then you will need to add a reference to the Microsoft.ServiceModel.DomainServices.LinqToSql.dll assembly

If you are using the Visual Studio Build->Publish option to deploy your application, make sure the following three assemblies under the Web Application->References have been marked as Copy Local = True


11.   Ideally where should my RIA service dlls lie in GAC or in bin?

Instead of copying the RIA Services assemblies in the Bin folder of every project that uses them, you can install the assemblies in the GAC. Any assemblies in the GAC are available to every application on the server. This approach is easier to maintain because an assembly only needs to be updated in the GAC instead of every Bin folder.

If you are copying the bits over manually to your deployment server, copy the above three assemblies to the Web Applications BIN folder right next to your [WebAppName].dll


12.   What is need to make the assemblies Copy Local = True?

Setting these property values to True results in the assemblies getting copied to the bin folder the next time you build the solution. When the assemblies are copied to the bin folder, they will be copied to the Web server when you publish the site.


13.   Why my installation works in some PCs and fails to run in other PCs?

Generally this happens because it makes zero sense to have Copy Local = True if an assembly is installed in the GAC.

Because the local copy will never be used, the GAC is always searched first. Leaving it unchanged would cause major confusion. Changing it causes a confusion too, that could perhaps have been addressed with a message box at solution load time.

To overcome this problem you can also add a PostBuild event to manually copy the assemblies into the output directory.


14.   Why Copy Local for some dlls is true by default whereas for some others it is true?

The project-assigned value of CopyLocal is determined in the following order:

1.       If the reference is another project, called a project-to-project reference, then the value is true.

2.       If the assembly is found in the global assembly cache, the value is false.

3.       As a special case, the value for the mscorlib.dll reference is false.

4.       If the assembly is found in the Framework SDK folder, then the value is false. Otherwise, the value is true.


15.   What are the things you need to take care in web.config file while deploying a RIA service?


WCF RIA Validations

How RIA Services Implement Validations

RIA Services have a built in way to validate entity up to the Silverlight UI.The validation logic used is common in the client as well as the server side.

Whenever an entity is changed , the ChangeSet is validated immediately , if the ChangeSet contains validation error , the validation results are passed  and shown at the client in a ValidationErrorContainer. In this case the ChangeSet does not travel to the server , thus doesn't call any service.

If the ChangeSet is a valid one that is there are no validation errors , the service is called. There may be cases where some business rules need to be implemented. For example , In an employee management application , whether the employee is eligible for a long leave is a decision to be taken based on the attendance data of the employee and this information cannot be shared with the client.  So, we implement the LongLeave rule in the server side.

Based on the business rule either the entity is set as valid or invalid. In case an entity is set as invalid at the server side , here we can show the errors either in a message box or an validation error container.

Following diagram shows how the RIA Services work in an MVVM way:





Data Annotation Validation Attributes

The namespace used for validation is System.ComponentModel.DataAnnotations.The class used to validate entities is the ValidationAttribute class in the above namespace.Any class that derives from ValidationAttribute class is a validator.

In RIA Services both property level and object level validations can be done.Validation attributes can be placed on the properties of metadata class. These validation attributes will be used for server side validation by WCF RIA Services,and they will also be used client side because the client generated entities will have those attributes on their properties.

Following are the common property level validator:
a. RequiredAttribute
b.StringLengthAttribute 
c.RangeAttribute
d.RegularExpressionAttribute



Custom Validation Attributes


Cross property validation


ValidationContext:


Validations during Submit Operation


Async Validation using Invoke Methods


References







Tuesday 26 February 2013

Windows Azure Mobile Services- Intro

Introduction:


Integration of Windows 8 and Azure Services started with Windows Azure toolkit for Windows 8 , but then Microsoft renamed it as Windows Azure Mobile Services. So, now if you are planning to develop Windows Store Application using Windows Azure then you need to understand Windows Azure Mobile Services thoroughly.

As with Windows Azure Service , the Windows Azure Mobile Services enables developers to provision, configure, and consume scalable backend services.

If you are new to Windows Azure , don't get panic-ed , followin section is for you. If you already know Windows Azure please skip the next section.

Windows Azure: In few lines.

Windows Azure is nothing but a cloud-computing platform  from Microsoft that can:
a.  run applications
b. store data in the cloud.
So that the development team can do their work without worrying about the underlying infrastructure and can concentrate more on application development rather than thinking about how to manage the operating system.

Following are a few capabilities of Windows Azure than can help a developer/development team as such:

 a. Availability of on-demand compute services,
 b. Availability of on-demand storage services,
 c. Availability of on-demand  networking services,
 d. Content-delivery capabilities.


Since , the scope of this article is not to explain or introduce you to Windows Azure as such , so I am restricting my explanation here.

We are discussing about blending Windows 8 and Azure together.

In case you don't know what a Windows 8 App is , you can read the following section , else skip it.

Windows 8 apps in few lines:


Windows 8 apps are the applications created with metro style UI , or using Microsoft UI Design guidelines that can be brought on to Windows 8 platform irrespective of whether a PC , a tablet , a mobile or any other type of devices. You can refer to my blogs on developing Windows 8 app to get a holostic knowledge on development of these apps.

Now, wgen Windows 8 Apps are used with Azure , the architecture of the apps as such changes a little , instead of depending on SQLite ot text file as storage  , the app connects to Microsoft Cloud Services and gives you a feel of an app that is mobile and is always connected.

Architecture of Windows 8 App with Azure:


This type of Architecture basically takes advantage of Windows Push Notification Services.

Following is a basic outline of how the architecture of Windows 8 Cloud connected app looks like:

 We will look at the Windows Notification Services in next article.

Tuesday 19 February 2013

Zomato Windows 8 App : Review Part II

Continuing the review:

Let me start with Explore: (2/2)



Functionality : Shows me list of hotels . Gives Recommendation , Explores by location and Explores by cusine.

Good here ,
a. the screen is very intuitive.
b. Filter and Sort options are put out very neatly.
c. Explore by location/ Explore by cuisine has come out wonderfully,
 The filter list concept is beautiful.



Rating for this module is 2/2
 
Next lets look at Top 25 (0.75/1)
 
Top 25 is simple , its a list of the top 25 trending resturants .

I would have liked this page to have sorts and filters as well.

So I give this (0.75/1)
 
LeaderBoard: (1/1)
Its good and same as the top 25.

It gives a Twitter button,.

So , Total Zomato App gets is : 13.35/14. (That is Awesome)

Great going Zomato app.
 


Monday 18 February 2013

Review : Zomato App for Windows 8

Zomato : A food and Dinning app at Microsoft App Store. It recommends the best eat outs at your location.

This review is from the point of view of a developer.

Zomato : On installation it creates a wide tile on the screen. ( Point :1/1)

Zomato uses your location , so it uses Internet Capability.(Point : 1/1)

Splash Screen is elegant and the application loads very quickly. (1/1)
The Home Page is good:(1.6/2)

a.  The layout is done with perfectness .
b. has both in-app live tiles and static tiles.
c. User Management is placed properly
d. There is no horizontal space bar placed for a small screen monitor. User has to browse to the user management part manually. This is a big drawback I see on the home screen.
 
e. The location of the user is found in the app loading time itself , the user can still change the location.
 
f. The location has been neatly shown as an expandable drop-down.
g. On changing the location the leader board tile and featured hotels, featured reviews etc  tile changes within no time.

I give (1.6/2) for the home page.
0.4 is deducted for not providing the horizontal scroll bar.

User Management Module:(2/2)

The user management module has come beautifully on this app.
a. You can login using facebook and Google APIs.
b. Login and Signup forms are very intuitive.
 
c. Messages and Notifications are well provided.

I give this module 2/2

BAD : The App closed without me closing it/ or without Alt+F4 key. The app has a button which reads 'ZOMATO' this button is used for going back and on the home screen when I click this button I got logged out. :(


Featured :(2/2)

a. The featured page has come out nicely.
b. The screen is basically divided into four parts:
c. I have a static panel and a scrolling panel on the same page. I liked this concept.
 
 
 
 
 
d. Lets start with what this page has:
a. A map : Simple and Straight forward.
b. Review : Simple ,Scrollable. I can read/ write reviews easily.
If I click anywhere on a review a flyout comes,

everything is okay here , but data is not consistent.

If I click on Foodie button , I can see the recent activities of the reviewer.

Now, if I click on the part of the reviewer's Favorite ,we reach the marked restaurant. I liked it.

c. If I click on Photo I get into the flipviewer, its clean and uses the same photo viewer concept as of Windows 8.

d. I can see a static menu for today. Liked this. Easy and Simple.

e. Info has been placed very cleanly.

f. Favorite , mark and footprint are easy to use, but there is no text coming in so it causes a less usable control. I am a new user and don't understand what the three icons mean.




g. The rating control is good and is of lot of use.


 h. App Bar is consistent with the page.
 

 
e . Thing I don't like here is : I can go back to my previous screen using two different buttons.
Or two buttons do the same thing for me.



 Search Module:(1/1)

Search uses the Search Contract of Windows 8.

It uses an in-app Search and shows the search results in a separate page.
 


 We will see on the rest of the modules in the next article.

Thursday 14 February 2013

Review : Book Your Table App

Name of App : Bookyourtable
Category : Food & Dining

About the app :
Bookyourtable was launched to deliver the convenience of online reservations, food ordering and Discount deals for all guests. Bookyourtable today operates in top 10 cities of India & has plans to expand to other cities in India very soon. It is also a perfect search destination if you are hoping to get some fabulous discounts to explore the culinary world in India.

Bookyourtable,  provides you a simple way to find tables that meet your desired criteria for cuisine, locality & price.  Through Bookyourtable you can view Restaurant details like address, cost for two,offers, restaurant timings etc. You can download coupons and vouchers.

You have this app in book your table website , you can download the app from Windows 8 App Store.

I am writing this review for the windows 8 app store app.

On Installing ;creates a wide tile on the start screen.

Splash Screen : Its is one of the applications where I have seen a metallic splash screen.

Capabilities : a. Internet connectivity and Geo Location.

Design Style : Uses Flat navigational m
Home Page :
Pros : 1. Tiles  are arranged properly , neat and informative.
2. Cannot click on a tile , which has no information.
3. When not signed in I am welcomed as Guest , but if I sign-in , close and open the app again I am not welcomed. :(




Flyouts : Uses a basic flyout .
When I click New User:Registration Form pop-ups .
Let us try to evaluate the registration module:
Pros:
1. Very simple and elegant.
2. Errors are notified in red like :


3. The UI navigations and tabbing that registers a user is good.

Cons:
1. Although this is a clean way to do , but all my errors are not notified to me at a single go , I would have appreciated if it had given me something like :
 2.  after signing-up the app doesn't clear already entered values. :(  That is a negative point from the app developers.
3. I need to login manually even after I have registered successfully and the session hasn't died. :(
I did not like this feature.

4. You get no notification mails even after after registering.

5. Mobile number is the primary key for registration , but for signing-in you need to remember username.

6. There is no forget password / reset password feature available.

7. I cannot sign out of my app without closing the app itself.

Now lets see My Profile:

 Pro :
1.  Simple and Straight Forward .
2. Shows User data and Bookings.

Cons:
1. There is a remove button , which should ideally remove the old bookings from the screen. It should be placed along with the booking info , on the div/ grid column itself , but it placed in the app-bar and most of the time it is of no particular use.


2. The Scroll bar and flip slider button should be invisible when no data is present.

Now , lets go to Featured Restaurants module:
Pros:
1. Select buttons are placed very nicely , neatly and can be accessed with ease.
2. Book Now feature is neat and easy to use. 
3. You can write and post reviews easily.
4. You can mark favorite easily.

Cons:
1. Although Home page shows 12 options , I see only 11 options in my Featured Resturants Page.



2. Featured Restaurants don't change when I change the location , put I show reload the page every time I change the location.

3. Not sure the distance is calculated, with reference to What? If it is calculated with respect to longitude and latitude then also the distances shown here don't match the actuals.




4. For the slots which are past. I am able to click on book now but am shown with wrong error
I am said to select a time slot when there is no where I can select a time slot.
5. The error messages are shown in white instead of read. :(
6. Even when the time has not passed  , I am not allowed to book any slots ( reason no more seats are available.) but I am shown with error message.
7. Session is not persisted between pages. If I plan to go back to previous page from Book now page to change the number of people/date the whole UI is reset back .

8.  Although I can take favorite , I cannot remove it. Marking the favorite doesn't reflect back on my profile immediately.

9. Post review does not validate if you have added any thing in the text box/marked the stars or not.



For all other modules( Dine Out and Buffet) , the above points remain valid .

Let us look on to the Coupons  module  now:
Pros: 
1. Simple and straight forwards , the ways coupons is handled is great.
2. You get all the relevant features in a single go.
Cons:

1. Share Source is not implemented I guess

2. Although I am logged-in and my information is there with the app , still them I am forced to enter the mobile number to send coupon.
Agreed I may want to send the coupon to someone else but we can always give it pre-filled , editable text box.

Final verdict

The app is good usable , fast and efficient.Although there are certain things that needs to be removed .
Many features from the website of BookYourTable is missing. Some of them like testimonials etc are missing.
But it can go a long way in future if properly taken care.