Tuple Madness 65
If there is a downside to modern OO languages like Python and Ruby it is the great built-in list types. They’re wonderful, but they’re tempting.
Today I had my fourth or fifth encounter with tuple madness. It seems that the siren song of “free” data structures with unnamed members is just too much to resist. I’ve decided to call it Tuple Madness. An example is: x = (2,3,-1) Could one be less descriptive? Probably not.
I came across some code which uses two-tuples where both values are encoded integer values. It’s a pain to figure out.
In a previous job, a coworker would write his python entirely as filters on n-tuples so that figuring out what his code was doing was really painful. A function would take a sequence of n-tuples, and return a sequence of n-tuples where some of the values were preserved (though reordered) from the input, and the rest were transformations on the input + some local data. It was really tough to read a program where the data structures had unnamed elements and only existed between the return of one function and the invocation of the next.
At least one of my colleagues has blogged about suffering from Tuple Madness as well.
I don’t think that “magic tuples” are always evil, only that they’re no substitute for proper objects and meaningful data structures.
Trackbacks
Use the following link to trackback from your own site:
http://blog.objectmentor.com/articles/trackback/169
As an old scheme/lisper where tuple/list like structures is the core abstraction and being taught programming by reading “Structure and Incterpretation of Computer Programs” by Abelson and Sussman. You learn its a good idea to write accessors to your tuple structures to raise the level of abstraction and enhance readability.
As another old Lisper, when I saw XML my first thought was “Named Parentheses!” My second thought was “GREAT!”
I prefer Io’s structures—they’re much more readable than XML. But I digress.
It sounds like the Python coder has a strong functional programming background. You’ll need to become more familiar with functional programming to understand more clearly the reasons why he did things the way he did (and that will, in turn, help elucidate the code and make it substantially more maintainable).
Still, taken to the extremes, writing ML code in Python is generally considered bad form by all parties around, including other ML coders. :)
No, I don’t think so. I understand the appeal of functional programming, and my problem is with the parade of obscure intermediate forms, all produced by obscure functions. Realize that I love “clear” and despise “clever”. I found this program to be very clever in its use of primitive structures, and not very clear at all.
I don’t have the actual code, and it was very, very, very long, but it looked mostly like this (strawman):
Clearly, it rearranges some of the input elements, drops some, and adds a new derived value. It does so without any real reference to the meanings of the input, transformation, or output.
Was there a meaning to that transformation? I would revisit it a few times, and still not know. It seemed to be arbitrarily decomposed and recomposed, as if the goal were to multiply intermediate forms. I suspect that Occam would have vomited.
The issue is not with the use of filters, but that the function and the data it operates on are completely non-self-describing, and can only be understood by grasping the entirety of this absurd parade of intermediate forms, from program start to program end.
A parade of meaningful forms, produced by meaningfully-named functions, operating on named variables, would have been quite welcome.
Indeed, it seemed to me that some transformations only existed to rearrange the elements of the array to an order expected by the next filter, which rearranged the elements for uncertain reasons. Considering that all the transformations were local, non-reused, purpose-built, that seemed mad to me. Why not keep the smallest number of functions on the most consistent forms?
Also realize the application was not number-crunching, was not parallel, and was not being run as a unix text filter. It was purpose built to manage mostly-textual structured data.
The python programmer had just learned lisp a bit earlier. It may be that he was trying to write lisp in python. I may be wrong, but I don’t think that’s how it’s supposed to look. He once bragged about how deeply he’d nested his lambdas, so maybe it was a brand of cool built out of complexity for complexity’s sake.
Python gives us unpacking syntax, so this could have been more clear, even if nothing was done to make it more simple:Maybe I’m a piker here, but it seems that there should be a way to make any code more clear, so that it can be adapted and maintained. Is that not a goal?
situation is improving.”Call volume replica hermes scarves volume has been very high due to hermes h enamel bracelet to two days of airport closures and burberry nova check bowling bag and flight cancellations,”
The issue is not with the use of filters, but that the function and the data it operates on are completely non-self-describing, and can only be understood by grasping the entirety of this absurd parade of intermediate forms, from program start to program end.
A parade of meaningful forms, produced by meaningfully-named functions, operating on named variables, would have been quite welcome.
Thanks for this post, I have searching this kind of information for how many times, this is really great… hope that you will continue sharing for your knowledge, I’ll be back again to read some of your post…
Identified your website on del.icio.us today and really liked it.. I bookmarked it and can be again to verify it out some a lot more later on ..
Thanks a lot it is very useful for us…
Dünyan?n en büyük online okey oyunu bu sitede sizleri bekliyor. Gerçek ki?ilerle sohbet ederek Okey Oyunu Oyna ve internette online oyun oynaman?n zevkini ç?kar
Whoa! This is a long one! I’ll have to read the whole thing when I finaly get home because the topics seem interesting.
Thanks for this article.I learned a lot of knowledge from this post.I hope you keep sharing your knowledge with us.If you want to buy boots you can contact me.I will do my best for you .
I am so glad that I have found this your article because I have been searching for some information about various recipes from pig meat almost an hour. You helped me a lot indeed and reading this your entry I have found many new and useful information about this question. Well, I will definitely bookmark your website and wait for other useful and detailed posts like this one in the future. Regards
Thank you so much for the English translation! I love this shawl and will be making is soon.
This shawl just jumped to the top of my project list! Very pretty indeed. Thanks for sharing the pattern with us.
very interesting article,and i am so happy to see this,thanks to lovely share
Your blog is a great one. What really impresses me is that you are correctly mentioned that there are thousands of tools that are available to create a website or launch one but what matters is that you choose the right one, the one that gives you all that is actually needed
Well good to read about this thanks.
Awesome…It’s nice share that, thanks very much!
Thanks for posting some great ideas and I’ll try to return back with a completely different browser to check things out! Also, I put a link to your blog at my site, hope you dont mind?
I am about to begin a blog and this will help me tremendously. Of course it has given me many things to consider as I update my website too. I appreciate it much.
good post as always man
You have a cool web site. It is almost the first time I encounter something like that.
That Post is Full of informative. Thanks for that kind of sharing. Hope u will again share with us.
Well, if anyone can shed some light on how genius does work, it’s people like Paul Simon, Frank Gehry, Tim Burton and Sarah Ruhl. Gathering together some of the most respected names in a Mens True Religion Straight Leg Jeans Buy Mens True Religion Bootcut Jeans Buy Mens True Religion Flare Jeans variety of the arts, The Atlantic has a got a series of first-person essays on the creative process of some of today’s most brilliant minds.
compressed package, damn the system tray did not integrate winrar, Heidengxiahuocheap beats by dre beats by dre store one by one to ask dorm brothers finally have a brother that he computer memory yet, and immediately use U disk to copy to, The results found winrar370.rar … ...
The “it” bag has become the decisive accessory for young twenty something girls partying every night on. Another attraction to using the big bag is the skinnier illusion it creates of the carrier adding much need excitement to any sort of unexciting outfit.
night on. Another attraction to using the big bag is the skinnier illusion it createsbeats by dr dre beats by dre sale of the carrier adding much need excitement to any sort of unexciting outfit.
This blog details are very much interested to the customers and frequently visit this website. Thank you very much for proving the wonderful services.
Thank you to share with me for something
thank you ! I like this news, I also have information to share, here is my message http://www.fashtogo.com
Named tuples: http://docs.python.org/library/collections.html#collections.namedtuple
This is very exciting article, read it with deep feeling. http://www.footycall.com/
Do you know something about t FM TRANSMITTER, are you looking for it for yourself. Today I will introduce it to you. it is a 25 W FM transmitter, the 25W FM transmitter have a lot of Advantages.First: the 25W FM transmitter is a handy and portable device which you can plug into the headphone jack or in an output port of portable audio and video device for instance, a portable media player, CD player or satellite radio system. The sound is broadcasted through the transmitter which plays through an FM broadcast band frequency. The use of 25 W is to play music on the go such as driving through a car, while using stereo and through radio. It plugs into the audio output of the devices and converts the audio output into an 20W FM TRANSMITTER signal which can be caught by the electrical device attached in the car or portable radios.Second: with a 25 W you can listen to your favourite songs without any problem.
It is true. I agree with what you’ve said and you can really give me advice in programming. To realize this idea. we need do more practice.
it seems that you have strong grip on the topic. i really liked your site. great job.
viagra High-fructose corn syrup (HFCS) is a popular sweetener because it is chemically different from sugar—it has a longer shelf life and mixes better into beverages. Yet the corn industry likes to downplay these differences, pointing out that sugar is 50 percent fructose and 50 percent glucose, while…
When I originally commented I clicked the Notify me when new comments are added checkbox and now each time a comment is added I get four emails with the same comment. Is there any way you can remove me from that service? Thanks! , convert all video to ipod touch format
I had really like it very much for the great technology in this blog and the great technology in this blog. This info is gathered for this info in the different websites that to helpful info in this blog
Your blog page is excellent. Thank you truly for sharing a huge amount of powerful ideas. I will bookmark your web site and will be without a doubt coming back. Again, I appreciate all your work and supplying much priceless info for the many people.
Tuple Madness 36 hoo,good article!!I like the post!12
Tuple Madness 37 good post174
I have unit converter pages online, would you please be interested in placing my website’s link (code below) on your page with the unit conversion tables? Thank you very much.
I found your website perfect according to my needs. It contains wonderful and helpful posts. Thanks for it.
oakley radar range Such a horrible wound, Dr Tam has no fear, concentrate on the treatment, so stand Zheng moved. ry32cvb
well, this is really a nice post.I really like the way you start and conclude your thoughts. Thank you so much for this information. keep posting such good stuff
hey mates,this is one of the best posts that I’ve ever seen; you may include some more ideas in the same theme. I’m still waiting for some interesting thoughts from your side in your next post. Best of luck
Thanks for sharing the idea there would be some apprehensions from segment but i am up for it.
Thanks for sharing the idea there would be some apprehensions from segment but i am up for it. (www.doctorsoftechnology.com)
Great to know the—in depth from this blog.This will really help for my forward steps to be taken.
Thanks a lot for blogging this, it was unbelieveably informative and helped me tons.
I thought it was going to be some boring old post, but it really compensated for my time. I will post a link to this page on my blog. I am sure my visitors will locate that extremely useful
Great to know the—in depth from this blog.This will really help for my forward steps to be taken.
Biodegradable bags have become popular these days?
Great to know the—in depth from this blog.This will really help for my forward steps to be taken.
Great to know the—in depth from this blog.This will really help for my forward steps to be taken.
Thanks for sharing the idea there would be some apprehensions from segment but i am up for it.
click here</> Hi, I thought I would drop you a line and inform you that your page layout is really messed up on the Firefox browser. Seems to work fine in Internet Explorer however. Anyways keep up the good work.
Great to know the—in depth from this blog.This will really help for my forward steps to be taken.
A mind blowing article is provided here. And it is written with great skill and the words directly explain the thought of author and it is nice to know the information provided around the Earth and really it is great topic of interest.
Thanks for sharing the idea there would be some apprehensions from segment but i am up for it.
Great to know the—in depth from this blog.This will really help for my forward steps to be taken.
I see the player piano as the grandfather of the computer, the ancestor of the entire nightmare we live in, the birth of the binary world where there is no option other than yes or no and where there is no refuge.
I wanted to thank you for this excellent read!! I definitely loved every little bit of it.Cheers for the info!!!! & This is the perfect blog for anyone who wants to know about this topic. You know so much its almost hard to argue with you …...... thanksHair Salon Las Vegas
Great to know the—in depth from this blog.This will really help for my forward steps to be taken.
Imagination grows by exercise, and contrary to common belief, is more powerful in the mature than in the young.
It has been a fine source of information for me in my study. Thanks for your piece of writing it have been very beneficial.
” rel=”follow”> psykologhus i Aarhus
Every one were at there best, great story and great performance by your team, keep up the good work, it is a great resources for the all members for recruit no doubt.
” rel=”follow”> psykologhus i Aarhus
Thanks for sharing the idea there would be some apprehensions from segment but i am up for it.