Thread: Obsessed about OOP design, can't get away until I do it!

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    83

    Obsessed about OOP design, can't get away until I do it!

    Recently I had just learnt C++. I come from a procedural oriented programming background. I do know the structure and methodologies of C++.

    The thing is that, whenever I'd try to make an program with an Object Oriented Design, I always fail to do so. I find myself worrying too much about classes, class name, member names and what member function to be kept rather than writing the actual code itself.

    Even if I managed to write a class, in the end I'd not be happy with the way I designed it, and would simply try to rewrite it. This has lead to be become frustated easily writing anything in C++ because I would think of it as a bad design. I wonder how do the otherr guys do it? Why is OOP that hard to understand? O.o

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by Swoorup
    I do know the structure and methodologies of C++.
    Of which OOP is just one aspect.

    Quote Originally Posted by Swoorup
    I find myself worrying too much about classes, class name, member names and what member function to be kept rather than writing the actual code itself.
    In whatever other programming language you use that has an emphasis on a procedural programming paradigm, do you find yourself worrying too much about procedures, procedure names, and what procedures are to be called rather than writing the actual code itself? What about when you were just starting out?

    Also, what kind of problems are you trying to solve with OOD/OOP? Maybe the problems that you are tackling simply are better represented and solved in another programming paradigm.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    >> I find myself [thinking] too much about ...
    Better than not thinking about it - so you got that going for you

    I sometimes find myself getting "hung up on the details". When that happens, here's some things that I think about when deciding:
    K.I.S.S
    Is it readable?

    Next time you're unsure of a design decision/direction, come here with it and what you're leaning towards.

    gg

  4. #4
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    I believe that it's hard to understand because they often first try and make you write your own classes.
    However, in my opinion, it is a lot more useful to learn how to use existing classes quite well before learning to make your own. Then, and only then do you have a good idea what it is that you're trying to achieve with writing the class.
    I guess I'm saying that you should learn OOP in a top-down fashion.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  5. #5
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    I struggled with this problem for years. It is not a programming issue, it is a matter of expectations. The solution begins in realizing the unattainability of perfection in software design. So many fallen warriors, so much deleted code over the years.

    Resist the urge to wipe the slate clean. It is a powerful urge but ultimately an unproductive one.

  6. #6
    Registered User
    Join Date
    Nov 2011
    Posts
    83
    Is it necessary that in C++, every thing should be treated as objects? I feel like I am trying to pursue a flawless design that I can never achieve.

    Ok, since I am still stuck with it, can you guys lend me a help in getting away with this stage. Are there any good books that present guide to OOP design styles and think like an Object oriented style and mentions about proper readable code?

    I am trying to write my rendering engine. So far this is what I have.
    Code:
    class WrappedGL
    {
    private:
    	int m_nParams;
    	char* m_pParams[];
    	int m_nWidth, m_nHeight;
    
    
    	void SetParameters(int& argc, char* argv[]);
    	void SetWindowSize(int nWidth, int nHeight);
    	void SetWindowName(char szWindowName[]);
    	
    	void InitAndCreateWindow();
    	void Init();
    
    
    	void CaptureError()
    
    
    	GLuint program;
    	GLint attribute_coord2d;
    	void Render();
    	int Initialize();
    	void InitGameObjects();
    public:
    	int InitializeWindow(int& argc, char* argv[]);
    	void Idle();
    	void Exit();
    
    
    	void print_log(GLuint object);
    };
    I want it to be pretty generic and easily understandable. But my OOP problem is not specific to this particular piece of code only. Every while I try to code something in C++, OOP issue is being a dead-end. Or am I simply being too crazy and worrying about really minor details?

    Thanks in advance

  7. #7
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    Is it necessary that in C++, every thing should be treated as objects?
    O_o

    I do know the structure and methodologies of C++.
    I have a strong suspicion that this may have been a slight exaggeration.

    But my OOP problem is not specific to this particular piece of code only.
    Your "OOP problem" is that you've bought into the notion that "OOP" is a thing.

    "OOP" is an umbrella buzzword for a lot of different concepts, tools, and techniques.

    Start with one aspect, like encapsulation, and work with it and as you come to the "collisions" where encapsulations works with and against other bits of "OOP" start learning those as well.

    Or am I simply being too crazy and worrying about really minor details?
    Designing a good and proper interface isn't a minor detail.

    You problem with design is almost certainly a simple lack of experience.

    Just keep at it and when you say to yourself "Wow. This interface turned out really bad." explore the alternatives until you understand what went wrong so you don't repeat it. Repeat for 10,000 hours.

    Soma

  8. #8
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Quote Originally Posted by Swoorup View Post
    Is it necessary that in C++, every thing should be treated as objects?
    No. One should probably avoid claiming to know the structure and methodologies of C before even asking that question as well.

    Quote Originally Posted by Swoorup View Post
    I feel like I am trying to pursue a flawless design that I can never achieve.
    If you don't know what your design will achieve, it is impossible for your design to be flawless.

    A particular methodology, such as OO, is not an alternative to being able to describe what your program should accomplish. Just as a procedural approach is useless without a description of what your program is to accomplish.

    A hammer is virtually useless unless you can describe where you want a nail to go. Similarly, OO or procedural approaches are useless if you can't describe what you want to do with it.

    Quote Originally Posted by Swoorup View Post
    I want it to be pretty generic and easily understandable. But my OOP problem is not specific to this particular piece of code only. Every while I try to code something in C++, OOP issue is being a dead-end. Or am I simply being too crazy and worrying about really minor details?
    You have picked up this hammer called OOP. You have decided, since you have a hammer, you can build a house. You haven't bothered to put together an architectural plan or a blue print for building a house, and have started obsessively hitting various things with the hammer. And you are wondering why the house keeps falling over.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  9. #9
    Registered User
    Join Date
    Nov 2011
    Posts
    83
    I feel I didn't get an proper answer except opinions. I guess I'd come back after 10,000 hours lol

  10. #10
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    You got proper answers.

    Your expectations are unrealistic and the only way people can help you - for now at least - is to point that out. That may not be what you want to hear, but that's life.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  11. #11
    Bored Programmer
    Join Date
    Jul 2009
    Location
    Tomball, TX
    Posts
    428
    I feel I didn't get an proper answer except opinions.
    If there is anything I have learned on this board its definitely that the right answer is probably not the one you like.
    Virtual reality hello world http://www.rodneybrothers.com/vr/vrh...rld/index.html in html and javascript.
    Viewable with dodocase, google cardboard, OR, and other compatible VR gear.

  12. #12
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    I feel I didn't get an proper answer except opinions.
    O_o

    I didn't much like it when I found out that it would take me at least 13 years to master compiler theory.

    Or 15 years to master C++.

    Or 26 years to master game programming.

    Soma (-> studied compiler theory for 12, C++ for 14 years, and game programming for 25 years as of this posting.)

  13. #13
    Registered User
    Join Date
    Nov 2011
    Posts
    83
    Ok tell me where to begin with?
    Are you recommending to just keep practicing?

  14. #14
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by Swoorup View Post
    Ok tell me where to begin with?
    Are you recommending to just keep practicing?
    that's exactly what everyone is recommending. you may consider looking at books and web pages that discuss object oriented design patterns and strategies, but you really just need to do it and get some experience to know what works well and what doesn't.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Web Design
    By wildcard_seven in forum Tech Board
    Replies: 11
    Last Post: 11-01-2011, 10:56 AM
  2. Design
    By tilex in forum C++ Programming
    Replies: 3
    Last Post: 10-03-2004, 12:59 AM
  3. Need help on design
    By g0dthefirst in forum Game Programming
    Replies: 1
    Last Post: 08-30-2003, 02:14 PM
  4. Web Design
    By CumQuaT in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 04-15-2003, 10:10 PM
  5. How would you design a RPG?
    By JoshG in forum Game Programming
    Replies: 12
    Last Post: 07-20-2002, 10:44 AM