473,729 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

The C++ Object Model: Good? Bad? Ugly?

What I like about the C++ object model: that the data portion of the
class
IS the object (dereferencing an object gets you the data of a POD
object).

What I don't like about the C++ object model: that most OO features
are not
available for class object design without loss of POD-ness.

So, I'm more than leaning toward "bad" because of the limitations and
that the language doesn't distinguish what is of very key importance.
How do you feel about the object model?
Nov 1 '08 #1
23 3142
On Nov 1, 6:02*am, tonytech08 <tonytec...@gma il.comwrote:
What I like about the C++ object model: that the data portion of the
class
IS the object (dereferencing an object gets you the data of a POD
object).

What I don't like about the C++ object model: that most OO features
are not
available for class object design without loss of POD-ness.

So, I'm more than leaning toward "bad" because of the limitations and
that the language doesn't distinguish what is of very key importance.
How do you feel about the object model?
Hi
I really don't get completely, what you mean, but for me, the
important things about C++ object model are simplicity, efficiency and
extenability. For example the representation of concrete classes like
Date in memory is exactly like a POD Date struct. The size of object
of a derived class is the size of base class sub-object and its data
members. The size of an object of a class with virtual functions
increases just by the size of virtual v-ptr. The above layout is
extended for classes with static members, multiple inheritance,
virtual base classes and RTTI.
In all, you can see these three items.

I hope it helps you.

Regards,
Saeed Amrollahi
Nov 1 '08 #2
On Nov 1, 4:02*am, tonytech08 <tonytec...@gma il.comwrote:
What I like about the C++ object model: that the data portion
of the class IS the object (dereferencing an object gets you
the data of a POD object).
No it doesn't.
What I don't like about the C++ object model: that most OO
features are not available for class object design without
loss of POD-ness.
So, I'm more than leaning toward "bad" because of the
limitations and that the language doesn't distinguish what is
of very key importance. How do you feel about the object
model?
The "object model" in the C++ standard is very low-level.
Intentionally. It is designed for you to build on. The object
model of the classes you write is for you to design. It can be
more OO than many other languages (e.g. Java or C#), when that's
appropriate. Just as it can drop the OO model completely when
that's appropriate (e.g value objects). The essential point of
C++ is that it doesn't impose any application level object
model; it lets you use whatever is appropriate.

--
James Kanze (GABI Software) email:ja******* **@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Nov 1 '08 #3
On Nov 1, 4:02*am, tonytech08 <tonytec...@gma il.comwrote:
What I like about the C++ object model: that the data portion
of the class IS the object (dereferencing an object gets you
the data of a POD object).
No it doesn't.
What I don't like about the C++ object model: that most OO
features are not available for class object design without
loss of POD-ness.
So, I'm more than leaning toward "bad" because of the
limitations and that the language doesn't distinguish what is
of very key importance. How do you feel about the object
model?
The "object model" in the C++ standard is very low-level.
Intentionally. It is designed for you to build on. The object
model of the classes you write is for you to design. It can be
more OO than many other languages (e.g. Java or C#), when that's
appropriate. Just as it can drop the OO model completely when
that's appropriate (e.g value objects). The essential point of
C++ is that it doesn't impose any application level object
model; it lets you use whatever is appropriate.

--
James Kanze (GABI Software) email:ja******* **@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Nov 1 '08 #4
On Oct 31, 10:02*pm, tonytech08 <tonytec...@gma il.comwrote:
What I like about the C++ object model: that the data portion of the
class
IS the object (dereferencing an object gets you the data of a POD
object).
Definitely not. Data is just data. The true power of the C++ Object
Model is the object's behaviour and extensability.
>
What I don't like about the C++ object model: that most OO features
are not
available for class object design without loss of POD-ness.

So, I'm more than leaning toward "bad" because of the limitations and
that the language doesn't distinguish what is of very key importance.
How do you feel about the object model?
Objects sometimes need to do more than just store data. Behaviour is
nice to have. That inludes 'behaviour' at construction and expected
behaviours through a secure interface. It makes maintaining and
extending code easy, simple.

Write a program that uses some given polymorphic type hierarchy and
have your customer invent / add some new improved class of his own.
The customer's new class works with your original program without
changing a single line of code (except maybe an include).

You can't do that with PODs only. Whats nice is you can bend the
language to choose what path you prefer.

Nov 1 '08 #5
On Nov 1, 2:12*am, ebony.s...@gmai l.com wrote:
On Nov 1, 6:02*am, tonytech08 <tonytec...@gma il.comwrote:
What I like about the C++ object model: that the data portion of the
class
IS the object (dereferencing an object gets you the data of a POD
object).
What I don't like about the C++ object model: that most OO features
are not
available for class object design without loss of POD-ness.
So, I'm more than leaning toward "bad" because of the limitations and
that the language doesn't distinguish what is of very key importance.
How do you feel about the object model?

Hi
I really don't get completely, what you mean, but for me, the
important things about C++ object model are simplicity, efficiency and
extenability. For example the representation of concrete classes like
Date in memory is exactly like a POD Date struct.
"Concrete class"? You are using that to mean "struct".
The size of object
of a derived class is the size of base class sub-object and its data
members. The size of an object of a class with virtual functions
increases just by the size of virtual v-ptr.
That's "the problem" I implied: that quickly the object model destroys
the concept of a class looking like the data portion in memory.

Nov 3 '08 #6
On Nov 1, 3:32*am, James Kanze <james.ka...@gm ail.comwrote:
On Nov 1, 4:02*am, tonytech08 <tonytec...@gma il.comwrote:
What I like about the C++ object model: that the data portion
of the class IS the object (dereferencing an object gets you
the data of a POD object).

No it doesn't.
class SomePODClass
{
public:
int first_int;
int second_int;

void Func1(){}
};

SomePODClass X;
int first_int_in_ob j = *(int*)&X; // this is not pretty, but true
>
What I don't like about the C++ object model: that most OO
features are not available for class object design without
loss of POD-ness.
So, I'm more than leaning toward "bad" because of the
limitations and that the language doesn't distinguish what is
of very key importance. *How do you feel about the object
model?

The "object model" in the C++ standard is very low-level.
Intentionally. *It is designed for you to build on. *The object
model of the classes you write is for you to design. *It can be
more OO than many other languages (e.g. Java or C#), when that's
appropriate. *Just as it can drop the OO model completely when
that's appropriate (e.g value objects). *The essential point of
C++ is that it doesn't impose any application level object
model; it lets you use whatever is appropriate.
It does restrict usage of OO concepts unless one jettisons the "value
object" concept, which is unfortunate (and unnecessary?).
Nov 3 '08 #7
On Nov 1, 4:41*am, Salt_Peter <pj_h...@yahoo. comwrote:
On Oct 31, 10:02*pm, tonytech08 <tonytec...@gma il.comwrote:
What I like about the C++ object model: that the data portion of the
class
IS the object (dereferencing an object gets you the data of a POD
object).

Definitely not. Data is just data. The true power of the C++ Object
Model is the object's behaviour and extensability.
Depends on how you want to view it. Sure, class = data+behavior, but I
wasn't talking about fundamental "definition s" but rather usage of
class objects, one aspect of which is manipulating the data directly
for, say for example, in a memory management scenario. That one has to
be severely restricted from using OO concepts without affecting the
representation in memory of the data portion, is unfortunate. I'm not
sure how much could be or could have been done to make the situation
better. For example, was it really necessary to disallow constructors
with initialization lists? I mean, no vptr needed for that!
>
What I don't like about the C++ object model: that most OO features
are not
available for class object design without loss of POD-ness.
So, I'm more than leaning toward "bad" because of the limitations and
that the language doesn't distinguish what is of very key importance.
How do you feel about the object model?

Objects sometimes need to do more than just store data. Behaviour is
nice to have. That inludes 'behaviour' at construction and expected
behaviours through a secure interface. It makes maintaining and
extending code easy, simple.

Write a program that uses some given polymorphic type hierarchy and
have your customer *invent / add some new improved class of his own.
The customer's new class works with your original program without
changing a single line of code (except maybe an include).

You can't do that with PODs only. Whats nice is you can bend the
language to choose what path you prefer.
That's only one usage scenario though. A LOT of usefull stuff can be
built without heavy class objects "weighed down" with vptrs and other
stuff. I of course am referring to that other scenario so talking
about the scenario you mentioned isn't relevant.

Nov 3 '08 #8
On Nov 3, 8:44*pm, tonytech08 <tonytec...@gma il.comwrote:
On Nov 1, 3:32*am, James Kanze <james.ka...@gm ail.comwrote:
On Nov 1, 4:02*am, tonytech08 <tonytec...@gma il.comwrote:
What I like about the C++ object model: that the data
portion of the class IS the object (dereferencing an
object gets you the data of a POD object).
No it doesn't.

class SomePODClass
{
* public:
* *int first_int;
* *int second_int;
* *void Func1(){}
};
SomePODClass X;
int first_int_in_ob j = *(int*)&X; // this is not pretty, but true
But it's only true for POD types, and only because of
constraints of C compatiblity. The data portion of the class
isn't the object in general.
What I don't like about the C++ object model: that most OO
features are not available for class object design without
loss of POD-ness.
So, I'm more than leaning toward "bad" because of the
limitations and that the language doesn't distinguish what
is of very key importance. *How do you feel about the
object model?
The "object model" in the C++ standard is very low-level.
Intentionally. *It is designed for you to build on. *The
object model of the classes you write is for you to design.
*It can be more OO than many other languages (e.g. Java or
C#), when that's appropriate. *Just as it can drop the OO
model completely when that's appropriate (e.g value
objects). *The essential point of C++ is that it doesn't
impose any application level object model; it lets you use
whatever is appropriate.
It does restrict usage of OO concepts unless one jettisons the
"value object" concept, which is unfortunate (and
unnecessary?).
It restricts the use of OO concepts to classes designed to be
used with OO concepts. It supports non OO concepts as well,
which are more appropriate in some cases.

--
James Kanze (GABI Software) email:ja******* **@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Nov 3 '08 #9
On Nov 3, 4:25*pm, James Kanze <james.ka...@gm ail.comwrote:
On Nov 3, 8:44*pm, tonytech08 <tonytec...@gma il.comwrote:


On Nov 1, 3:32*am, James Kanze <james.ka...@gm ail.comwrote:
On Nov 1, 4:02*am, tonytech08 <tonytec...@gma il.comwrote:
What I like about the C++ object model: that the data
portion of the class IS the object (dereferencing an
object gets you the data of a POD object).
No it doesn't.
class SomePODClass
{
* public:
* *int first_int;
* *int second_int;
* *void Func1(){}
};
SomePODClass X;
int first_int_in_ob j = *(int*)&X; // this is not pretty, but true

But it's only true for POD types,
Well that's why I added the parenthetical part in my original post: to
make clear I was referring to what I like about the C++ model and wish
it wouldn't get abberated so quickly by changing the memory
representation of the data portion. 'POD' was very key for my thought,
though could have been worded better to show that I guess.
and only because of
constraints of C compatiblity. *The data portion of the class
isn't the object in general.
I tend to think of the data portion (noun, vs. behavior=verb) as "the
thing" because that's what get's operated on and maybe even directly
manipulated. I'm not willing to go to a paradigm that only allows data
manipulation via class methods. That is way to high level and
constraining for me. A lot of people complain about C and C++ because
of the memory management, but for me, that's one of the things I like
about it! GC breaks MY programming model for example.
>
What I don't like about the C++ object model: that most OO
features are not available for class object design without
loss of POD-ness.
So, I'm more than leaning toward "bad" because of the
limitations and that the language doesn't distinguish what
is of very key importance. *How do you feel about the
object model?
The "object model" in the C++ standard is very low-level.
Intentionally. *It is designed for you to build on. *The
object model of the classes you write is for you to design.
*It can be more OO than many other languages (e.g. Java or
C#), when that's appropriate. *Just as it can drop the OO
model completely when that's appropriate (e.g value
objects). *The essential point of C++ is that it doesn't
impose any application level object model; it lets you use
whatever is appropriate.
It does restrict usage of OO concepts unless one jettisons the
"value object" concept, which is unfortunate (and
unnecessary?).

It restricts the use of OO concepts to classes designed to be
used with OO concepts. *
Not really, since one can have POD classes with methods, just not
CERTAIN methods (you are suggesting that "classes designed to be used
with OO concepts" are those heavyweight classes that break PODness,
right?). You seem to be saying that POD classes are not supported or
at least not encouraged. That would be a real downer if true. I'd like
to see more support in the langauge for POD classes. I don't know how
much can be implemented before it becomes impossible. Certainly
initializing constructors can be had? Polymorphism not, but only NOT
because of the way C++ implements it?
It supports non OO concepts as well,
which are more appropriate in some cases.

Nov 3 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
2431
by: R | last post by:
Hello everybody. I'm writing my own Content System in PHP5. I've written so far main classes for handling DB connections, XML, XForms and Sessions. But I've got problem with one thing - it's not even relative with implementation - I'm looking for a smart solution My present system works like this:
34
7102
by: yensao | last post by:
Hi, I have a hard time to understand difference and similarities between Relational database model and the Object-Oriented model. Can somebody help me with this? Thank you in advance. Yensao
21
2294
by: Jure Sah | last post by:
Hello, I have been promising an object orientated ASM IDE for a while now. Trying to make the best of what is already here, I have made a compiler, that will parse XML code and output ASM files. The program still needs an internet interface (will do that tommorow), but here is an example of what the code looks like, to wet your appetite: <?xml version="1.0"?>
16
3032
by: D Witherspoon | last post by:
I am developing a Windows Forms application in VB.NET that will use .NET remoting to access the data tier classes. A very simple way I have come up with is by creating typed (.xsd) datasets. For example dsParts.xsd and including that in the data tier. I then will create a class that looks like this Public Class CPart Inherits dsParts
34
3198
by: Pmb | last post by:
Hi. I'm new to this group. I'm refreshing/learning C++ and am starting to learn Object Oriented Programming (OOP). In discussing this with people I came up short as to what the benefits of OOP are. For example: As I understand it, OOP has its main benefit in software reuse. Thus one develops a software library of classes and this cuts down the overhead of reinventing the wheel. Someone might say that this can be done with structured...
8
3510
by: al.cpwn | last post by:
Which sections of the 2003 standard should I study to understand the object model? I am looking to find information similar to that in Stanley B. Lippman's book, "Inside the C++ Object Model"
206
8345
by: WaterWalk | last post by:
I've just read an article "Building Robust System" by Gerald Jay Sussman. The article is here: http://swiss.csail.mit.edu/classes/symbolic/spring07/readings/robust-systems.pdf In it there is a footprint which says: "Indeed, one often hears arguments against building exibility into an engineered sys- tem. For example, in the philosophy of the computer language Python it is claimed: \There should be one|and preferably only one|obvious...
0
1526
by: topmind | last post by:
siddharthkh...@hotmail.com wrote: Good luck. The behavior and conventions of web versus fat-client (or paper-oriented) reports are so different that making a generic anything that serves both of them without rewrite is a big challenge unless you pick a lowest common denominator, which limits things. If you have more than about 50 and they will be changing often by different people, consider tracking report configuration settings in a
0
1157
by: =?Utf-8?B?SmVhbi1GcmFuY29pcyBCcmV0b24=?= | last post by:
"siddharthkhare@hotmail.com" wrote: The context is important in this kind of design concern : I assume there's a lot of user and that application will evolve to add richer functionality. My first concern would be to separate the business logic code from data contener : the new code would look like that : LineItemBusinessComponent.Delete(LineItemBusinessEntity) Exposing CRUD component isn't the best thing to do because your presentation...
0
8923
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9285
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9203
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9151
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8155
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6025
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4529
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2165
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.