Saturday, February 25, 2006

Alice and Bob - archetypal characters

I was reading Wikipedia article about Public-key cryptography and suddenly noticed "Alice and Bob - a commonly used placeholders for archetypal characters"
Isn't it nice and funny?

Monday, January 09, 2006

Axiom: In HTTP, GET must not have side effects.

Alex Bosworth's Weblog: Google's new web accelerator breaks webapps
Univeral Resource Identifiers -- Axioms of Web architecture

I knew it for a long time - learned a hard way. But how often you see ASP pages which include statements modifying database data in visible pages - pages containing HTML, how often you see such pages being linked from other pages! It's a GET operation when you follow a link!
Moreover, one thing which I don't like in ASP.NET (and it's a common tendency for Microsoft's products for developers) is that it tends to hide everything. There is no server and client, everything is mixed together into web controls. I don't need to know if it POSTs or GETs or is just sitting on a client in JavaScript. In my experience, such attempts always fail: to program something meaningful you have to now inner details.

Sunday, January 08, 2006

Hijax:

DOM Scripting: Hijax
Adactio: Journal - Progressive enhancement with Ajax

I like this idea of "progressive enhancement and graceful degradation" using a modular server-side architecture "capable of returning entire pages or portions of pages"! It's clear and doable!
Basically, you need to write a set of functions or maybe a class with a set of functions running on a server and then have one page [with server side script and no html] which handles a normal form POSTs using a set of those functions, and other pages which handle xmlhttp request post/get submissions by using an appropriate subset of the same functions. It could be even the same page which behaves differently depending on who and how calls it. A kind of Web Service :)
This page then either redirects to an appropriate HTML page, or just sends an appropriate XML or text back to AJAX caller.

Saturday, January 07, 2006

Dynamic web applications and disabling browser's "Back" and "Forward" buttons.

Introduction:
I have recently read several good articles talking about problems with browser's "Back" and "Forward" buttons on AJAX, and, speaking in more general terms, any web pages with a dynamic content. Basically: when user clicks one of these buttons browser loses document's state. So, it is not possible to go back. It's perfectly described in isolani's article.

It's a long known problem with pages with frames, dynamic PHP/ASP pages using session variables, etc. People discuss various possibilities to save a state in browser's history/cache and for AJAX commands to add entries into history/cache. I believe that as this problem has only one radical solution: a web browser should allow HTML document to conditionally disable "Back" and "Forward" buttons.
Such dynamic web pages are not plain but rather web applications - speaking in isolani's terms. And an old web ideology which restricts from doing that does not apply to such pages.
Not everybody knows that Internet Explorer already allows to control these buttons in a indirect way with its onbeforeunload() event.

Again, here are several articles when people desperately try to resolve these issues:
Fixing the back button that AJAX broke
Hijax
Back button and Undo in Ajax applications
public-webapi@w3.org - Ajax Back/Forward History problem – saving document state

I sent a couple of messages in reply to this lists.w3.orgdiscussionn - not sure when and where they will appear. So, below is a copy of these messages:

***************
In reply to Karl Pongratz's message I said the following:

Karl Pongratz wrote:
> I also want to note that I wanted to propose something
> simple that solves the emerging Ajax web application web
> browser history problem, something that is strongly tight
> to the xmlhttp request object and would be easy to
> implement by user agent vendors.

Karl, I strongly believe that modifying browser's engines to save *state* in addition to URL just cannot be simple enough. I highly doubt it would be implemented any soon.

As says here, "Part of the AJAX problem is understanding whether an AJAX enhanced page is actually a web application, or is it still just a web document?"

I believe that an AJAX enhanced page should be considered a web application by itself. I also believe, that the best and really easy solution would be to conditionally disable "Back" and "Forward" buttons on an AJAX page. When I said "conditionally" I meant that in case a user clicks one of these buttons a browser should display a confirmation window asking if user really wants to *leave application*.

Yes, it would break a "pure HTML ideology", but this ideology applies to web pages, not to web applications.

AJAX web pages aren't first pages which would benefit from conditionally disabling "Back" and "Forward" buttons. The same issue arises for any web pages with dynamically modified content: for pages with frames, for pages with Java applets or ActiveX controls.

Even plain HTML pages generated by server-side (PHP, ASP, etc.) script often experience troubles with "Back" and "Forward" buttons. Consider a standard situation when a page uses HTML form to POST to itself, or when server-side script uses SESSIONS to save data on a server side. It immediately breaks a normal behavior of "Back" and "Forward" buttons, because document's *state* is not exclusively determined by a URL, it may depend on a session variable or even data, retrieved from a database.

So, again, such pages are web applications by themselves - something similar to a graphical Windows desktop application, and they should be able to restrict "Back" and "Forward" buttons' behavior.

Internet Explorer does provide a way to do it with onbeforeunload Event.
Unfortunately, other browser's vendors consider themselves more "purist" and do not provide such ability. If you try to Google like this you'll get a long list of messages from people struggling to disable those buttons... I understand that controlling "Back" and "Forward" buttons' behavior from a loaded HTML document may introduce some security risks, but I think that it well worth to implement as standard behavior - advantages are immense.

***************
In reply to Garret Wilson's message I said that:

Garret Wilson wrote:
> Web applications are truly applications, and it may be
> correct for them to expose certain commands to their
> runtime container (which may be a browser)

I think that you words apply perfectly to "Back" and "Forward" browser's buttons which should be controllable to certain degree by HTML document itself. If properly implemented, it would solve a lot of problems with dynamic web pages (like pages using AJAX) being not compatible with "Back" and "Forward" buttons - because they lose their state when browser leaves a page.

See Ajax Back/Forward History problem thread here and/or here.
Also take a look at Ajax Mistakes topic SourceLabs forum.

***************
After thinking about this issue and reading more articles I understood, that we should distinguish two different situations of using "Back" and "Forward" buttons:
1) To Enter/Exit current web application.
2) To travel inside current web application.

All my words above about conditional disabling of buttons apply to 1).
In 2) "Back" and "Forward" buttons are a convenient tool. I recently found an article written by Mike Stenhouse and called Fixing the Back Button and Enabling Bookmarking for AJAX Apps. It does allow to use navigation buttons inside AJAX application. But despite the fact that it's a clever code, I consider it as a hack. Just too much smart efforts for such a simple and common thing.
I wonder why it is considered better to have navigational buttons provided by a container (web browser). Coming from a windows desktop applications background (VB/Delphi) I would say, that it is oftensimplerr and more flexible to control navigation inside an application using its own tools. Speaking about web application, I would say that it is often better todisablee "Back" and "Forward" buttons inside application and to use application's custom buttons/links to go back and forth.
Unless some major changes are incorporated into modern browsers allowing to track changing state by means of AJAX.

A good website and ACRONYM and ABBR tags

I was browsing developer's sites all the day and found a site which is IMHO good for all Web developers
http://www.w3schools.com/default.asp
There are tutorials on almost all Web-related technologies!

In particular, I was surprised to find simple HTML tags I've never heart about:
ABBR and ACRONYM
http://www.w3schools.com/tags/tag_abbr.asp
http://www.w3schools.com/tags/tag_acronym.asp

Move a mouse over dotted words on this page to see how it works.

Open IE in Mozilla/Firefox Tab

If, for some crazy reason you just want to open some page not in your normal Firefox/Mozilla, but in IE...

Google rules!

I wanted to install Google Toolbar on my home machine to be able to spell check on any form - just as I did recently at work, started to look at Google pages and immediately got lost with it's endless features. I went to Google Blog Search, searched for "AJAX" and found... Guys, for example, take a look at AJAX-based slideshow here!

Thursday, December 15, 2005

Atlas: Rapid Ajax Development with ASP.NET 2.0

Guys, did you hear about Atlas? Once again technology evolves faster that I grasp existing concepts :(

I knew that Ajax is a fantastic technology; it turned out that Microsoft knows it as well :)

See the book: "Foundations of Atlas: Rapid Ajax Development with ASP.NET 2.0"

Monday, December 05, 2005

Using MS Indexing Server to query multiple catalogs

Guys, I've just resolved one of the most difficult errors I ever got. It was partially due to my bad English, though. But it was mostly due to idiots' Microsoft style of software development. Every time, when you start to do something advanced using some MS technology you're finding that it is not really documented and there is no info even on Google - just because no one uses MS software for advanced development... I remember one case when I was told to use Application Role and Connection Pooling with MS SQL Server 2000. We started to get some irregular type of errors; identical queries returned errors first time and work on subsequent attempts. I was happy to guess that there should be something wrong with Connection Pooling, like not releasing some settings... And we immediately found on Google that there is a known SQL Server bug which does not allow using Connection Pooling with Application Roles. No way.

OK. Back to what I found today: We have a simple ASP interface for MS Indexing Server to search some catalogs for some documents. Someone wrote it in the past; I never worked with Indexing Server (I remember someone played with it in ADI; Tom do you remember?) I was told to modify this interface to be able to search in all catalogs. Since I didn't want to rewrite all the pages, I started to read MSDN in hope that Indexing server has a support for doing that. And yes, it does: MSDN says, "The catalog name can be the name of a directory on the local computer. You can specify more than one catalog name by separating each name with a comma." I modified an ASP code making comma-separated list and immediately got "CreateRecordset error '80041827' Mismatch in cardinality of machine(s)/catalog(s)/scope(s)" error. Here's where my bad English didn't allow recognizing a source of error immediately. I started to search Google and MS Knowledge Base for this error - no info. Nothing meaningful at all. I suspect that as usual no one actually used this slightly advanced approach with MS software - as usual. I was going to give up on my attempts and tell my boss that it' snot doable in a short period of time... But suddenly I understood the error: I set Catalog property as a comma-separated list... maybe folders (scopes) should be set as comma-separated list as well. Using Utility.AddScopeToQuery(objQuery, strPath[,strDepth]) with strPath set as a comma-separated list did not help. But applying objUtility.AddScopeToQuery() several times (the same number as a number of catalogs) did help! Hurrah! I found a solution!

Thursday, December 01, 2005

An excellent site for ASP, .NET, and ColdFusion developers

Guys, I've just found an excellent site for ASP, .NET, and ColdFusion developers - xefteri.com. I was searching for MS Indexing Services bug description and found this detailed article. But there's much more: articles, forums, etc. It is run basically by one guy!

Thursday, November 17, 2005

.NET positions

Guys, I was on an interview with a guy from HireStrategy. He said they have several excellent .NET job opportunities. Since I'm still not fluent enough with .NET I would be happy to give you their contact info. Please contact me directly if interested.

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.)