possible use for a properties file?

B

Brandon McCombs

I am developing an LDAP client that will allow a user to search and
browse a directory server. I currently have the main window spawn a
settings dialog that stores user auth. credentials into a class I
created to hold that type of data. I then am attempting to pass an
instance of that credential clas around to use in various places in the
code when I have to authenticate for a directory context connection.
That worked until I started having to pass it between classes and I
figured there had to be a better way.

I started wondering whether this would be a good time to start learning
how to use a props file. I'm currently already using a file though to
store my user credentials and that data gets put into my credential
class instance so I'd end up with the same problem I think of having to
share data across classes instead of just methods.

Is the only way to share this data to pass my credentials class instance
into the constructor of any class that needs access to it or is there a
cleaner way of doing that like a props file?

thanks for any tips
 
C

castillo.bryan

I would suggest having some type of Manager/Application class that all
of your UI classes have a reference to. You would have to pass it to
every constructor that needed information. Chances are some class will
need something else from the application besides credentials. When
that happens, you can change your Manager class so that those items can
be retrieved from it.
 
H

Hiran Chaudhuri

I would suggest having some type of Manager/Application class that all
of your UI classes have a reference to. You would have to pass it to
every constructor that needed information.

Instead of passing around all these references to the Manager/Application it
is easier to have the Manager/Application class be static (with all fields
and methods) or create a singleton pattern.

Just my 0.02?...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top