C++ philosophy

Can someone cite a site (sorry) giving some high-level design examples of how to "think about" good design when creating components and classes for a system?

Would especially be interested in one giving examples of embedded systems in which one or more of the components may represent a piece of hardware (sensor bank, motor controller, etc). My system will also have a web presence and will act as a server and client for HTTP traffic.

I'm just trying to figure out how C++ programmers delineate the different parts of a system into classes to make it extensible and easy to understand.

My background is hardware design (VHDL/Verilog for FPGAs an ASICs), not a professional programmer, so this way of thinking is a little different for me.

Thanks very much for your suggestions.
Kevin Smith
It's a significant step to go from extremely procedural languages such as Verilog to OOP.

In OOP we may define a button as a class, we may also define edit boxes, radio buttons, and check boxes as classes. We may make our own dialogue window. The dialogue window will inherit from a base dialogue so that it has all of the functionality of a normal dialogue. We will also make instances of the edit boxes, buttons etc as members of our dialogue.

For your applications, You may want to do determine what types of classes you'll need and find a library for it. If you are doing HTTP traffic, you'll want something that will work with your network (perhaps a socket class) which will give you a high-level interface for communicating over a network. You'll also want some sort of parser to understand the HTTP protocol and translate it into something you can understand. You'll also want some classes to store the information that you've just parsed and perform whatever operations you need on that data.
You may want to get answers to the following questions (and more):
- Who is interacting with your system? (Admin, different type of users, ...)
- Describe those interactions.
- You may identify different objects, like admin, sensor, actors, timers, ... Classify them.
- Those objects interact with each other. The timer may send a timeout message to a sensor. The sensor then may send a measured value to some controling object. The controler may in turn calculate some new output value to be sent to an actor object.......... Describe those interactions and the objects behaviour. Minimize an objects responsibility! F.e. the controler mentioned shouldn't know how to handle sensor hardware. This will be the responsibility of sensor objects only. Nor should it know the details how to communicate with users.
- Properly yo'll need most of your time to find out error conditions and how to handle them.

Nice language to express all your analyses is UML. There exists several commercial and free tools to edit UML and to transform UML into some programing languages.

Finally classifications may be expressed in C++ as C++ classes. Objects are instances of those classes. Their attributes are C++ class member variables. Communication is expressed by sending messages to an object. You may think of sending a messages as of a function call addresses to an object.
Topic archived. No new replies allowed.