Skip to content

Architecture of Algernon

kej-jay edited this page Aug 4, 2020 · 15 revisions

here

legend:

  • purple - 0 software
  • yellow - GUI
  • blue - application software
  • green - technology software

Classification according to Siedersleben2004 (Moderne Software-Architektur. J. Siedersleben; dpunkt, 2004.)

Basic functioning of Algernon

Algernon is currently based on a very simple search procedure, which should probably adapted very soon.

  1. All searchable items are created in ALGItemProvider initializeItems
  2. When entering a search term, the fitting ALGItemFilter is selected.
  3. The searching behavior depends on the filter (e. g. searching for class comments works differently), but by default a fuzzy matching algorithm (ALGFuzzyMatcher) is used to find all items that have all characters of the query in the right order. All items are assigned a score based on that.
  4. The ALGSmartSorter sorts these items based on the fuzzy matching score, how often they were seletced before and when.
  5. Matching results are displayed in the ALGResultList.

Where to start with different common problems

Add a new ALGType

An ALGType represents a kind of search result result. For example classes and methods have an ALGType. If you work on Algernon you will often find yourself in the situation to add a new type.

  1. Subclass ALGType to ALGMyNewType
  2. Implement ALGMyNewType>>algertemList. This method should return all things that algernon should search for. For example ALGClassType>>algertemList returns an ALGItem for each class in the image. Take a look at ALGItem>>withAlgertype: for how to create an ALGItem for your type.
  3. Add your new type to ALGItemProvider>>initializeItems. This method will be called when Algernon is first launched and will create all the items to search through, including your new ones.

Create a new filter

Everytime you search something in Algernon, the items are matched by an ALGItemFilter. Normally this is done by the ALGRegularFilter that implements the fuzzy matching based on item name you are used to. But sometimes we want to have special logic around filtering. For example: If you enter a keyword like open you only want to see results that respond to that keyword. You might want to create your own filter. This is how to do it.

  1. Subclass ALGItemFilter to ALGMyNewItemFilter.
  2. Overwrite ALGMyNewItemFilter>>filter:anItemCollection:given:aStringCollection. The first argument will be the set of all items to filter through and the second will be the tokens of the input string. Here you can now filter how ever you like.
  3. Overwrite ALGMyNewItemFilter>>helpTexts and ALGMyNewItemFilter>>keywords. Here you define which keywords activate your filter and write the help texts for these keywords. These texts will be displayed by the help keyword.