Ads

Saturday, August 01, 2009

Coding styles

So, on the shower time thoughts, I figured out what I was going to blog about today.

I was contemplating on some code that I wrote/am writing for work. I started out doing a good job with creating new functions to do stuff that I do over and over and planning out how it will look. As I got into the phase where I was just implementing it, and not really doing design, I got sloppy and made these huge functions that were a whole heck of spaghetti.

So, I was remembering factor and other concatenative languages. Neat thing is, if you want to take something and make it a function/word, a good editor can let you just highlight it and hit some sort of "make function/word with name ___".

Seems like something I could have used. No good plotting library that I could find quickly though, so factor will have to wait. Going to give Common Lisp a fair shake first. (though now I am seeing why some people like LISP-1 (ala Scheme with the unified namespace), keeping track of types for something, even if that something is a function isn't completely necessary). I don't know about plotting for it either, I might just start using gnuplot and have my code create outputs that I pipe to gnuplot.

Anyway, the main thought was that its easy to get sloppy as you go along developing code. My computations are pretty clean (or so I think), but the graphing part is a bunch of ugly. Some of that is because I am learning the nuances of the matplotlib api, but eh. I ended up embedding calculation/transformation code in with the plotting, which is sometimes hard to keep straight. Not going to really fix it, I don't have time, but I'll try and keep it in mind next time. Keep stuff separate if you can!

I realize this post makes no sense and doesn't have any real content.

No comments: