Help me pick an API design (OO vs functional)
Michael Herrmann
michael.herrmann at getautoma.com
Tue Mar 26 08:18:41 EDT 2013
On Tuesday, March 26, 2013 12:43:18 PM UTC+1, Chris Angelico wrote:
> On Tue, Mar 26, 2013 at 8:38 PM, Michael Herrmann
>
> > What do you think of designs #3 and #4?
>
> > notepad_1 = start("Notepad")
> > notepad_2 = start("Notepad")
> > switch_to(notepad_1)
> > write("Hello World!")
> > press(CTRL + 'a', CTRL + 'c')
> > switch_to(notepad_2)
> > press(CTRL + 'v')
> >
>
> > notepad_1 = start("Notepad")
> > notepad_2 = start("Notepad")
> > notepad_1.activate()
> > write("Hello World!")
> > press(CTRL + 'a', CTRL + 'c')
> > notepad_2.activate()
> > press(CTRL + 'v')
>
> Ehh, I referred to these as options 2 and 4. Got lost in the indexing
> somewhere. These are the same two I meant, though - these are the
> options I think are the most plausible.
>
> (Hindsight being 20/20, it'd have been awesome if the original
> snippets had had identifiers next to them. Oh well, no matter.)
True, and the indexing mistake was my fault... Here goes:
Design #1:
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')
Design #2:
notepad_1 = start("Notepad")
notepad_2 = start("Notepad")
switch_to(notepad_1)
write("Hello World!")
press(CTRL + 'a', CTRL + 'c')
switch_to(notepad_2)
press(CTRL + 'v')
Design #3:
notepad_1 = start("Notepad")
notepad_2 = start("Notepad")
with notepad_1:
write("Hello World!")
press(CTRL + 'a', CTRL + 'c')
with notepad_2:
press(CTRL + 'v')
Design #4:
notepad_1 = start("Notepad")
notepad_2 = start("Notepad")
notepad_1.activate()
write("Hello World!")
press(CTRL + 'a', CTRL + 'c')
notepad_2.activate()
press(CTRL + 'v')
Michael
www.getautoma.com
More information about the Python-list
mailing list