tags:

views:

180

answers:

7

Hello

When trying a new component for which there's no documentation, I need to go through its methods, properties, and events to try to figure out what it can do. Doing this through the IDE's Object Inspector is a bit tedious.

Is there a utility that presents this list in a more readable format?

Thank you.

A: 

There is RTTI...

smok1
I think he's looking for information at design-time.
Mason Wheeler
@Mason Wheeler ... hmmmm... you mean simply guessing what a component is doing?
smok1
It looks like he's looking for something like the Object Inspector but "more readable"
Mason Wheeler
A: 

Look at the .hpp that is generated for C++Builder support. It resembles the interface section of a Delphi unit.

Moritz Beutel
(Of course, this doesn't make sense if you have the source code. From your question I assumed you don't.)
Moritz Beutel
+3  A: 

When I want to know what something can do, I read the source code. The class declaration will contain a succinct list of all the methods and properties, unless there is a lot of inheritance. The definitions will tell you want the methods do.

Another thing is to declare a variable of the type you're interested in, type its name and a period, and then press Ctrl+Space to let Class Completion show you everything you can do.

Rob Kennedy
+1. I've always preferred the UTSL method.
Mason Wheeler
+1  A: 

You can use the Class Browser that comes with GExperts.
I would also recommend to build a Model diagram with the IDE or ModelMaker. It helps to see the visual relations.

François
Thanks for the tip, but when opening Class Browser, nothing more can be done than double-clicking on an object in the right-pane and being sent to the line where the instance is created.I thought Class Browser would display the list of methods, proprerties, and events provided by an object.
OverTheRainbow
+1  A: 

In the immortal words of Obi Wan Kenobi -- "Use the source".

There is no substitute for reading and understanding the source code of a component (or anything) to understand what it does and what it is up to.

Source code is the Lingua Franca of programming.

Nick Hodges
A: 

I just use code completion. If you can't figure out what the component does from the names of the properties and methods, then it's probably poorly designed anyway, and you're better off not using it. Also, since you're asking the question, I'm guessing you do not have the source. If you don't, again, I wouldn't use the component. You're only storing trouble for yourself.

Steve
A: 

As the others said, use the source. Also an UML tool will help. But if you don't want to use this, you can use this procedure (you need Delphi 2010 for this, and be sure to add RTTI to your 'Uses' clause):

procedure DumpProps(aObject: TObject; aList: TStringList);
var
  RttiContext: TRttiContext;
  RttiType: TRttiType;
  I: Integer;
  n: integer;
  props: TArray<TRttiProperty>;

begin
  aList.Clear; //it must be <> nil
  RttiType := RttiContext.GetType(aObject.ClassType);
  props:=RttiType.GetProperties;
  with aList do 
    begin
      Append('');
      Append('==========');
      Append('Begin Dump');
      Append('----------');
      for I := Low(props) to High(props) do
      begin
        try
          Append(props[i].Name+': '); //odd construction to see if the Getter blows
          n:=Count-1;
          Strings[n]:=Strings[n]+props[i].GetValue(aObject).AsString;
        except
          on E: Exception do
            Strings[n]:=Strings[n]+' >>> ERROR! <<< '+E.Message;
        end;
      end;
    end;
end;

The above you can use either at run-time, either if you build a Menu Wizard, you can have your info at design time.

HTH