Help me pick an API design (OO vs functional)

Jean-Michel Pichavant jeanmichel at sequans.com
Tue Mar 26 08:16:56 EDT 2013



----- Original Message -----
> On Tuesday, March 26, 2013 11:07:45 AM 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.
> 
> Thanks for your reply. What do you mean by "So is the example above"
> though?

Well the example above :).

 
[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.

JM


-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.


More information about the Python-list mailing list