Skip to content

Commit

Permalink
Sarthak | Adds some notes on Arguments to think about refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
SarthakMakhija committed Jan 10, 2025
1 parent eff6d2b commit c77a832
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/java/com/codurance/training/commands/Arguments.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
import java.util.List;
import java.util.stream.Collectors;

/**
* The class `Arguments` is showing signs of both mutability and immutability.
* Signs of mutability:
* - Arguments extends from ArrayList<String> which is mutable.
* - The method `skipOne` creates a new instance of Arguments, which means the author does not want to change the existing collection.
* An instance of Arguments is passed to all the Commands. Given, Arguments extends from ArrayList<String>, it gives all the commands
* the authority to mutate arguments.
* Technically, Arguments should never be mutated once created.
*/
public class Arguments extends ArrayList<String> {

static Arguments skipOneAndCreate(String[] parts) {
Expand Down

0 comments on commit c77a832

Please sign in to comment.