pharo icon indicating copy to clipboard operation
pharo copied to clipboard

Make class abstract driver

Open hernanmd opened this issue 1 year ago • 8 comments

This PR implements the "Make Abstract" class refactoring using the new Driver interface.

Make RBAbstractClass match the MOP answering both false by default in #isAbstract. Migrate RBMakeClassAbstractTransformation. Add data for testing: #RBClassWithoutSelfClassReferenceTest and #RBWithSelfClassReferenceTest Update RBMakeClassAbstractParametrizedTest Add #RBMakeClassAbstractDriver with tests Update #SycCMakeAbstractCommand

hernanmd avatar Mar 25 '24 20:03 hernanmd

What is the logic of this refactoring? I mean I do not really understand what is an abstract class in pharo and when i will need it.

Ducasse avatar Mar 25 '24 20:03 Ducasse

I migrated because it was there and some people may be using it.

However, I never bought the arguments for "improving code clarity" or "preventing improper instantiation" (maybe they're good for educational purposes), so I'll provide an example where I used it some time ago as a dirty experiment: To migrate a legacy system, using automated scripts, some classes couldn't be migrated to the new system. To get a quick diff of which ones weren't migrated, I annotated the already migrated abstract classes with the "isAbstract" method, so I could later see which hierarchies have fewer subclasses than expected.

If there are other use cases I would have to think about them because as you said, there doesn't seem to be too many.

hernanmd avatar Mar 26 '24 08:03 hernanmd

I use it a lot, it is useful for the Browser and the Rules to know that a class is abstract. Imagine having a subclassResponsibility method. The browser nags you to implement it, but the subclass is Abtract, too. So we could add the method again, then it complaints that the method is the same as in the superclass.

=> add #isAbstract, and the Browser/Rules know that you do not have to implement the #subclassResponsability here and just ask you to implement it where you want it

MarcusDenker avatar Mar 26 '24 09:03 MarcusDenker

I also like to know easily when a class is abstract when I'm exploring a project I'm not familiar with. Like that I'm able to understand the structure of the project more easily.

And I know that I should not instantiate those classes but just look at the subclasses.

jecisc avatar Mar 26 '24 10:03 jecisc

CI got a random failure. I'm restarting it

jecisc avatar Mar 28 '24 14:03 jecisc

Thanks Cyril, it seems that failing tests are not related:

Screenshot 2024-03-28 at 16 37 42

hernanmd avatar Mar 28 '24 16:03 hernanmd

Some tests are refactoring related so it's possible it comes from here no?

jecisc avatar Mar 28 '24 17:03 jecisc

Some tests are refactoring related so it's possible it comes from here no?

Ok, I fixed the failing tests. Now it seems good to go

https://ci.inria.fr/pharo-ci-jenkins2/blue/organizations/jenkins/Test%20pending%20pull%20request%20and%20branch%20Pipeline/detail/PR-16347/6/tests

hernanmd avatar Mar 29 '24 11:03 hernanmd