Did you mean to send two copies of your question?



On Sep 2, 2013, at 10:42 PM, Michael Zhang 
<m...@solumtech.com<mailto:m...@solumtech.com>>
 wrote:

Hi guys,

My name is Michael Zhang, and I am very new to Pyramid. I have a quick question 
in designing a large web application backend, and hope the community can help 
me out. I really appreciate your help. It helps me to learn and get my job done.

My question is simple: what are some good strategies in organizing common 
methods or classes for operations that we might constantly use in our 
applications? For example, if we have a method to collect all the comments 
belonging to a blog post, where we should put this method/class in our 
application in a clear and organized fashion? To us, there are potentially two 
choices:

Choice A. We can define our model Blog, and inside Blog, we can define a method 
like getAllComments.

Choice B. We can separately define BlogCRUD class, that has methods to get all 
comments.



I actually think both choices might not be the best to do. While Choice A 
clearly define all our methods at one place for one class of object, it feels 
not right - the getAllComments method intuitively should belong to the View 
callable, and should not be at the place where we define basic columns of the 
Blog, correct? And Choice B, though it separates model and operations on the 
models, it will let us loose some functionality provided by Sqlalchemy, like 
jumping from table to table (Blog.Comment.User, etc).

So I think our choices so far are just not perfect, yet I know that this must 
be a common design problem that people face. So community, what should we do in 
your opinion? Again, I appreciate your help!

I think you've created an unnecessary dichotomy.  I would recommend a general 
approach rather than a prescription.The nice thing about pyramid is that you 
can write this to work, then easily refactor it when the right pattern *for 
you* becomes apparent.

Your app will likely start as simple functions in a module that interact with 
you model. I would say write the code in a way that is easy to test and your 
factoring should become apparent along the way.

-w

d. "whit" morriss
Platform Codemonkey
w...@surveymonkey.com<mailto:w...@surveymonkey.com>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-devel+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-devel.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to