nus-cs2103-AY2223S2 / forum

12 stars 0 forks source link

Question on code reuse policy #288

Closed EvitanRelta closed 1 year ago

EvitanRelta commented 1 year ago

Snippet from W12 "Policy on reuse":

Policy on reuse

...

  • You are allowed to reuse work from external sources, subject to following conditions:
    • In case of reusing more than a short code snippet (e.g., reusing an entire library or an entire feature), the work comes from a source of 'good standing' (such as an established open source project). This means you cannot reuse a significant portion of codebase written by a friend or a past student. But you may reuse/adapt small code snippets from any source such as stackoverflow.


With regards to the underlined part, I have the following questions:

  1. How much is considered "significant" (and thus not allowed to be reused)? Is copying a single .java file with ~250 lines "significant"?

  2. If it is significant, what if a SIGNIFICANT part of the copied code is later then changed/refactored/bug-fixing to suit our needs?
    In this case:

    1. are we then allowed to reuse said code?
    2. how do we mark code that's written by the source authors, and code that's modified/added by us?
    3. are we then credited for the modifications that we did to the code? Or will we not be credit AT ALL for the ENTIRE code (modified or not)?
  3. (unrelated to the 2 qns above) What if we copied code, commit it, then made major changes to it?
    (such that the copied code is in the Git history)

    Do we credit the source as if we read the code to understand the approach and implemented it ourselves:

    //Solution below adapted from https://stackoverflow.com/a/16252290
    {Your implementation of the reused solution here ...}

    Or credit it the same way as copy-pasted a non-trivial code block with minor modifications:

    //@@author {yourGithubUsername}-reused
  4. Will we be credited reused code that we read the code to understand the approach and implemented it ourselves?
    (ie. code that we've been "inspired by" and that's been changed significantly from the source code)

    Because I'm afraid that if we spend significant effort improving/fixing/adapting, we'll end up with basically no code contribution if we get no coding credit for modifying reused code (although I guess we get reuse credit? not sure how that will affect our grade)

damithc commented 1 year ago

@EvitanRelta my answers below:

  • How much is considered "significant" (and thus not allowed to be reused)? Is copying a single .java file with ~250 lines "significant"?

Yes, that's hardly a snippet.

  • If it is significant, what if a SIGNIFICANT part of the copied code is later then changed/refactored/bug-fixing to suit our needs? In this case:

    1. are we then allowed to reuse said code?
    2. how do we mark code that's written by the source authors, and code that's modified/added by us?
    3. are we then credited for the modifications that we did to the code? Or will we not be credit AT ALL for the ENTIRE code (modified or not)?

Parts that remain largely unchanged, mark as reused, and cite the source. Parts that were significantly adapted, cite the original source and explain the extent to which the code was modified. You can use @@author tags to indicate authorship, as explained in https://nus-cs2103-ay2223s2.github.io/website/admin/tools.html#tool-reposense-for-authorship-tracking

Same as my answer above. In fact, 'commit the original code first and modify later' is a more transparent and more history-preserving way of reusing code.

  • Will we be credited reused code that we read the code to understand the approach and implemented it ourselves? (ie. code that we've been "inspired by" and that's been changed significantly from the source code) Because I'm afraid that if we spend significant effort improving/fixing/adapting, we'll end up with basically no code contribution if we get no coding credit for modifying reused code (although I guess we get reuse credit? not sure how that will affect our grade)

Reuse needs to be cited accurately for ethical and legal reasons, and also for future reference (if a future dev wants to take a look at the original code). In addition, it need to be factored in estimating the effort (reusing and adapting requires effort too -- it's just a matter of estimating how much).

EvitanRelta commented 1 year ago

@damithc

Parts that were significantly adapted, cite the original source and explain the extent to which the code was modified.

So does that mean we are allowed to reuse large copied code (eg. ~250 lines) AS LONG AS we heavily modify said code?

By "cite the original source and explain the extent to which the code was modified", are you referring to:

//@@author USER-reused
// Adapted from https://stackoverflow.com/a/16252290
// with heavy modification to...

or are you referring to:

//Solution below adapted from https://stackoverflow.com/a/16252290



Reuse needs to be cited accurately for ethical and legal reasons, and also for future reference (if a future dev wants to take a look at the original code). In addition, it need to be factored in estimating the effort (reusing and adapting requires effort too -- it's just a matter of estimating how much).

So will we be credited reused code that we either heavily modify, or read the code to understand the approach and implemented it ourselves?

Grade wise, how does code contributions in the form of such "heavily modified/adapted reused code" compare against original code written by us?

For example: If ALL of a student's code contributions are reused code, such that all those reused code are heavily modified/adapted, how does his grade compare against a student that has only written original code?

damithc commented 1 year ago

@EvitanRelta

Parts that were significantly adapted, cite the original source and explain the extent to which the code was modified.

So does that mean we are allowed to reuse large copied code (eg. ~250 lines) AS LONG AS we heavily modify said code?

As per the policy you quoted above, we don't actually want students to reuse code from non-standard sources (e.g., from past projects) at such a scale but if you have reused such code already, and modified the code heavily too, declaring that reuse accurately is still 'acceptable'.

By "cite the original source and explain the extent to which the code was modified", are you referring to:

//@@author USER-reused
// Adapted from https://stackoverflow.com/a/16252290
// with heavy modification to...

or are you referring to:

//Solution below adapted from https://stackoverflow.com/a/16252290

The former.

Reuse needs to be cited accurately for ethical and legal reasons, and also for future reference (if a future dev wants to take a look at the original code). In addition, it need to be factored in estimating the effort (reusing and adapting requires effort too -- it's just a matter of estimating how much).

So will we be credited reused code that we either heavily modify, or read the code to understand the approach and implemented it ourselves?

Grade wise, how does code contributions in the form of such "heavily modified/adapted reused code" compare against original code written by us?

For example: If ALL of a student's code contributions are reused code, such that all those reused code are heavily modified/adapted, how does his grade compare against a student that has only written original code?

The level of reuse needs to be factored in when estimating the effort. As you know, the effort is estimated on an S/U basis. So, it should be the same outcome as long as your effort surpasses the bar, irrespective of whether you reused code or not. Of course you are still responsible for the quality of the reused code, which means bugs and code quality problems in that code will affect the corresponding components of the tP marks.

EvitanRelta commented 1 year ago

@damithc Alright, I think that clarifies most of my doubts. Thanks! :D

The level of reuse needs to be factored in when estimating the effort.

Last qns, what do u mean my "needs to be factored in when estimating"?

Does it mean:
"the effort used in reusing code will be factored in our overall effort, thus effort spend modifying code is still accounted for in the overall effort"?

Or does it mean:
"when our efforts are estimated, the contributions from reused code are deducted, and thus not accounted for in the overall effort"

damithc commented 1 year ago

Last qns, what do u mean my "needs to be factored in when estimating"?

Does it mean: "the effort used in reusing code will be factored in our overall effort, thus effort spend modifying code is still accounted for in the overall effort"?

Or does it mean: "when our efforts are estimated, the contributions from reused code are deducted, and thus not accounted for in the overall effort"

@EvitanRelta The aim is to estimate the effort you spent on the tP. So, it means, "how much effort did the current dev spent on this code, keeping in mind the code was reused from elsewhere?" Without the part in italic (i.e., if the code was not reused), the answer is likely to be different.

EvitanRelta commented 1 year ago

@damithc

Ok, for this question, I'm not worried about grades but, should I still use the @@author USER-reused tag if after modifying the reused code, 95% of the code has been recoded and 90% of the logic/feature ended up different?

Because I ended up overhauling/refactoring/adding-new-features/bug-fixing the source code, so much that it's almost unrecognisable from the source. And it feels wrong to credit it as being done by the source authors (instead of "adapted").

Should I change the @@author USER-reused tag to //Solution below adapted from URL instead?

For reference, here's my modified version of the code, and the reused-code source:

My reused code: https://github.com/AY2223S2-CS2103T-W12-2/tp/blob/master/src/main/java/seedu/address/logic/commands/AutocompleteEngine.java

Source code: https://github.com/AY2223S1-CS2103T-T12-2/tp/blob/master/src/main/java/swift/logic/commands/CommandSuggestor.java

damithc commented 1 year ago

Should I change the @@author USER-reused tag to //Solution below adapted from URL instead?

@EvitanRelta Yes, that's the right thing to do if the code has been modified substantially along the way.