views:

179

answers:

8

Hi,

I understand that the power to think about abstract things is very handy in programming well. Abstraction is usually a mental map, an image that you can refer to in your mind as you are progressing with writing your code.

Can you suggest any good technique, book, web link which talks about improving this art?

Thanks

+3  A: 

Write lots of code. Better yet, maintain lots of BAD code. You will quickly learn the "art" of abstraction. Often it is a value judgment you make when coding/refactoring.

  • Am I currently using this in multiple places?
  • Does this simplify the logic ?
  • Does this make the logic more complex ?
  • Will I use this abstraction (object, function module etc) in other places in the future?

Take a higher math classes if you are in school. Higher math is pure abstraction.

Byron Whitlock
higher math is abstraction. But I never understood that in school to be honest...
StampedeXV
A: 

Design Patterns by Gamma, Helm, Johnson, and Vlissides is full of good examples, especially if you are working in C++.

Refactoring your own code based on things you learned or insights you had since you last wrote the code also develops this.

John at CashCommons
+1  A: 

I recommend Design Patterns by the Gang of Four. The book describes recurring solutions to common problems in software design, and is one of the more influential programming books today.

jusunlee
+1  A: 

Pragmatic Thinking and Learning, by Andy Hunt.

SFEley
+2  A: 

Structure and Interpretation of Computer Programs by Abelson, Sussman, and Sussman is one of the best texts for this I've seen, though you really need to do the exercises. They walk you through many problems, occasionally noting that there's a repeated portion in what you've written, so you might as well generalize that out into its own abstraction. You will learn several useful ones along the way, but the emphasis is always on finding ways to generalize your solutions.

With the Design Patterns book, there is a greater focus on taking past abstractions and treating them like sacred artifacts. This is the wrong approach, IMHO - writing yet another Visitor pattern won't teach you anything new about abstraction. Rather than emphasizing the techniques for extracting recurring elements from new code, a few named abstractions are displayed like precious jewels. Actually, some of them are idioms, and some are just workarounds for flaws in C++'s type system.

silentbicycle
+1  A: 

I also recommend studying the SICP book.
(BTW, I really enjoyed the video lectures)

Also read Paul Graham's Programming Bottom-Up essay.

Nick D
+3  A: 

Always Be Coding. Practice will always be the most important thing you can do.

Read the design patterns books others have recommended. Then code some more.

Learn a MVC framework. Rails is the currently popular one. Code something with storage requirements which can be solved with data structure manipulation behind the scenes. Alternately, play with Hadoop (Pig, Cascading, etc.) or another dataflow abstraction.

Study math, especially abstract algebra and group theory. Or law, or other logical fields.

Play sokoban, it's all about seeing parity, cycles, and other higher order structures. Or play with a Rubik's cube, one of Bram Cohen's puzzles, or another geometric puzzle. Or play go or chess. Then code something.

Karl Anderson
The "law" suggestion sounds good in theory, but in my experience most laws are very bad at abstraction (from the software developers point of few) and usually provide no abstractions at all or very leaky ones.
Joachim Sauer
+1  A: 

This book isn't all about Abstracting, but it does likely have examples of where you'd want to pull something out and use abstraction:

Refactoring by Martin Fowler

JB King