Forum

'Extract module' feature request

Hey,

I had an idea for a feature that would make ‘cleaning up’ and refactoring patches easier.

In the more advanced IDE’s, there are ways to extract some code to a new function.
Most of the time you start adding stuff to your main procedure (or patch in vvvv). At a certain moment, you realize that it becomes complicated to understand, and that some of the functionality can be defined as 1 operation (1 action that could be described in words), and could possibly be reused at a later time.

I would love to have a function in vvvv, that allows you to

  • select a bunch of nodes
  • middle-click and choose ‘extract new sub-patch’ or something
  • and have vvvv create a new module, complete with all in and out-pins (name taken from what they are connected to)
  • and replace all these nodes by the newly created node, everything properly connected.

The only thing you would need to do afterwards, is change some input and output names that are unclear, to something that describes them better, save this node with a well-chosen name, and voila.

didn’t @woei do a module called midwife?

maybe search http://legacy.vvvv.org

That’s not what I mean.

I would like to select some nodes and replace these nodes by a vvvv module that is created automatically for me, and that contains these selected nodes.

I don’t want to add some ‘code snippets’ that I already have, I want to extract a new module from a selection of nodes that I just wrote.

Let me explain the equivalent of what I mean in ‘normal’ (pseudo)code:

function main() {
  String s = "hello";
  for (each character in s) {
    replace character by Uppercase(character);
  }
  s += " Here's some more text";
}

Now I would select the for-loop and choose ‘Extract method’, and the IDE will create a new function for me (which I could name ‘string2uppercase’), that would look like this. On top of that, the IDE would replace the selected lines by a call to this function.

function main() {
  String s = "hello";

  s = string2uppercase(s);

  s += " Here's some more text";
}

function String string2uppercase(String s) {
  for (each character in s) {
    replace character by Uppercase(character);
  }
  return s;
}

So I mean the equivalent of this functionality in vvvv, creating a new v4p-file with input and output nodes.

@woei did that called subpatch
https://discourse.vvvv.org/

it just gets very tricky when theres a subpatch of a subpatch, you have to go down all file paths to get everything, and woei’s was buggy like that, I looked at it, but was scared off, too complicated for woei is saying something!

Would be nice if it was built into vvvv though (and woei’s module doesn’t seem completely finished).

i called for this a while ago. so nice one ft. I played with woei’s but it buggy and has limitations.

People talk about fast patching and things get added like double right click and this saves some seconds but by far the biggest time consuming task currently is sub-patching. It’s fine if you plan ya patching ahead but if a patch is growing organically or you’re just free-styling, patches tend to get a bit large and then sub-patching that up is a pain in the butt. Seems so obvious to me to select the group of nodes and press some keys and bang, sub-patched for you. Come on devs, give us all a massive speed increase! please. :)

oh yeah. when I’m live patching in a club with loud music and a beer I find it nearly impossible to sub-patch things up. It generally takes a bit of concentration and if you not careful you can really make a mess of things. I’ve ended up a few times with some patches with hundreds and hundreds and even more hundreds of nodes cos of live patching at a club.

+1 for the feature request!

Yeah, I get the feeling that this might not be a simple as you think, we’ve all been suggesting it for years! And given woei’s attempt, I can see its not easy! It is in quartz composer though, and it is bloody useful!
I also thought about the reverse, I’m sure I remember a dev talking about all subpatches getting expanded into a super patch for rendering, might be nice to have 1 insane patch for delivery, as well as being hard to read it would be easier to deliver and hide from idiots, and possibly use setpatch to create it from a hidden location…

like encapsulate in max/msp +1 for that feature!

+2… no text …

+1 … no text …