#Google Analytic Tracker

Pages

Showing posts with label Windows 7. Show all posts
Showing posts with label Windows 7. Show all posts

Dec 27, 2011

How the Developers Sell a Bug as a Feature

Awhile ago one of my colleges handed me the above picture. It was funny, so I put it up on my wall. I could see how this situation could happen, but couldn’t recall any good example in my past experience.

Usually a bug in a software is fairly obvious.  If there is a debate among the stakeholders and the developers, it would properly be a design problem more than a software bug.

During the last sprint of the release, my team has debated a side effect that was introduced due to an UI architecture change. (I am guilty of making such change) We joked about it and believed that we could sell this bug as a FEATURE, and we named this feature “Instance Preview”. Similar to the format preview feature in MS Word 2007, user can see how the text formatting change simply by hovering your mouse over the tool bar items.

Background Story

A couple of years ago, our development team came up with a new UI architecture design that manages how data are modified in the application. It allows users cancel their changes at multiple sub form (windows) level. The application was tightly coupled to a typed DataSet. The dataset acts as a in-memory database for the application to manipulate data. Most of the UI controls are bind to the DataSet though data binding.

So we know we need some sort of versioning to keep track of data changes. The DataSet has a row version feature, but this feature wasn’t well understood by the development team back then. Therefore we implemented our own way.  We called it the FormTransaction. Each FormTransaction object contains a DataSet, and has a reference to a parent FormTransaction. Whenever user drills down the data detail, a sub window is opened, a form transaction object is also created, which contains a subset of data from the main data set.

image

The Main DataSet is the application main data repository. The forms are data bind to their FormTransaction’s DataSet. When a user makes a change in the UI, data are immediately updated in the DataSet. If another form updated the same DataSet, the changes would also immediately shown on other binded UI. If user want to discard the change, they simply click on a Cancel button on the form, and the sub dataset are disposed. If user want the save the change, the data are merge to the parent dataset, until all the changes reach to the Main DataSet.

FormTransaction Advantage:

  • Cancel change implement is easy, you simply close the form and dispose the FormTransaction object
  • You can control what data are loaded to the sub DataSet, which also acts as a filter

FormTransaction Disadvantage:

  • DataSet constraint validation can only run when data are merge back to the Main DataSet, this makes debugging more challenging because you won’t know which form created the invalid data until data are merged back to the Main DataSet..
  • Increase memory usage. If you need to load a lot of data in the subform, you need to duplicate the rows
  • It takes time to load data from Main DataSet to the sub DataSet, and it also take time to merge data changes to the parent DataSet.

Over the past year, we notices that our application is getting slower because we need to handle more and more data. The DataSet definition has grown and more data are needed to do certain calculation. FormTransaction were slowing down the application.

In addition, there was another feature that we need to do but it requires a lot of data to be loaded to a sub form. This UI architecture simply does not scale at all.  Thus, we came up with a newer approach using the opposite idea of the FormTransaction. We call it the RollbackTransaction

image

RollbackTransaction Advantage

  • No memory duplication, all the form works on the Main DataSet.
  • No need to load data, or figure out what data you need in the sub form, and no need to merge.
  • You have access to all the data in your sub form all the time.
  • Changes that made by the user are immediately validated

RollbackTransaction Disadvantage

  • Need to implement data filtering on all the data bind controls, since we don’t use FormTransaction to filter data.
  • If user made a lot of changes, undo (rollback) the changes can be slow

The implementation of the RollbackTransaction is pretty trivial. You basically backup all the original values that were changing. The DataTable comes with the following events:

You can attach to these events and store data change into a queue.  When the user wants to undo the change, reply the the action in an undo fashion. (i.e. if a new row was added, delete it)

Side Effects

Rollback transaction was great, it speeded up the application performance. However, there was a minor side effect. Since all the forms that uses RollbackTransaction are bind to the same DataSet, any changes you made in the child form will immediately show in the parent form. This side effect looks really cool, because you can see how the parent form behaves as you modify the child form. Especially if the parent form has a sorted grid, as you change the name of the sorted column value in the child form, the grid will resort itself as you type.

image

Had we Break the User Experience UX?

If you take a closer look at the our application design (above), you will notice there is a OK button and a Cancel button. The major conflict introduced by this side effect is that without user clicking on the OK button, the parent form are being updated as user making the change. The good news is that these windows are modal, which means user can’t edit the data from multiple windows. Most of the time user may not even see the parent form is updating because it is covered by the child form.

With many tasks on hands, our team left this minor side effect and continue on other developments.

Trying to Fix the Side Effect

To fix the issue, our idea is to update the DataSet, but delay the parent form update even it is data bind to the same DataSet.  We know that we can’t just unblind the form because the form would simply show no data. It would look silly, and it is worst than the side effect.

There has to be a way to suspend the datablinding. The gird is the first UI control that we want to suspend the data binding. We use Infragistic UltraGrid. UltraGrid had many functionalities and I was hopeful that it would have a method where I can suspend the data binding, and resume it which causes the gird to refresh itself.

We tried a number of solutions:

  1. UltraGrid.BeginUpdate() – This method looked very promising. In fact, it was the first solution that I implemented. It actually stop UltraGrid from painting itself, and I got what I expected, until the a QA come to me with the following issue:Schedule grid
    So, what’s the going on, why would the QA’s machine behaves differently than my machine. Well there is a big different, I was running Windows 7 with Aero Theme, while the QA was running Windows XP with Classic Theme.

    Aero Theme works most likely due to Windows secretly take a screen capture of the windows, this is need to create the Aero glass-liked effect on the title bar. When UltraGrid.BeginUpdate() is called, it stops the grid from painting, but Aero Theme override the painting somehow. In XP or Win 7 Classic Theme, it doesn’t do that. As a result you get the above issue.
  2. UltraDataSource.SuspendBindingNotifications() – This method also look promising. Unfortunately we don’t use UltraDataSource, since the gird bind directly to the DataSet.
  3. Create a data binding proxy – Using a proxy,  we have more control on what data go into the UI. However, such implementation can get complicated, and this really the same concept as the Form Transaction.
  4. Override the CurrencyManager – Totally a wrong concept, CurrentManager can’t control when the UI updates, its purpose is to synchronize record navigation with different controls.
  5. Use a picture box to mask the underlying changes – I saw this idea on a forum. I thought it was funny, so I mentioned this idea to the team, and we concluded that there should be a better solution. The limitation using a picture box is that you can’t interact with the grid at all. However, in our situation, we use modal window, so it may work. 

Why Don’t We Just Sell the Bug as a Feature!

Failing to find a good solution to fix this side effect, or a bug, the development team (which include myself) tried to convince ourselves that this bug is really an awesome feature. Existing customers may find it odd, but its functionality still works, new customers probably wouldn’t care, all we need to do is sell this bug as a feature to the QA team and other stakeholders: We call it “Instance Preview”.

Instance Preview – Similar to MS Word preview feature when applying format change, user can immediately see data change as they make modification to the detail form before changes are committed.

I bet that QA team won’t even know that it is a bug! We can market this as a new production feature. I think this is just evil genius. It saves developers time from fixing the problem while we have a new feature.

Solution

Of course, who are we kidding with.  No customers ever ask for such feature, and adding feature that doesn’t have a demand and proper requirement would create more maintenance problem down the road. So I contacted to Infragistics and hope they could provide a better solution:

http://forums.infragistics.com/forums/p/60424/306715.aspx#306715

And the solution is… (drum rolling)… picture box!!!

Here is a code snippet:

   1: Size s = ultraGrid1.Size;
   2: Bitmap memoryImage = new Bitmap(s.Width, s.Height);
   3:  
   4: grid.DrawToBitmap(memoryImage,new Rectangle(grid.Location, grid.Size));
   5: PictureBox p = new PictureBox();
   6: p.Name = "CoverGrid";
   7: p.Image = memoryImage;
   8: p.Location = grid.Location;
   9: p.Size = s;
  10: this.Controls.Add(p);
  11: p.BringToFront();
  12: ultraGrid1.BeginUpdate();

The code turns out to be more simple than what I was expecting. Originally I was about how the PictureBox behave if it is masked over the original windows. Would the picture box follows the gird if user move the window around.  As you can see, because the PictureBox.Location is a Point struct, and pictureBox.Size is a Size struct. These are reference type and as a result the PictureBox would simply be the same as the grid control’s location and size.

Ultimately, our team call these technique “PictureBoxing”.

This technique not only works for the grid, but also some other controls in our application.

Others Bug-Liked Features or Feature-Liked Bugs

  1. Incorrect decimal rounding due to unclear specification
  2. Duplicate data begin generate and you told your customer this increase reliability
  3. Click and hold on a Windows 7 title bar and shake it that minimize other windows
  4. Shaking your iOS device and it pops up “There is nothing to undo”
  5. Logon screen that ask you if you want to save your password, and yet you have to retype your password the next time your run the application. Reason: The saved password only used during the session to reduce multiple logons, and the application never persist the password.
  6. Calculation appears to be incorrect because it was displaying in metric while users expected the value is in empirical.

I am sure there are properly many similar situations which a bug and a feature is merely a different perceptive among different people.

Dec 6, 2009

Upgrading From XP to Windows 7 does not require XP Product Key?!?!

After using Windows 7 Ultimate RC for almost half a year, it was about time to install the production version. I had received the Windows7 Professional Upgrade package from BestBuy from my pre-ordered in July. I got it for about $129CND, which is a 50% off promotion.

Since this was an upgrade, I expected Windows 7 installation would require me to install Windows XP or at least has the Windows XP CD installation disk ready.

After using BootCamp to recreate a new partition, I restarted my Mac and began install Windows 7. By the way, I had to clean up the Mac partition, so that BootCamp could split the partition.

Here was the problem I encountered, when I tried to type in my Product Key for Windows 7, it failed to validate it.  After retyping it a couple of times, I gave up and google for solution.

Fortunately, the first entry of my search results gave me the solution, which was to install Windows 7 without the typing in the product key.

http://social.answers.microsoft.com/Forums/en-US/w7install/thread/a7a018fa-17b8-4a27-9657-52ba4d178e87

So, that what I did. I installed it without the product key. Once I am in the desktop, I used Windows Search and open the Windows Activation screen.

I typed in the product key again, and it passed.

Hmm… strange, why it didn’t ask for my Windows XP Key???

After I did a search, it turned out that I may have by pass the procedure of installing Windows XP. Legally speaking, you still need a legit copy of Windows XP, however, with the by pass, it looks like you may not really need your Windows XP or Vista installation disk.

Just a side note, some local computer stores in Calgary or Edmonton are selling Windows 7 Professional OEM 64bit for about $149, which is reasonably inexpensive. If you are a student, you can get the Windows 7 Home edition for $40CND.

Apr 17, 2009

Windows 7 - Problem Steps Recorder (psr.exe)

This tool maybe a godsend for the software developers.  It enables the end users record their problems. This helps a lot because customers aren’t usually good when expressing their software problem:

image_thumb[19]

Here is how it works, you click on the “Start Record” button, and you try to reproduce the problem of your application. Isn’t it simple! Once you get to the problem, you can click “Stop Record” to end the record. You can also “Pause” if you need to do something else in the middle. It will create a zip file that contains a .mht (MIME HTML). That’s easy!

Once you open the .mht in your web browser, you would see something like this:

image

Basically, the .mht files contains screenshots for each user actions. Notice that there is a green border around the Windows Live Writer, because this the current window user is interacting.

Each screenshot comes with a description of what the user was doing. For example:
Problem Step 9: User left click on "OK (push button)" in "Options"

At the end of the file, you will see this detail description:
image

The details contains all of your user actions. This definitely going to help us developers a lot!

Apr 16, 2009

My First Windows 7 Experience

For awhile, I had been avoiding of trying out new OS. Windows XP works so well that I rarely care about other OSs. Until last year, one of my colleges, who is more or less a Mac fanatic, talked me into getting a Mac.  After many months of indecision, I finally brought a MacBook Pro, and got to experience what is like to use a Mac.

Mac OS X has many nice features that I wish to see in XP, but at the same time, I struggled to understand some of the UI design  philosophies behind Mac OS X. I will talk about this concern in another time.

Of course, there is Windows Vista. Its bad reputations on the medias deter me from try it.  I tried it one time, and the UAC pops up for pretty much for everything I do. Even opening your Control Panel would require your permission.

This week, I got a rare opportunity learn about Windows 7 in a 3 days training session. Yes, this is for software developers! There are hand-on-labs to do and you get to try to do some programming with the Windows 7 features.

So far, I like Windows 7 beta a lot. Here are some of the things that I like.

  • Taskbar
  • Libraries and Federated Search
  • Background Services and Tasks

In addition, the session also covers Power Management, Multi-Touch and Ink, and the obvious the Windows Ribbon (Office Ribbon).

Snipping Tool

But first, I have to mention about this tool that I find in Windows 7 (Ultimate), the Snipping Tool.

image

This tool obviously does more than your typical “Alt-Print Screen”. You can do capture in these 4 modes:

  • Free-form snip – allow you to draw around an area
  • Rectangle snip – a rectangle screen capture
  • Windows snip – allow you to select a windows and do a screen capture on it
  • Full screen snip

In addition, you can draw and highlight the captured screenshot.

image

Taskbar

One major improvement that I find in Windows 7 compare with XP is the Taskbar

image

  • Icon display only, no text, it saves you space
  • Activate your program right from the task bar. There is no quick launch.
  • All related windows are hidden in a single program icon, it only shows the running and pinned programming.

So, how do you see your opened Windows? You can simple hover your mouse pointer over the executing program on the taskbar and it will display all it related windows in a thumbnail.

image

In terms of programming, you can dictate what you want to display.

Preview

The taskbar get even better, than you put your mouse on the program thumbnail, all the other windows will become glass, leaving only your selected window.

image

In addition, you can close your windows with the little red cross button on the preview screen.

Notice that if you have multiple windows open, you can see the icon look like a stack:

image

Other things including the following also make the taskbar attractive:

  • Thumbnail Toolbars
    image
  • Progress bar icon
    image
  • Jump List- right click on the icon
    image

The item in the Jump List and Thumbnail can be customized though Windows 7 API.

Ribbon

Ribbon from Office 2007 has comes to Windows7. Both Ribbons look very similar. My question is why not just rip the Ribbon out from Office.

Windows 7 Paint:

image

Windows 7 Word Pad:

image

Oh you can’t use Ribbon in Windows XP. Your application will not be able to run under XP if you have Windows Ribbon. For developers, this make our life a lot tougher. You either need have 2 different version of your program, or buy a third party ribbon that works in Windows XP.

Libraries

Another feature that I like is the Library feature. The concept is similar to Unix’s links. This is like a virtual folder where you can put whatever you want in it.

The idea is that you can use the library to “collect” other folders’ contents. For example, if I have a number of folders storing pictures, I can add these locations to the library and I can get a single view of all my pictures. This is similar to your Windows Media Player, or iTune where it scans all your music, videos and pictures into an organized folder view.

Libraries and Preview functions:

image

You can also create your own libraries:

image

One thing to note, my college and I have some concerns where the users may get confuse on how the folder system works. Note that if you delete the file from the library, it will delete it from your harddrive, which is not the same as a link.  We will have to wait out the public feel about this feature.

UAC

One thing I notice that that Windows 7 is not as annoying as Vista. UAC only shows up when I try to run program in administrative mode, or when I install new programs. Opening your Control Panel doesn’t need your UAC permission, yeah!

Boot Time

Another thing I should mention is Windows boot time significantly faster because:

Less start up background service – Service that not needed are removed.

Delayed Auto Start service – Service that doesn’t need to start at boot time.

Service can start up by Trigger – A service doesn’t start up unless an event occurs.

These strategies help Windows 7 Start up faster.

Software Development

I never do any COM and unmanaged programming (C++) in Windows. Fortunately, Windows 7 SDK will comes with managed code for me to do Windows 7 programming in C#.

However, this SDK is not the final product from Windows 7, so use it at your own risk. .NET 4.0 should include the API needed to program in Windows 7.

Conclusion

There is a lot I want to talk about Windows 7, but I will probably stop here for now.  In some ways, I feel that MS took a number of UI design idea from Apple.  However, if it works, why not use it.  One of the things I learn from the training is that programming in C++ (unmanaged) is a lot more troublesome compare with C# (managed). Am I glad I am working in C#!