Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explore refactoring code base's formatting to improve readability #490

Closed
kensoh opened this issue Jul 8, 2019 · 4 comments
Closed

Explore refactoring code base's formatting to improve readability #490

kensoh opened this issue Jul 8, 2019 · 4 comments
Labels

Comments

@kensoh
Copy link
Member

kensoh commented Jul 8, 2019

Most of TagUI's code was written while I was on a year plus sabbatical, mostly in Eastern Europe. There is no external monitor, so on my Vim editor, I pack lines of code tightly to maximise screen real estate. This helps to reduce development time.

Though the project is unlikely to often have contributions and PRs from users, improving the formatting would make it easier for someone else to maintain the codebase at AI Singapore in future. Raising an issue to look into that.

Python code is already formatted due to its inherent indentation formatting. Some of the newer code are already formatted nicely. The bulk of the code re-formatting would likely be in tagui_parse.php and tagui_header.js.

For post-change, besides testing the translation test cases in positive_test, there is a need to validate further to ensure no regression in functionality.

@kensoh kensoh added the feature label Jul 8, 2019
@kensoh
Copy link
Member Author

kensoh commented Jul 11, 2019

List of TagUI source files with easy-to-read formatting - 43/46 (93% of files)

  • 8 source files in chrome folder
  • 1 file in languages folder
  • 0 file in media folder
  • 14 files in samples folder
  • 1 file in tagui.sikuli
  • 1 file in tagui_py
  • 1 file in tagui_r
  • 1 file in test
  • end_processes
  • end_processes.cmd
  • erina
  • erina.cmd
  • sleep.php
  • transpose.php
  • tagui
  • tagui.cmd
  • tagui_chrome.php
  • tagui_config.txt
  • tagui_crontab
  • tagui_footer.js
  • tagui_helper.php
  • tagui_report.php
  • tagui_runner.php
  • tagui_service.php

List of TagUI source files with hard-to-read formatting - 3/46 (7% of files)

  • tagui_header.js
  • tagui_parse.php
  • translate.php

@kensoh
Copy link
Member Author

kensoh commented Jul 11, 2019

More details at issue #490. Only 7% of files are not formatted for easy reading. It makes no sense to refactor these 7% (3 files tagui_header.js, tagui_parse.php, translate.php) at a risk of hurting existing compatibility and scripts. Solution is to provide beautified snapshots of these 3 files and add link to these snapshots at top of the files, so that any developer who wishes to view or edit the source code can see the beautified version.

As TagUI is an engine that tries to translate human languages into working JavaScript code that works with its various components, it has mash-up code using string manipulations and replacements in order to get some things done. Simply using a beautifier may break some parts of the engine that affects some existing users' scripts. Thus it is better to provide beautified versions for the 7% of files that is hard to read, than try to refactor at risk of breaking existing users' scripts.

kensoh added a commit to tebelorg/TagUI that referenced this issue Jul 11, 2019
More details at issue aisingapore#490. Only 7% of files are not formatted for easy reading. It makes no sense to refactor these 7% (3 files tagui_header.js, tagui_parse.php, translate.php) at a risk of hurting existing compatibility and scripts. Solution is to provide beautified snapshots of these 3 files and add link to these snapshots at top of the files, so that any developer who wishes to view or edit the source code can see the beautified version.

As TagUI is an engine that tries to translate human languages into working JavaScript code that works with its various components, it has mash-up code using string manipulations and replacements in order to get some things done. Simply using a beautifier may break some parts of the engine that affects some existing users' scripts. Thus it is better to provide beautified versions for the 3% of files that is hard to read, then try to refactor at risk of breaking existing users' scripts.
kensoh added a commit that referenced this issue Jul 11, 2019
More details at issue #490. Only 7% of files are not formatted for easy reading. It makes no sense to refactor these 7% (3 files tagui_header.js, tagui_parse.php, translate.php) at a risk of hurting existing compatibility and scripts. Solution is to provide beautified snapshots of these 3 files and add link to these snapshots at top of the files, so that any developer who wishes to view or edit the source code can see the beautified version.

As TagUI is an engine that tries to translate human languages into working JavaScript code that works with its various components, it has mash-up code using string manipulations and replacements in order to get some things done. Simply using a beautifier may break some parts of the engine that affects some existing users' scripts. Thus it is better to provide beautified versions for the 3% of files that is hard to read, then try to refactor at risk of breaking existing users' scripts.
@kensoh
Copy link
Member Author

kensoh commented Jul 11, 2019

Committed to master, closing issue.

@kensoh kensoh closed this as completed Jul 11, 2019
@kensoh
Copy link
Member Author

kensoh commented Dec 13, 2019

Dummy checklist to go through codebase on functional level with @siowyisheng -

  • TagUI architecture
  • tagui.sikuli/tagui.py
  • tagui_py/tagui_py.py
  • tagui_r/tagui_r.R
  • test/positive_test
  • end_processes
  • end_processes.cmd
  • erina
  • erina.cmd
  • sleep.php
  • transpose.php
  • tagui_chrome.php
  • tagui
  • tagui.cmd
  • tagui_config.txt
  • tagui_crontab
  • tagui_footer.js
  • tagui_helper.php
  • tagui_report.php
  • tagui_runner.php
  • tagui_service.php
  • tagui_parse.php
  • tagui_header.js
  • translate.php
  • chrome extension

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant