Skip to content

Refactor MockListView: replace magic numbers with ComponentConstants#3796

Open
sumavyshnavy wants to merge 2 commits intomit-cml:masterfrom
sumavyshnavy:docs-bluetooth-sendxbyte
Open

Refactor MockListView: replace magic numbers with ComponentConstants#3796
sumavyshnavy wants to merge 2 commits intomit-cml:masterfrom
sumavyshnavy:docs-bluetooth-sendxbyte

Conversation

@sumavyshnavy
Copy link

General items

For all other changes

  • I branched from master
  • My pull request has master as the base

What does this PR accomplish?

Description

This PR replaces hardcoded magic numbers used for image dimensions in MockListView with constants defined in ComponentConstants.

Changes made:

  • Added LISTVIEW_DEFAULT_IMAGE_WIDTH and LISTVIEW_DEFAULT_IMAGE_HEIGHT in ComponentConstants.java.
  • Updated MockListView.java to use these constants instead of hardcoded values.

This improves maintainability and follows the existing pattern of defining reusable constants for component configuration values in the codebase.

@AppInventorWorkerBee
Copy link
Collaborator

Can one of the admins verify this patch?

1 similar comment
@AppInventorWorkerBee
Copy link
Collaborator

Can one of the admins verify this patch?

public static final int LISTVIEW_PREFERRED_HEIGHT = 40;
public static final int LISTVIEW_FILTER_PREFERRED_HEIGHT = 30;
public static final int LISTVIEW_DEFAULT_IMAGE_WIDTH = 40;
public static final int LISTVIEW_DEFAULT_IMAGE_HEIGHT = 40;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation

Copy link
Member

@jisqyv jisqyv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: Even with the comments below addressed, I'm not sure this change is worth the effort, given there are other constants that are still hardcoded.

imageHeight = 40; // (200 / 5)
imageWidth = 40; // (200 / 5)
// TODO (Jose) extract magic numbers as ComponentConstants.java
imageHeight = ComponentConstants.LISTVIEW_DEFAULT_IMAGE_HEIGHT;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You lost the comment (200 / 5)

public static final int LISTVIEW_PREFERRED_HEIGHT = 40;
public static final int LISTVIEW_FILTER_PREFERRED_HEIGHT = 30;
public static final int LISTVIEW_DEFAULT_IMAGE_WIDTH = 40;
public static final int LISTVIEW_DEFAULT_IMAGE_HEIGHT = 40;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix the indentation

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback! I've restored the (200 / 5) comment in MockListView.java and fixed the indentation in ComponentConstants.java.

I understand your concern about other hardcoded constants as well. I started with these values since they were directly referenced in the TODO comment, but I'm happy to extend the refactor further if that would be more useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants