SpiderBasic code structure and style

Everything else that doesn't fall into one of the other categories.
User avatar
SparrowhawkMMU
Posts: 281
Joined: Wed Aug 19, 2015 3:02 pm
Location: United Kingdom

SpiderBasic code structure and style

Post by SparrowhawkMMU »

Out of curiosity, I built a small code analysis tool in PHP to scan my SpiderBasic files and analyse my code for my current project. The results were not entirely surprising to me - I comment a lot and use whitespace a lot too in pretty much all languages I've ever used (except RPG/400 on mainframes that enforces a rigid code layout structure - but that was years ago :) ):

Code: Select all

$ php sb_count_code_lines.php /data/fse_repos/fse-ui-spiderbasic/

SpiderBasic Code Line Analyzser v1.0.0
Scanning files in: /data/fse_repos/fse-ui-spiderbasic/

Files processed: .... 22
Smallest file: ...... 0.6KB
Largest file:  ...... 32.6KB

Total lines: ........ 7466
Code lines: ......... 4792 (64.18 %)
Whitespace lines: ... 2071 (27.74 %)
Comment lines: ...... 603 (8.08 %)

Modules: ............ 19
Procedures: ......... 167
Structures: ......... 26
Enumerations: ....... 33
Maps: ............... 26

Remote API Calls: ... 31

Finished
I have almost no global code except for a few helper procs, system constants (eg version) and a global Registry map for eg auth token handling: all windows and business logic resides in modules with the bear minimum exposed to the public scope (eg Windows have Open(), Close() , Disable() and SetActive() public methods (with some exceptions), and a few have a SetxxxxData() style one too when a child window passes values back.

Actually my windows are too tightly coupled to my business logic a the moment - if I have time I would like to make all my business logic in non Windows modules, but for now they are intertwined. A legacy of blundering my way through learning SpiderBasic!

It would be interesting to know how others tend to code SB - how do you tend to structure your own code?
User avatar
SparrowhawkMMU
Posts: 281
Joined: Wed Aug 19, 2015 3:02 pm
Location: United Kingdom

Re: SpiderBasic code structure and style

Post by SparrowhawkMMU »

Interestingly, these percentages are very close to the (smaller) SpiderBasic project that I have already deployed here at work:

Code: Select all

SpiderBasic Code Line Analyzser v1.0.0
Scanning files in: /data/vault/vault-ui-spiderbasic/

Files processed: .... 18
Smallest file: ...... 1KB
Largest file:  ...... 64.1KB

Total lines: ........ 4743
Code lines: ......... 3015 (63.57 %)
Whitespace lines: ... 1273 (26.84 %)
Comment lines: ...... 455 (9.59 %)

Modules: ............ 16
Procedures: ......... 104
Structures: ......... 15
Enumerations: ....... 28
Maps: ............... 10

Remote API Calls: ... 8

Finished
So I guess my coding style could be described as... consistent!! :lol:
Fred
Site Admin
Posts: 1506
Joined: Mon Feb 24, 2014 10:51 am

Re: SpiderBasic code structure and style

Post by Fred »

Interesting :)
Post Reply