Home  |  Castalia for Delphi

 Writing your first program
 Writing your second program
 Amending this program
 Delphi data types
   Sets and enumerations
 Programming logic
   Exception handling
 Dates and times
 Printing text and graphics
 Object Orientation basics
   Memory leaks!
   An example class

 Standard components

 Learn to program in Pascal - online education course

 Castalia for Delphi
 A brief history of Delphi
 Usability : file handling
 Usability : reference books
 Author links

  Castalia for Delphi
Time saving tools
Castalia is a set of time saving tools that integrate into the IDE. The authors wanted to promote their product via this web site, so I was naturally curious about what it offered. In my short investigation, I was sufficiently impressed with the combination of features and the price to be happy to add a graphic link to the Castalia site, and to summarise my findings in this little review.
This is a brief exploration of some of Castalia's features - you can trial the product for 30 days if you want to explore yourself. Castalia intercepts your key strokes, and is fully cognisant of the unit being edited. This enables it to offer some powerful and subtle benefits.
Syntax highlighting
Castalia adds box-type brackets around blocks of code, such as begin..end and try..finally..end, along with code flow arrows. It also provides live syntax highlighting - a benefit of knowing the code of the unit being edited. Just as with the native IDE, round bracket pairs are highlighted when editing, but Castalia is not confused by brackets within strings. This illustrates some of the attention to detail in the product.
Code navigation
Castalia adds drop down lists of classes and methods within the unit being edited, allowing direct access to code in large units. The bookmarks it adds confused me somewhat - in that they are pushed and popped from a stack, but I suspect that I did not spend long enough trying them out. Playing with code is somewhat different from writing code in earnest.
Where Castalia clearly shines is with the search box - it replaces what is an irritating aspect of the Delphi 7 version I tend to use, where the search argument was replaced by something different each time search was invoked. A really neat feature is the smart home key - press once and the cursor positions hard left - press again and it moves to the first non-blank character.
Code analysis
Castalia provides easily accessed stats for each function in your project. This was something that had no particular appeal to myself, but I can see that it could help identify bloated code. A key stat with regard to this is Cyclomatic complexity - the number if paths through your code, a factor important in thorough testing. It also gives the overall 'toxticity' of each function.
When you end up with a bloated unit, it is often wise to restructure. Refactoring helps you move a class definition and all its methods into another unit. I had a few problems doing this until I realised that the target unit had to exist and contain appropriate skeleton code. It would have been nice for it to generate new units as well, if appropriate.
Refactoring also works on variables, allowing them to be renamed with a local scope, and to have redundant definitions removed for example. But the latter expects you to position against each variable in turn before it can do this - I expected that it could work on a whole unit basis.
This is one of my favourite features. I knew this as macros when I started out in personal computing in the early 1980s. There are many inbuilt macros, all triggered by a letter sequence terminated by space (and again, if typing in a string or a comment, Castalia is smart enough to block the template action). For example, type trycf followed by space and a try block appears. The cursor is positioned at the appropriate point for completion, the escape key jumping to the next part of the try clause. But the ability to add your own templates, coupled with the ability to pick up contextual information from the unit you are editing is worth the price of Castalia to me. I set up a routine that lets me insert a block comment below the first line of a function, highlighting the function name within the block. Just 3 key strokes to do this is a big time saver!
Some editing features
There are some other features, such as the Ctrl+W combination that highlights text at the cursor in increasingly wider scope for each press of the combination. And the introduction of shift-tab for untabbing of text. And a split editor function that provides two views of the same unit being edited. And a clipboard history panel where paste is possible from cuts or copies done a while ago. And multi-line pasting, especially useful for blocks of similarly formatted text.
Visit the Castalia web site

Delphi Basics Neil Moffatt All rights reserved.  |  Home Page