Network

Follow kosalanuwan on Twitter
View Kosala Nuwan Perera's profile on LinkedIn
Showing posts with label Tutorial. Show all posts
Showing posts with label Tutorial. Show all posts

Kanban was my unicorn and now it is my bitch

I remember one of my colleagues asked me once how good I am in work-life balance. I didn't have a perfect answer for him at that time. The newest addition to our life is Kanban. We made Kanban task boards out of all the surfaces we found, such as the almirah, bookshelf, doors, fridge and it would have been great if we had French windows.

We first started a Kanban task board with my wife's studies. In the beginning, she was using the timetable concept for prioritizing and scheduling study topics. This was working fine till she married (still is) to a husband who is on the computer 24/7.

Prioritizing the backlog items

It was an easy task for us to prepare a Backlog. Some have been already prioritized and weighted with hours (according to her calculations) required on the timetable. We took a collection of sticky notes, each with the topic and the weight written on it. It took only few hours for us to compile all the stickies into a Backlog.

Timetable schedule, mind maps, text books

Some study topics have a pile of materials to go through. These are split into smaller topics. Some are very little but include practical. These are noted with smaller stickies on the study topics. Some topics include those already studied in her previous courses.

Our mission was to prioritize these tasks as Urgent, Important, and Optional (topics that can wait).

Kanban task board

The task board initially happened to be our almirah, but now it is part of our almirah and a door, with three (3) sections labeled “To Do”, “Studying”, and “Done”, and we put all selected stickies for the upcoming week in the “To Do” section. My wife then moves stickies from “To Do” to “Studying” to “Done”.

Kanban door with To Do, WIP, and Done

The Studying in Progress (same as Working In Progress - WIP) is always limited to one study topic since this Kanban Board is only for my wife's studies, where as my Grooming Kanban Board has a WIP of four (4), one item for each Category of tasks.

Grooming Kanban Board with WIP of Many

As she completed each study topic, she is required to come up with a Mind Map. Once the Mind Map is sketched, the topic could then can be moved from “Studying” to “Done”, and then she could proceed to another study topic in the “To Do” list.

Monitoring the progress

However, I found that her tasks were moving a bit slower during later in the day than in the morning. I suspect that when she wakes up in the morning, she can see the tasks and that motivates and gives her a fresh start but it wasn't in a place near to her study area and that decreases her productivity. So we moved that task board to our door which is visible even when she is in the kitchen.

Kanban door at the end of first week

My wife enjoyed using the Kanban system. She felt that it reduces her stress and increased the productive time more than the previous timetable practice she had. She also expressed that she wish to continue her studies with Kanban every week.

PM> Install-Package ClassicDalHelpers

NuGet! Didn’t like the name when I heard for the first time! Anyways, NuGet has taken away the .NET open source PAIN! Consequently, now .NET open source is as easy as “Add Reference”.

http://nuget.org/List/Packages/ClassicDalHelpers

You do not need to work hard to refer Classic DAL Helpers by downloading at Codeplex.com. You can now add Classic DAL Helpers directly to your Data Access Layer via Visual Studio 2010.

Library Package Manager

But first, we need to get NuGet Library Package Manager from Visual Studio Gallery.

Visual Studio 2010 Library Package Manager

Visual Studio 2010 > Tools > Library Package Manager > Add Library Package Reference…

Once this is added to Visual Studio, you will get Library Package Manager under Tools menu. Also notice that you will get an additional reference option when you right-click on a project in Solution Explorer.

Add Reference

Add Library Package Reference

Right-Click on Reference > Add Library Package Reference…

This prompts the similar Add Reference Dialog that can be used to search NuGet packages online. To add Classic DAL Helpers, just search for “DAL” under “Online” Packages and click “Install” button.

Seach for DAL using Online package source

That’s it! You have now added Classic DAL Helpers to your project.

Refer Classic Data Access Layer Helpers to implement data access layers in application architecture for usage on Classic DAL Helpers.

Source code and samples are available at Codeplex.com.

Build & Publish NuGet Packages

Building and hosting our own NuGet packages is quite easy with NuGet Package Explorer, available at Codeplex.com as ClickOnce application.

image

NuGet Package Explorer > New > Edit > Edit Package Metadata

In order to publish packages at NuGet Gallary, you need to get registered at NuGet.org (no Open Auth yet!). This will give you an Access Key which has to be provided when publishing packages.

image

Please don’t copy mine! Smile

 

More references:

NuGet > Videos:
There are few videos available at NuGet Videos. Mix11 NuGet in Depth covers almost everything you need to know about NuGet.

Your Own Feeds:
You can have private/corporate feeds as well. Hosting Your Own NuGet Feeds article covers step-by-step approaches.
Refer Setting up a Local NuGet Gallary post to have your own gallery.

Build Server Option:
Integrating building packages into a Build System is possible. Refer Creating and Publishing a Package using NuGet.exe post.

Writing user stories: a practical approach

Let me be clear. Software projects are predictably unpredictable. You cannot solve all the problems in the project plan. It’s good if we can schedule good ideas but people don’t think like this way. People solve problems in unexpected ways. This is where good ideas come from. Many are called “Ahaa Thoughts”.

Explaining things are easy. Documenting it is the hardest part, not only that, many devs hate this part, in a software development process. We could only interpret around 50% of "Ahaa Thoughts" into "words".

Writing user stories is not a hard task. Once you master it you can say:

"Documentation in Development processes was my Unicorn, and now it is my bitch"

Or

"Writing user stories was my Unicorn, and now it is my bitch"

As a good citizen, a Business Analyst or a Product Owner could use a template/standard. I use something like this:

User Story

Name: Customer List
As a: User
I want: Interactive Customer List
So that: I can change the details of my customer
Size: XS, S, M, L, XL

This user story comes from my Product Backlog List. It is a White Note on my wall. Things I can do about this story are called Story Points, that explains further about the story. A story point is a Yellow Note on my White Note. I write it like this:

Acceptance Criteria/Story Points

Name: Delete an address
Given: The customer is in an editable state
When: The remove address button is pressed
Then: The address will be removed from the list
And: The change will persist after a refresh

Name: Add an address
When: The application is loaded
Then: A list containing customer addresses will be displayed
And: The name of each customer will be displayed with an image next to it

To reduce the number of documents that we have to maintain in a development process, I use these User Stories and Acceptance Criteria for Testing. A Bugs is reported under a White Note or a specific Yellow Note, if not, a separate Defects Backlog List (parallel to my Product Backlog List).

For more readings;

Beyond Functional Requirements On Agile Projects by Scott W. Ambler
Complex Requirements On an Agile Project by Scott W. Ambler
Introduction to User Stories by Ambysoft
User Interface Prototypes by Ambysoft

Classic Data Access Layer Helpers to implement data access layers in application architecture

In a simple application architecture with three layers there is always a layer that queries data from the database, extract, shape it to some CLR typed entities, push it to next layers that initiates it. Right now we get plenty of frameworks to get this job done. But those who are not fond of ADO.NET Datasets, nHibernate, LINQ-to-SQL, EF etc. will usually stick with the classic old school approach of handling CRUDs in data access layer.

You will see how I have used the Classic DAL Helpers (from CodePlex.com) to get this job done in a much cleaner and easier way. In this article, I will try to demonstrate following topics with samples;

  • Creating and handling stored commands.
  • Materializing relational data into CLR types.
  • Using template classes to reduce repetitive tasks.

The code samples are based on the Mini NorthWind project which have 3 main classes:

Sample class diagram

In a traditional approach, code to call a stored procedure in the database (with proper connection handling), extract relational data, create set of objects and identities could be very large even with rapid tools have been used such as Data adapters, EF, LINQ-to-SQL. Here is what I had to write:

public List<Category> GetAllCategories()
{
var connString = ConfigurationManager.ConnectionStrings["SampleModel"].ConnectionString;
using (var conn = new SqlConnection(connString))
{
using (var comm = conn.CreateCommand())
{
comm.CommandType = CommandType.StoredProcedure;
comm.CommandText = "dbo.GetAllCategories";

if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
try
{
using (var reader = comm.ExecuteReader())
{
var cats = new List<Category>();
while (reader.Read())
{
var idOrdinal = reader.GetOrdinal("cid");
var nameOrdinal = reader.GetOrdinal("name");

if (!reader.IsDBNull(idOrdinal))
{
var category = new Category
{
Id = reader.GetInt32(idOrdinal),
Name = reader.GetString(nameOrdinal)
};
cats.Add(category);
}
}
return cats;
}
}
finally
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
}
}
}
}


Below sections demonstrates how you can start refactoring this code using Classic DAL Helpers. There are few important classes, helpers and extensions methods that you can use in this refactoring process.


Creating and handling stored commands



As a good citizen, you have to add library namespace to your classes in order to use the extension methods and helpers in Classic DAL Helpers library.

using Microsoft.Data.Extensions;


Now you can use SqlDatabaseHelper.HandleCommand method to manage connection lifetime and to create a stored command as below:

var cats = SqlDatabaseHelper.HandleCommand<List<Category>>(
"SampleModel",
"dbo.GetAllCategories",
new SqlDatabaseHelper.CommandHandler<List<Category>>(GetAllCategoriesCommand));


Once this is done, you can get rid of few steps relates to stored command such as initialization of the database connection, retrieving connection string in the application configuration file, and creating and managing lifetime of a stored command. The HandleCommand<T> method facilitates an IDbCommand with a live connection for you to handle your stored command execution and you do not need to validate and verify whether the connection is opened or not since the helper method takes care of that part for you.


In order to pass parameters to your stored procedure you will require to instantiate SqlParameter objects, assign relevant values to those, pack it to your command before the execution. Here is how we used to do:

comm.CommandType = CommandType.StoredProcedure;
comm.CommandText = "dbo.GetAllCategories";

var catParam = new SqlParameter { ParameterName = "cid", Value = categoryId, Direction = ParameterDirection.Input };
comm.Parameters.Add(catParam);

Instead of this, you can use the extension methods that provided by the Classic DAL Helpers library:

command.AddParameter<int>("cid", (int)args.First());

Materializing relational data into CLR types



I heard the term “Materialization” from the EF Team. It means; converting the relational data returned via stored command into actual objects, pretty much similar to an ORM process. Here is a sample code that we used in previous section to populate Category objects:

using (var reader = comm.ExecuteReader())
{
var cats = new List<Category>();
while (reader.Read())
{
var idOrdinal = reader.GetOrdinal("cid");
var nameOrdinal = reader.GetOrdinal("name");

if (!reader.IsDBNull(idOrdinal))
{
var category = new Category
{
Id = reader.GetInt32(idOrdinal),
Name = reader.GetString(nameOrdinal)
};
cats.Add(category);
}
}
return cats;
}


Instead, I can materialize relational data into Category objects like this:

return reader.Materialize<Category>(this.Materialize);


The materialize extension method requires a delegate that knows how to map data record into a single Category object. The generic extension method Field<T> in IDataRecord can return value relevant to the Ordinal or the Column name. This is how it would look like:

protected override Category Materialize(IDataRecord record)
{
var cat = new Category
{
Id = record.Field<int>("cid"),
Name = record.Field<string>("name")
};

return cat;
}


While the materialization is more convenient, it is much more efficient to use a single materialize method per CLR type. However, you can use the same materialize method to instantiate multiple CLR types if they all derive from a common super class.


You can use the same ProductDataAccess object to materialize both Product and DiscontinuedProduct objects as below:

protected override Product Materialize(IDataRecord record)
{
Product prod = record.Field<DateTime?>("discontinued_date").HasValue ?
new DiscontinuedProduct
{
Id = record.Field<int>("pid"),
Name = record.Field<string>("name"),
CategoryId = record.Field<int>("cid"),
DiscontinuedDate = record.Field<DateTime>("discontinued_date")
} :
new Product
{
Id = record.Field<int>("pid"),
Name = record.Field<string>("name"),
CategoryId = record.Field<int>("cid")
};

return prod;
}

The CLR type could be a Business Entity in the model, a View Model used to present data, a Data Transfer Object that used to transport data among tiers, or it could be a Data Contract in your WCF service.


Using template classes to reduce repetitive tasks



A traditional Data Access Component would contain all the CRUDs related to a single business entity, facilitating ORM functionality to that same entity. The Classic DAL Helpers library contains few template classes. DataAccessObject template is one of the main classes you can use to implement CRUD functionality. Now I can declare Category and Product Data Access Objects as below:

public sealed class CategoryDataAccess : DataAccessObject<Category>
public sealed class ProductDataAccess : DataAccessObject<Product>


In order to use CRUD functionality via template DataAccessObject, you must make sure your CLR types are derived from RootEntity template. Now I can change my class declaration as in below sample:



image


I have extent Product class further to a DiscontinuedProduct class. The class declarations for this diagram look like this:

public sealed class Category : RootEntity
public class Product : RootEntity
public sealed class DiscontinuedProduct : Product

The Classic DAL Helpers library source code is now available in CodePlex.com. You can download directly from the below link;


CodePlex.com, Classic Data Access Layer Helpers and Samples
http://classicdalhelpers.codeplex.com/

Enhance your blog with more plug-ins, hacks, tweaks

You can have facebook like/recommend links, sharing buttons, navigation bar-less and many more to your blog with minor tweaks.

image[9]

Blogger Plugins, Label Cloud Widget
http://www.bloggerplugins.org/2008/06/label-cloud-widget-for-blogger-blogspot.html

Blogger Plugins, Tutorials
http://www.bloggerplugins.org/search/label/Template%20Hacks?&max-results=5

Blogger Plugins, Facebook Like/Recommend button
http://www.bloggerplugins.org/2010/04/facebook-like-button-for-blogger.html

Blogger Plugins, Official Sharing buttons
http://www.bloggerplugins.org/2010/06/official-sharing-buttons-on-blogger.html

Blogger Plugins, Remove Blogger Navigation Bar completely
http://www.bloggerplugins.org/2010/04/remove-blogger-nav-bar-completely.html

Anyways, I tried the Facebook Like button, it only appears when you click on an article!

File upload tutorials

I found several file upload sample codes, tutorials using jQuery, Ajax, JavaScript, ASP.NET, C# …

Ajax file upload using jQuery, ASP.NET & C#

jQuery Ajax uploader plugin (with progress bar!)

JQuery Ajax File Upload and ASP.NET

I will keep updating the list when I find something interesting that relates to this topic :)

jQuery with Visual Studio 2008

Visual Studio 2008, still the #1 developer tool for .net (apart from the price you have to pay). However, Microsoft still keeps adding features and trying to enhance the IDE, making our life ez’err!

jQuery is one of the most popular scripting languages these days. But without IntelliSense and Documentation for the libraries, the language or the IDE will not get popular within communities.

I found few articles on how you make your Visual Studio 2008 IntelliSense supportive for jQuery both external scripting files (.js) and .aspx pages. More info in these links;

Setting up Visual Studio IntelliSense for jQuery
KB958502 - JScript Editor support for “-vsdoc.js” IntelliSense doc. files

I tried this and it works for me!

Using tag cloud control

 

I was looking for some cloud control samples, tutorials etc. and followings are the resources I found;

Creating a Tag Cloud in ASP.NET By Scott Mitchell

Building a Photo Tagging Site using ASP.NET 2.0, LINQ, and Atlas By ScottGu

Cloud Control for ASP.NET By Rama Krishna Vavilala