cormas icon indicating copy to clipboard operation
cormas copied to clipboard

Models in Pharo should not display class prefixes

Open olekscode opened this issue 3 years ago • 1 comments

In VisualWorks, there are namespaces, which allows one to create classes with generic names such as Agent, Model, etc. In Pharo, we need to prefix classes to avoid collision: CMAgent, CMECECModel, etc.

However, those prefixes should not be displayed in Cormas UI. Here are three examples:

  1. It should display Unrestrained instead of ECECUnrestrained

Screenshot 2022-12-20 at 11 51 17

  1. It should display VegetationUnit or Vegetation Unit instead of ECECVegetationUnit

Screenshot 2022-12-20 at 11 51 04

  1. It should display Unrestrained, Restrained, Forager, VegetationUnit (or Vegetation Unit) instead of CMECECUnrestrained, CMECECRestrained, CMECECForager, and CMECECVegetationUnit

Screenshot 2022-12-20 at 11 51 39

olekscode avatar Dec 20 '22 11:12 olekscode

One solution would be to introduce the name method for CMEntity that would try to detect a prefix and remove it, and in case of failure, display the full class name.

Specific subclasses could then override the name method to provide more meaningful names. For example, a class name could be CMECECVegetationUnit, the default CMEntity >> name would return VegetationUnit, and the user could choose to override it as Vegetation unit.

I can see that there is a method CMEntity >> povClassName. Perhaps, it acts like name in this case

olekscode avatar Dec 20 '22 11:12 olekscode