V
V
Vlad45732019-07-09 11:13:11
Graphic arts
Vlad4573, 2019-07-09 11:13:11

How to choose the structure of a 2d program?

Need advice from programmers. I started writing a program in c#.
The essence of the program is to draw up a diagram of a pneumatic system from elements.
Set the characteristics of the elements and the program will calculate the output parameters.
In the process of writing, I realized that I no longer had a program, but a lump of pasta.
I read about patterns. I tried some, but it didn't get much better.
Can anyone tell me if there are any typical program structures with a clear separation of graphic or non-graphic parts?
Or in such cases, you need to use the "engine" (I learned little about them).
Maybe somewhere you can find similar projects.
If anyone has information on the literature on this issue, I would be very grateful if you share it.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Adamos, 2019-07-09
@Adamos

I created a class of objects, (for example, a heat exchanger) it has properties based on which the calculation is made (for example, efficiency). And the properties on the basis of which the rendering occurs (for example, the position when displaying (x, y coordinates)) I'm not sure what I did correctly.

Create an abstract class "calculation element" with a common interface for all elements. Create a base class "graphic element" with a common drawing interface.
Create a class "drawing element" whose properties are coordinates and links to the calculation element and the corresponding graphic element.
The renderer has an array of drawing elements, bypasses them and draws one by one, calling the necessary functions of the graphic element, which can apply to the calculation element for parameters. It is important that the calculation element does not know anything about any drawing, and the graphic element knows no more than it needs to draw its picture.
All calculation and drawing elements are presented as classes-heirs of those abstract classes and are processed uniformly - the renderer does not see any differences between them at all, they are removed to the graphic element class.
More or less like this...

T
tsarevfs, 2019-07-09
@tsarevfs

Try to describe what objects your program consists of.
Draw at least some diagram from your classes (I used draw.io): It's better
to use UML, but it's not necessary.
Think about user scenarios:
How will you receive input?
Is there a hierarchy of elements (elements from other elements)?
After that, it will be possible to somehow look and improve some parts.

A
Alexander Skusnov, 2019-07-09
@AlexSku

It seems that Scada + has already been made in C #
There, however, there are no calculations, there is a graphical interface and communication with controllers.
History of how it was designed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question