Friday, November 12, 2010

DayLight Saving and DateTime in .Net

Today, while looking to solve one issue related to DataTime in .Net, I came across article from MSDN that describes the best practice recommendations for writing programs that use the DateTime type in Microsoft .NET-based applications and assemblies.

While going through article, I came across the Daylight saving time (DST) and its impact on Applications. So I decided to give brief about DST and will discuss how it effects the Programmers.

Daylight saving time:

Daylight saving time (DST)—also summer time in British English is the practice of temporarily advancing clocks during the summer time so that afternoons have more daylight and mornings have less. Typically clocks are adjusted forward one hour near the start of spring and are adjusted backward in autumn.

In a typical case where a one-hour shift occurs at 02:00 local time, in spring the clock jumps forward from 02:00 standard time to 03:00 DST and that day has 23 hours, whereas in autumn the clock jumps backward from 02:00 DST to 01:00 standard time, repeating that hour, and that day has 25 hours.

A digital display of local time does not read 02:00 exactly at the shift, but instead jumps from 01:59:59.9 either forward to 03:00:00.0 or backward to 01:00:00.0. Clock shifts are usually scheduled near a weekend midnight to lessen disruption to weekday schedules.

Advantages of DST:
  • Many countries observe DST, and many do not. The reason many countries implement DST is in hopes to make better use of the daylight in the evenings.
  • Some believe that it could be linked to reducing the amount of road accidents and injuries.
  • The extra hour of daylight in the evening is said to give children more social time with friends and family
  • DST can even boost the tourism industry because it increases the amount of outdoor activities.
  • Majority of people also believe that DST saves energy as it influences people to spend more time out of the house, thus decreasing the need for artificial lighting as well as the likelihood of using home electric appliances.

Disadvantages of DST:
  • Flight schedules and inaccurate transportation timetables have caused confusion among travelers, for both personal and business purposes, and regular commuters. The transport industry needed to take into account the costs for adjusting to new time schedules.
  • Other complaints about daylight saving include the safety fears in the dark mornings, especially for school children waiting for a bus in some areas. Those who went early to work or study, they would be leaving their homes in the dark, the time when crime was at its highest, putting them in potentially dangerous situations.
  • Farming groups have also expressed anti-daylight saving views, saying that daylight saving time had a significant adverse impact on rural families, businesses, and communities. There are also those who express health concerns linked with daylight saving time.

Daylight Saving Time and .Net:

Consider a case when on particular morning during DST, at 2:00 AM, the local clock is reset to 1:00 AM, creating a 25-hour day. Since all values of clock time between 1:00 AM and 2:00 AM occur twice on that particular morning—at least in most of the United states and Canada. The computer really has no way to know which 1:10 AM was meant—the one that occurs prior to the switch, or the one that occurs 10 minutes after the daylight savings time switch.

Similarly, programs have to deal with the problem that happens in the springtime when, on a particular morning, there is no such time as 2:10 AM. The reason is that at 2:00 on that particular morning, the time on local clocks suddenly changes to 3:00 AM. The entire 2:00 hour never happens on this 23-hour day.

Programs have to deal with these cases (Particularly applications that deals with Scheduler. Such as Marketing Emails to send during night hours or taking Backup during night), possibly by prompting the user when you detect the ambiguity. 

If you aren't collecting date-time strings from users and parsing them, then you probably don't have these issues. Programs that need to determine whether a particular time falls in daylight savings time can make use of the following:
    Timezone.CurrentTimeZone.IsDaylightSavingTime(DateTimeInstance)
or
DateTimeInstance.IsDaylightSavingTime
   
So, if you need to perform DateTime calculations (add/subtract) on values representing time zones that practice daylight savings time, unexpected calculation errors can result. Instead, convert the local time value to universal time, perform the calculation, and convert back to achieve maximum accuracy.

For the complete tips for dealing with DateTime, go through the below link from MSDN.

http://msdn.microsoft.com/en-us/library/ms973825.aspx

I believe that above link from MSDN is helpful to all the Programmers. If we take care of above points, our software are least prone to errors.


For further details on DST:
http://www.timeanddate.com/time/dst/

Thursday, October 14, 2010

Accessing Master page control values from child page

Accessing Master page control values from child page:

Today, I am discussing about very common requirement where we need to access value of Master page from Child page. We will consider a case where there is dropdownlist in Master page and on change of dropdownlist, we will use selected value of Dropdownlist in child page. Lets start by following below steps:

1. Create Master page and add dropdownlist on aspx page

<asp:DropDownList ID="ddlThemes" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlThemes_OnSelectedIndexChanged">
<asp:ListItem Text="Select Theme" Value="0" Selected="true"></asp:ListItem>
<asp:ListItem Text="Red" Value="Red"></asp:ListItem>
<asp:ListItem Text="Blue" Value="Blue"></asp:ListItem>
<asp:ListItem Text="Green" Value="Green"></asp:ListItem>
</asp:DropDownList>

2. We need to raise an event when dropdownlist is changed. For this create public event and raise event from dropdownlist selectedindex change event in masterpage.cs file

public event CommandEventHandler ThemeChanged;
protected void ddlThemes_OnSelectedIndexChanged(object sender, EventArgs e)
{
    if (ddlThemes.SelectedIndex != 0 && ThemeChanged != null)
        ThemeChanged(this, new CommandEventArgs(ddlThemes.SelectedItem.Text, ddlThemes.SelectedValue));
}

3. Now create child page referring to above master page created. Add below code in aspx file:

<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/MasterPages/masterpage.master" CodeFile="ChildPage.aspx.cs" Inherits="ChildPage" %>
<%@ MasterType VirtualPath="~/MasterPages/masterpage.master" %>

4. Now write the code to handle the event (created in Master page) in child code behind page:
public partial class ChildPage : System.Web.UI.Page
{
    protected void Page_Init(object sender, EventArgs e)
    {
        Master.ThemeChanged += new CommandEventHandler(ThemeChangedFromMasterPage);
    }
    private void ThemeChangedFromMasterPage(object sender, CommandEventArgs e)
    {
        string ThemeText = e.CommandName;
        string ThemeValue = e.CommandArgument.ToString();
        Response.Write(ThemeText + " " + ThemeValue);
    }
}

That's all. Above steps will also help you to understand concept of Events and Events Handlers in .Net.

Friday, October 8, 2010

Google Announcing Google TV: TV meets web. Web meets TV.

Google had launched its official website this week for Google TV (a new experience of enjoying TV and Web together). Check out all the features of Google TV here. Some of the features of Google TV are quite interesting i.e. multiple phones acting as remote control, voice search, watching and browsing simultaneously, recording of program and great home page for TV. I hope with introduction of Google TV, TV will no longer be 'idiot box' and will become an interactive way to do lot more things.

There are some questions arises with introduction of Google TV, i.e. Does Google TV will replace Personal Computers in near future? Will all websites owners do changes to make compatible with Google TV?

For the Software Professionals, Google TV is built on Android and comes with the Google Chrome web browser. If you are interested in learning more about how to optimize website for viewing on Google TV, please visit developer page.

Also, I think I need to wait for another year for Google TV to come in India. Hope Google will launch Google TV soon in India.
Also check out Official Google Blog Announcing Google TV.

Checkout Logitech Revue and other stuff to use with your existing TV:

1. Logitech Mini Controller for Logitech Revue and Google TV


2.Logitech Keyboard Controller for Logitech Revue and Google TV


3. Logitech Revue Companion Box with Google TV and Keyboard
 

Wednesday, October 6, 2010

Agile methodology and Scrum

Today, in majority of IT / Non IT organizations, management is following Agile Methodology for the execution of the projects. Earlier also we might have completed projects successfully following same methods as Agile suggests but we were not known about terms and all tools that supports Agile. Today, I like to share concept, benefits and tools that support Agile Methods.

Agile methodology: Agile methodology is an approach to project management, typically used in software development. It helps teams respond to the unpredictability of building software through incremental, iterative work cadences, known as sprints.

It is very effective where Client frequently changes his requirement. Since it has more iteration, you can assure a solution that meets client requirements. It involves more client interaction and testing effort.

Agile Methodology Characteristics:
  • More Iterations
  • Frequent Delivery
  • Test frequently
  • Less defects
  • Accepts change of requirement at any stage, even late in development.
  • Continuous attention to technical excellence and good design enhances agility.
There are various methods by which Agile methodology can be implemented:-
  1. Extreme Programming (XP)
  2. Scrum
  3. Crystal
  4. Adaptive Software Development (ASD)
  5. Feature Driven Development (FDD)
  6. Dynamic Systems Development Method(DSDM)
  7. Lean software development
  8. XBreed
Out of the above methods Scrum and Extreme Programming (XP) are mostly used. We will discuss Scrum here.

Scrum: Scrum is an agile framework for completing complex projects. Scrum originally was formalized for software development projects, but works well for any complex, innovative scope of work. The possibilities are endless. The Scrum framework is deceptively simple.

In Scrum, projects are divided into succinct work cadences, known as sprints, which are typically one week, two weeks, or three weeks in duration. At the end of each sprint, stakeholders and team members meet to assess the progress of a project and plan its next steps. This allows a project’s direction to be adjusted or reoriented based on completed work, not speculation or predictions.

The Roles of Scrum:

Scrum has three fundamental roles: Product Owner, Scrum Master, and Team members.

1. Product Owner: In Scrum, the Product Owner is responsible for communicating the vision of the product to the development team. He or she must also represent the customer's interests through requirements and prioritization. Because the Product Owner has the most authority of the three roles, it's also the role with the most responsibility. In other words, the Product Owner is the single individual who must face the music when a project goes awry. At the same time, Product Owners must be available to answer questions from the team.

2. Scrum Master: The ScrumMaster acts as a liaison between the Product Owner and the team. The ScrumMaster does not manage the team. Instead, he or she works to remove any impediments that are obstructing the team from achieving its sprint goals. In short, this role helps the team remain creative and productive, while making sure its successes are visible to the Product Owner. The ScrumMaster also works to advise the Product Owner about how to maximize ROI for the team.

3. Team Members: In the Scrum methodology, the team is responsible for completing work. Ideally, teams consist of seven cross-functional members, plus or minus two individuals. For software projects, a typical team includes a mix of software engineers, architects, programmers, analysts, QA experts, testers, and UI designers. Each sprint, the team is responsible for determining how it will accomplish the work to be completed. This grants teams a great deal of autonomy, but, similar to the Product Owner’s situation, that freedom is accompanied by a responsibility to meet the goals of the sprint.

The Scrum Framework:

A typical working model of Scrum is described as below:
  • A product owner creates a prioritized wish list called a product backlog.
  • During sprint planning, the team pulls a small chunk from the top of that wish-list, a sprint backlog, and decides how to implement those pieces.
  • The team has a certain amount of time, a sprint, to complete its work - usually two to four weeks - but meets each day to assess its progress (daily scrum).
  • Along the way, the ScrumMaster keeps the team focused on its goal.
  • At the end of the sprint, the work should be potentially shippable, as in ready to hand to a customer, put on a store shelf, or show to a stakeholder.
  • The sprint ends with a sprint review and retrospective.
  • As the next sprint begins, the team chooses another chunk of the product backlog and begins working again.
Below image shows the Scrum framework:


The cycle repeats until enough items in the product backlog have been completed, the budget is depleted, or a deadline arrives. Which of these milestones marks the end of the work is entirely specific to the project. No matter which impetus stops work, Scrum ensures that the most valuable work has been completed when the project ends.

Meetings: Meetings play an important role in Scrum. Following different types of meetings are held at different stages of Scrum.

1. Daily Scrum: Each day during the sprint, a project status meeting occurs. This is called a "daily scrum", or "the daily stand-up". This meeting has specific guidelines:
  • The meeting starts precisely on time.
  • The meeting is time-boxed to 15 minutes
  • The meeting should happen at the same location and same time every day
During the meeting, each team member answers three questions:
  • What have you done since yesterday?
  • What are you planning to do today?
  • Do you have any problems preventing you from accomplishing your goal? (It is the role of the ScrumMaster to facilitate resolution of these impediments. Typically this should occur outside the context of the Daily Scrum so that it may stay under 15 minutes.)
2. Sprint Planning Meeting: At the beginning of the sprint cycle (every 7–30 days), a "Sprint Planning Meeting" is held.
  • Select what work is to be done
  • Prepare the Sprint Backlog that details the time it will take to do that work, with the entire team
  • Identify and communicate how much of the work is likely to be done during the current sprint
  • Eight hour time limit. 1st four hours: Product Owner + Team: dialog for prioritizing the Product Backlog. 2nd four hours: Team only: hashing out a plan for the Sprint, resulting in the Sprint Backlog
At the end of a sprint cycle, two meetings are held: the "Sprint Review Meeting" and the "Sprint Retrospective"

3. Sprint Review Meeting:
  • Review the work that was completed and not completed
  • Present the completed work to the stakeholders ("the demo")
  • Incomplete work cannot be demonstrated
  • Four hour time limit
4. Sprint Retrospective:
  • All team members reflect on the past sprint
  • Make continuous process improvements
  • Two main questions are asked in the sprint retrospective: What went well during the sprint? What could be improved in the next sprint?
  • Three hour time limit
Benefits of Scrum:
  • First thing first: A well-functioning Scrum will deliver the highest business value features first and will avoid building features that will never be used by the customer. Since industry data shows that about half of the software features developed are never used, development can be completed in half the time by avoiding waste, or unnecessary work.
  • High Productivity & Quality: In most companies, development is slowed down by issues identified as impediments during the daily meetings or planning and review meetings. With Scrum, these impediments are prioritized and systematically removed, further increasing productivity and quality.
  • Ease Pressure @ Work: Scrum removes management pressure from teams. Teams are allowed to select their own work, and then self-organize through close communication and mutual agreement within the team on how best to accomplish the work. In a successful Scrum, this autonomy can significantly improve the quality of life for developers and enhance employee retention for managers.
We can say that simple rules of Scrum are: continual inspection, adaptation, self-organization, and emergence of innovation. 

This can produce an
- exciting product for the customer,
- develop high team spirit and satisfying work,
- generate high productivity and customer satisfaction, and
- achieve the market and financial goals of the company.
- a win-win situation for company and team members.

As a result, Scrum is being widely adopted worldwide in companies large and small, localized or distributed, open source or proprietary, for virtually any type or size of project.

Burn Down Chart:
Here, we will also discuss about Burn Down chart - a very common term in Agile Methodology. Burn Down Chart is for tracking day to day project/resources activities.

The Burn Down chart is a publicly displayed chart showing remaining work in the sprint backlog. Updated every day, it gives a simple view of the sprint progress. It also provides quick visualizations for reference.

It short, Burn Down Chart is a graphical representation of work left to do versus time. The outstanding work (or backlog) is often on the vertical axis, with time along the horizontal. That is, it is a run chart of outstanding work. It is useful for predicting when all of the work will be completed. Sample Burn Down chart is shown below:


With the help of Burn Down chart we can get clear idea of following attributes:

1. List of task to be done
2. Timeliness
3. Status
4. Remarks/comments
5. Actions to be taken against pending items in project
6. Extra time spent on lunch, tea, etc

Hope above information will helpful to start your new project with Agile Methodology.

Some of the Agile software Project management Open Source Tools:
http://www.icescrum.org/
http://www.agile42.com/cms/pages/
http://www.agile-tools.net/

Thursday, September 30, 2010

Cloud computing

Today, Cloud computing is not a new word, but still its considered to be one of the services that will be opted by every company directly or indirectly in near future. So we can say that future of Information Technology will be in 'Cloud'. I tried to put few things related to Cloud computing in this article and also tries to include basic information about Windows Azure platform (windows cloud platform).

What is Cloud computing?
Cloud computing is Internet-based computing, whereby shared resources, software, and information are provided to computers and other devices on demand, like the electricity grid.

In general, cloud computing customers do not own the physical infrastructure, instead avoiding capital expenditure by renting usage from a third-party provider. They consume resources as a service and pay only for resources that they use. Many cloud-computing offerings employ the utility computing model, which is analogous to how traditional utility services (such as electricity) are consumed, whereas others bill on a subscription basis. 

Some of the companies which provide cloud computing services are Amazon, Google, Salesforce, IBM etc.

Key Advantages:

1. Agility improves with user's ability to rapidly and inexpensively re-provision technological infrastructure resources.
2. Cost is claimed to be greatly reduced and capital expenditure is converted to operational expenditure.
3. Device and location independence: enable users to access systems using a web browser regardless of their location or what device they are using (e.g., PC, mobile).
4. Multi-tenancy enables sharing of resources and costs across a large pool of users thus allowing for:
  • Centralization of infrastructure in locations with lower costs (such as real estate, electricity, etc.)
  • Peak-load capacity increases (users need not engineer for highest possible load-levels)
  • Utilization and efficiency improvements for systems that are often only 10–20% utilized.
5. Scalability via dynamic ("on-demand") provisioning of resources on a fine-grained, self-service basis near real-time, without users having to engineer for peak loads.
6. Security could improve due to centralization of data, increased security-focused resources, etc., but concerns can persist about loss of control over certain sensitive data, and the lack of security for stored kernels.
7. Maintenance is nil for consumers as they didn't need to worry about that.
8. Metering means that cloud computing resources usage should be measurable and should be metered per client and application on a daily, weekly, monthly, and yearly basis.

Layers of Cloud Computing:

Client: A cloud client consists of computer hardware and/or computer software that relies on cloud computing for application delivery. Examples include some computers, phones and other devices, operating systems and browsers.

Application: Cloud application services or "Software as a Service (SaaS)" deliver software as a service over the Internet, eliminating the need to install and run the application on the customer's own computers and simplifying maintenance and support.

Platform: Cloud platform services deliver a computing platform and/or solution stack as a service, often consuming cloud infrastructure and sustaining cloud applications. It facilitates deployment of applications without the cost and complexity of buying and managing the underlying hardware and software layers

Infrastructure: Cloud infrastructure services, also known as "Infrastructure as a Service (IaaS)", delivers computer infrastructure - typically a platform virtualization environment - as a service. Rather than purchasing servers, software, data-center space or network equipment, clients instead buy those resources as a fully outsourced service.


Windows Azure Platform

The Windows Azure Platform is an Internet-scale cloud computing and services platform hosted in Microsoft data centers. The Windows Azure Platform includes the foundation layer of Windows Azure as well as a set of developer services which can be used individually or together. The Windows Azure platform provides the tools and documentation necessary to develop hosted services that run on Windows Azure.

The Windows Azure platform consists of a hosted infrastructure of hardware, software, network, and storage resources each providing a specific set of services to application developers. These services include:

1. Windows Azure

In its simplest form, Windows Azure is a cloud services operating system that serves as the foundation for running Windows applications and storing data in a scalable Internet-accessible virtual environment. 

Windows Azure is part of the Windows Azure platform which consists of a hosted infrastructure of hardware, software, network, and storage resources.

Windows Azure handles load balancing and resource management and automatically manages the life cycle of a service based on requirements that the owner of the service established.

2. Windows Azure Storage services

The Windows Azure Storage services are comprised of:
  1. Blobs: Used to store unstructured binary and text data
  2. Queues: Used for storing messages that may be accessed by a client and providing reliable messaging between role instances
  3. Tables: Used to store non-relational structured data
  4. Windows Azure drives: Used to mount an NTFS volume accessible to code running in your Windows Azure service

3. Microsoft SQL Azure

Microsoft SQL Azure Database is a cloud-based relational database service built on SQL Server technologies. It provides a highly available, scalable, multi-tenant database service hosted by Microsoft in the cloud. SQL Azure Database helps to ease provisioning and deployment of multiple databases. Developers do not have to install, setup, patch, or manage any software.

4. Windows Azure AppFabric

The Windows Azure AppFabric Service Bus and Windows Azure AppFabric Access Control together make hybrid, connected applications. Applications that communicate from behind firewalls, across the Internet, from hosted cloud servers, between rich desktops and smart devices—easier to build, secure, and manage.

Although you can build hybrid, connected applications today, doing this often means you have to build important infrastructure components before you can build the applications themselves.

AppFabric Service Bus and AppFabric Access Control provide several important infrastructure elements so that you can more easily begin making your connected applications work now.

  1. The AppFabric Service Bus securely relays messages to and from any Web service regardless of the device or computer on which they are hosted, or whether that device is behind a firewall or NAT router.
  2. The AppFabric Access Control is an interoperable, claims-based service that provides federated authentication and authorization solutions for any resource, whether in the cloud, behind a firewall, or on a smart device.

5. Microsoft Codename "Dallas"

Microsoft Codename “Dallas” is a service allowing developers and information workers to easily discover, purchase, and manage premium data subscriptions. “Dallas” is an information marketplace for ISVs and IWs that provides both trusted public domain and premium commercial data via integrated consumption experiences and easy data discovery, exploration, and purchasing on any platform.

Additionally, Dallas APIs allow developers and information workers to consume this premium content with virtually any platform, application or business workflow.

Hope you get enough information to move into cloud. Enjoy the ride !!!

References:

Monday, September 27, 2010

Rules for happy and successful life

Below are the few rules which everyone should try to adopt for happy and successful life. Even if you follow some of them, you will definitely find positive improvements in your current life style.
  • Avoid Negative Thoughts, People, Things and Habits.
  • Believe in yourself.
  • Consider things from every angle and others points of view.
  • Dare to Dream and Dream Big
  • Energy, Excitement and Enthusiaism should be in your blood.
  • Family and Friends are hidden treasures; enjoy these riches.
  • Give more than you planned to.
  • Have a good sense of humour.
  • Ignore Critisism, Ridicule and Discouragement from others.
  • Jump on Problems because they are Opportunities in disguise.
  • Keep up the good work however hard it may seem.
  • Love yourself, just as you are.
  • Make Impossibility a Possibility.
  • Never lie, cheat or steal, always strike a fair deal.
  • Open your eyes and see things as they really are.
  • Prefect Practice makes you perfect.
  • Quitters never Win and Winners never Quit.
  • Reward yourself for every small success and achievement.
  • Stop Wasting your Time and Procrastinating important Goals.
  • Take control of your Life and your Goals.
  • Understand so that you could Understood.
  • Visualize your Goals and Dreams everyday.
  • Win over your own weaknesses and make them as your Strengths.
  • Xccelerate your efforts
  • Yes Yes Yes, Yes you Can and You Will
  • Zap your Stress and Enjoy your Life.