I come from a C# background, so I _get_ the whole module per class
structure.  The thing to remember is that python is not the same thing by a
long shot.  C#/Java automatically link everything together in a folder, so
it all becomes a single module, even with individual files.  .  You want to
minimise dependencies between modules as much as possible, and using the 1
class per module structure makes that a *lot* harder.

Especially as you get more complex in your code structure, it's very easy
to get yourself into a situation which has circular dependencies if you're
doing that.  The current structure I tend to use for UI's is a single
module of widgets, potentially moved out to a different package if/when
reuse is needed, once I'm sure I won't have weird circular dependencies
creeping in.  I generally start at the specific level in a given library,
and then (as needed) bubble the individual classes up to more and more
general on an _as-needed_ bases.

The real key is not to try to overarchitect things.  Start with a single
module, then break pieces out as it starts to make sense to do so (for
separation of concerns, reuse, cutting dependencies etc).  Otherwise you'll
tend to paint yourself into corners you might not intend to.

On Sun, Oct 15, 2017 at 3:25 PM Justin Israel <[email protected]>
wrote:

>
>
> On Sun, Oct 15, 2017, 2:03 PM Phil Sloggett <[email protected]>
> wrote:
>
>> My rule of thumb: If in doubt, use separate modules per class, it’s a
>> much nicer place to be as your code grows, or as time goes by and you
>> wonder “where you left that class”. If you KNOW your class is depended on
>> exclusively by other things inside a single module, then maybe they can
>> share the module.
>>
>> My opinion is that there isn’t much reason not to do a module per class,
>> which goes hand in hand with my opinion that “many smaller modules” >
>> “fewer larger modules”.
>>
>
> I know these are just opinions and workflow preferences, so it's all good.
> But I feel like a class per module feels very Java. I usually like to start
> with one module and then refactor into more than one as the complexity
> increases.
>
>
> On Sun, 15 Oct 2017 at 10:46 am, Justin Israel <[email protected]>
>> wrote:
>>
>>>
>>>
>>> On Sun, Oct 15, 2017, 12:20 PM Rudi Hammad <[email protected]> wrote:
>>>
>>>> Ok. They are related only to 1main UI. So I will create 5 classes
>>>> inside the same module. My doubt was if I had to do 5 modules.
>>>> So I guess that if they were usable in other different UIs it would
>>>> make sinc eto do different modules, but If they are all relate only to 1
>>>> UI, multiple classes if the better choice,
>>>>
>>>
>>> Oh, different modules just depends if they grow larger and serve
>>> completely different purposes. Even if you wanted to reuse them you could
>>> keep them all in one module. But if say, one of them had a dependency on
>>> another external library, you could separate them so that other apps can
>>> still use the ones that don't have dependencies
>>>
>>>
>>>
>>>> El sábado, 14 de octubre de 2017, 23:48:06 (UTC+2), Justin Israel
>>>> escribió:
>>>>
>>>>>
>>>>>
>>>>> On Sun, Oct 15, 2017 at 10:23 AM Rudi Hammad <[email protected]>
>>>>> wrote:
>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> I am writing a tool in maya with pyside and I was wondering if I
>>>>>> should do multiple classes inside a module. After reading different
>>>>>> opinions , I didn´t get a clear answer.
>>>>>> To simply my question, imagine that you have a UI with 5 buttons
>>>>>> that, when clicked, open different sub-UIs more or less complex..
>>>>>>
>>>>>> For instance, one of the buttons opens a simple color picker ui,
>>>>>> antoher one opens a dialog with a table widgets, another one opens a more
>>>>>> complex UI with its own layout and widgets etc...etc...
>>>>>>
>>>>>> Should I create 5 classes inside the same module for this secondary
>>>>>> UIs, only 1 class doing all (which will make it less clean because it 
>>>>>> would
>>>>>> have to many methods)
>>>>>> or should I create five modules. The color picker ui is very simple
>>>>>> and can be done in less than 20 lines, but other uis could be around 200
>>>>>> lines.
>>>>>> So If I am consistent and decide to write modules, I will have one
>>>>>> module with 20 lines, and another with 200.
>>>>>>
>>>>>
>>>>> My opinion is that if the other widgets are anything more than trivial
>>>>> dumb widgets (a dialog with some initial settings), that it is beneficial
>>>>> to separate them into individual classes. This will help keep your
>>>>> separation of concerns clear and help keep the code maintainable. If your
>>>>> color picker is generic, then making it a discreet class would mean you 
>>>>> can
>>>>> reuse it in other code.
>>>>>
>>>>>
>>>>>
>>>>>>
>>>>>> Thanks,
>>>>>> R
>>>>>>
>>>>>> --
>>>>>> 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 [email protected].
>>>>>> To view this discussion on the web visit
>>>>>> https://groups.google.com/d/msgid/python_inside_maya/76fd4881-de81-462c-955e-a23f75c3eed2%40googlegroups.com
>>>>>> <https://groups.google.com/d/msgid/python_inside_maya/76fd4881-de81-462c-955e-a23f75c3eed2%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>> .
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>> --
>>>> 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 [email protected].
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/python_inside_maya/eb945a4b-210f-4fa7-aa94-f3ebf43b7151%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/python_inside_maya/eb945a4b-210f-4fa7-aa94-f3ebf43b7151%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>> --
>>> 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 [email protected].
>>>
>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1UGjDXzsfrER5JaJ8DTzGoueW%3Di%3Dvv_PqGhzgGVxmpyQ%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1UGjDXzsfrER5JaJ8DTzGoueW%3Di%3Dvv_PqGhzgGVxmpyQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>
>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> 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 [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/python_inside_maya/CAPzKG6VqaeUeJKJ%3D6t6_Wazq-kd6ZfJgM%3DuvfH8b2vuNVZLQTA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/python_inside_maya/CAPzKG6VqaeUeJKJ%3D6t6_Wazq-kd6ZfJgM%3DuvfH8b2vuNVZLQTA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0jrzUvZ3W9XXuuva%3DbNixtgtSoBp5W%3Dba4wS1pqyPR-Q%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0jrzUvZ3W9XXuuva%3DbNixtgtSoBp5W%3Dba4wS1pqyPR-Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAM33%3Da7msR2scX2_tYNG7aW0of3%3D1wzyHmqkSx8iiUZ7r5VqkA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to