Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2. (20 points) For each of the following code sketches answer the following: i. ii. iii. Does the code represent a violation of the principle

image text in transcribed

image text in transcribed

2. (20 points) For each of the following code sketches answer the following: i. ii. iii. Does the code represent a violation of the principle of abstraction or information hiding (pick the most significant)? What is the negative impact of the violated principle? Assume the code is part of a larger project. Suggest how it could be refactored to fix the violated principle, but still provide the same features. a) public class IndexedElementContainer extends Element { public Vector children = new Vector(); // ... public void addChildAt(Element child, int index) { children.add(index, child); } public Element getChildAt(int index) { return children.elementAt(index); } // ... } b) public class FileReader { /** Opens a file for reading * @param filePath path of the file to open * Oparam buff will be used to buffer file I/O, pass null for no buffering * @param crypto will be used to decrypt the file, pass null for no encryption * @param compress will be used to decompress the file, pass null for no compression * @return 1 on success, on failure */ public int openFile(String filePath, Buffer buff, Decryptor crypto, Decompressor compress) { } public String readLine() { // ... } public void closeFile() { } }

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 System MCQs Multiple Choice Questions And Answers

Authors: Arshad Iqbal

1st Edition

1073328554, 978-1073328550

More Books

Students also viewed these Databases questions

Question

=+impact member states and MNEs?

Answered: 1 week ago