Most immediately you want to run the same validation code on the GUI and the backend - a lot of bugs are caused by inconsistent validation in different places.
But you also want to use the same datatypes - why have two representations for the same thing? Of course it's important that what you pass between client and server be inert data (i.e. records), but there are far better ways to achieve that than a custom text-based protocol, which is adding a lot of overhead and opportunities for error to no benefit.
Validation in the ui and the logic layer are different.
No, the same type has the same set of valid states, by definition.
Do not be a lazy copy-paster, do the right thing.
This is utterly backwards. You avoid copy-pasting by avoiding repeating yourself, which means reusing the same logic - not a copy but the actual same code - when you want to do the same thing.
And, text-based communication have tons of benefits: scriptable easy to replace gui frontends testable easy to insert something (e.g., logging, network forwarding, etc.) in between
All that remains true for more structured communication mechanisms, which avoid the security issues and unreliability inherent in text-based approaches. Custom parsers are still one of the biggest sources of security vulnerabilities, and interleaving control and data is still another one.
0
u/[deleted] Dec 04 '18
Why would you ever want to reuse something from your logic part in your GUI? Reeks of a very leaky abstraction.
GUI must be entirely separate and, ideally, unless it's 3D models, video or audio, must communicate with your logic over a dumb text-based protocol.