473,382 Members | 1,447 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

OOP: inheritance of a base class

Nutshell: I want my base class to have all the necessary properties while my derived classes have fewer properties.

My base class is Story. It contains all metadata associated with a story exposed as properties: ID, Date, Name, Text, Status, etc.

My derived class(es) are restricted versions of the base class, so :
BareBonesStory contains only ID, Name, Text and
StoryHeader contains only ID, First10CharsText.

I don't seem to be able to arrange this with any combination of overrides.


Why am I doing this?
1] I'm using a 3rd party app (NewtonSoft.JSON) that takes a class - and all public properties it sees in that class - and returns it as a JSON formatted string (bascially an XML string). So my class has to only expose the properties I want in the string, not everything.


2] I could design it the other way around - with Header as the base class and Story as the dreived class, but that makes little sense. It means I'd have to edit two classes everytime I want to edit my story class.

Ideas?
May 31 '07 #1
1 1499
pbmods
5,821 Expert 4TB
BareBonesStory sounds more like a base class, with Story being the derived class.

StoryHeader could be its own class; perhaps a Story object should have a member StoryHeader.
Jun 5 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

56
by: Xah Lee | last post by:
What are OOP's Jargons and Complexities Xah Lee, 20050128 The Rise of Classes, Methods, Objects In computer languages, often a function definition looks like this: subroutine f (x1, x2, ...)...
6
by: Bharat Sharma | last post by:
Hello All Wise Persons. I don't know wheather my question is okay or i need to revisit my OOP fundamentals. AS we have read till now in OOP that Every Parent Class can see and execute the...
19
by: Kamilche | last post by:
I have looked at many object-oriented programming frameworks out there for C. Though the ideas presented are intriguing, and I've used some of them in my own work, they all suffered some drawback...
16
by: Manuel | last post by:
Please, excuse me for starting this discussion. I'm not a troll, and I love the OOP architecture. However I'm a C++ newbie, and sometimes it's hard for me to fully understand the improvement of...
8
by: Michael | last post by:
Hi, I think my problem deals with class casting and inheritance. I want to deal with various Audio Formats, reading into memory for modification, working with it (done by different classes),...
7
by: jason | last post by:
In the microsoft starter kit Time Tracker application, the data access layer code consist of three cs files. DataAccessHelper.cs DataAcess.cs SQLDataAccessLayer.cs DataAcccessHelper appears...
8
by: Techno_Dex | last post by:
I have base classes defined in a hierarchy structure which all have XMLElementAttributes on them and marked as Serializable. I then have classes which inherit from the base classes and hide some...
5
by: a | last post by:
Hi, I have an oop inheritance graph problem. What is the difference betweent the following 2 inheritance graph? How does the C++ solve the naming conflict problem for multiple inheritance...
65
by: Chris Carlen | last post by:
Hi: From what I've read of OOP, I don't get it. I have also found some articles profoundly critical of OOP. I tend to relate to these articles. However, those articles were no more objective...
7
by: Immortal Nephi | last post by:
I have an idea how to design an object in a better way. I would like to give you my thought example. Please let me know what you think if it is best object design. Please recommend me any book...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.