Friday, February 23, 2007

Solve problems where they exist, don't forward them...

I was fixing a bug in a web form that takes input from user in form of drop down lists that were put inside a table in the same row, each in a table cell.
The form required to work in both directions (RTL , LTR), according to some configurations. So if the user chooses to display the form in RTL, the alignment of the input controls must to change to "right" and so the direction should change to RTL, quite simple..

For some reason, the developer that added this functionality did adjust the alignment but did not adjust the direction of the table. This can make the user get confused because he expects the input sequence to be from right to left in case the form is right-aligned.

He solved this problem by changing the logic of reading and saving user input to reverse data in case of RTL. And problems started.

Being a relatively complex module, this change in logic caused other errors that were hard to trace. I solved this bug simply by removing any special handling to RTL case in application logic and changed the direction of the table that contains the drop down list to RTL. This solved the problem and made the code clearer.

I'm fond of thinking about and studying the real causes of bugs and issues. One of them is what the fellow developer did...
The RTL behavior is clearly a UI function. Supporting this functionality should not go to other layers or places in the code.

A new lesson I must remember:
Solve problems where they exist, don't forward them...

Should I say whenever possible?


Anonymous said...

Thank you for the article
could you please help me
I have a problem with my blog
when I write in arabic which is rtl language and insert some english words in the same line the english words fix in the right , never be in the middle of arabic sentences ...
thank you in advance

Hesham A. Amin said...

You need to press (Edit HTML) and adjust the rtl attribute manually like:
<div style="text-align: right;" dir="rtl">احمد aaa حسن</div>

Sherif Adel Medhat said...

I know what you mean now,
and i realize how this way of thinking could make things easier,
i'll do my best to folow.
That is a new lesson i must remember too.
Thank You :)