Proper code/class layout diagram before writing any code.

A place to discuss software and code that isn't automotive related. Free and open source preferred but not compulsory.
Post Reply
User avatar
SleepyKeys
LQFP144 - On Top Of The Game
Posts: 549
Joined: Mon Feb 11, 2008 10:52 pm
Location: Arizona
Contact:

Proper code/class layout diagram before writing any code.

Post by SleepyKeys »

I would like to refine this diagram/note so that I can use it to create a new loader that utilizes a "comms suite". I used dia to create what I like to call a proposed class sheet.
Image

I don’t necessarily want to create all these classes at once, some have higher priorities than others. I also don’t want to work myself back into a corner making it too much work to add/change some of the underlying classes.

I will use loading an s19 file from the GUI to the Device to iterate though the diagram.

1. the user loads the application creating within it an instance of the Communications/Operations class.

2. the user selects properer comms method and protocol(rs232 and serial monitor)- this could be the default

3. The user clicks connect and depending on their settings the Communications/Operations initializes within it self the a Data-I/0 class with the specified parameters. In this example Data-I/O will use the serial monitor over RS232.

4. The user clicks load and chooses an s19 file from the file menu.

5. The Communications/Operations class receives a file name parameter and a "load" command after which it reads out the file and gets/checks the payload data via the functions in this s19 lib.

6. CO class feeds data to the Data-I/O object who checks for proper acks etc depending on the transport protocol and set options.

7. After the operation has completed the user has the option to reset the device state and disconnect etc.

I think what would be a big help is to define what each part should and should not do before writing any new code.

-sean
You snooze, you lose!
User avatar
Fred
Moderator
Posts: 15431
Joined: Tue Jan 15, 2008 2:31 pm
Location: Home sweet home!
Contact:

Re: Proper code/class layout diagram before writing any code

Post by Fred »

I've had a bunch of graphviz tabs open in my browser for months, so I'm dumping them here for the time being.

Gallery of examples: http://graphviz.org/Gallery.php
Live online engine: http://graphviz-dev.appspot.com/

The balance were from the gallery page, trying to choose a style.

Fred.
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
User avatar
SleepyKeys
LQFP144 - On Top Of The Game
Posts: 549
Joined: Mon Feb 11, 2008 10:52 pm
Location: Arizona
Contact:

Re: Proper code/class layout diagram before writing any code

Post by SleepyKeys »

awesome thx!
You snooze, you lose!
MotoFab
1N4001 - Signed up
Posts: 307
Joined: Thu May 29, 2008 1:23 am
Location: Long Beach CA

Re: Proper code/class layout diagram before writing any code

Post by MotoFab »

Thanks for the link!
User avatar
Fred
Moderator
Posts: 15431
Joined: Tue Jan 15, 2008 2:31 pm
Location: Home sweet home!
Contact:

Re: Proper code/class layout diagram before writing any code

Post by Fred »

http://plantuml.sourceforge.net/activity.html

Check out the other types of diagram that they offer. It USES graphviz, so it IS a front end to graphviz, just a text based one. Nice stuff.

Code: Select all

@startuml EMS.Purchasing.png
title EMS Purchasing Flow Chart

(*) --> "Looking for an EMS"

if "FreeEMS?" then
  -->[yes] "Run engine beautifully"
  --> "Have money left over for..."
  if "Hungry?" then
    -->[yes] "Pizza!"
    --> "Be very happy!"
  else
    -->[no] "Beer!"
    --> "Be very happy!"
  endif
  --> "Laugh at MS user"
  --> "Still be very happy!"
  --> "Buy second project car"
  --> "Be happier than ever"
  --> "Retire early"
  --> (*)
else
  -->[no] "Which EMS then?"
  if "Rich?" then
    -->[yes] "Motec"
    --> "Not anymore!"
    --> "Run engine well"
    --> "Put on smug face"
    --> "Desire customisation"
  else
    -->[no] "Get a Link"
    --> "Bros like it"
    --> "Run engine ok"
    --> "Bros get one too"
    --> "Desire customisation"
    --> "Be very sad"
  else
    -->[poor] "MegaSquirt"
    --> "Laugh at Motec user"
    --> "Load new code, again"
    --> "Melt coils"
    --> "Replace coils"
    --> "Bad PID idle"
    --> "Use open loop"
    --> "DB37 Problem"
    --> "Melt piston"
    --> "Be very sad"
  endif
  --> "Be very broke"
  --> (*)
endif

@enduml
Build like so:

Code: Select all

fred@cheetah:~$ java -jar plantuml.jar EMS.Purchasing.plantuml 
fred@cheetah:~$ eog EMS.Purchasing.png
Image

I hope you have a sense of humour!

Fred.
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
User avatar
EssEss
LQFP112 - Up with the play
Posts: 244
Joined: Thu Sep 10, 2009 9:23 am
Location: Dayton, OH

Re: Proper code/class layout diagram before writing any code

Post by EssEss »

I use this a lot for diagramming state machines: http://www.umlet.com
User avatar
Fred
Moderator
Posts: 15431
Joined: Tue Jan 15, 2008 2:31 pm
Location: Home sweet home!
Contact:

Re: Proper code/class layout diagram before writing any code

Post by Fred »

Sean and I were talking the other day and agreed that he should do a meta summary of the parts required to build an awesome loader. I didn't want to lose what we had discussed into the depths of time, so here it is!

The issue tracker can act as a guide about needed glue logic and the current spec too. Plus, you know the sort of chunks it has in it to do the work, stuff like:
  • low level serial
  • sm commands
  • fw commands
  • s19 parsing/reading/writing
  • etc
And the glue:
  • micro sequences
  • combos of sequences
  • logic on how to handle different states
Once you've thoroughly done that, with feedback, we can talk about how to assemble the pieces :-)

Fred.
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
User avatar
SleepyKeys
LQFP144 - On Top Of The Game
Posts: 549
Joined: Mon Feb 11, 2008 10:52 pm
Location: Arizona
Contact:

Re: Proper code/class layout diagram before writing any code

Post by SleepyKeys »

Selecting previously deselected package umlet.
Unpacking umlet (from .../archives/umlet_10.4-1_all.deb) ...
Processing triggers for menu ...
Processing triggers for man-db ...
Setting up libecj-java (3.5.1-3) ...
Setting up libitext-java (2.1.7-2) ...
Setting up libjlibeps-java (0.1+2-1) ...
Setting up umlet (10.4-1) ...
Processing triggers for menu ...
You snooze, you lose!
Post Reply