Pages

Thursday, January 30, 2014

Metaprogramming (Part 2)


Metadata-Driven Applications

Metadata can be used for configuring and driving the applications. Our goal is to create highly dynamic and adaptable programs. For this, we adopt a general rule: program for the general case, and put the specifics somewhere else—outside the compiled code base.

Put Abstractions in Code Details in Metadata

The benefits of this approach are:

  1. Helps us to decouple our program, resulting in a flexible and adaptable program.
  2. Helps us to create a robust, abstract design by deferring details out of the program.
  3. We can customize our applications without recompiling it.
  4. Metadata can be expressed in a manner that's much closer to the problem domain than a general-purpose programming language might be.
  5. We can implement several different projects using the same application engine, but with different metadata.

The next important question is, when to configure?  Most of the applications read the configuration only during start up. In this case, most of the times, we have to restart the application for applying the configuration.  A more flexible approach is to write programs that can reload their configuration while they're running.


- summary of Metaprogrammingfrom The Pragmatic Programmer: From Journeyman to Master


No comments:

Post a Comment