Re: How to go about describing my software with a component diagram?

Liste des GroupesRevenir à cl python 
Sujet : Re: How to go about describing my software with a component diagram?
De : ram (at) *nospam* zedat.fu-berlin.de (Stefan Ram)
Groupes : comp.lang.python
Date : 24. Dec 2024, 18:35:32
Autres entêtes
Organisation : Stefan Ram
Message-ID : <diagram-20241224183440@ram.dialup.fu-berlin.de>
References : 1 2
marc nicole <mk1853387@gmail.com> wrote or quoted:
Could it be improved for better description and readability?

  ASCII art is very readable in Usenet.

  With Unicode:


┌─────────────────┐      ┌─────────────────┐
│    Component A  │      │    Component B  │
│                 │      │                 │
│  ┌───────────┐  │      │  ┌───────────┐  │
│  │ Interface │<>┼──────┼─>│ Interface │  │
│  └───────────┘  │      │  └───────────┘  │
│                 │      │                 │
└─────────────────┘      └─────────────────┘
         │                        │
         │                        │
         │                        │
         ▼                        ▼
┌─────────────────┐      ┌─────────────────┐
│    Component C  │      │    Component D  │
│                 │      │                 │
│  ┌───────────┐  │      │  ┌───────────┐  │
│  │ Interface │<>┼──────┼─>│ Interface │  │
│  └───────────┘  │      │  └───────────┘  │
│                 │      │                 │
└─────────────────┘      └─────────────────┘

  With plain ASCII:

.----------------.      .----------------.
|   Component A  |      |   Component B  |
|                |      |                |
|  .-----------. |      |  .-----------. |
|  | Interface |<+------+->| Interface | |
|  '-----------' |      |  '-----------' |
|                |      |                |
'----------------'      '----------------'
         |                       |
         |                       |
         |                       |
         v                       v
.----------------.      .----------------.
|   Component C  |      |   Component D  |
|                |      |                |
|  .-----------. |      |  .-----------. |
|  | Interface |<+------+->| Interface | |
|  '-----------' |      |  '-----------' |
|                |      |                |
'----------------'      '----------------'

  With turtles (there are some errors, but one get's the idea!):

import turtle

def draw_box(t, width, height):
    for _ in range(2):
        t.forward(width)
        t.right(90)
        t.forward(height)
        t.right(90)

def draw_component(t, x, y, label):
    t.penup()
    t.goto(x, y)
    t.pendown()
    draw_box(t, 160, 100)
   
    # Draw interface
    t.penup()
    t.goto(x + 20, y - 40)
    t.pendown()
    draw_box(t, 120, 30)
   
    # Write component label
    t.penup()
    t.goto(x + 80, y + 70)
    t.write(label, align="center", font=("Arial", 12, "normal"))

def draw_arrow(t, start_x, start_y, end_x, end_y):
    t.penup()
    t.goto(start_x, start_y)
    t.pendown()
    t.goto(end_x, end_y)
   
    # Draw arrowhead
    t.setheading(t.towards(end_x, end_y))
    t.right(150)
    t.forward(10)
    t.backward(10)
    t.left(300)
    t.forward(10)

def main():
    screen = turtle.Screen()
    screen.setup(800, 600)
    screen.title("Component Diagram")
   
    t = turtle.Turtle()
    t.speed(0)  # Fastest drawing speed
   
    # Draw components
    draw_component(t, -200, 150, "Component A")
    draw_component(t, 100, 150, "Component B")
    draw_component(t, -200, -100, "Component C")
    draw_component(t, 100, -100, "Component D")
   
    # Draw arrows
    draw_arrow(t, -40, 125, 100, 125)
    draw_arrow(t, -120, 50, -120, -100)
    draw_arrow(t, 180, 50, 180, -100)
    draw_arrow(t, -40, -125, 100, -125)
   
    t.hideturtle()
    screen.exitonclick()

if __name__ == "__main__":
    main()







Date Sujet#  Auteur
24 Dec 24 * How to go about describing my software with a component diagram?2marc nicole
24 Dec 24 `- Re: How to go about describing my software with a component diagram?1Stefan Ram

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal