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...
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...
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)
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...
C# A car dealer wants an application that calculates the cost of a car. The GUI...
C# A car dealer wants an application that calculates the cost of a car. The GUI application should link the “BuildYourCar.accdb” database and display all the data in four different “ListBox” based on the category. Each “ListBox” should display all the items in that category. The user can only choose one item from each “ListBox” to add an item to a car. As each item is selected, the application displays the item in a separate “ListBox” to display. If user...
Create an application that calculates mph or (Miles Per Hour). There should be 2 textboxes for...
Create an application that calculates mph or (Miles Per Hour). There should be 2 textboxes for input, and 2 labels to label the input textboxes. The first textbox should be the miles driven. And the other textbox should be hours taken. There should be a button to calculate miles per hour. And a label or textbox for the results of the calculate. 1textbox for miles [input] 2textbox for hours (time used) [input] 3label for miles textbox 4label for hours textbox...
***IN C# ONLY, USING WINDOWS FORMS*** --NO JAVA--. Create a GUI application in C# that calculates...
***IN C# ONLY, USING WINDOWS FORMS*** --NO JAVA--. Create a GUI application in C# 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...
Write a program that calculates the balance of a savings account at the end of a...
Write a program that calculates the balance of a savings account at the end of a three month period. It should ask the user for the starting balance and the annual interest rate. A loop should then iterate once for every month in the period, performing the following: Ask the user for the total amount deposited into the account during that month. Do not accept negative numbers. This amount should be added to the balance. Ask the user for the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT