tags:

views:

529

answers:

2

Spring Python seems to be the gold-standard for how to define good quality APIs in Python - it's based on Spring which also seems to be the gold-standard for Java APIs.

My manager has complained (with good reason) that our APIs are in a mess - we need to impose some order on them. Since we will be re-factoring it makes sense to take advantage of what is considered best practice - so we would like to consider Spring.

Could somebody point me to the best learning resources for getting started with Spring? I've googled for a while and not found anything which seems to start from first principles. I'm looking for something which assumes good knowledge of Python but zero knowledge of Spring on other platforms or it's principles.

Thanks

+8  A: 

How did you come to decide on Spring Python as your API of choice? Spring works well on Java where there's a tradition of declarative programming; defining your application primarily using XML to control a core engine is a standard pattern in Java.

In Python, while the underlying patterns like Inversion of Control are still apposite (depending on your use case), the implementation chosen by Spring looks like a classic case of something produced by a Java programmer who doesn't want to learn Python. See the oft-referenced article Python is Not Java.

I applaud your decision to introduce order and thoughtfulness to your codebase, but you may wish to evaluate a number of options before making your decision. In particular, you may find that using Spring Python will make it difficult to hire good Python programmers, many of whom will run the other way when faced with 1000-line XML files describing object interactions.

Perhaps start by re-examining what you really want to accomplish. The problem cannot simply be that "you need a framework". There are lots of frameworks out there, and it's hard to evaluate a) if you truly need one and b) which one will work if you haven't identified what underlying software problems you need to solve.

If the real problem is that your code is an unmaintainable mess, introducing a framework probably won't fix the issue. Instead of just messy code, you'll have code that is messy in someone else's style :-) Perhaps rigour in the dev team is where you should recommend starting first: good planning, code reviews, stringent hiring practices, a "cleanup" release, etc...

Good luck with the research.

Jarret Hardie
Our code is mostly quite good - however the APIs are inconsistent. We'd like to make our APIs much easier to use and take a chance to benefit from what the leaders in API design have achieved.
Salim Fadhley
Please know that Spring Python isn't just a simple port[1], nor is it constrained to XML. Don't run away from XML, just use decorators instead![2] I always welcome ways to make things pythonic. -- 1. http://tinyurl.com/dz3dk6, 2. http://tinyurl.com/dzupa9, 3. http://tinyurl.com/d53d8v
gregturn
Let's cut through this issue - you wish to have a consistent API. I advise you read PEP-0008 http://www.python.org/dev/peps/pep-0008/, which is the official style guideline for python.
gregturn
+1  A: 

I won't go so far as to suggest that Spring Python is bad (because I don't know enough about it). But, to call Spring Python the "gold standard for Python APIs" is a stretch. To me, it seems that Spring Python is more of a way to allow Python apps to interact with Java Apps using Spring.

At any rate, after taking a precursory glance at the official documentation, it seems fairly easy to understand for me having decent knowledge of Python but no knowledge of spring. Aside from the fact that it almost looks like Java code where the author forgot the typenames, semicolons, and curly braces. :-)

Jason Baker
I should have mentioned: We are a Python + Java shop. All our business logic is in ptython. Most of our GUI is Java, so making Python play nice with Java is REALLY important to us. The Java devs love Spring and I cannot think of a good reason to disappoint them.
Salim Fadhley
That sounds like a perfectly good reason to use it to me. But you should be prepared to get reactions like you've seen in this question to using a very java-oriented framework in Python. :-)
Jason Baker
Spring Python wasn't built to simply integrate with Java. In fact, that section is a little weak right now. However, adding security to your app, providing easy ways to do easy SQL (short of an ORM), and dynamically intercepting code in 3rd party libraries with AOP seem like valuable tools to have.
gregturn