- 4 hours
- Hard
Free online content available in this course.
course.header.alt.is_video
course.header.alt.is_certifying
Got it!Last updated on 2/21/22
Separate Application Layers Using Model-View-Controller
Evaluated skills
- Separate Application Layers Using Model-View-Controller
Description
The first two questions refer to the following code segment:
private static void buildTableModel(JTable table) {
ResultSet rs = DroneDb.getResultSet("SELECT * from drones");
try {
ResultSetMetaData metaData = rs.getMetaData();
Vector<String> columnNames = new Vector<String>();
int columnCount = metaData.getColumnCount();
for (int column = 1; column <= columnCount; column++) {
columnNames.add(metaData.getColumnName(column));
}
// data of the table
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
while (rs.next()) {
Vector<Object> vector = new Vector<Object>();
for (int columnIndex = 1; columnIndex <= columnCount; columnIndex++) {
vector.add(rs.getObject(columnIndex));
}
data.add(vector);
}
table.setModel(new DefaultTableModel(data, columnNames));
} catch (SQLException e) {
e.printStackTrace();
}
}
Question 1
Which of the MVC layers is being addressed in the code example above?
Model
View
Controller
Calculator
Question 2
In this code segment, what makes independent testing of the function difficult?
Careful, there are several correct answers.It requires the visual layer to be constructed.
It requires the data layer to be constructed.
It uses poorly named variables.
The function is not difficult to test.
Question 3
What is the purpose of refactoring?
To add a new user story to an application.
To fix code that has bugs/defects.
To explore various architectural decisions before committing to a design.
To improve existing code, while maintaining the same functionality.
- Up to 100% of your training program funded
- Flexible start date
- Career-focused projects
- Individual mentoring