tags:

views:

261

answers:

12

I am reading this C++ book, "Problem Solving with C++" in my free time. I have gotten through 4 chapters, and now I am at a split. I can either go to chapter 5 which is file operations and an introduction to OOP, or I can go to chapter 12 which is recursion. So far I have only gone over compiler basics, all that if, else, and loops syntaxy jazz, and both call by reference and call by value functions. The book gives no mention on whether its better to learn recursion, before oop or not, but it does say that some teachers may prefer to teach it that way, and its ok to skip to chapter 12 and go back. I being a novice in both paradigms just wanna know is it benefical for me to learn one before the other.....and yes I plan to learn both so don't be that wise guy.

+5  A: 

There's a reason the author of the book put recursion in chapter 12, and not chapter 5.

Robert Harvey
They're both important, but OOP is more important in the context of C++.
Jim Ferrans
+6  A: 

Disclaimer: This is really a matter of opinion. Having said that, you should learn recursion first.

Asaph
+1, for the simple fact that if recursion breaks your mind, it's best to get out early.
Matthew Scharley
...and recursion takes less than an hour to understand, if ever. OO is more like chess; it'll take a life time to master.
idstam
Joel Spolsky once said that pointers and recursions were the cornerstone any programmer worth its salt should know about. Recursion is a simple concept, not so easy to use, learn it and be done with it.
Matthieu M.
+3  A: 

You must understand recursion whether you learn OOP or not. It's a fundamental chapter.

Rodrigo
+3  A: 

Recursion and OOP are not mutually exclusive.
i.e. it doesn't matter, whether you learn about recursion first or OOP.

OOP is the way you structure your code.
Recursion is the way to express the solution to a given problem, which could be solved by iteration.

shahkalpesh
I hate it when people bring up this point. Just because it *can* be solved with iteration doesn't mean it *should* be.
Matthew Scharley
@Matthew: I agree. It depends on the programmer to think of the given problem either in recursion or iteration.
shahkalpesh
I conside recursion a structural problem solving mothod , while iteration is kind of optimization skill using memorization.
pierr
+8  A: 

Recursion is a mathematically fundamental concept, but I wouldn't consider it such a key topic in C++ as to make it worth your while to skip over files, OOP, and other very practically useful concepts. An instructor might wish to reorg the chapters/subjects to fit their own teaching style, but, missing an instructor, I'd recommend continuing with the chapters in their natural order (which has to be the order the book authors favored, after all!-) and coming to recursion later, after you have OOP, files &c under your belt.

Alex Martelli
A: 

OOP and recursion are two vastly different things. OOP is much bigger a concept compared to recursion. I suggest you to go by the order in the book. If he is not going to talk about recursion upto chapter 12 then he is not going to use it also. So you will not miss on anything.

Naveen
A: 

i say read chapter 5, whatever the topic is since its the next chapter after 4.

Andrew Keith
A: 

Recursion first. Because you should learn functions before you learn objects. And recursion is mainly about functions.

bobobobo
A: 

Recursion has nothing to do with OOP. When teaching Recursion ,people ususal use Fibonacci sequence ; when teaching OOP , people ususally say "a car has four wheels".

I would suggest you go for what is more interesting to you - it seem to be Recursion in this case. Recursion as a foundmental problem solving mothod ,if not more imporatant than OOP , is as important as OOP.

pierr
A: 

In my personal opinion I would say go with recursion first, but spend more time on oop.

Additionally, if what you are getting at is: will one help you learn the other better- then yes and no.

Yes in that once you learn one in programming, the next thing you learn (even unrelated) will be easier to learn just because you are gaining more and more experience with programming in general.

No in that the order in which you learn these in respect to one another is not important.

instanceofTom
A: 

The only way to truly understand recursion is to have a problem that is effectively solved by it, and then write the recursive code. One does not learn it in a leisurely manner. Wait until you need it.

Though, hopefully your ah-ha moment for recursion won't be in an interview like mine was.

jeffamaphone
My ah-ha moment for recursion was when learning Haskell.
pierr
+1  A: 

Recursion first.

Recursion is a very basic and fundamental structure in programming; if you don't know it, you don't yet know the basics of programming.

OOP on the other hand, is a high level code organization methodology.

Learn the low levels first.

hasen j