Answered step by step
Verified Expert Solution
Question
1 Approved Answer
what is unclear? 3. (10 points) Critique the following code refactoring, does it represent an application of the principles of abstraction and/or information hiding? Assume
what is unclear?
3. (10 points) Critique the following code refactoring, does it represent an application of the principles of abstraction and/or information hiding? Assume the code is part of a larger project, how could the design be improved further? class Dataloggervi { JDBCDatabaseDriver driver; public Dataloggervi (JDBCDatabaseDriver driver) { this.driver = driver; } class Dataloggerv2 { JDBCDatabaseDriver driver; public DataloggerV2 (JDBCDatabaseDriver driver) { this.driver = driver; } public void storeSample (Sensor sensor) { driver.openTransaction(); double value = sensor.getValue(); Location location = sensor.getLocation(); MeasureType type = sensor.getMeasureType(); driver.execLoggerPreparedstmt(value, location, type); driver.closeTransaction(); } public void storeTemp (Temp Sensor temp Sensor) { driver.open Transaction(); double value = temp Sensor.getValue(); Location location = temp Sensor.getLocation(); MeasureType type = temp Sensor.getMeasureType(); driver.execLoggerPreparedStmt(value, location, type); driver.closeTransaction(); } public void storeHumidity (Humidity Sensor humiditySensor) { driver.openTransaction(); value = humiditySensor.getValue(); location = humiditySensor.getLocation(); type = temp Sensor.getMeasureType(); driver.execLoggerPreparedStmt(value, location, type); driver.closeTransaction(); } } 3. (10 points) Critique the following code refactoring, does it represent an application of the principles of abstraction and/or information hiding? Assume the code is part of a larger project, how could the design be improved further? class Dataloggervi { JDBCDatabaseDriver driver; public Dataloggervi (JDBCDatabaseDriver driver) { this.driver = driver; } class Dataloggerv2 { JDBCDatabaseDriver driver; public DataloggerV2 (JDBCDatabaseDriver driver) { this.driver = driver; } public void storeSample (Sensor sensor) { driver.openTransaction(); double value = sensor.getValue(); Location location = sensor.getLocation(); MeasureType type = sensor.getMeasureType(); driver.execLoggerPreparedstmt(value, location, type); driver.closeTransaction(); } public void storeTemp (Temp Sensor temp Sensor) { driver.open Transaction(); double value = temp Sensor.getValue(); Location location = temp Sensor.getLocation(); MeasureType type = temp Sensor.getMeasureType(); driver.execLoggerPreparedStmt(value, location, type); driver.closeTransaction(); } public void storeHumidity (Humidity Sensor humiditySensor) { driver.openTransaction(); value = humiditySensor.getValue(); location = humiditySensor.getLocation(); type = temp Sensor.getMeasureType(); driver.execLoggerPreparedStmt(value, location, type); driver.closeTransaction(); } }Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started