Join GitHub today
Coding style #7
I'm teaching Python classes right now and some of those people will use IBM Websphere with Python. I thought I give it a short look. As the first hit was the IBM homepage I took that version of wsadminlib.py. I use the function "compareIntLists" as a worst-practice example of how not to code Python. The version here on github is a lot better (and even works correctly). Why does IBM still serve this very old and broken version of wsadminlib.py? At the moment I'm very concerned about my students who will use this kind of code. A couple of suggestions:
As a start I would suggest you run pep8 over the script and fix some of the 6879 issues:
$ pip-2.7 install pep8
Just my suggestions...
Good suggestions. You can always go hero mode and submit a patch to correct
On Wed, Jun 10, 2015 at 8:28 AM, floyd email@example.com wrote:
Even though you'll find many things in wsadminlib to improve, and I'd invite you and your students to help out with that, I think it makes sense to point out that the real world is never a best-practice and wsadminlib is a library primarily targeted at testers and system admins and will only be used for configuration-time and never at run-time, so easy comprehensible code and clarity of what is being modified are more important than performance.
The real world is, that people who use Websphere Python will have to read your code. And I hope you didn't just say that system admins don't need nice to read code. More than 10'000 lines of code in one flat file without classes/hierarchy is a little hard to read. If you really don't want to code object oriented you could even do sub-functions:
As far as I remember, when I make mistakes during configuration-time, that can have pretty bad outcome at run-time.
Easy comprehensible code is exactly what Python is aiming and designed for. If you check my list again, there is not a single point where I'm talking about performance. It's all about readability.
The big problem with your code is that it is very inconsistent. My Python heart would bleed if you would write #endIf and #endDef every time, but ok that would be according to your coding style guide. But it is not consitently used.