[Compiler] Make Compiler not being a singleton anymore
Concern Raised1e419ca34154

Authored by Jan Marker <jan@jangmarker.de>.

Description

[Compiler] Make Compiler not being a singleton anymore

Singletons make testing harder and in general make it harder
to follow modules dependencies over an application. Anyway,
Compiler is not used at the moment (will change in future).

Details

Auditors
akreuzkamp
Committed
Jan Marker <jan@jangmarker.de>Jul 15 2015, 2:37 PM
Parents
R18:19008435755b: Merge branch 'feature/refactor_pipeline'
Branches
Unknown
Tags
Unknown
References
feature/no_compiler_singleton
Jan Marker <jan@jangmarker.de> committed R18:1e419ca34154: [Compiler] Make Compiler not being a singleton anymore (authored by Jan Marker <jan@jangmarker.de>).Jul 15 2015, 2:37 PM
akreuzkamp raised a concern with this commit.Jul 16 2015, 7:54 PM
akreuzkamp added a subscriber: akreuzkamp.

I'm not sure, if this is really a good idea.
If it's about the singleton itself — yes, from my current perpective, I'd prefer it to be a static class instead of a singleton.
If so, ignore the stuff below. ;)

If it's about the idea of having global data, I would not change that. It's not all only about include paths, it's at least
everything that we can pass as command line parameters. Passing that through constructors is not only architecturally
a mess, but also very error-prone.
It's up to you, but I advise against it.

It's abut testability and data encapsulation: global objects are hard to mock (i.e. change their behaviour) when testing.

I think global data should be avoided if possible and be put into objects which are responsible for the data, for example the Compiler object is responsible for the compiler arguments. If that object is responsible, it should be either passed down to the objects (e.g. compiler passes) needing that information or it should configure those objects itself.

How would a solution based on a static class look like?