I was now inspecting Jesse's leo forum code and I think I've got an
Aha moment.
Consider the following node:
<< download forum data from server >>
------------------------------------------------
import urllib
g.es("downloading posts...")
response = urllib.urlopen(url)
response_string = response.read()
response.close()
------------------------------------------------
This is a small code snippet. The string "response_string" is used
later (the code that uses it is in another section, below). This
becomes obvious as soon as you try to understand the logic, but it's
not obvious instantly.
Compare it with the following code:
------------------------------------------------
import urllib
def get_str(url):
g.es("downloading posts...")
response = urllib.urlopen(url)
response_string = response.read()
response.close()
return response_string
response_string = get_str(url)
------------------------------------------------
This is more readable, but there is still a problem. Here is the node
that is using response_string:
<< convert response to node strings >>
------------------------------------------------
split_string = "<?xml version"
node_strings = []
for node_string in response_string.split(split_string):
if node_string:
node_strings.append(split_string + node_string)
------------------------------------------------
Note that response_string is used somewhere in the middle, it is not
instantly obvious that this is the input data for this code snippet.
I've noticed this moment because I had a "deja vu" feeling: I've tried
a couple of times to start using leo seriously as IDE for programming
projects more complex than trivial code snippets, but I have failed,
and this situation was one of the pitfalls.
I would like other people, especially Edward, to comment on this. I'm
making a statement now.
"Using sections when using leo as programming IDE is confusing."
Perhaps I have such a feeling because I'm doing something wrong, or
I'm not doing something right (these two are usually different things
in practice). I would like to hear from you how you avoid the
described pitfall when using sections (if you do) to split the code
into logical blocks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/leo-editor?hl=en
-~----------~----~----~----~------~----~------~--~---