Find a source code of a program or developed software system.
You can select any source code in any programming language. Provide
a brief description of the source code you chose and properly cite
the source.
Find two code “bad smells” on the selected code, and then refactor
the code with an appropriate refactoring method. You should specify
the bad smells that you found and the refactoring method that used.
You should provide the original code and the Refactored
code.
//Source code with code smell class Person { // code smell - Temporary Field public int getScore(int a, int b){ int score = a * b; if(score > 100){ return score * 0.95; } else { return score * 0.25; } } } // code smell - duplicate code class Customer extends Person { // calculate age public function getAge() { return date('Y') - date('Y', strtotime("2012-10-5")); } } class Vendor extends Person { // calculate age public function getAge() { return date('Y') - date('Y', strtotime("2012-10-5")); } }
Refactored code:
// Refactored code class Person { // removed temporary variable public int getScore(int a, int b) { if(a * b > 100){ return a * b * 0.95; } else { return a * b * 0.25; } } // removed duplicate code and moved to parent class public function getAge() { return date('Y') - date('Y', strtotime("2000-11-25")); } } class Customer extends Person { } class Vendor extends Person { }
I have added my custom method for another code smell.
Two code smells found in code:
1. Temporary field :
There was temporary field score in getScore(int,int) method
2. Duplicated code:
There was duplicate code for getting age in Customer and Vendor class in getAge() method.
Refactoring method used:
Note : Source code is written in Java
Find a source code of a program or developed software system. You can select any source...
Design Java (source code) a program (name it IndexOfLargest) to find the index of the first largest value in the array. Note that the largest value may appear more than once in the array. The program main method defines a single-dimensional array of size 10 elements and prompts the user to enter 10 integers to initialize the array. The main method then calls method findIndex() that takes a single-dimensional array of integer values and return the index of the first...
If your program does not compile, you will not receive any points! You will write a program to keep up with a Jewelry store and some of the Inventory (rings/necklaces/earrings) purchased there (The Jewelry store can be real or not) using Object-Oriented Programming (OOP). The important aspect of object-oriented programming is modular development and testing of reusable software modules. You love selling rings, necklaces, and earrings as well as programming and have decided to open a Jewelry store. To save...
Write a software key-logger and test it while you fill out a web form or type in the contents of a document using your favorite document preparation software. You can use Java or Python to do this assignment. C and C related programming language is not allowed for this assignment. Hints: You can find a demo and API for key-logger hook in the following link for JAVA. https://github.com/kwhat/jnativehook This project can only be used to learn how to use JNI...
The question of validity is to answer the question of whether for a Boolean expression consisting of n variables . There is a combination of values of variables that make the result of the expression true or not. In this phrase each The variable can be simple or contradictory. Force brute method of all compounds . Creates and evaluates the possible and the first time the result is true (if it is) the answer to the problem Come and stop...
For artificial intelligence. Can you find me a open source code online for face recognition? Like in C++ or any other langauge. Just show me the steps on how to run it and I can figure out then rest. The objective is to run the code and than let the computer find my face in pixel etc.
ROR ANALYSIS WITH ESTIMATED
LIVES THAT VARY Background Make-to-Specs is a software system under
development by ABC Corporation. It will be able to translate
digital versions of three-dimensional computer models, containing a
wide variety of part shapes with machined and highly finished
(ultra smooth) surfaces. The product of the system is the
numerically controlled (NC) machine code for the part’s
manufacturing. Additionally, Make-to-Specs will build the code for
superfine finishing of surfaces with continuous control of the
finishing machines. Information...
I need this Program code made for Java please with the sample
results.
Echo Input from the Console to the Screen Using Methods
Review the resources and instructions in the Discussion Prep
Study before completing this discussion.
For this discussion, you practiced using Java methods to echo
input from the console to the screen. Create a Java program that
reads in any value entered at the console and then prints it out to
the screen. The program must have at...
All code will be in Java, and there will be TWO source code. I. Write the class MailOrder to provide the following functions: At this point of the class, since we have not gone through object-oriented programming and method calling in detail yet, the basic requirement in this homework is process-oriented programming with all the code inside method processOrderof this class. Inside method processOrder, we still follow the principles of structured programming. Set up one one-dimensional array for each field: product...
CIS363 Web Interface Design With Lab Lab 4: Navigation, Graphics and Slideshows Instructions Scenario Obtain 10 original photos. Research on the Internet and find some code that will allow you to create a slideshow. Create a page with your photos and the code that you find. Create a Word document showing the source for your slideshow code. Be sure to document your HTML code as well. Lab Steps Part A: Get Photos The photos can be obtained through http://quest.eb.com.proxy.devry.edu/ or...
Sequences of numbers are a useful mathematical tool for exploring transitions and trends. Sequences of symbols create words, and sequences of words create languages, both Human and Computer. While sequences of nucleotides create DNA, which in turn create new sequences of nucleotides called RNA, which in turn creates sequences of amino acids called proteins, which in turn create, among other things, humans that create, among other things, computers. The quest to identify this “Source Code of Life” quickly became the...