Loading...
Logo
Processing Forum
Hi all,
According to your ideas to my previous post[1] I decided to implement a tool for automatic class creation.
Basically tool will have two functionality. 
One functionality will be for simple users where they can enter class name, attributes and methods through a wizard and generate their code automatically.
Second functionality will be for advanced users where they can draw the class diagram and then auto generate the code from it.
So is this idea in the caliber of a GSOC project. Can I apply to GSOC with this ides?

Replies(6)



proposal for a third functionality:
automatic class creation based on existing code which is not yet OOP.

This automatic class creation is re-factoring of Code.

What I mean is, you have a Code that is not OOP but should be:
http://processing.org/learning/topics/bounce.html

I'll show it with this example.

You then start your automatic class creation wizard
and tell it the name of the new class (ball)
then you mark the existing (!) lines and tell it those are the objects properties:
Copy code
  1. int size = 60;       // Width of the shape
    float xpos, ypos;    // Starting position of shape    
    
    float xspeed = 2.8;  // Speed of the shape
    float yspeed = 2.2;  // Speed of the shape
    
    int xdirection = 1;  // Left or Right
    int ydirection = 1;  // Top to Bottom


Then you mark some lines and tell the wizard that's your constructor:
Copy code
  1.   // Set the starting position of the shape
      xpos = width/2;
      ypos = height/2;


Then you mark some lines and tell the wizard that's your method 1 (and enter it's name when it's not a function already):
Copy code
  1. // Update the position of the shape
  2. xpos = xpos + ( xspeed * xdirection );
  3. ypos = ypos + ( yspeed * ydirection );

      name of the method: move()


Then you mark some lines and tell the wizard that's your method 2 (and enter it's name):
Copy code
  1.   // Test to see if the shape exceeds the boundaries of the screen
      // If it does, reverse its direction by multiplying by -1
      if (xpos > width-size || xpos < 0) {
        xdirection *= -1;
      }
      if (ypos > height-size || ypos < 0) {
        ydirection *= -1;
      }

      name of the method: collisionCheck


And a 3rd method:
Copy code
  1.   // Draw the shape
      ellipse(xpos+size/2, ypos+size/2, size, size);
      name of the method: display


Then you tell your wizard to finish and he puts together the new class.

In the places where he removed the old lines he puts in the code for calling the new method (e.g. ball.display(); )

That could be helpful.

Greetings, Chrisir 



This is a great idea for a tool!  Look forward to your proposal.

This is a simple feature, but allowing users to auto-generate blocks of code, like so . . .

void setup() {

}

void draw() {

}

void mousePressed() {

}

would be very useful.  I find myself making blank sketches and typing this out while teaching often!

Dan
@shiffman: Looks like InitSketchFromTemplate (but I never tried it).
That's also a functionality found in some clipboard managers (independent of running software, then), like CLCL for Windows (there are many others on all systems, that's just my favorite...).
@Chrisir: original and interesting. Perhaps it would need a refactoring context menu, like selecting lines, then in a context menu, Move to... and display a number of existing classes, and a category (fields, constructors, methods...).
Slightly faster and probably more educative than simple copy & paste.

@phi.lho: Thank you!

@Chrisir: Great idea. Yeah I think that feature will be very much usable to beginners. They initially do not think in OO manner. They just code it. So giving it the functionality to refactor the existing code into class will be great. Thanks a lot for the idea.

@Dan: What about implementing it as a separate tool. So then we have a automatic class creation wizard(initial suggestion) and a automatic code generation tool(Your suggestion). You can create code blocks like draw(), onMouseClick(), if(), for(). (Some what like generation feature of eclipse IDE). What is you idea?

phi.lho thanks for the comments. These feed-backs help a lot to come out with a good proposal.

Tishan.