java amateur
in this refactoring (and perhaps due to my inexperience) my layouts end up with lots of nested panels
Maneesh Godbole wrote:
in this refactoring (and perhaps due to my inexperience) my layouts end up with lots of nested panels
Why do you feel this is bad? In my experience, having nested panels is easier to understand as well as maintain as compared to having one single container with lots of child components added directly. Relax. You are doing good.
Maneesh Godbole wrote: For buttons, except in cases where I needed to enable/disable them (e.g. for authentication purposes) you rarely required to access them directly. Most of the times the actionPerformed defined in their corresponding action classes does the trick.
Maneesh Godbole wrote: For rest of the fields, one would usually define them as instance variables. Depending on the requirement, you would define the getter/setters. e.g. if you got a password field, a get/set password is all you require from outside the class. These methods in turn would access the specific fields/components.
Maneesh Godbole wrote: I am not aware of your requirement, but do you really need to provide access to each and every field?
Maneesh Godbole wrote: Think OOP.
Maneesh Godbole wrote: Would it make sense to have a generic object encapsulate all the data and you exchange the object instead of all the individual data?
Maneesh Godbole wrote: Imagine a scenario where you got an application where individual users are mapped to say a list of data folders created by the application. For various reasons, the user is allowed access to only those files owned by him.
On the UI, I would have a login screen with fields for username and password. After the user clicks submit, I would wrap these two parameters inside a user object
and pass the object to the server side for authentication. On successful authentication the server would return to the UI a similar user object, which is now populated with a list of all the folders owned by the user. On the client I would flip the UI and now display say a list of all the folders. To populate the table, I can use the information available inside the user object.
Does this make sense?
java amateur
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |