See below.
Hi,
As some of you may know, I'm a "savage coder" who learned
Smalltalk/Pharo by himself, of course thanks to communities, books and
videos, but without formal training or peers in the same country and
guided mostly by necessity. All this to say that this maybe kind of a
silly question.
Anyway, we have this project called Minipedia[1], that imports Wikipedia
articles and their history. A Minipedia language there, is just a
dictionary, where the key is the language two letters code and the value
for each key is an array of article titles. There is any way to
specialize a Dictionary to tell it, name your 'key' as language and your
'value' as 'titles'?
There are several ways, depending on your intention.
If you intend that the full Dictionary and Collection API is available to all the places where this artefact will be used, you can add extensions to the Dictionary class to provide alias accessing methods or you can also subclass Dictionary and only have your aliases (and whatever API) visible only to consumers of that class. The former is a quick and dirty approach. The latter is better, since every Dictionary is NOT a language keyed collection of article.
If you want to have a limited API, you wrap a dictionary with a new class that exposes just the API you desire consumers to use.
In general, inheritance is often overused or/ misused. Composition is usually a better technique unless you want the full API of the hierarchy to be available and used.
[1] https://mutabit.com/repos.fossil/minipedia/
Thanks,
Offray