Hi carl_tawn,
Attached is a conceptual class design in PNG format with a few examples on how I intend to use and interace this object.
If you require more information, please let me know.
Main Topics
Browse All TopicsHi,
I am looking for is mainly some guidance in this subject rather than solving a specific problem presented here. If the examples I have given can be solved, this should help me on my development futher.
I am trying to develop is a self contained object which contains all the properties and classes using inheritance, polymorphism and interfaces. However, I am running into difficulty setting the object up without causing errors and not being able to have the expected visibilty that I require.
The example I have been working on is based on a Car object, and has various objects including a couple of Doors and a Engine with various properties, methods and attributes.
What I'd like to be able to do with this Car object is a number of things:
1. Self Contained
The Door and Engine cannot exist on their own without the Car object. Additionality, the Door Handle cannot exist without a Door. These objects should be visible when using the IntelliSense when coding the Class.
2. Reusability
I have created a Dimension Class and would like to reuse and apply the class to any current/future object created at a later stage which may require these properties. However, if the property is not required. For example, a Windscreen Wiper class requires only a length field, so I can hide the Height and Width properties when creating this object.
3. Interfaces
I have limited the interface of the Class to only what I have provided through the various properties and methods using Interfaces to ensure objects are being using in the right way and call at the level in the object. For Example, preventing typing source code with a reclusive call like Car.Door.Door.Door.... or being able to call something that doesn't make sense Car.Engine.DoorHandle.
4. Visiblity
If I am in a nested class, I should be able to read, but not update any properties of the parent class which I am currently accessing. For example, If I am in the Engine class, I'd like to still be able to see the Year at the Car Class level.
5. Methods
I would also like to how to call a method from a class to another class object either or a nested class inside. For example, If I have a Door Handle with a method called Pull(), this function calls a function in the Door object which Opens the door. Similarility, If I have a Fuel Cap Door, the only method aviable would be Push() which opens the fuel cap "Door".
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: carl_tawnPosted on 2009-09-11 at 09:26:39ID: 25311088
Ok, taking a very broad view of what you are doing, there are a couple of immediate things that, from an OO perspective, don't make a lot of sense.
1) You have CEngine inheriting from Car, which is a little odd. Think of inheritance as an "is a" relationship. You are currently saying that an Engine "is a" Car, which doesn't make sense. More logically a Car "has a" (containment/aggregation) Engine rather than being one.
2) Having the IEngine interface seems a little unnecessary. Engines (generally speaking, as far as cars go at least) work in pretty much the same way. So in this scenario it would make more sense from a design perspective to create a base Engine class that you can inherit from if, at some point, you need a more specialised engine type.