Need help dividing Module.

Hey everyone!
I recently realized probably the last version of BANANA.py

Check it out here: http://sunjay-varma.com/scripts.html#BANANA

I really need some feed back. The module is now over 2000 lines and is getting too big.

There are tons of functions in it for all purposes, and because it is now so big, I decided to split it up into several different modules.

After looking at the script, what do you think? How should I split it? What categories should it have?

In that script view link above, it is already broken up into categories such as Variables, Mouse/Screen Functions, Object Functions, Math Functions, Scene Camera Functions, Useful Classes, Artificial Intelligence Functions, Miscellaneous Functions/System Functions, and GUI functions.

As you can see…there is a lot. So how should I organize this…is this enough? Or should there be more categories.

What do you think??

Also, just so you know, there will be a great API generated for each module and you will be able to access all of them from the tie together module bapl (Blender All Purpose Library).

Please Help.
-Sunjay03

Hi Sunjay,

really a lot of work you did here. Did you wrote this script with Blenders text editor?
Good - there are comments, to see what the functions should do.

I have thrown your script into PyDev. I shows there is one bracket to much at line 451 >>force = diff*(strength/diffLen**2))

The function names are a little bit inconsistent, following different naming conventions. This makes the whole file a bit confusing and can easily lead to typing errors.

In general I suggest to mark functions that can directly be called by the Python module controller. But it seems ther aren’t any.
example: ShowMouse() could be ShowMouse(cont) and HideMouse(cont) to be called directly.

I can’t see the benefit of some functions:

  • assignProp() - much shorter to directly assing the value
  • getprop() - beside the fact it is not named getProp() - it does exactly what x = object[key] does.
  • replaceMesh() - what is the purpose of this one-line function? It is not that complicated
  • draw() - just calls drawLine() - I think it will raise an exception anyway.
    I haven’t looked through all. It is really a lot of code. I think you should remove some functions that aren’t really necessary.

To split the library I would think of following additional topics:
Filesystem,
UV
Constraints
mesh manipulation
physics utilities
Sound

It would be good to keep functions with dependencies to external modules like Tkinter separate.

Thats for now

@ Monster: Thank you very much for the excellent feed back. I understand that right now the code is very messy, but thanks to you and your s2a module I found out about epydoc which will allow me to properly over haul my code.

This module is a new and very much improved version of APPLE3.py an old module with lots of cool functions. I have added probably over 20-30 more functions than APPLE3 originally contained.

The module is very huge and this is why I made this thread to get some input about the over hauling process. Thanks to you I have some more great categories that I can add.