On Sun, Aug 18, 2019, 5:08 AM Rudi Hammad <rudiham...@gmail.com> wrote:
> Hey Marcus, > Subclassing is how I had my previous code. I am just exploring to see if > can come up with something that could create any type of widget using one > unique function, but > I might be over thinking it. Does the design I posted make any sense or is > it completely wrong for any reason I don't see? > I agree with Marcus that the original multi line approach is more clear. Also, if your goal is just to reduce the number of lines, aren't you going to end up having to format the single functor call across multiple lines anyways to avoid a super long line as the parameters increase? The only benefit I can think of is that it does make it easier for you to store and reuse widget initialisation contexts as dictionaries so that you could stamp out different widget instances like: widgetA = factory(**typeA) But I don't know if that was your intended goal? You only refer to reducing line count. It's also easier to make a typo when you switch from calling first class setters to custom named parameters where it would skip any unrecognised params. Is that a consideration? I forgot to mention that the methods are supposed to be private. So > basically, the idea was to create a function object to set up any type of > widget. > The implementation of the functor actually doesn't need to store any state at all. Technically those methods could be static and just get passed a widget. It's also probably not a good idea to have it store the widget anyways since it prevents garbage collection or could hold onto something that gets deleted in C++. Also it seems like your impl calls every method multiple times, since it's doing it in a loop for the provided parameters. > 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 python_inside_maya+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/python_inside_maya/96a7b5f6-9ab4-4028-93a3-c57fe1df6c2b%40googlegroups.com > . > -- 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_maya+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2YQWP4U2fJr6ujUuqe4VscimPMaPPye5iaKGKHdJKoqw%40mail.gmail.com.