I am learning swings for making GUI. I was thinking which is the best possible way in case of socket with swings.
1. The whole swing code goes in the server file. All the handlers and logic in on server side. Client only create socket.
2. The server have logic part. The code for the swing to display interface goes on client side. Client Creates stream to send / rec. data from server.
Whch is the good way out of 2 ?
While the options aren’t clear to me the way you described them, I will describe what is common practice.
Probably the widest adopted (enterprise system) architecture uses some kind of database as a persistence layer, a middle layer with business logic and an interface (either rich client like swing or web interface) containing the view logic.
The client only contains view state-related logic: event processing, notifications, data presentation, data binding etc. Things like data persistence, retrieval, validation are done by sending a request from the interface to the middle layer which then knows how to process the request, processes it and returns any results. This communication usually takes places in the form of web services or session bean method invocations.