Re: id calling function

0 views
Skip to first unread message

Jonathan Ellis

unread,
Jun 27, 2008, 4:36:03 PM6/27/08
to Bell, Kevin, utahp...@googlegroups.com
in this case I would structure things something like this

def __testForLocationChange(self):
'''noChange: pass
yesChange:
create movement line showing travel
__populateDeltaTable'''


def __populateDeltaTable(self):
do the regular delta table entry
ADD RECORD TO TABLE'''

... and maybe make "create movement line" its own function.

generally you want functions to do only one thing; if you find
yourself passing "flags" to do different things, or doing different
things based on your caller, then it's time to split things up.

Let me know if that's not specific enough.

-Jonathan

On Fri, Jun 27, 2008 at 11:51 AM, Bell, Kevin <kevin...@slcgov.com> wrote:
> I don't have my google sign in info here at work, so hence the direct reply…
>
>
>
> I'm stubbing out some functions for a class that will OOP streetlight
> behavior.
>
>
>
> I was starting to do something like this:
>
>
>
> def __testForLocationChange(self):
>
> '''noChange: pass
>
> yesChange: __populateDeltaTable'''
>
> pass
>
>
>
> def __populateDeltaTable(self):
>
> '''if called by __testForLocationChange:
>
> YES: create movement line showing travel
>
> NO: do the regular delta table entry
>
> ADD RECORD TO TABLE'''
>
> pass
>
>
>
> …but I suppose I can just add the __populateDeltaTable code to the original
> function, but it needs to be called outside of that function as well, so
> that's why I was making it it's own function. I just didn't want redundant
> code.
>
>
>
>
>
>
>
> Kevin Bell
>
> GIS Specialist
>
> Salt Lake City Transportation Division
>
> 349 South 200 East, Suite 450
>
> P.O. Box 145502
>
> Salt Lake City, UT 84114-5502
>
> 801-535-7131
>
>

Reply all
Reply to author
Forward
0 new messages