In teaching Plone to developers recently I've found some things that are hard to explain. I'm wondering if, in the future, we could do some refactoring.
Here's a snippet from a configure.zcml file.
<browser:page
name="my_view"
for="*"
class="mypackage.views.browser.viewlogic.SimpleView"
template="templates/my-view.pt"
permission="zope2.View"
/>
By convension we tend to name the classes for browser views "XxxxView". This helps but a newbie needs to know the following.
- the thing called class will be returned as a view object in their page template.
- the component, though it is defined as "browser:page" is most commonly called a browserview
I'd like them to be able to reason more easily about where view came from.
So that when they see code like this in their template
<div tal:define="listofitems view/list_stuff">
<tal:block "tal:repeat=item listofitems">
<span tal:content="item"></span>
</tal:block>
</div>
they should be able to see obviously how this was declared in the configure.zcml file and then quickly know to look in the viewlogic.py file.
Currently, this requires layers of explanation to help a newbie understand where view came from in their template. The Grok approach was at least helpful, by putting the information in the context of the .py file it reduced the number of things a developer had to carry in their head.
For working with zcml I think that their understanding could be enhanced by
changing the names of a few names.
Suppose the entry in the zcml file looked like this:
<browser:view
component_name="my_view"
context="*"
view_class="mypackage.views.browser.viewlogic.SimpleView"
template="templates/my-view.pt"
permission="zope2.View"
/>
Now the entries are more descriptive. I currently don't know enough to implement this, but it certainly would reduce the amount of explanation.
Someone once said:
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
I hope my thoughts aren't too incomplete, I thought I'd put it out there.