spartan7777 / Individual-Enterprise-Project

Enterprise Java Individual Project
0 stars 0 forks source link

Q&A Set 2 #13

Open pawaitemadisoncollege opened 3 years ago

pawaitemadisoncollege commented 3 years ago

@spartan7777 Following are the questions you sent via email and my response. I thought it would be valuable to keep this information right in the project.

Q1. Is there a formula or some universal way of knowing when to use a Try/Catch block? Or is this not a formula thing but an experience or trial and error kind of thing to see where an exception will occur that needs to be caught?

A1. There are couple ways to know when you will need to handle an exception.

Screen Shot 2020-10-27 at 7 20 10 AM

Q2. What kind of database security are we looking for in these projects? Do we need to have our own passwords for them?

A2. On the vm I don't think it's critical to change the password for the mysql database. Because your AWS mysql database is in the cloud and perhaps more accessible, it may be a good idea to at least change that password, as everyone in our class is starting with the same amazon machine image and all have the same mysql uid/pwd.

Q3. It looks like a Java class (POJO) is needed for each database table. How about DAOs...? Can we do the same thing for those and have one be out there for each database table?

A3. I recommend writing 1-2 entity-specific Daos to understand how the Daos work. After that, I expect you will remove those entity-specific daos and use the generic dao. Here is some feedback that I usually provide on the week 4/5 hibernate work:

"You'll likely notice, if you haven't already, that writing a Dao for each entity will be very repetitive - watch for the abstract/generic dao to be introduced in week 5 and plan to use it in your project so that you can use a single dao! Note that you will still have unit tests each for each entity(dao) to make sure that annotations and database relationships are set up correctly."

Q4. For my project: There is a Concept table...I tied this to the userid in the user table. I wanted to eliminate the chances of duplicate concepts being displayed through a method call if they happen to belong to separate users. Is this overthinking the idea of privacy in this application? Will having log in capabilities provide that privacy?

A4. Yes, the combination of Hibernate and Authentication will give you the ability to get a user based on the logged in user's username, and then access that user's concepts.

Q5. The database credentials that we need for IntelliJ....we got these from you. Had I been successful in setting up my own environment, would the credentials be what I entered into the MySQL database at the time of that set up?

A5. Yes, the root user is defined during installation. After installation, and at anytime, you can create new users and passwords in the database. Refer to Week 7 where we create a user in the database called "tomcat".

Q6. Packages....I have noticed that you and a lot of the examples I studies had several packages within their projects. Is this a matter of choice for better organization? I was under the impression it would be best to put all relevant code for an application into one package....but I don’t really think that is what packages are for. Am I overthinking this too?

A6. As applications grow larger it's nice to have them organized. In this course, I'm demonstrating a package organization based on the role the classes play, for example:

Note that some organizations choose to create packages based on function.

It doesn't matter too much, just choose a way to organize that makes sense to you.

Q7. In looking at a lot of these examples - I have found that while I can define classes and objects and what they do - I am not very clear on how objects move from one class to the other. I find that this is making it tough for me to decdie how I want to actually code this project. I would like to disucss this with you to get this down in a way I can really understand. I feel that I never tackled this before and I am not able to ask this question in a way that will get me an answer I can digest. Unfortunately, all I get are the various condescending responses in Stack Overflow.

A7. Maybe talking through a specific example would be helpful. Your User class, for example, will need to know about a User's Concepts.

The User class might have the following instance variables:

The Concept class might have the following

The Hibernate annotations and the Database tables and keys work to tie the User and Concept together, such that when you retrieve a user or a concept from the database, the other stuff automatically comes with it. Behind the scenes, a sql join is executing to do this work, then hibernate places the retrieved data into a user object and one or more Concept objects.