V
V
vipermagi2016-10-07 03:24:17
C++ / C#
vipermagi, 2016-10-07 03:24:17

Does a large number of typedefs negatively affect anything meaningful?

I use typedef as a shorthand for overly long constructs. For example these:

typedef boost::function<void(std::shared_ptr<event>)> event_handler;

As a result, several identical packs of typedefs are formed in the code in several files.
Is this generally a problem that has a standard solution or is it not worth taking a steam bath?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
Nikita, 2016-10-07
@jetu

There is a problem in general. If you write something only for yourself in 1000 lines, then everything is OK, but if there is a possibility that other people will edit your code later, then think 100 times before using typedef. The person who will then accompany this will be very painful in different parts of the body. So he sees "event_handler" in the code ... and what it is and where it is, he will start spending time studying what should follow from the code itself.

T
tsarevfs, 2016-10-07
@tsarevfs

It's okay if it improves readability.

D
Daniil Demidko, 2016-10-07
@Daniro_San

You can abandon definitions in favor of copy-paste types. It's easier and clearer

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question