Thread: Switching from procedural to OOP

  1. #1
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681

    Switching from procedural to OOP

    For those of you who have changed styles (doesn't have to be all the time) what did you find helpful it making the switch?

    Reason I ask is because I'm currently trying to teach myself C++ and trying to do it in the OOP way but keep coming up with code thats looks like a bastardized version of both.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    I found some parts of OOP useful and others worthless. For example, objects are very nice for ADTs, but I never use inheritance. The key is to learn the fundamental concepts and then slowly integrate them into your designs:

    Abstraction
    Polymorphism
    Inheritance
    Encapsulation

    Not necessarily in that order of course. I recommend encapsulation first, then abstraction, then inheritance, then polymorphism.

    >but keep coming up with code thats looks like a bastardized version of both.
    That's okay. My first C++ coding was awful (as if it were any better now ).
    My best code is written with the delete key.

  3. #3
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Location
    Phildelphia, PA
    Posts
    1,146
    Bruce Eckel wrote a book available free online called "Thinking in C++." I found that helpful. A Google search ought to dig that up for you.

    The only advice I can suggest is to think of things in your programs as objects. Everything's an object. Objects contain information about themselves, and they should be able to take care of themselves.
    FAQ

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

  4. #4
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    I have read parts of the thinking in c++ but I would rather read a book on the OOP concept without regard to a particular language.

    Thanks for the info Prelude

  5. #5
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    I like to be fair, and I'll admit that you can do some really neat things with C++ and OOP that are nearly impossible to do with C and procedural stylce coding. If you read code written by someone that really knows how to use C++ and OOP then it really does look like a totally different language (read stuff in the standard template library for example).

    Other than that, I freaking hate excessive use of C++ and OOP, so I kind of mix the two (procedural + oop) together, i.e I code in a C++ compiler, and I use classes and inheritance ADT, but all of my classes are basically structs (i.e everything is always public, I never use private), and I only have one homegrown class that actually uses a template (and that's to interface witha problem of using an stl class, lol). so basically everything i write looks like a 'bastardized version of both'

  6. #6
    I'm a huge OOP advocate. None of this half way stuff for me. My change to OO program design was the start of my path to well structured programs.

    I can't say _exactly_ what helped me along the way other than simply doing it a lot. Just make the choice to switch and stick to it. You'll become fluent in no time.
    "There's always another way"
    -lightatdawn (lightatdawn.cprogramming.com)

  7. #7
    Board Conservative UnregdRegd's Avatar
    Join Date
    Jul 2003
    Posts
    154
    The problem, of course, is switching back to procedural programming from OOP. I'm so used to object-oriented programming now that programming in pure C would be disconviencing at best.
    I am a programmer. My first duty is to God, then to nation, then to employer, then to family, then to friends, then to computer, and finally to myself. I code with dignity, honor, and integrity.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OOP flu
    By Hussain Hani in forum General Discussions
    Replies: 15
    Last Post: 06-27-2009, 02:02 AM
  2. Data Mapping and Moving Relationships
    By Mario F. in forum Tech Board
    Replies: 7
    Last Post: 12-14-2006, 10:32 AM
  3. recommendation for a good OOP book
    By Mario F. in forum C++ Programming
    Replies: 2
    Last Post: 06-15-2006, 04:28 PM
  4. OOP Theory Question
    By Zeusbwr in forum C++ Programming
    Replies: 2
    Last Post: 10-30-2005, 08:37 AM
  5. OOP v Procedural
    By NickESP in forum C++ Programming
    Replies: 7
    Last Post: 02-08-2003, 06:46 AM