So I'm developing a linkedIn-style social network in Java (JSP and Servlets) and SQL. And I have to use JDBC. I think my SQL is strong and I understand how the database operates. But then trying to implement OO principles on this data makes me think I'm doing it all wrong.
In my database I have these tables: profiles, profile_education and profile_experience. Profiles contains name, location, dob, etc. The other two tables use profiles_id as a foreign key and are designed for a user to be able to enter multiple records (i.e. more than one job as experience).
But when it comes to Java I'm confused. Should I have separate classes for profiles, education and experience? Below is my attempt at coding based on the database. I feel like I'm writing waaaay too much code. Do I need to make getters and setters for every variable from the database? Here's my attempt at writing the profile class:
import java.util.ArrayList;
import java.util.List;
public class Profile {
private int id;
private String first_name;
private String last_name;
private List<Education> educationList = new ArrayList<Education>();
private List<Experience> experienceList = new ArrayList<Experience>();
private List<Skills> skillList = new ArrayList<Skills>();
I would appreciate any feedback I can get.
But when it comes to Java I'm confused. Should I have separate classes for profiles, education and experience?
I would go for separate classes as well.
Do I need to make getters and setters for every variable from the database?
No but for every variable in your DA-/Domainobjects.
Apart from that, your implementation looks reasonable to me.
And yes, boilerplate code is part of the game in any case.