Help me pick an API design (OO vs functional)

Michael Herrmann michael.herrmann at getautoma.com
Tue Mar 26 13:27:49 CET 2013


On Tuesday, March 26, 2013 1:16:56 PM UTC+1, Jean-Michel Pichavant wrote:
> ----- Original Message -----
> > > > 	notepad_1 = start("Notepad")
> > > > 	notepad_2 = start("Notepad")
> > > > 	notepad_1.write("Hello World!")
> > > > 	notepad_1.press(CTRL + 'a', CTRL + 'c')
> > > > 	notepad_2.press(CTRL + 'v')
> > > > 
> 
>              ^
>              |
>           here, this is an above example :D
> 
> > > > The problem with this design is that it effectively duplicates
> > > > our
> > > > API: We want to keep our "global" functions because they are so
> > > > easy
> > > > to read.
> > > 
> > > So is the example above. This is the best solution in my opinion.
> > 

Ah, so you meant "is also easy to read" ;) I agree but the example with global functions is even easier to read. I guess I am being pretty anal about these issues, but I see every unnecessary syntax we can save as a win.

> [snip]
> > Doesn't the IPython do auto-completion for "global" functions?
> 
> Yes it does, but as Chris pointed out, your global/module namespace will be "polluted" by a lot of names.
> By using completion on an object, you get the method it has access to, which is very useful to narrow down what you can do with it.

I see. I know you prefer design #1 but that would at least place design #4 over #3, right?

Thanks.
Michael
www.getautoma.com



More information about the Python-list mailing list