Sunday, October 28, 2007

BST - Bites me again

I don't know what it is that make this happen every year.

But every single time that the clocks have to be adjusted due to either the start or the end of BST, I inevitably find out about it at around midday on the Sunday on which the change occurs.

I therefore, am either late for some appointment, or alternatively miss that all important extra hour in bed.

Of course I could simply go to bed an hour earlier this evening, but frankly it's been a week since I touched a computer so if you think I'm gonna leave this one early his evening you've got another thing coming.

:)


Friday, October 19, 2007

Holiday???... What's that then?

The trouble with working for yourself (or family in my case) is that you very rarely get to take any official time off.

Not withstanding the birth of my last child Rosie, I haven't taken "official holiday" in about 3 years.

But I'm taking next week off to chill with a few good books.

Money is a bit tight so my wife, my 3 kids and myself are going to visit my in-laws (Just for a few days) who don't really know what the Internet is, much less have a computer.

I'm leaving my laptop behind and I'll probably switch off my mobile phone.

I might take a pen and paper but that's the technological limit.

The pace of life is going to slow to a snail pace and I might finally be able to relax for a bit :)

Of course we'll be staying with the in-laws so there's no guarantees :)

So this is me dutifully giving notice that my DX-Squad presence is going to lapse like never before.

So to anyone who emails me during the next week.... replies will be a little delayed. :P

Tuesday, October 09, 2007

Aliases - The art of readable regular expressions

Here's a simple question.. Which of these is more readable?

  • (\.?((\[(([A-Z]|[a-z]|([À-Ö]|[Ø-ö]|[ø-ə]))|_)
    ((([A-Z]|[a-z]|([À-Ö]|[Ø-ö]|[ø-ə]))|_)|[0-9])*
    (\u0025|&|@|!|#|\$)?\])|(([A-Z]|[a-z]|([À-Ö]|[Ø-ö]
    |[ø-ə]))|_)((([A-Z]|[a-z]|([À-Ö]|[Ø-ö]|[ø-ə]))|_)
    |[0-9])*(\u0025|&|@|!|#|\$)?)((\s*)\.(\s*)((\[(([A-Z]|[a-z]|([À-Ö]
    |[Ø-ö]|[ø-ə]))|_)((([A-Z]|[a-z]|([À-Ö]|[Ø-ö]
    |[ø-ə]))|_)|[0-9])*(\u0025|&|@|!|#|\$)?\])|(([A-Z]|[a-z]|([À-Ö]
    |[Ø-ö]|[ø-ə]))|_)((([A-Z]|[a-z]|([À-Ö]|[Ø-ö]
    |[ø-ə]))|_)|[0-9])*(\u0025|&|@|!|#|\$)?))*)


  • %Identifier%


I'll give you a minute to let that sink in......


The 2 expressions above are both valid and equivalent in DXCore's 'Alias' subsystem. The 'alias' subsystem backs the 'Duplicate Line', 'Selection Inversion" and "Intelligent Paste" functions of CodeRush.


Which would you rather type?


The 'Alias' subsystem is a very simple but very powerful recursive substitution system which starts with a simple phrase. (In this case %Identifier%) and then expands it according to 1 or more rules. The resultant phrase is then analyzed and, if capable, expanded again... and again ... and again.


%Identifier%

...becomes...

(\.?%SimpleIdentifier% (%ws%\.%ws%%SimpleIdentifier%)*)

...becomes...

(\.?(%EscapedIdentifier%|%NonEscapedIdentifier%) (%ws%\.%ws%(%EscapedIdentifier%|%NonEscapedIdentifier%))*)

...becomes...

(\.?((\[%AlphaOrUnderline%%PartialIdentifier%%TypeCharacter%?\]) |%AlphaOrUnderline%%PartialIdentifier%%TypeCharacter%?) (%ws%\.%ws%((\[%AlphaOrUnderline%%PartialIdentifier%%TypeCharacter%?\]) |%AlphaOrUnderline%%PartialIdentifier%%TypeCharacter%?))*)

A few rounds later and we have our full expansion....


(\.?((\[(([A-Z]|[a-z]|([À-Ö]|[Ø-ö]|[ø-ə]))|_)
((([A-Z]|[a-z]|([À-Ö]|[Ø-ö]|[ø-ə]))|_)|[0-9])*
(\u0025|&|@|!|#|\$)?\])|(([A-Z]|[a-z]|([À-Ö]|[Ø-ö]
|[ø-ə]))|_)((([A-Z]|[a-z]|([À-Ö]|[Ø-ö]|[ø-ə]))|_)
|[0-9])*(\u0025|&|@|!|#|\$)?)((\s*)\.(\s*)((\[(([A-Z]|[a-z]|([À-Ö]
|[Ø-ö]|[ø-ə]))|_)((([A-Z]|[a-z]|([À-Ö]|[Ø-ö]
|[ø-ə]))|_)|[0-9])*(\u0025|&|@|!|#|\$)?\])|(([A-Z]|[a-z]|([À-Ö]
|[Ø-ö]|[ø-ə]))|_)((([A-Z]|[a-z]|([À-Ö]|[Ø-ö]
|[ø-ə]))|_)|[0-9])*(\u0025|&|@|!|#|\$)?))*)


At each round of the substitution you can see the power of  Aliasing (not to mention the pre-built list of aliases) at work.


And what a list it is..... 93 separate pre-built aliases found in the "Core\Aliases\Regular Expressions\System" section of the DXCore options.


If  you find, somehow, that these aren't enough you can create you own. DevExpress have even allocated a place for you to do just this in "Core\Aliases\Regular Expressions\User"


But it doesn't stop there. Each defined alias can be referenced either on it's own, or with a numeral suffix from 1 to 9. Thus you can have %Identifier%, %Identifier1%, %Identifier2% .. all the way through to .. %Identifier9% all used in the same expression.


This paves the way for some pretty powerful features


In my next couple of posts I'll show you how we take advantage of aliases in our use of "Duplicate Line", "Smart Paste" and "Selection Inversion".