0

I want to provide some functionality for compiling sources of a specific kind (e.g. java). As the process of compilation needs additional information i need to give in some more arguments and not only the sourcefile. E.g. working directory, compiler parameters and so on.

There are two ways in my mind how to design it:

  1. Using OOP, that means creating a compiler class, saving the additional arguments when constructing a specific compiler object that can then be used for compiling by just providing the sourcefile

  2. Not creating a class for creating objects but just a (static final?) closure in a class and then using curry to pass in the needed arguments and returning another compile function which can then be provided by for example just the sourcefile to compile it

What are the pros and cons? Is there maybe an even better way to get things done?

valenterry
  • 757
  • 6
  • 21
  • So you want to compile a file which reads/has properties to compile another set of files? What about adding these params in a properties file under META-INF? – Will Apr 23 '14 at 09:59
  • No i just want to compile sourcefiles (C, Java, whatever) and the params may even be dynamically delivered at runtime. They are not in a property file. – valenterry Apr 23 '14 at 10:22

1 Answers1

0

According to me it only depends on if this should be done well or it's just a kind of a proof of concept. If there will be multiple source files with different types, then it's better to create well-designed, robust class hierarchy. Otherwise You can use a bunch a predefined closures if suites your needs.

Mind the fact that these two solutions are not mutually exclusive. You can still create a robust class hierarchy that will be using predefined closures internally.

Opal
  • 81,889
  • 28
  • 189
  • 210