How to implement a network protocol?

Read up on the State design pattern to learn how to avoid lots of switch statements.


“sometimes what comes out has some “blind spot”, I mean statuses of the protocol that have not been covered…”

State can help avoid gaps. It can’t guarantee a good design, you still have to do that.

“…as I have to write lines and lines of code to cover every possible situation.”

This should not be considered a burden or a problem: You must write lines of code to cover every possible situation.

State can help because you get to leverage inheritance. It can’t guarantee a good design, you still have to do that.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)