Homework 6
- Git & Github (Git&Github Readings)
- Refactoring (Refactoring Readings)
- You are expected to work individually.
- Due: Wed February 11th at 11pm EST (Baltimore time).
Getting set up!
- Please go to https://classroom.github.com/a/ivm2uDnq
- Login to your GitHub account and accept the invitation!
- A GitHub repository will be created for you that contains the starter code. The repository is "private" and you must not change it to a "public" one. You must not add any collaborators to it. Clone this repository locally. Open the folder in your favorite text editor and start working on it.
Task 1: Refactoring
- Consider the following code to get the credit score of a user (i.e., person) from a credit agency as part of a loan-lender app. Can you identify and name a particular code smell (among the ones we have covered in class)? How would you go about fixing the code smell? Explain.
// ...
CreditAgency cA;
// code to properly initialize cA
int score = cA.getCreditScore(personFirstName, personLastName, personSSN, personAdddress);
// more code
- Identify and name a code smell in class
Person(among the ones we have covered in class)? How would you go about fixing it/them?
There might be more than one occurrence of a particular code smell!
public class Person {
String fullName;
String mailingAddress;
String email;
// method implementations
}
Save your answers task1.md.
Task 2: Git & Github
In this task, you will get practice with Git and GitHub. You are expected to be using a terminal for working with Git. You must follow the instruction below. Some of the instructions require you to run Git commands in the terminal. You must keep a log of the Git commands you use, in the order you use them, in the task2.md file.
Make a folder called
task2. Open the terminal and change the working directory totask2folder.Initialize a Git repository in this folder.
Add a
README.mdfile and writeThis is a readme file!in it and save it.Add and commit changes with a descriptive commit message. (For all the following instructions, when you "commit", we expect that you enter a descriptive commit message.)
Go on GitHub and make an empty repository under your own account (not the course organization!).
tipIt doesn't matter what you call this repo, and whether it is public or private!
Push your local repository to the remote (GitHub repository) that you've created.
Open the
README.mdon GitHub and rewrite theREADME.mdto containThis is a remote readme file!. Save (commit) the file on GitHub. Next, edit the local copy ofREADME.mdto containThis is a local readme file!.

Notice the only difference between the README on GitHub and on your local computer is the words local vs. remote.
Commit the changes on your local repository and try to push them to the remote repository. This should not work! Try to solve the problem. (As you solve the problem, more problems may arise, including a merge conflict! You should resolve the conflict, and eventually when all issues are resolved, both local and GitHub repository must contain
This is a readme file!)Assume your repository contains the code for your software. Moreover, assume we are going to add a new feature to your software using the GitHub Flow.
Go to your repository on GitHub.
Create an issue with the title "Making feature 1!".
Create a new branch on your local repository and call it
feature1.Make a new file
FEATURE1.mdin this new branch and writeThis is feature 1!in it!Commit changes and push to remote (GitHub) repository. You must get an error now. Try to solve it! (Hint: pay attention to the error message!)
Once you've resolve the issue and committed the changes to the remote repository, go to GitHub and create a pull request to merge the
feature1branch to themainbranch.Approve the pull request and merge the
feature1branch to themainbranch.After the merge has been successful, close the issue related to adding the new feature.
Go on to your local repository and pull the latest changes from remote to your local
mainbranch.
You may consult git and github documentations to look up various git commands and how to do things on Github! Here are some resources:
- Git cheat-sheet: https://education.github.com/git-cheat-sheet-education.pdf
- Git tutorial: https://git-scm.com/docs/gittutorial
- Github Docs: https://docs.github.com/en
Save your answers in task2.md.
Submission
- Go to Gradescope
- Click on Homework 6.
- Select your homework repository.
- Select the "main" branch.
- Hit Upload!
The files in your GitHub repository are now submitted as your homework submission.
If submitting using the above-mentioned Github option does not work, you can always submit manually by uploading your files!
Gradescope does not automatically fetch changes from your GitHub repository. If you make any updates to your repository, you must "resubmit" your work to Gradescope. (The resubmission process is exactly the same as the first submission.)