JetBrains-Research / TestSpark

TestSpark - a plugin for generating unit tests. TestSpark natively integrates different AI-based test generation tools and techniques in the IDE. Started by SERG TU Delft. Currently under implementation by JetBrains Research (Software Testing Research) for research purposes.
MIT License
53 stars 23 forks source link

[Language-related-refactoring] Factory Pattern into the Factory Method Pattern #305

Open Frosendroska opened 3 months ago

Frosendroska commented 3 months ago

Description

More description is in the PR comment.

Every [Something]Factory class that we have often contains a single method createSomething. We can turn the Factory Pattern into the Factory Method Pattern.

These create[Something]() static methods can be moved into the base abstract classes/interfaces (e.g., in this case we can place createTestBodyPrinter() static method into TestBodyPrinter interface (and maybe rename to just create()). This will allow us to remove a single entity from the codebase, namely TestBodyPrinterFactory. It'll reduce the code complexity.

In TestBodyPrinterFactory, TestCompilerFactory and TestSuiteParserFactory

Frosendroska commented 3 months ago

Some of this factories are used not only on one class.

For example, TestCompilerFactory is used in TestSparkStarter, TestCasePanelFactory and in LLMProcessManager, therefore we need to have an extra entity for it.

For other classes it could happen that we will need them in other places as well, so having the Factory abstraction is crucial