Hello Everyone!
This is the page for EC601(Fall 2017) A1 Code Review 2 Assignment βΏ
The page for EC601(Fall 2017) A1 Code Review 1 Assignment can be found HERE βΏ
The Code Review 2 follows the same criteria as the Code Review 1 .
The project reviewed | @github.com/kev5/Go-Meet |
---|---|
The Reviewer | π¦ Qinjin Jia qjia@bu.edu π@github/qinjinjia |
Criteria Followed | MIT 6.005 fall 15 - Reading 4 Code Review |
Code Review Checklist |
π Summary of the Code Review Criteria π Code Review Criteria.pdf
π Code Review auxiliary tool: jslint, pep8, pylint
π This is an exciting project Go & Meet. The project is essentially a social/recreational application which gives information of all the events (public/private) happening in the local vicinity of the user on a real-time basis.
π The Github Repository of the Project Go & Meet becomes more abundant. There are some new files:file_folder: are added into the repository.
π There is a ReadMe file in the repository, which is perfect. However, there are many files in the Repository and GitHub file structure and directory structure is not clearly understandable. It seems that it is because the project is still under development π§.
π There are ten java files I reviewed in Code Review 1:
File Name | Link |
---|---|
ChooseLoginRegistrationActivity.java | π ChooseLoginRegistrationActivity.java |
Community.java | π Community.java |
Database.java | π Database.java |
LoginActivity.java | π LoginActivity.java |
MainActivity.java | π MainActivity.java |
Post.java | π Post.java |
RegistrationActivity.java | π RegistrationActivity.java |
User.java | π User.java |
readFromFireBase.java | π readFromFireBase.java |
writeToFireBase.java | π writeToFireBase.java |
π There are five java files and four python files I reviewed in Code Review 2:
File Name | Link | Comments |
---|---|---|
ChooseLoginRegistrationActivity.java | π ChooseLoginRegistrationActivity.java | Revised since Code Review 1 |
Database.java | π Database.java | Revised since Code Review 1 |
LoginActivity.java | π LoginActivity.java | Revised since Code Review 1 |
MainActivity.java | π MainActivity.java | Revised since Code Review 1 |
RegistrationActivity.java | π RegistrationActivity.java | Revised since Code Review 1 |
boston_crime.py | π boston_crime.py | New Added |
csv2json.py | π csv2json.py | New Added |
wikidata_get.py | π wikidata_get.py | New Added |
zipcodeData.py | π zipcodeData.py | New Added |
π |
Removed before Code Review 2 | |
π |
Removed before Code Review 2 | |
π |
Removed before Code Review 2 | |
π |
Removed before Code Review 2 |
All python files are assessed by the Code Review auxiliary tool: pep8 and pylint for an overview of the code quality.
Python File Name | Link | pep8 check | pylint check |
---|---|---|---|
boston_crime.py | π boston_crime.py | 25 Problems | 4.59/10 |
csv2json.py | π csv2json.py | 7 Problems | 3.75/10 |
wikidata_get.py | π wikidata_get.py | 9 Problems | -3.16/10 |
zipcodeData.py | π zipcodeData.py | 5 Problem | 3.16/10 |
PEP8 Example: PEP8 check for boston_crime.py
boston_crime.py:9:43: E251 unexpected spaces around keyword / parameter equals
boston_crime.py:9:45: E251 unexpected spaces around keyword / parameter equals
boston_crime.py:17:80: E501 line too long (96 > 79 characters)
boston_crime.py:20:20: E261 at least two spaces before inline comment
boston_crime.py:20:20: E262 inline comment should start with '# '
boston_crime.py:25:1: E302 expected 2 blank lines, found 1
boston_crime.py:30:12: E231 missing whitespace after ','
boston_crime.py:32:13: E201 whitespace after '('
boston_crime.py:32:31: E202 whitespace before ')'
boston_crime.py:33:20: E221 multiple spaces before operator
boston_crime.py:36:1: W293 blank line contains whitespace
boston_crime.py:47:21: W291 trailing whitespace
boston_crime.py:48:38: E231 missing whitespace after ','
boston_crime.py:69:12: E231 missing whitespace after ','
boston_crime.py:72:14: W291 trailing whitespace
boston_crime.py:76:70: W291 trailing whitespace
boston_crime.py:79:14: W291 trailing whitespace
boston_crime.py:86:80: E501 line too long (259 > 79 characters)
boston_crime.py:88:1: W293 blank line contains whitespace
boston_crime.py:89:1: W293 blank line contains whitespace
boston_crime.py:91:43: E251 unexpected spaces around keyword / parameter equals
boston_crime.py:91:45: E251 unexpected spaces around keyword / parameter equals
boston_crime.py:92:60: E251 unexpected spaces around keyword / parameter equals
boston_crime.py:92:62: E251 unexpected spaces around keyword / parameter equals
boston_crime.py:92:76: W292 no newline at end of file
Pylint Example: Pylint check for boston_crime.py
************* Module boston_crime
C: 9, 0: No space allowed around keyword argument assignment
f3 = open("zip_pos_us.csv", 'rt', encoding = 'latin-1')
^ (bad-whitespace)
C: 30, 0: Exactly one space required after comma
for key,value in zip_boston_pos.items():
^ (bad-whitespace)
C: 32, 0: Unnecessary parens after 'if' keyword (superfluous-parens)
C: 32, 0: No space allowed after bracket
if ( distance < lenmin ):
^ (bad-whitespace)
C: 32, 0: No space allowed before bracket
if ( distance < lenmin ):
^ (bad-whitespace)
C: 33, 0: Exactly one space required before assignment
zipcode = key
^ (bad-whitespace)
C: 36, 0: Trailing whitespace (trailing-whitespace)
C: 47, 0: Trailing whitespace (trailing-whitespace)
C: 48, 0: Unnecessary parens after 'in' keyword (superfluous-parens)
C: 48, 0: Exactly one space required after comma
for key, value in (zip(header,row)):
^ (bad-whitespace)
W: 49, 0: Bad indentation. Found 16 spaces, expected 12 (bad-indentation)
C: 69, 0: Exactly one space required after comma
for key,value in d.items():
^ (bad-whitespace)
C: 72, 0: Trailing whitespace (trailing-whitespace)
C: 76, 0: Trailing whitespace (trailing-whitespace)
C: 79, 0: Trailing whitespace (trailing-whitespace)
C: 86, 0: Line too long (259/100) (line-too-long)
C: 88, 0: Trailing whitespace (trailing-whitespace)
C: 89, 0: Trailing whitespace (trailing-whitespace)
C: 91, 0: No space allowed around keyword argument assignment
json.dumps(dict(boston_crime_data_from2015 = data))
^ (bad-whitespace)
C: 92, 0: Final newline missing (missing-final-newline)
C: 92, 0: No space allowed around keyword argument assignment
print(json.dumps(dict(boston_crime_data_from2015_statistics = crime_stat)))
^ (bad-whitespace)
C: 1, 0: Missing module docstring (missing-docstring)
C: 5, 0: Invalid constant name "f1" (invalid-name)
C: 6, 0: Invalid constant name "reader1" (invalid-name)
C: 7, 0: Invalid constant name "f2" (invalid-name)
C: 8, 0: Invalid constant name "reader2" (invalid-name)
C: 9, 0: Invalid constant name "f3" (invalid-name)
C: 10, 0: Invalid constant name "reader3" (invalid-name)
C: 12, 0: Invalid constant name "zip_boston" (invalid-name)
C: 13, 0: Invalid constant name "zip_boston_pos" (invalid-name)
W: 29, 4: Redefining name 'zipcode' from outer scope (line 39) (redefined-outer-name)
W: 30, 8: Redefining name 'key' from outer scope (line 48) (redefined-outer-name)
W: 30,12: Redefining name 'value' from outer scope (line 48) (redefined-outer-name)
C: 25, 0: Missing function docstring (missing-docstring)
C: 37, 0: Invalid constant name "data" (invalid-name)
C: 38, 0: Invalid constant name "header" (invalid-name)
C: 39, 0: Invalid constant name "zipcode" (invalid-name)
C: 42, 7: Do not use `len(SEQUENCE)` as condition value (len-as-condition)
W: 46, 8: No exception type(s) specified (bare-except)
C: 58, 0: Invalid constant name "crime_stat" (invalid-name)
-----------------------------------
Your code has been rated at 4.59/10
According to the Code Review auxiliary tool Pep8 and Pylint, Overall Code Quality(Formatting) is OK.
For all java files revised after Code Review 1 and all new added python files, the uses of alignments are perfect. The code block starting point and ending point are easily identifiable.
The βcamelCodeβ nameing convention is used in the project. The developers utilize capital letters to indicate the start of a word, which makes name of variables be meaningful.
πPerfect! The code can fit in the standard 14-inch laptop screen.
The commented code in Database.java has been deleted (Or removed from the master branch) before Code Review 2.
public class Database {
public FirebaseDatabase mDatabase;
public DatabaseReference myRef;
// public String ID = "690"; <-This commented code should be removed
public Database(){
}
and the commented code in MainActivity.java has been removed as well.
al.add(post01.getPostText());
// al.add(post02.getPostText()); <-This commented code should be removed
// al.add(post03.getPostText());
// al.add(post04.getPostText());
// al.add(post05.getPostText());
// al.add(post06.getPostText());
However, it seems that it is because the project is still under development π§. There are still some commented code blocks in the project. The commented code in MainActivity.java, for instance.
// public void postEvent(View view) {
// view = (LayoutInflater.from(MainActivity.this)).inflate(R.layout.activity_post, null);
// AlertDialog.Builder alertBuilder = new AlertDialog.Builder(MainActivity.this);
// alertBuilder.setView(view);
//
// Dialog dialog = alertBuilder.create();
// dialog.show();
//
// alertBuilder.setCancelable(true)
// .setPositiveButton("GO", new DialogInterface.OnClickListener(){
// //private EditText mEventName;
//
// @Override
// public void onClick(DialogInterface dialog,int which){
// mEventName = (EditText) findViewById(R.id.event_name);
// final String eventName = mEventName.getText().toString();
// final String userId = mAuth.getCurrentUser().getUid();
// DatabaseReference postDb = FirebaseDatabase.getInstance().getReference().child("Users").child(userSex).child(userId).child("dd");
// postDb.setValue(eventName);
//
// }
// });
// }
It seems that the developers follow the Singleton pattern, which is good.
Additionally, code is in sync with existing code patterns/technologies.
Therefore, the architecture of the project is nice.
π Good!. There is no hard coding in the project.
The java file π MainActivity.java contains magic number. It is difficult to understand what is the meaning of 1, 2, 3 etc here. This might be solved by utilizing the enumeration.
mWrite.writePosts("1",post01);
mWrite.writePosts("2",post02);
mWrite.writePosts("3",post03);
mWrite.writePosts("4",post04);
mWrite.writePosts("5",post05);
mWrite.writePosts("6",post06);
This issue has been revised before the Code Review 2. π Perfect!
There are some to-do comments mention pending tasks, which is good. For instance, in User.java
public User() {
// Default constructor required for calls to DataSnapshot.getValue(User.class)
}
However, this kind of comments(i.e. comments to help developer understand the tutorial) should be deleted (or removed from the master branch).
public void onLeftCardExit(Object dataObject) {
//Do something on the left!
//You also have access to the original object.
//If you want to use it just cast it (String) dataObject
Toast.makeText(MainActivity.this, "NOPE!", Toast.LENGTH_SHORT).show();
}
Additionally, the developers could add some comments to help others understand the code.
π Good, there is no multiple if/else block in the project.
N/A
The Readability of the code is good. The team uses βcamelCodeβ nameing convention, which makes name of variables be meaningful. The project is still under development π§, there is no .apk file in the repository, therefore, "Testability", "Debuggability", "Configurability" of the project are not reviewed. Unit test should start before or during the project itself.
Some places in the code violate DRY (Do not Repeat Yourself) principle.Duplicated code is a risk to safety. If you have identical or very similar code in two places, then the fundamental risk is that thereβs a bug in both copies, and some maintainer fixes the bug in one place but not the other. For instance, DRY code in π writeToFireBase.java
public void likePost(String postID){
DatabaseReference commentPostRef = this.writepostRef.child(postID);
commentPostRef.child("likes").push().setValue(this.user.getUid());
}
public void dislikePost(String postID){
DatabaseReference commentPostRef = this.writepostRef.child(postID);
commentPostRef.child("dislikes").push().setValue(this.user.getUid());
}
However, the project utilizes generic functions and classes, which increase reusability of the project.
Exception handling is not found in the code, which could be considered to add after achieveing the main functions of the software.
The project utilizes classes and functions, which makes the code has Good Extensibility. The enhancements could be added to the existing code with minimal changes under this design(i.e. classes and functions).
The developers considered the security of the software, Authentication is addded by utilizing the firebase in LoginActivity.java.
public void onClick(View v) {
final String email = mEmail.getText().toString();
final String password = mPassword.getText().toString();
The project is still under development π§, there is no .apk file in the repository, therefore, Performance of the project is not reviewed.
The firebase realtime database is utilized as the backend of the porject, which can be found in writeToFireBase.java. The firebase realtime database supports a large user base/data. Therefore, the scalability of the project is good.
public writeToFireBase(){
this.user = FirebaseAuth.getInstance().getCurrentUser();
this.database = FirebaseDatabase.getInstance();
this.writepostRef = this.database.getReference("posts");
this.userRef = this.database.getReference("users");
}
The project is still under development π§, therefore, Usability of the project is not reviewed.
The classes in the code are checked, each single class or function has one responsibility. Therefore, the code obeys the Single Responsibility Principle (SRS). Nice design! π
Owing to the developers' good design, each single class or function has one responsibility. While adding new functionality, existing code does not need to be modified. Therefore, the project obeys the Open Closed Principle.
The class hierarchy does not exist in the project. Therefore, the project does not violate the [Liskov substitutability principle](https://en.wikipedia.org/wiki/Liskov_substitution_principle)
The project is still under development π§, there is no .apk file in the repository, therefore, Interface segregation of the project is not reviewed.
The project utilizes firebase to achieve authentication. Dependency injection is not applicable to the project.
π The overall code quality is high, the design of the software is good. Many issues mentioned in Code Review 1 has been revised. Commented Code Problem, for instance. Thanks π.
π The project has proper code formatiingοΌusing βcamelCodeβ nameing convention makes name of variables be meaningful. However, code formatting still can be improved according to the reports from the Code Review auxiliary tool: jslint, pep8, pylint.
π The architecture of the project is nice.
π There are some to-do comments mention pending tasks, which is good.
π The Readability of the code is good. The developers considered the security of the software, Authentication is addded by utilizing the firebase.
π The project obeys Single Responsibility Principle(SRS), Open Closed Principle and Liskov substitutability principle.
π GitHub file structure and directory structure is still not clearly understandable. It seems that it is because the project is still under development π§.
πThere are some commented code blocks in the project. The commented code blocks could keep in other branch rather than the master branch. Additionally, the comments that help developer understand the tutorial should be deleted (or removed from the master branch).
π The developers could add some comments to help others understand the code.
π There is no .apk file in the repository, therefore, "Testability", "Debuggability", "Configurability" of the project cannot not reviewed. It is also a good practice to do Unit Test along the code development. Unit test should start before or during the project itself.
π Finally, Good Luck for your project :D)β