I am new new in OOP stuff.I have read the Herbert Schildt's C++ reference.But it just gave me the idea, about how it work.Not how to make it work.

I am read few chapters from "Object-Oriented Programming in C++ by Robert Lafore"(old edition featuring UML 1, i guess).But it was just an good overview.

I am still in the dark.I dont know how to effectively design or implement OOP context.
I am trying to come up with some design, but they all were bad.

Where can I have tutorials on OOP design.I mean, a problem described and coded from the scratch and providing a greater insight about how to do things like that on my own.

Is there any good book, which is smart enough to enlighten an amateur, to make him able to come up with a standerd OOP design.

Edited 6 Years Ago by iamcreasy: n/a

There's not really a "standard" for OOP design... There are really just processes with good/bad components to them and good/bad design ideas. What's a good design process and what's a bad design process is highly dependent upon on your personal Point of View.

For a general overview of what is considered a good/bad OOP design (not design process, mind you), check with your library or on Amazon for "Object Oriented Design Heuristics" by Arthur Riel. That helped me a lot with designing for OOP.

In addition, and if I remember correctly, most of the pieces of example code that are in the book are written in C++.

Edited 6 Years Ago by Fbody: n/a

The book which opened my eyes to what OOP code really looked like was Design Patterns. It's old, but it's a classic and still extremely relevant.

Beyond that, the best way to get a feel for what works and doesn't work in an OOP context is to just write lots of code. No book can show you what object oriented design looks like in the same way as building your own object oriented system. You'll screw up at first, but that's fine - just refactor, fix your mistakes, and learn.

What's a good design process and what's a bad design process is highly dependent upon on your personal Point of View.

That sounds really different from what I have thought.I thought, there are some specific ways to handle particular situations.

For example, why i should bother about private data member, when i can declare that kind of data in the global space in that cpp file.It can be shared among all the methods but, it wont exists outside the file.Is it acting as a private data member?

One more thing, it is a necessity to learn UML for good OOP design.

Cause, in some books, I have found that, they first analyse the problem.Go through USE CASES, CLASS DIAGRAMS etc etc.How I am going to learn them?I haven't seen individual chapter, rather i have seen individual book! :|

If your looking for OOP design then you can give this book a try: "Head First Design Patterns" from O'Reilly. It's very good. Regarding UML you only need to learn a few basics and the rest will come along as and if you work with it. For that you can start with a book called UML distilled by Martin Fowler.

Hope it helps.

That sounds really different from what I have thought.I thought, there are some specific ways to handle particular situations.

For example, why i should bother about private data member, when i can declare that kind of data in the global space in that cpp file.It can be shared among all the methods but, it wont exists outside the file.Is it acting as a private data member?

I guess if you never define more than a single class in a .cpp file, then yes, it would be functionally equivalent to a private member variable. But why do it? It's non-idiomatic and confusing to other programmers. Conceptually, it makes sense that a member variable is part of its class. There's no reason to switch that up. If you're worried about hiding implementation details from header files, there's already an idiom for that.

One more thing, it is a necessity to learn UML for good OOP design.

No, not really.

That sounds really different from what I have thought.I thought, there are some specific ways to handle particular situations.

There are action-oriented and data-oriented design processes. Both have their pros and cons, but I won't get into that. Riel's design heuristics are designed to be guidelines for how to detect and address various situations. They are not intended to define a design process.

For example, why i should bother about private data member, when i can declare that kind of data in the global space in that cpp file.It can be shared among all the methods but, it wont exists outside the file.Is it acting as a private data member?

This approach negates the benefits of using a properly-guarded protected/private data member. When you create a global variable, there can only be one copy of it in existence at any given time. A private data member will have one instance for each object of that class that gets created. The behavior you describe would be similar to a static data member. Every instance of the class would be accessing the same data. If you have 5 instances of a car class that all access "global" variables instead of private members, all 5 cars would be identical. If the data members are part of the class, each car can be different.

One more thing, it is a necessity to learn UML for good OOP design.

I would say it's beneficial, but not "a necessity". UML is intended to be a standardized way to communicate design intent. I really don't know it at all, but (according to my instructors at least) all of the OOP designs I have created have been really good.

Cause, in some books, I have found that, they first analyse the problem.Go through USE CASES, CLASS DIAGRAMS etc etc.How I am going to learn them?I haven't seen individual chapter, rather i have seen individual book! :|

UML is really nothing more than a visual depiction of information that can be just as easily shared verbally or in writing. It's visual note taking/brainstorming....

I guess if you never define more than a single class in a .cpp file, then yes, it would be functionally equivalent to a private member variable. But why do it? It's non-idiomatic and confusing to other programmers. Conceptually, it makes sense that a member variable is part of its class. There's no reason to switch that up. If you're worried about hiding implementation details from header files, there's already an idiom for that.

Please see the second part of my response a few lines up.

Edited 6 Years Ago by Fbody: n/a

I would say it's beneficial, but not "a necessity". UML is intended to be a standardized way to communicate design intent. I really don't know it at all, but (according to my instructors at least) all of the OOP designs I have created have been really good..

ok..but I was just wondering how i could make the design process more simple and well organized(like UML). If i knew a standard and structured process to start with pen and paper then, I think the coding process might have been less painful.

1) Write code.
2) Write more code.
3) Read up on design patterns, whether it be wiki or whatever
4) goto 1 until comfortable
5) Now every time you write code, you can either :
5a) Finish the code, and the project ( depending on its size) then take a step back
and see how you can better the system, decouple it, give each class its minimal
job.
5b) Or take a step back first, and think about how each class interacts with the
other and then how all class interacts to make the program. This is where UML
comes in. It provides a visual
6) Repeat all of this procedure for like your whole life, and eventually you'll get
to be a better programmer.

1) Write code.
2) Write more code.
3) Read up on design patterns, whether it be wiki or whatever
4) goto 1 until comfortable...

yes, but I need a problem in front of me which I have to solve.Then I need to have a good a solution of that problem, to compare with my solution.Then I will be able to understand my weakness or limitations.I also need some explanation of the solved problem, how he did it in this way, why this is approach is better then the other...etc etc.

So, is there any book or online materials like that, from where I can start practicing?

My one month summer vacation has started and I wanna grab a strong understanding about OOP within this one month and I am willing to work very hard for it.

Already I have collected some books("Object-Oriented Design Heuristics by Arthur J. Riel" "UML Distilled - A Brief Guide to the Standard Object Modeling Language, Third Edition by Martin Fowler." and "Design Patterns Element Of Reusable Object Oriented Software by Erich Gamma (Author), Richard Helm (Author), Ralph Johnson (Author), John M. Vlissides") from college library...But when I started reading those, I realized that they are going to provide me theoretical insight but no practical(example by example by hand) experience.

I know they are important, but still, if i continue reading these books, then after this one month vacation i will learn a lot about different theories and other stuff's about OOP...but still, I wont be able to code a working and satisfying OOP design.

>>but still, I wont be able to code a working and satisfying OOP design

Don't worry not many people do. It takes time and practice and more time and practice.
Until, then start reading and coding. Eventually, you will start to recognize some
type of pattern you can do to solve a problem.

Read your books then apply the processes/information contained in them to this:
The Dice Game 10,000 or any of the mentioned variations on the linked page. Relatively speaking, it's a fairly small simple project. Once you do that, I'll compare notes with you. I have done a couple command line interface versions of a variant of the Farkle version of it.

Start by thinking about what classes/objects you will need. What objects are you going to need multiple instances of? How will any containers interact with the objects they contain?

Just as an FYI, the only one of those books I have read is Riel's, so I won't debunk any of the other books, I simply can't. I prefer designing iteratively based on general guidelines over the strict always-forward-moving rules of a linear design process.

Edited 6 Years Ago by Fbody: n/a

>>Don't worry not many people do.

..it kinda makes me feel happy. :D

Read your books then apply the processes/information contained in them to this:
The Dice Game 10,000 or any of the mentioned variations on the linked page. Relatively speaking, it's a fairly small simple project. Once you do that, I'll compare notes with you. I have done a couple command line interface versions of a variant of the Farkle version of it.

Start by thinking about what classes/objects you will need. What objects are you going to need multiple instances of? How will any containers interact with the objects they contain?

Just as an FYI, the only one of those books I have read is Riel's, so I won't debunk any of the other books, I simply can't. I prefer designing iteratively based on general guidelines over the strict always-forward-moving rules of a linear design process.

Great, now I have something to think about...though, dont know how long it is gonna take.

I will post, when I will come up with a solution.

Do you have any other problems like this?

Thanks a lot. :)

Edited 6 Years Ago by iamcreasy: n/a

>>Great, now I have something to think about...though, dont know how long it is gonna take.
Depends on how quickly you move. Right now, I do coding mostly for fun. I'm actually a draftsman in the Construction industry so I don't dedicate all my time to code.

The design itself took me a few days. The actual code took me a couple weeks. Most of the coding time (a little over a week) was spent organizing, tracing and debugging the code I had initially written. I probably had a total of 40-50 hours in to it...

Edited 6 Years Ago by Fbody: n/a

a really good book though not really relevent but has some interesting problems is

Cryptography in C and C++
by Michael Welschenbach

a couple others are

C++ for Mathematicians
An Introduction for Students and Professionals
Edward Scheinerman

Exceptional C++: 47 Engineering Puzzles, Programming Problems, and Solutions
By Herb Sutter <-this book has some hard puzzles but provides solutions and explains them

the way i learned was i started with html which was easy then i went over to my friends house and he is a C++ coder and he showed me a couple of mods he did for Tremulous that inspired me to learn c++

then i found both of these good resources and after those i just did stuff by trial and error now i have a pretty good understanding of the language :)
http://www.cprogramming.com/
http://www.cplusplus.com/

Edited 6 Years Ago by avarionist: n/a

This question has already been answered. Start a new discussion instead.