I've taken a course this semester at my university in Object Oriented Programming. I was a decent C and C++ procedural programmer and didn't think that object oriented programming would be that difficult. How wrong I was.
I was unable to complete the course assignment. Or rather, I completed it and spent even longer on debugging it to find out why it crashed. In the end, I was unable to locate the logical errors, but submitted the assignment anyway. Eager to get the project out of the way, I had started writing code fast, but without a good design.
What I realized was that while I understood the syntax of the language, I was not taught any code design and management skills (don't know if I should blame my Uni or myself there), which eventually led to my downfall. I rewrote large sections of the code 3 times, wasting time as the design was not completely object oriented (e.g. other classes could control the behavior of some classes, rather than each class being able to control its own behaviour and attributes). Soon, I found myself facing thousands of lines of code, over a dozen classes and over 50 to 60 different functions (some with very similar names, but in different classes!). Couldn't even figure out where the logical errors where anymore and just reading the code became hard.
Conclusion:
What I would like to learn now is how to organize a project like this better. I am set to graduate soon and my first job ironically enough is going to be in writing software. I don't want to repeat my mistakes above.
I want to ideally be able to make the best possible design (with execution efficiency and future maintanence) once, write the code once, debug once and be done with it. I am willing to read up extra books to educate myself on this design issue.
So, kind fellow DC members, please throw some tips. How do you organize your large code? I would also like to know how much of a big deal Object Oriented Programming is. After this assignment, I've started disliking it as I wasted too much time trying to contain everything inside classes, eliminate friend functions and so on. This even led to longer lines of code and seems counter productive to me.
I was unable to complete the course assignment. Or rather, I completed it and spent even longer on debugging it to find out why it crashed. In the end, I was unable to locate the logical errors, but submitted the assignment anyway. Eager to get the project out of the way, I had started writing code fast, but without a good design.
What I realized was that while I understood the syntax of the language, I was not taught any code design and management skills (don't know if I should blame my Uni or myself there), which eventually led to my downfall. I rewrote large sections of the code 3 times, wasting time as the design was not completely object oriented (e.g. other classes could control the behavior of some classes, rather than each class being able to control its own behaviour and attributes). Soon, I found myself facing thousands of lines of code, over a dozen classes and over 50 to 60 different functions (some with very similar names, but in different classes!). Couldn't even figure out where the logical errors where anymore and just reading the code became hard.
Conclusion:
What I would like to learn now is how to organize a project like this better. I am set to graduate soon and my first job ironically enough is going to be in writing software. I don't want to repeat my mistakes above.
I want to ideally be able to make the best possible design (with execution efficiency and future maintanence) once, write the code once, debug once and be done with it. I am willing to read up extra books to educate myself on this design issue.
So, kind fellow DC members, please throw some tips. How do you organize your large code? I would also like to know how much of a big deal Object Oriented Programming is. After this assignment, I've started disliking it as I wasted too much time trying to contain everything inside classes, eliminate friend functions and so on. This even led to longer lines of code and seems counter productive to me.











, since it seemed that it was going to be such a small and easy program. It was, but I'm now facing rather large rewrites in order to get full unicode support, because I didn't plan ahead (fixing all API calls and static buffers was easy-peasy, but there's a couple of classes that definitely aren't unicode-friendly).
- carpe noctem
. I like Mouser's point about practice, it is so true, you really learn by doing. Back when I took that course I was reading everything I could on the subject and it all became so academic. For me it all started to fall into place when I took the basic OOP methodology and applied it to small,manageble projects, with a very well defined problem domain, and after a while it became easier and easier to see what needed to be an object and how behaviors should be implemented, and when a logical section of code became too long I could feel myself wanting to break it up into manageable contained parts that could be reused. Once all that starts happening, the design comes much easier earlier in the project, because you start to see the problem and solution from an object oriented perspective. I also helps to design small functional units that can be easily tested, rather than a monolithic code base that is like a black box. I also think Gothi[c] had a good point about looking at real working code bases with good OOP design. I learned a lot from the
..
) - it would just make the first legal move - I wanted to enhance it and give it a basic brain a couple of years after I wrote it but realised I'd have to wade through most of the code again to actually get a grip on things & dumped it coz it was too painful to do that. It was well commented but the only way I could (maybe) have got up to speed fast was if I had done some kind of detailed flowcharting. Do any of you flowchart or do any kind of preliminary documentation before getting on with the syntax? How do you cope with getting back to really old code?