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

BlElement: Find a better name for hasParent: #694

Open
tinchodias opened this issue Feb 12, 2025 · 2 comments
Open

BlElement: Find a better name for hasParent: #694

tinchodias opened this issue Feb 12, 2025 · 2 comments

Comments

@tinchodias
Copy link
Collaborator

tinchodias commented Feb 12, 2025

hasParent: is awkward IMHO. This is the method:

hasParent: anElement
	"Return true if I have a given element in my parent chain, false otherwise"

	self allParentsDo: [ :aParentElement |
		aParentElement == anElement
			ifTrue: [ ^ true ] ].

	^ false

I propose to choose a more descriptive name + add a deprecation with a transformation rule.

@tinchodias
Copy link
Collaborator Author

tinchodias commented Feb 12, 2025

In contrast, hasParent (without arguments) is fine, as it answers whether the element has a parent:

hasParent
	"Return true if I have a parent, otherwise false.
	Being added as direct child to other element does not necessary
	mean that I am in the space scene graph"
	<return: #Boolean>

	^ self parent isNotNil

but my problem is with hasParent: that receives another element as argument and determines if it has a parent and its the received element. IMO a Pharo developer would look for this method with something like "isChildOf:"

@tinchodias tinchodias changed the title BlElement: #hasParent: should be renamed to #isChildOf: BlElement: Find a better name for hasParent: Feb 12, 2025
@tinchodias
Copy link
Collaborator Author

In fact, I first thought the new name could be isChildOf: but it should be more like allParentsInclude:.

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

No branches or pull requests

1 participant