Question

In: Computer Science

How can we write an application that calculates connascence of an application?

How can we write an application that calculates connascence of an application?

Solutions

Expert Solution

Solution:-

Connascence is a process where we check th strength of two different parts of the application. Connascence may sound like waste of space and time in the application during application testing, but it playes an important role to prioritise what should be refactored first.

Connascence can be done for algorithms, block of code or coupling in the application. Connascence of algorithm is where multiple block of code must agree on a particular algorithm for giving ouput.

Connascence of code is where two piece of code agrees on certain point of calculation for it to work further. Connascence of code is same for block of code here all it does is refactorize the parts on the priority bases during the unit testing.

How it is done:-

Lets consider two piece of code, consider an example of connascence of algorithm.

def write_data_to_file(data_string):
    with open('/path/to/file', 'wb') as file_values:
        file.write(data_string.encode('utf8'))
def read_data_from_file():
    with open('/path/to/file', 'rb') as file_values:
        return file.read().decode('utf8')

The test code for these two block would be:-

We are testing for the users password.

def test_user_password(self):
    user = User.new(name="xyz")
    actual = user.password()
    expected = hashlib.md5(user.name).hexdigest()
    self.assertEqual(expected, actual)

Related Solutions

JAVA - The Westfield Carpet Company has asked you to write an application that calculates the...
JAVA - The Westfield Carpet Company has asked you to write an application that calculates the price of carpeting for rectangular rooms. To calculate the price, you multiply the area of the floor(width times length) by the price per square foot of carpet. For example, the area of floor that is 12 feet long and 10 feet wide is 120 square feet. To cover that floor with carpet that costs $8 per square foot would cost $960. (12 X 10...
C++ application that calculates the sales at the end of the day. Need to know how...
C++ application that calculates the sales at the end of the day. Need to know how much money I made on selling my famous banana muffins each day. At the end of each day I must not only enter the number of banana muffins I sold but I must also enter the price of the banana muffins. Each day I have to experiment with changing the price in an attempt to maximize my revenues for his muffins. I also want...
You've been hired by Yogurt Yummies to write a C++ console application that calculates and displays...
You've been hired by Yogurt Yummies to write a C++ console application that calculates and displays the cost of a customer’s yogurt purchase. Use a validation loop to prompt for and get from the user the number of yogurts purchased in the range 1-9. Then use a validation loop to prompt for and get from the user the coupon discount in the range 0-20%. Calculate the following:         ● Subtotal using a cost of $3.50 per yogurt.         ● Subtotal...
In Java write an application that calculates total retail values for 5 different shoes entered by...
In Java write an application that calculates total retail values for 5 different shoes entered by the user. Shoe 1 $15.50 Shoe 2 $27.30 Shoe 3 $34.50 Shoe 4 $42.11 Shoe 5 $54.25 Application must read shoe number and quantity sold for each product stdin, compute the total value of that sale, and add the value of that sale to a grand total for that shoe. After all data has been entered, display the total value of each of the...
In C++ write an application that calculates total retail values for 5 different shoes entered by...
In C++ write an application that calculates total retail values for 5 different shoes entered by the user. Shoe 1 $15.50 Shoe 2 $27.30 Shoe 3 $34.50 Shoe 4 $42.11 Shoe 5 $54.25 Application must read shoe number and quantity sold for each transaction stdin, compute the total value of that sale, and add the value of that sale to a grand total for that shoe. After all data has been entered, display the total value of each of the...
Create an Investment application that calculates how many years it will take for a $2,500 investment...
Create an Investment application that calculates how many years it will take for a $2,500 investment to be worth at least $5,000 if compounded annually at 7.5% ( Java Programming)
Lab 10-2:You've been hired by Yogurt Yummies to write a C++ console application that calculates and...
Lab 10-2:You've been hired by Yogurt Yummies to write a C++ console application that calculates and displays the cost of a customer’s yogurt purchase. Use a validation loop to prompt for and get from the user the number of yogurts purchased in the range 1-9. Then use a validation loop to prompt for and get from the user the coupon discount in the range 0-20%. Calculate the following:           ● Subtotal using a cost of $3.50 per yogurt. ● Subtotal...
Operation  This application calculates the charges for a stay at a hotel based on the...
Operation  This application calculates the charges for a stay at a hotel based on the arrival and departure dates.  The application begins by prompting the user for the month, day, and year of the arrival and the departure.  Next, the application displays the arrival date, the departure date, the room rate, the total price, and the number of nights. Specifications  Create a class named Reservation that defines a reservation. This class should contain instancevariables for the...
Create an application that calculates and displays the amount of a homeowner’s property tax. The tax...
Create an application that calculates and displays the amount of a homeowner’s property tax. The tax is 1.35% of the property’s assessed value, which will be entered by the user. a. Prepare a Planning Chart for the application. b. Draw a sketch of an appropriate interface. Be sure to follow the GUI design guidelines covered in the chapter. The guidelines are summarized in Figure 2-20. (If you want to include an image in the interface, you can either use your...
In C# Create a GUI application that calculates and displays the total travel expenses of a...
In C# Create a GUI application that calculates and displays the total travel expenses of a business person on a trip. Here is the information that the user must provide: Number of days on the trip Amount of airfare, if any Amount of car rental fees, if any Number of miles driven, if a private vehicle was used Amount of parking fees, if any Amount of taxi charges, if any Conference or seminar registration fees, if any Lodging charges, per...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT