D
D
Daria Motorina2022-02-16 23:48:13
OOP
Daria Motorina, 2022-02-16 23:48:13

Is it bad practice to create an interface for DTOs to get away from specific implementations using them?

There is a module that has many arguments tied to the transfer of a specific DTO implementation. It is necessary to make this logic more flexible and pass "one family" to the DTO arguments. Will shitcode create a marker interface to avoid being tied to specific implementations? Technically, this will solve the problem, but on various forums I met the answer that this is a bad practice, because implicit logic appears.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shamanov, 2022-02-17
@SilenceOfWinter

Is it bad practice to create an interface for DTOs to get away from specific implementations using them?

uh... and when can creating interfaces in general be a bad practice? well, if you do not take completely idiotic examples .. DTO is not an analogue of stdClass in PHP, a class can and should encapsulate data, access is via methods. An interface declares methods for working with "required" "properties" of a class.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question