Classes vs Functions ?

What are the pros and cons of using a classes versus functions in blender scripts, are classes slower, faster, less intuitive. I have yet to see a blender script that uses class structure.

Any informed opinion would be well come!

Using classes doesn’t mean you cannot use functions and vice versa. So it’s not really that radical a choice. Procedural programming and object oriented programming both have their uses. It is more of a personal choice what way to use and when.

Classes can be particularly useful when you want to encapsulate certain data and functionality in the same place. There are certain problems where this is particularly useful. One common use for this is modeling of data structures. Taken step further proper class hierarchy lets you solve bigger problems by using design patterns. In this scope we may be talking about architecture of a whole program.

I don’t think classes is significantly slower or less intuitive than using functions if you know what you are doing. In fact proper abstraction and implementation usually leads to faster code. It’s much easier and more effective to refactor architecture instead of some small piece of code.

Probably the reason why not many scripts use classes is that people may not be used to coding in object oriented way or that their problems don’t need them to abstract in such way. There are many ways to solve problems. Think different programming paradigms as tools which you can use.

There is no right or wrong answer to this question. It’s up to your personal preferences to solve problem at hand by using the tools you have at your disposal.

The reason I asked is because I’m programing an animated mesh deformer and I’m thinking of using classes so that it can be reused and manipulated to have more than one functional outcome. Code reuse, is my goal. Modules are also a possibilty but my personal opinion is classes can be more dynamic.

I know how to prgram but am new to Python programming in Blender. Exactly how is this accomplished?
I’ve already downloaded and installed both Blender & Python. Python looks very neat and useful, but how to use in Blender is a blank to me.
[email protected]