3

This is the problem: I am designing a framework that is basically getting chemical compounds, perform operation with them (or among them) and return results.

At the moment I have a class that holds all the operations(like mix, centrifugate, separate, heat up and so on). I create a sequence basically by hand, including this class and adding the actions one after another. This is OK for me, since I am a developer, but many of my coworkers do work mostly in a lab environment, and they are not willing to get into writing a new file as such.

I am planning to shift to JSON, holding in there a sequence of operations; although I am not sure if this is the right way to create a series of operations, for the lab technicians. Is there a better design to accomplish something similar to my needs?

By "better" I mean something that is safe for the data, easy to use and maintain and performant. Term very generic, especially in the design context.

  • 1
    How do you define "better?" – Robert Harvey Feb 12 '17 at 3:55
  • Hmm, a bit vague; let me be more specific: Safer(data wise), easier to use for people not much into development, more efficient, easy to maintain. I understand that there is no such thing as better or worst, since they are tied to the context; but there are better practices and worst practices, that in the long run assure that you don't go insane working on your own code. Better is probably an incorrect term, I agree – rataplan Feb 12 '17 at 3:59
  • It's not clear to me whether you are writing the whole system or only adding a "configuration engine" over the top of an existing system. If you are only making a configuration engine for a stable system then advanced techniques may make sense. If you are writing the whole system then it's better to let the system mature before attempting to add a sophisticated capability to configure it such as a domain specific language. – simbo1905 Feb 12 '17 at 7:42
5

JSON (as well as XML) are formats made for transferring information in machine readable form. They can be managed by humans, of course, but for many use cases there are more ergonomic ways to accomplish what you are after. The modern buzzword for this is Domain Specific Language, which means you might invent your own "mini-language" which suits your (and your coworkers) needs, and write a parser and interpreter for it.

If your use case just involves a sequence of operations with some parameters, this is very simple and should not be a big issue. Just define one command for each operation, and let your coworkers write the commands into a text file. In our company, we often used spreadsheet files in the past for such command sequences, which makes it a little bit more "user friendly", since in a spreadsheet you can add easily some things like comments, integrated examples, validations, separated parameter columns etc. If you need something more sophisticated, google for "domain specific language python", and you will find plenty of articles, tutorials and modules.

  • I was not aware of Domain Specific Languages; indeed it make sense to go in that direction; I am going to explore over it. Thanks! – rataplan Feb 13 '17 at 5:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.