Protocol abstraction in C #

There are dozens of network protocols and file formats (WAV, TCP, BMP, etc.).

Is there a solution for creating an abstraction layer between the protocol implementation and the code using the resulting data?

Take the wav file. A software component may contain logic to identify cartridges and analyze them into classes. The user of this component will not need to know if the number of channels is stored in two or four bytes.

The specification of the WAV format is no different from hundreds of other formats and protocols, so why not create a common solution? To create an even better abstraction, the protocol specification can be stored in XML. I was not lucky to find anything like that. Can you point me in the right direction?

EDIT: This is clearly not a problem that is easily mailed. The current answers are not really what I'm looking for, but I would like to thank everyone for at least giving him a chance.

+3
source share
4 answers

Most things can be wrapped in protocols - just think how much was wrapped in the URLs. But this does not always mean that the structure is really abstracted into the content layer. I think the variety of protocols and formats indicates that there are probably categories for which you could abstract, but not just one abstraction, to manage them all.

, IMAP ZIP , .

+1

, , .

, . , XML .

+2
source

If you abstract something too far away, it becomes useless, and you need to open the black box to do something.

A β€œgeneral” container that contains sound files, images, and spreadsheets will be useless, because in any case you will have code that deals with data specific to these types of data, but now you are covered by additional general container nonsense.

+1
source

Source: https://habr.com/ru/post/1750535/


All Articles