Background I started my professional career with a Pascal program (I know that dates me a bit) and then continued with C and C++ and discovered Python around version 1.4 and used it heavily for over ten years, and really didn’t like Java when I first met it (version 1.3-1.4 time frame).
I’ve also used a ton of other languages for real deployed projects, like Python, Ruby, C, C++, Common Lisp (which I <3 love), C#, Clojure, Visual Basic, and Go, so I’m a not the average “blub” programmer saying this.
I’ve not done a ton of programming in Python for a while, but I still do like the language. I also like trying to do things in one line (ok, one statement), just because it’s a bit more difficult :). These are pretty old, but I used to keep these in my email signature line…
Mandlebrot set
#this one really only works if your terminal window is 80 wide import os;map(lambda i:os.
AKA Good Programmers Are Doing Real Science There are a bunch of long-ish winded definitions of the scientific method, but I think a reasonable pithy description would be:
Come up with a theory to explain an existing phenomena. Use that theory to come up with a falsifiable prediction. Conduct experiments to prove or disprove the truth of the prediction. Independent parties repeat #3 and reproduce the results. Now if the experiments at step three or four disprove the truth of the prediction, one of a few things can happen:
When dealing with the problem of a
long method, the simplest thing
you can usually do is to break it into it’s conceptual pieces and have a
series of tail called functions that call the next chunk of the computation.
So given this:
private Thing methodThatIsTooLong(TypeThing arg1, OtherType arg2) {
// chunk1
// chunk2
// ....
// chunkN
}
You get:
In The Cult Of Abstraction I railed against the over-use of abstraction. Here, I want to talk about a particular source cause of over-abstraction I have seen (and been guilty of).
Recently, while working with another team here at Spotify, I was working through some of their test code using the Helios Testing Framework, and the harness used a surprisingly complicated tree of classes to set up the various containers it used.
While I’m often at odds with software frameworks (libraries are to be preferred over frameworks, generally), I’ve found that process frameworks can be very good indeed, when done right. Implementors of agile methodologies ironically can fall into the trap of doing it wrong.
Why ironic? Well let’s look at the agile manifesto from the agile manifesto website:
Individuals and interactions over processes and tools Working software over comprehensive documentation Customer collaboration over contract negotiation Responding to change over following a plan What I’ve heard is that in many companies they prescribe: “We do agile this way”, which breaks the first statement of agile.
I’ve known handywrite shorthand for a number of years, and finally decided that I should learn shorthand proper, ideally with the best bang/buck ratio, as well as minimal amount of initial learning, with being able to ramp up the amount I learn later, as time permits. I settled on Gregg shorthand, Anniversary Edition.
In hunting the net in the hopes of learning Gregg, I’ve found a bunch of PDFs that I’ve found helpful.
(see here for the full Agile Organizer series)
Retrospectives If you do Agile, it’s probable that you do something called a retrospective. At least in the ones I’ve been involved with, there’s usually a part where we go over what’s going well, and what could be changed. With the agile organizer, I’ve found that periodically doing retrospectives about the way I am using it is useful and worthwhile. If you use it, I hope you would too.
(see here for the full Agile Organizer series)
In The Agile Organizer, I described the basics my organization system. In this second part, I go into some ways that I use it that weren’t covered in the first post.
The Dumping Ground Sometimes, when I’m working on an idea, I just want to get the bits down, but don’t want to think, necessarily, about how they fit just yet. In such a case, I’ll have a page where I just stick the stickies to a page wherever they’ll fit, with the idea that I’ll come back to it later to sort it all out.
In looking at functional languages, I’ve often been impressed with the clarity of implementations of Quicksort. Now that Java 8 includes lambdas, we can now do one that, while not as nice as an implementation in, say Haskell, is still quite nice.
While I wouldn’t use the below code in production, as it’s choice of pivot point is naive and would go kaboom on a large sorted list from stack exhaustion, it is a nice illustration of the utility and clarity that Java 8’s lambdas when mixed with Guava functional stuff give.
As far as programming languages go, my truly favorite language is a
Lisp. Scheme or Common Lisp are fine. I have a few hesitations about
Clojure (the way it does recursion is offputting
to me, but perhaps a few macros might clean it up), but for what I’ve
done with it when working with Riemann, it’s been
a pleasure, even if it’s slow going because I don’t do it frequently
enough to have the needed bits already in my head.
In one of my previous posts, I wrote
about how I’d written the website software for a website I maintain in
Common Lisp. There were a few macros I wrote while building it that I
thought were potentially useful and illustrative of the kinds of
things you can do with macros that make Lisps cool.
In this post (there may be others later), I’ll be talking about a
macro I wrote to deal with database queries. When dealing with
database queries, making sure that you write/generate the queries
properly with respect to escaping and bind variables, and connection
caching, etc. can be a real pain, and I’m not a big fan of ORMs as
they never really do what I want.
In the course of reading various design patterns and refactoring books (like Refactoring), I noticed while flow control is sorta mentioned here and there, it’s not addressed especially well. It mostly encourages things like replacing conditional with polymorphism and replace nested conditional with guard clauses and the like, rather than finding ways to straighten out and clarify code that contains flow control and conditionals.
One of my thoughts on flow control and conditionals follows one of the rules of the Zen of Python: