Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management An Organizational Perspective

Authors: Richard T. Watson

1st Edition

0471305340, 978-0471305347

More Books

Students also viewed these Databases questions