Friday, November 18, 2011

Parameterize Sorting Stored Procedure


In Data-driven application or website, dynamic sorting is common need. Ideally we should write stored procedure for dynamic sorting.

We found nice solution for above problem. Bellow stored procedure fetch ordered data with passed parameter. There two parameters for dynamic sorting stored procedure. Parameter @sortDirection pass for order direction (asc or desc). Second parameter @sortCol for pass sorting field name.


Code


=====================================================-
-- Create date:   18-Nov-2011
-- Description:   Example of Fetch Data With Sorting Parameter
=====================================================
Create PROCEDURE Product_Sorting_Parameter
    -- Add the parameters for the stored procedure here
    @sortDirection as varchar(5),
    @sortCol as varchar(50)
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from

    SET NOCOUNT ON;
    -- Select Query
    SELECT
        [ProductID] ,[Name],[ProductNumber],[Color],[ListPrice],[Size]     
     FROM         [AdventureWorks2008R2].[Production].[Product]
     ORDER BY
     -- Name
     Case WHEN @sortCol = 'Name' and @sortDirection = 'asc' THEN Name end,
     Case WHEN @sortCol = 'Name' and @sortDirection = 'desc' THEN Name end desc,
     -- Size
     Case WHEN @sortCol = 'Size' and @sortDirection = 'asc' THEN Size end,
     Case WHEN @sortCol = 'Size' and @sortDirection = 'desc' THEN Size end desc,
     -- Color
     Case WHEN @sortCol = 'Color' and @sortDirection = 'asc' THEN Color end,
     Case WHEN @sortCol = 'Color' and @sortDirection = 'desc' THEN Color end desc,
     -- Price
     Case WHEN @sortCol = 'Price' and @sortDirection = 'asc' THEN ListPrice end,
     Case WHEN @sortCol = 'Price' and @sortDirection = 'desc' THEN ListPrice end desc
END
GO

Thursday, November 17, 2011

MVP Pattern


MVP pattern is one of the major patterns used for extracting business logic outside of UI elements and by that, enabling unit testing the UI without the need for using specific UI based testing tools.
As technologies such as ASP.NET and Windows® Forms become more and more powerful, it's common practice to let the UI layer do more than it should. Without a clear separation of responsibilities, the UI layer can often become a catch-all for logic that really belongs in other layers of the application. One design pattern, the Model View Presenter (MVP) pattern, is especially well suited to solving this problem.

For follow MVP pattern, we divide whole solution in 3 different project as per bellow.
MVP Structure
  • Model Project (Class Library) :
    • DAL Classes (Data Access Layer):
      • Exchange data between your business objects, the DAL and vice versa. 
      • All interaction between your business objects and the DAL occurs by calling data access methods in the DAL from code in your business objects.
      • The method parameters and return values in the DAL are all database independent to ensure your business objects are not bound to a particular database.
    • BAL(Business Access Layer) Classes:
      • BAL contains business logic, validations or calculations related with the data.
      • Responsibility is to validate the business rules of the component and communicating with the Data Access Layer. 
      • Business Logic Layer is the class in which we write functions that get data from Presentation Layer and send that data to database through Data Access Layer.
  • Presenter Project (Class Library):
    • Presenter Class:
      • Orchestrates the overall interaction of the other components within the application.
      • Roles include the creation of the appropriate Models, Selections, Commands, Views, and Iterators, and directing the workflow within the application.
    • View Interface:
      • Interface class use for bridge between presenter class and View.
      • Define all properties and method related to UI(User Interface).
  • View Interface:
    • View project may be possible asp.net website, Silverlight application, WPF application or windows form application.
    • View contains only User interface of application. It contains user controls and forms for application. The View is the visual representation of the Model and is comprised of the screens and widgets used within an application.
    • Integrators are components which address how user events are mapped onto operations performed on the Model, such as mouse movements, keyboard input, and the selection of checkboxes or menu items.

Wednesday, November 16, 2011

iPhone Application Developer - Thomas Suarez ( Amazing Boy )

Thomas Suarez of Manhattan Beach, California is releasing apps for iOS devices. The sixth grader recently gave a talk at TEDx Manhattan Beach in which he discussed his love of computers (he got into them in kindergarten), his plans for the future for development in Android also.

"I've gotten a lot of inspiration from Steve Jobs", Thomas Suarez says.

Monday, November 14, 2011

Spotify on Windows Phone 7

Spotify is a new way to listen to music. Spotify has new music collection with millions of tracks and counting. It is available for Windows, Mac, home audio systems and mobile Phone. With Spotify you can share music with your friends and on social networks like Twitter, Facebook and others.

Spotify charges $9.99 for month for all above service.

Spotify is also available for Windows Phone 7. With Spotify's service, you share or play your favorite songs on Social Networks like Facebook, Twitter and others. You can pin your songs, album or artist as live tiles to start screen for fast access.

Here I submit cool video of Spotify For windows Phone 7 from channel 9.


Friday, November 11, 2011

What is new in Dot .Net 4.5 Framework Poster

Jouni Heikniemi, CEO and consultant in a four-person consultancy had create nice poster for new features of dot .net framework 4.5.

What's new in Dot .Net Framework

Visual Studio Code Analyzer

Visual studio (only for Ultimate and Premium edition) has very important tool for code analyzing. With help of code analyzer, developer can make rules for coding. Visual studio analyzer tool has in built 200 rules. If you don't has ultimate and premium edition, you can use FxCop as code analyzer.

I found great episode by Rebert green on channel 9. 


Tuesday, November 8, 2011

Adding Push Notifications to Windows Phone Apps

Here it is nice video add push notification for windows phone 7 with Windows Azure. This video nicely explain different type of notification to windows 7.