How can you be dry with a programming language that is not reflected?

Any programming language that does not have a suitable reflection mechanism, I find it serious debilitating for rapidly changing problems.

With some languages, it seems incredibly difficult or impossible to do:

  • Context setting
  • Auto data binding
  • AOP / Meta strong programming>

without reflection.

Some examples of languages ​​that do not have a kind of software reflection: C, C ++, Haskell, OCaml . I am sure there are many more.

To show that you can use the DRY (Do not Repeat Yourself) example, which most of these languages ​​violate when you need to write Unit Tests. You almost always have to register your test cases in these languages ​​outside the place where you define the test.

How do programmers in these languages ​​mitigate this problem?

EDIT: Common languages ​​that are reflected for those who do not know: C #, Java, Python, Ruby, and my personal favorites F # and Scala.

EDIT: Two common approaches: toolkit code and code generation. However, I have never seen a toolkit for C.

Instead of just voting, you can comment on why this should be closed, and I will delete the message.

+5
source share
4

. , , - , , - .

, JSON-Parser, , :

struct SomeStruct
{
        int a;
        int b;
        double c;

        typedef int serializable;
        template<class SerializerT> void serialize(SerializerT& s)
        {
                s("a",a)("b",b)("c",c);
        }
};

, , , , , (, ), , , .

+3

, . - .

, , DRY, . , , , , . , , , , . (, .)

, - DRY , , - . , , . ( , , "" , , - , . . - CodeSmith, : http://www.codesmithtools.com/)

+2
  • , , , ( ) . , . ( , ?) . .

  • ++ ( , ?) .

+2

++ - cxxtest: http://cxxtest.tigris.org/. python script, ++, ++ python.

, , - "". - , . , C . ++ - . , , , . , , .

+1
source

All Articles