Friday, October 14, 2005

Fully qualified names in MS Access query

Guys, did any of you ever noticed that in MS Access query written as inline ASP code using fully qualified names (like TableName.FieldName) [in SORT BY clause] makes it to work faster [in case a query joins more than one table]? I guess I saw it today. Maybe Access doesn't need to determine each time which table you're talking about... Or maybe I'm just dreaming...

Inner-Browsing? XMLHTTPRequest? AJAX is the word!

I was suprised at the speed of development of technology once called as Inner-Browsing: Extending Web Browsing the Navigation Paradigm by Netscape DevEdge. I created my postXMLHTTP() JavaScript function which utilizes XMLHTTPRequest technology a couple of years ago I used it sucessfully in several PHP (including an administrative interface for my photo gallery) and ASP applications.
Now I fell behind once again. Technology evolves at great spead and powerfull standards for inner-browsing and new data excahnge formats emerged. Now the name is - AJAX. Today I found the following great link: PowerWEB LiveControls for ASP.NET. They use remotely generated script to replace the standard postback with a non-refresh callback. By the way I believe that this will be a built-in feature of ASP.NET 2.0...
Please read a small article I wrote some time ago. I placed it into my photo gallery developed in PHP/MySQL because gallery's administrative interface uses XMLHTTPRequest heavily.

Thursday, October 13, 2005

Search engine friendly URLs using ASP.NET (C#.NET)

Here's an article which could be helpful for .NET developers: Search engine friendly URLs using ASP.NET (C#.NET).
Goal:
Instead of sending parameters like http://www.mydomain.com/?pageid=4 which is not search engine friendly, we want to change it to http://www.mydomain.com/page4.aspx

Similar thing is well known on Apache world and is called MOD_REWRITE. It could be interesting to compare these two technologies.

Andrew said, "Blog It!" :)

I was working with Andrew for just several months in Enterprise Database Corporation (2-programmer's company :)). But it was an excellent time: Andy gave me ideas and I implemented them (arguing). Now I'm glad to welcome him here.
I sent Andrew a message and his answer was, "Don't tell me ... blog it!" So, here's what I sent:

"Andrew, I saw on your Wiki that you are interested in Design Patterns. I think I'm interested too. I bought a couple of books and going to study. I feel more and more that I'm reinventing the wheel, that I'm continuously performing similar tasks but cannot tell exactly what is common between them."

Andrew answered:
"If you bought the Gamma et al book, return it. Everyone says "Head First Design Patterns" is the best to start with. Then "Patterns of Enterprise Application Architecture " by Fowler.

See his Refactoring post over there.

Refactoring

I just spent the last day and a half fixing some bugs and adding some features to a relatively simple VB6 application. The first half day was really stressful because the code was not up to my very high standards - 300+ line routines, no objects, schizophrenic routines (save also validated), operational data split between memory and screen controls, etc. I couldn't understand the logic nor the functionality. Then it hit me ... REFACTOR!

I read Martin Fowler's book, Refactoring over the summer and it gave structure to a practice I already followed and renewed my interest in continuing. For those who are not familiar with the term refactoring, it is the process of changing code structure without changing the behavior to increase legibility, decrease complexity, etc.

Back to my hell, one piece of functionality I had to add involved the followng code:
    If Not IsNumeric(tvItems.Tag) Then tvItems.Tag = -1
    If CInt(tvItems.Tag) <> tvItems.SelectedItem.index Then
        If tvItems.Tag <> -1 And Me.chkIgnoreThisJob <> 1 Then
            ...
I knew I could figure it out if I beat my head against a wall for a few hours, which I actually started doing (by actually trying to understand the code). Then I took a different tack. I realized that "Not IsNumeric(tvItems.Tag)" actually meant we do not know which item is selected and that "tvItems.Tag = -1" actually meant no job is selected, so I wrote the following functions:
    Private Function WeDontKnowWhichJobIsSelected() As Boolean
        WeDontKnowWhichJobIsSelected = (IsNumeric(tvItems.Tag) = False)
    End Function

    Private Sub SetThatNoJobIsSelected()
        tvItems.Tag = -1
    End Sub

and changed the original code to read:
    If WeDontKnowWhichJobIsSelected Then
        SetThatNoJobIsSelected
    End If
    If CInt(tvItems.Tag) <> tvItems.SelectedItem.index Then

        If tvItems.Tag <> -1 And Me.chkIgnoreThisJob <> 1 Then
            ...
Can you see where this is going? Eventually I added a few more functions and the original block of code looked like this:
    If WeDontKnowWhichJobIsSelected Then
        SetThatNoJobIsSelected
    End If
    If TheSelectedJobHasChanged Then

        If AJobIsSelected And IgnoreThisJob = False Then
            ...
Now the code code was completely clear and I knew where to make my change. Not only that, but I knew life would be easier for the next person.

So the real purpose of this story is to ask the following questions:

  • Is there anyone else who does this?
  • Did you know you were doing it?
  • Are you glad you do it?
  • Will you do it in the future?
  • What is the airspeed of an unladen swallow?

Andrew

Monday, October 10, 2005

Hey Vlad, Thanks for the invite.

Friday, October 07, 2005

Test, test, test...

Speaking English:
Three witches watch three swatch watches. Which witch watches which swatch watch?

... and Russian (UTF-8):
Три ведьмы разглядывают трое часов "Свотч". Какая из ведьм разглядывает какие часы?"

Hello guys!

For a long time I wanted to have something convenient to be able to share our thoughts on software (Web) development issues. Andy Marshall suggested me to use Wiki but for now I decide to use this blog. (I'm a big fan of Google software and this one was created or associated wth Google.)