Wednesday, August 5, 2009

Width or No Width: that is the question

“To be, or not to be: that is the question:”
-William Shakespeare
codeproject

Width is very important element in application design. If not used wisely it can break entire screen design. Few days back i was working on fixing few bugs in one of application. QA team reported that they were not able to see a table (which was created using GridView of .net) was not displaying data properly. Here is an example of it.

Hi, my wife tried to use a credit card online by inserting it into the floppy port of our pc. I have tried to fish it out but looks like it will have to come apart to retrieve the card. Is that a easy task to do?
What would be your immediate reaction to spilling a beverage on your laptop?

Here is HTML code for this

<table cellspacing="0" cellpadding="5" border="1">
<tr>
<td>
Hi, my wife tried to use a credit card online by inserting it into the
floppy port of our pc. I have tried to fish it out but looks like it will
have to come apart to retrieve the card. Is that a easy task to do?
</td>
<td width="40%">
<select style="width: 100%">
<option>I would call GeekSquad for help.</option>
<option>I would search on web for answers.</option>
<option>I would google for an action.</option>
</select>
</td>
</tr>
<tr>
<td>
What would be your immediate reaction to spilling a beverage on
your laptop?
</td>
<td>
<select style="width: 100%">
<option>I would turn it off immediately.</option>
<option>I would cream for help.</option>
<option>I would google for an action.</option>
</select>
</td>
</tr>
</table>

This looks OK enough, right? It has 60-40 split, all text comes properly. That's what we thought initially too. When QA team reported that they were not able to see this page properly I was surprised, I requested for screenshot and they send me this.

How to Buy Inexpensive Quality Computers and Electronics?
How to Choose a Computer?

Instead of using long question text they has short questions and long responses like in above example. As they reported text in dropdown, After reviewing code I found that code for creating dropdown <select style="width"100%"> was root of problem I changed it to <select> and ... see the result.

How to Buy Inexpensive Quality Computers and Electronics?
How to Choose a Computer?

As you can see here by removing style="width:100%" dropdown expanded to accommodate text and user can see entire text in dropdown.

Here is another example, in this example I needed to display some text, this text can be few words, short statements or many words and long statements as this was free form text entered by user. UI specification was if it is short text it should come into center, if there are more then one line then all lines should be left aligned and come into center of screen, as line becomes wide it shold automatically change it's position to be in center till line can not fit in same row at that time it should fall into next row. Here are few examples of this.

Example: 1
To create this table you should follow these steps.
  1. open ms-word
  2. select insert -> table
  3. select number of rows and columns you need.
  4. use that table


Example: 2
To create this table you should follow these steps.
1) open ms-word. 2 ) select insert -> table. 3) select number of rows and columns you need. 4) use that table

As you can see here in both of above examples text gets adjusted automatically according to width.
Here is code for it.


<table width="100%">
<tr>
<td align="center">
<table>
<tr>
<td align="left">
To create this table you should follow these steps.
<br />
1) open ms-word. 2 ) select insert -> table.
3) select number of rows and columns you need, even after
creating table if you can change this selection if you need.
4) use that table
</td>
</tr>
</table>
</td>
</tr>
</table>

The trick here is not to define width for inner table. By not defining width for inner table it will expand to accommodate longest text and will automatically come to next row if text is more then one row and align="center" on outer <td> will keep inner table into center all the time.


"Using width can be very tricky and can produce unexpected results some time, specially if input is controlled by user, in this kind of situations use minimum width and maximum width as text input to avoid any 'surprises' "

Saturday, August 1, 2009

Why UI/UX is important?

“Programming today is a race between software-engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots.

So far, the Universe is winning”
-Rich Cook

codeproject

Many times during interviews I have been asked the above question. There could be many different answers and opinions about this; I came up with the following. If you are a system developer probably this would give you more insight and a different view of application you are working on/have worked on.


For any application UI is its face. Everyone likes beauty which applies to computer users (and users of your application too?); UI can help to create a strong brand name and good company image. By providing consistence, UI minimizes the learning curve and helps the end user to start using the system from day one. This helps to make a popular application.


As end user if I am frustrated or feel helpless with an application then probably I will wait and look for alternatives (and soon I will find one too). While designing any application if developers do not think as end users then the product fails. As an example; even though Gateway was first to launch an online ordering system, Dell got a very good start because of continuously providing a good user experience. Dell realized soon that online ordering system is not against phone ordering system but it is ‘with’ Phone ordering system. Few changes like replacing dropdown boxes with lists, radio buttons or check boxes with graphic buttons, giving clear descriptions and creating ordering wizards instead of one long ordering page boosted Dell’s sales significantly.


Following table is code line analysis for .Net Pet Shop 4.0 application.



As you can see from the above example the amount of code we write for presentation layer is very high. In most of the cases this is true as Presentation layer or UI has to provide access to various functions of an application. As presentation layer is a huge code it is very critical that it should be designed very carefully.


Windows 95Windows 95
Windows VistaWindows Vista

Everyone likes a change towards more beautiful applications. Since Microsoft launched Windows 95 in 1995 and Windows Vista in 2007 you will notice many changes, many things got more beautiful and more elegant. As an end user even if 2 applications have exactly the same functions I would be willing to pay a bit more money to get the more beautiful application.


As the application user I don’t care how ‘good’ your application is, which ‘great’ programming methodology you have used to create your application, which testing method you used, which programming technology you used, I only care about one thing, ‘How does it make my life easy?’ As a developer if you think about the above question you will win users of your application, no one likes to click 10 buttons to get a single piece of information; it has to be very simple and easy to relate to. As an application user I don’t like changes (which is contradictory to my earlier statement ‘everyone loves change’). I like change but it should be more sensible like the ‘Start’ button of Windows. Since Windows 95 introduced it in 1995, the ‘Start’ button has been on the bottom left corner of the screen. It has always been there; today, in Vista it looks different but it is still there. You have the option to move the ‘Start’ button on any side of your screen but by default it will be on the bottom left corner of your screen. Few more examples could be Close (Minimize and Restore) button, menu items, toolbar etc.


"UI is very important part of any application as it is the only way for user to access functionality of application, it can be deciding factor to make or break any application."

Happy Coding & designing :)