Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
I am new to design pattern and donot have much experience in it .I am confused with object pattern and class .one difference i noticed is class pattern uses inheritence and object pattern uses composition.I am working on c++ ,so let me know c++ support object/class pattern ,SInce in the Book GOF ,there is not having clear explanation .

my question is why class pattern and object pattern is used and when and where it is used .As i am very new to this .please let me know in simple ,with example.
Posted
Comments
Sergey Alexandrovich Kryukov 30-Nov-14 22:36pm    
What do you mean by object pattern and class pattern? I don't think there is such thing. Are you familiar with the basics of OOP, to start with?
—SA

1 solution

As SA has stated, these "patterns" do not mean anything, not officially anyway. If an article or book you are reading uses these terms, it has likely coined them itself, and should provide the definitions. But these are not design patterns that you can find in the GoF book, nor are they in any way official terms from the C++ terminology.

The official meaning of "object" in the context of C++ is the instantiation of a class. attaching "pattern" to either "class" or "object" therefore doesn't make a lot of sense to me. I suggest you get some better article/book that actually uses the official terminology rather than confusing people by using their own. Check on books by any of the following authors (in no particular order):

- Bjarne Stroustrup
- Andrei Alexandrescu
- Herb Sutter

Personally I find Stroustrup a bit easier read for beginners, but the others really help to get the hang of more complex aspects of the language once you're ready for that.

There are other very good authors as well, but IMHO you don't know C++ if you haven't read works from these three authors!


Quote:
one difference i noticed is class pattern uses inheritence and object pattern uses composition

Forget these "pattern" terms. Inheritance is one cornerstone of the "Object Oriented Programming" (OOP), whereas composition is a basic element used in "Procedural Programming". You can find more information about this when you search for Programming Paradigms. The term "pattern" in this context is entirely misplaced!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900