Skip to main content
190 votes
Accepted

Is it ok to use meta-programming even though not all of my colleagues understand it?

Metaprogramming is OK. What you are trying to do is not OK. I use metaprogramming all the time in my job. It's a powerful tool which can be used to do a lot of things in a more readable and ...
Cort Ammon's user avatar
  • 11.7k
40 votes

Is it ok to use meta-programming even though not all of my colleagues understand it?

First and foremost, this is the team's issue, and you have to solve it with the team. If you have backup from the team for programming using certain elements and constructs, do it; if not, discuss it ...
Doc Brown's user avatar
  • 214k
19 votes

Is it ok to use meta-programming even though not all of my colleagues understand it?

My general opinion: if you have a choice, as is often the case, between the following three options: Type out many nontrivial code structures repetitively by hand; Use C++ template metaprogramming to ...
Brian's user avatar
  • 627
12 votes

Is it ok to use meta-programming even though not all of my colleagues understand it?

Software developers should aspire to write code that works, that works obviously, that can be tested, that can be reviewed, that can be debugged, and that can be adapted when changes are needed. If ...
gnasher729's user avatar
  • 47.5k
9 votes

Is it ok to use meta-programming even though not all of my colleagues understand it?

An argument from compassion: Does your job give free time for learning, or in alternative, can you convince your bosses to allocate some hours for learning these language features? If not, using ...
André Paramés's user avatar
8 votes

Is it ok to use meta-programming even though not all of my colleagues understand it?

Code should be written firstly for humans to read, and only incidentally for the compiler to parse. Now the thing to remember about non trivial TMP is that you are restricting the number of people ...
Dan Mills's user avatar
  • 642
8 votes

Was template meta programming really discovered "by accident"?

There is more to invention than giving a simple list of implications and with C++ Stroustrup aimed for generality: I'm not interested in a language that can only do what I can imagine This is from ...
manlio's user avatar
  • 4,236
7 votes

Is it ok to use meta-programming even though not all of my colleagues understand it?

No you should not. You are employed to produce code that satisfies a specification. This code has to be maintainable not an ego trip. You could be run over by a bus tomorrow, so someone has to be able ...
Darryl SCOTT's user avatar
4 votes

Was template meta programming really discovered "by accident"?

The following excerpt is subject to: https://creativecommons.org/licenses/by-sa/3.0/ History of TMP Historically TMP is something of an accident; it was discovered during the process of ...
rwong's user avatar
  • 17k
3 votes
Accepted

Common methods of generating code with code

Doing code generation is not overly rare. In fact, it's a common approach for implementing REST APIs. But it's difficult to do this robustly when generating code from arbitrary user input. It's also ...
amon's user avatar
  • 135k
2 votes

Compile-time IOC

I'm working on a project to do exactly this, using Roslyn's preview SourceGenerators. It does all the wiring up at compile time, and gives you compiler errors/warnings if you make a mistake. Try it ...
Yair Halberstadt's user avatar
2 votes

How to deal with different level of abstractions (blurred line between data and models)

For representing the data, you will usually need a meta model, a model of how your data shall look like, something like a database schema. The app will have to provide a schema designer component, ...
Doc Brown's user avatar
  • 214k
2 votes

Is it ok to use meta-programming even though not all of my colleagues understand it?

The only way to answer this question in context is to look at the specific problems and the specific way you solved them with meta programming. Unless you post code here we cannot know whether you ...
Peter - Reinstate Monica's user avatar
1 vote

Finding intermediate type for conversion

A better way to think about this is via sub-type relations. If you need a type that represents the base type of A and B then that is by definition A intersect B which contains all values that exist in ...
Telastyn's user avatar
  • 110k
1 vote

Is tag dispatch as used in CppCoreGuidelines T.65 antiquated?

When evaluating the approaches, keep this in mind: The Tag dispatch example suffers from being contrived, trivial and self-contained for illustration purposes. In the cases it is most appropriate, ...
Deduplicator's user avatar
  • 9,131
1 vote

How to deal with different level of abstractions (blurred line between data and models)

I would like to be able to use the app's programming language to dynamically create classes that match our form models, but I do not consider a good practice do to so. On the other hand, I don't think ...
Laiv's user avatar
  • 14.8k

Only top scored, non community-wiki answers of a minimum length are eligible