spdx-online-tools icon indicating copy to clipboard operation
spdx-online-tools copied to clipboard

Limit code repetition in license namespace section

Open Ugtan opened this issue 4 years ago • 4 comments

Since the license request and license namespace section of the SPDX online tools is quite similar in functionality. Both of these section provides the user the ability to submit license requests or license namespace, But to a different repository. Some of the code of namespaces is quite similar to that of license request, We could have easily adapted our code to use license request code to limit code repetition.

Code repetition means we will have to test that code as well, make changes at both the places, similar js files take up space, and load time it slows down the website due to more HTTP requests.

Some egs of code repetition-

  1. Like these two functions https://github.com/spdx/spdx-online-tools/blob/8d1d83b530e56dbac0928e86bf3e064e3cba49e1/src/app/views.py#L1576 https://github.com/spdx/spdx-online-tools/blob/8d1d83b530e56dbac0928e86bf3e064e3cba49e1/src/app/views.py#L1630
  2. Similarly, the files script.js and ns_script.js are quite similar.

Ugtan avatar Jun 13 '20 18:06 Ugtan

Hi, may I work on this issue?

tomokos2 avatar Jun 16 '20 03:06 tomokos2

@tomokos2 Yes, you can. You don't need to be an assignee to work on the issue.

rtgdk avatar Jun 16 '20 04:06 rtgdk

@rtgdk Hi, I was thinking about how to solve the similarity issue in script.js and ns_script.js --

  1. Have 3 files, one holding the similar code and the other two holding the different code, and load two scripts each in editor.html and ns_editor.html.
  2. Combine the two files into one and have if statements that control which functions to use for the normal script and the namespace script? May I have your thoughts on these solutions? Is there one that would be preferable? Thank you.

tomokos2 avatar Jun 24 '20 19:06 tomokos2

@tomokos2 The 1st option looks fine to me. Having a common template that contains common functions and elements will be the way to go.

rtgdk avatar Jun 30 '20 17:06 rtgdk