Pipeline - Using OOP

111 views
Skip to first unread message

David Martinez

unread,
Oct 28, 2013, 3:47:31 PM10/28/13
to python_in...@googlegroups.com
Hi,

I'm trying to re-write part of our system to take advantage of Python's Object Oriented Programming but I'm not entirely sure on how to go about it. I'll explain what is it that I'm trying to achieve and what my first thoughts are but any feedback/advice is more than welcome. (Game Development)

The way I see it, we should have a main type of object (Project) and subclass from that class to have classes such as 'Character', 'Object', 'Cinematic' and so on...

The 'Project' kind of object should encapsulate data (such as list of objects, characters, cinematics, etc) as well as functionality (such as 'get cinematics list from current project', 'get character list from current project' and so on. The other kind of objects will contain information about where the Maya file for those character/objects/cinematics are as well as the path to their export for the game. The path of the project will exist within the 'Project' object where the other objects will create paths relative to that one.

I'd like the system to work both ways. That means that having a 'Project' object would allow you to get information about all it's data but also, I'd like to be able to get the project when opening the file of a character, object, cinematic etc... Does that make sense?

The goal behind all of this will be to be able to manage great amounts of data without having to remember all the paths and files containing information.

Here are some of the objectives that I'm trying to hit:

- The system should allow for several projects.
- The data within a project is split in two branches with the same folder structure structure (Source/Exported). That means that when working on a file, I should be able to know where its export is (if it exists yet).
- Heavy usage of text files (would prefer XML but the system is already there and text files are easy to parse)

Does that sound like a good idea to you? Even though that we have a few tools using procedural programming, I think that there is a good oportunity to link everything together using OPP but I'd like to get your take on it.

Many thanks,


Dave

Eduardo Grana

unread,
Oct 28, 2013, 4:15:37 PM10/28/13
to python_in...@googlegroups.com
Hello David,

I'm currently writting something like that, and i think
maybe it's better to make a 'project' object that has 'assets' objects (characters, props, sets, cameras, etc),
instead of a asset object that inherits from project.
Instead of xml, i like using json, its easy to parse, and write, and is more human readable.
Hope this is useful, although it's just my point of view...
Cheers!
Eduardo


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/19c21723-5511-49c7-9da0-721b2556cf2e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Eduardo Graña
www.eduardograna.com.ar

Justin Israel

unread,
Oct 28, 2013, 4:17:59 PM10/28/13
to David Martinez, python_in...@googlegroups.com
It sounds like you are (re)writing an Asset Management System?
"Project" would probably be a concrete final class, and not have subclasses such as "Character". For that, you might have a base class called "Asset", where every asset type subclasses it. Assets would all have a reference to a project.

Is there a reason you are using text files for all the records in your system? Does that mean for every query you want to make, you have to have each client scan the file system to piece together the results? That would be pretty slow, and also hard to maintain when people are making concurrent updates to the system. What happens if I am editing the project file at the same time as someone else, to change a value. We both have to save the entire file out again, so one would clobber the other complete file.
What about using a database and storing it all in one place that can be queried much more efficiently? That would easily allow you to maintain asset that have foreign key relations to projects and do stuff like "Give me all assets where project is FOO"

Jesse Kretschmer

unread,
Oct 28, 2013, 5:52:52 PM10/28/13
to python_in...@googlegroups.com
David,
It seems like you want an ORM to handle your pipeline. That's a great idea in theory. I would certainly temper that decision with a solid cost-benefit analysis. Will it work with existing code? Will the other developers on the project be able to contribute easily?

Don't make OOP the end goal. It's a great way to organize a set of functions or methods against a shared context, but it's not necessarily any better than a function-based design.

As Justin points out, it is an asset management system and for that you may need a database. If you can define how your database works, it will probably reveal what operations you want to attach to your objects. However, I have actually seen file system based data stores using xml files for metadata. The major limitation was that the data queries could only be simple without a lot of extra work. Conversely, the advantage was that most of the tools still worked even if a server went down or we sent a machine on set.

If you have a good object design and clean code, you can certainly leverage object inheritance to handle many of the shared methods that all the objects will use. This can be great when for future problems when you need to add something to all object classes, like a serialization class for when you need to generate an XML or JSON string of your object.

There are plenty of asset management systems out there why reinvent the wheel?
Cheers,
jesse
 


David Martinez

unread,
Oct 29, 2013, 5:13:28 AM10/29/13
to python_in...@googlegroups.com
Thanks for getting back to me Eduardo, Justin and Jesse

Having a reference to object instead of inherit from it makes sense as I won't be duplicating any data. Apart from that, there are a few restrictions on how to approach the situation as Jesse said in his message (I need to get it work with the existing system). Later today, I will try to write another email with more information about the current system and how I can manage the information in it without breaking existing functionality.

Cheers,




--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages