How to make flow chart and write code for actual idea ?

bogosort

Joined Sep 24, 2011
678
On the subject of flowcharts, I'll offer a different take. Flowcharts are just another form of documentation, and by no means are they necessarily the first step. For complicated projects, as an intermediate step, I'll sometimes draw a flowchart to help me clarify (to myself or others) how a particular subsystem works/should work, but typically the flowchart, if any, is created at the end, once the software has been written.

Personally, I've never found it helpful to start with a flowchart. I know a lot of developers swear by them, but we humans are a varied lot and there is no one-size-fits-all approach to software development. I prefer to start with an English-language description of the problem, the desired outcomes, and the constraints. Depending on the project, this can be an informal "thinking out loud", or a full software requirements specification (SRS). Then, I iterate (in English) on how it can be solved. Very high-level flowcharts can be useful here, as can writing a basic user manual or API specification. Solution ideas are transformed into implementation ideas, converging to a development plan. Again, this can be an informal set of notes, or a full-on software design document (SDD). Once the relevant stakeholders agree that the SDD satisfies the SRS, coding begins.

In any case, the OP seems to be asking how to use C++ classes. Are flowcharts really the best path for this goal?
 

djsfantasi

Joined Apr 11, 2010
7,911
The difficulty here is that the TS isn’t trying to achieve ANYTHING with code.
I want to use vehicle example to learn coding for encapsulation, inheritance and polymorphism
Or he doesn’t know what he’s trying to achieve. All of his focus Is on learning OOP techniques but he doesn’t have a problem statement to which he can code.

I know he’s made a comment previously about not wanting to read a tutorial because he believed writing his own code from scratch is a better way to learn.

As my gf would say, yeah no! If you don’t have the basics, haven’t seen other examples and understood other’s code, you’ll spend a lot of time spinning your wheels. As you seem to be doing.

This link has a lot of short code examples for C++ OOP. Skim through these pages looking for their code examples.

(Note, I didn’t mention a flowchart once. I always wrote out a program’s steps in natural language (English), sometimes in pseudo-code. Then when I was required to, I drew a flowchart from it)
 

BobTPH

Joined Jun 5, 2013
4,024
Let's look at how people write a recipe.

Typically, there is a list of ingredients at the top.

This is followed by a list of steps one performs using the ingredients, which result in the finished dish.

A flowchart is a list of steps, not a list of ingredients. There is nothing to write a flowchart for in what you have described so far.

From what you have described so far, the classes and the relationships of them, what you might want to write what is called a class diagram.

Here is a Wiki Article on the subject.

Class Diagram

Bob
 

KeithWalker

Joined Jul 10, 2017
2,032
You are taking me to different discussion. My original question was how to write code for real time idea.

Code is written to produce a program. A program is a device which accepts data in some form, modifies it and uses the result to do something.
You can not write code for a real time idea until you have defined the idea. To define it, you must define what goes in, what happens to what goes in and how the result is used to give the required output.
An OOP is just a tool to write programs. If all you are trying to do is understand how the OOP works, you will never do it by defining variables in another language.
To get to understand how the OOP works, take a simple example program written in the OOP and try to follow it's flow. Try to see how some objects are defined to hold specific data, some are defined to modify the data, some are defined to interface with an operator and some to control the flow and timing of the process. When you have done that, try writing a very simple program in the OOP. I suggest a program that accepts a numeric input from an operator, modifies it (like multiplying it by two) and displays the result in a specified format. When you have achieved that, you can elaborate on it. For example, the program could check the value of the input and use that decide what colour to display the result in, etc.
 
Last edited:
Top