Possible Refactoring Improvements

Have you ever wanted to assign a method to an event property in code when you haven’t written the event handler yet?  Code Insight can provide the method prototype for the event, but you have to manually type in the declaration for the new method you want to assign.  Clear as mud?  Perhaps an example to illustate the situation will make it clear:

Let’s say I  want to assign an event handler to a TcxSpinEdit control’s OnValidate event.  I have the following in code:

TcxSpinEdit(Control).Properties.OnValidate

and I press Ctrl+Space for Code Insight.  It shows the method prototype below.

CodeInsight

CodeInsight Shows the Prototype

and I assign it the name of a method I’m about to declare:

TcxSpinEdit(Control).Properties.OnValidate := ValidatePercentage;

Now I don’t work with Developer Express controls often enough to have memorized all their method prototypes so I have to remember the prototype CodeInsight provided so I can key it, and then use Ctrl+Shift+C to declare it (or in my case CodeRush’s Ctrl+M which also provides the ability to scope the declaration - something that Code Completion should have had eons ago).  Wouldn’t it be nice to be able to Rt. Click on the Event property (OnValidate in this case) and choose “Declare Handler” or something to that effect that would do it all for you?

6 Responses to “Possible Refactoring Improvements”

  1. Colin Johnsun Says:

    I wonder what would it take to get Mark Miller to resurrect CodeRush for Delphi again…

  2. Uli Gerhardt Says:

    As I’m doing a lot GUI development without form designer I would like some automation for event handlers too. However you already can get along without memorizing and typing in the method signature, e.g. with your OnValidate example:
    1. Ctrl-click on the event property (OnValidate)
    2. Ctrl-click on its type (TcxEditValidateEvent)
    3. Copy-and-paste the event type definition and make a method signature out of it (remove the “of object” etc.)

  3. Jeroen Pluimers Says:

    It would; you might also want to write Gerrit Beuze (ModelMaker Code Explorer) or/and Jacob Thurman (Castalia) a message to see if they can help out.

    –jeroen

  4. Larry Hengen Says:

    @Jeroen,

    Thanks for the suggestion. The only downside to having them implement it, would be having to then buy their product :-)

  5. Larry Hengen Says:

    @Colin,

    I too would love it if CodeRush were open sourced. I’m sure the community would be able to effectively maintain and enhance it. Unfortunately, I asked Julian Bucknall of Developer Express that very question and he said they would not release it, because it’s part of their IP acquired from Eagle Software. Personally I don’t understand why the IP embedded into that product needs to be kept under wraps. CodeRush for VS is so different I can’t image any competitor using it to try to challenge the dominant products from Developer Express or JetBrains. For one thing, CodeRush for Delphi is specific to the Delphi language. In any event, it’s not going to happen.

  6. Larry Hengen Says:

    @Colin,

    I misread your comment. For some reason I thought you were advocating a release of the source code. Resurrecting CodeRush I don’t think is realistic. For one thing, Mark is occupied with his existing products for .NET. The second thing is that I believe Mark got a bitter taste in his mouth when he tried to get Borland to fix bugs that were impeding his ability to implement features. I saw this myself in the Q&A sessions at Borcon in San Diego when he asked engineers some very pointed questions. Borland et al have AFAIK have never catered to third parties wanting to enhance the IDE. As a result I think Mark got frustrated and decided to abandon CodeRush and Delphi when .NET and an offer from Developer Express came onto the scene.

Leave a Reply