Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Peer Review #13

Open
wants to merge 79 commits into
base: review
Choose a base branch
from
Open

Peer Review #13

wants to merge 79 commits into from

Conversation

jillianKhoo
Copy link
Owner

No description provided.

std::cout << "Make sure the parent id actually exists" << std::endl;
}
}
else {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the google style guide, they normally put elses on the same line as the closing bracket for the if

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should fix this throughout the codebase.

else {
int num_chirps = reply.chirps_size();
for(int i = 0; i < num_chirps - 1; i++) {
chirp::Chirp this_chirp = reply.chirps(i);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could declare this_chirp outside of the loop

std::unique_ptr<grpc::ClientReader<chirp::MonitorReply> > stream_handle (stub_->monitor(&context, request));
while (true) {
while (stream_handle->Read(&reply)) {
chirp::Chirp this_chirp = reply.chirp();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also here, chirp could be declared outside of loop

if (FLAGS_monitor && my_username != "") {
client.monitor(my_username, stub_);
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove blank line maybe?

#include "service.pb.h"
#include <iostream>
#include <gflags/gflags.h>
#include "client.h"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im p sure that there should be a blank line between iostream and the rest, and iostream should go first

}
chirp::Chirp* chirp_pointer = reply->add_chirps();

return grpc::Status::OK;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know whether return statements need an empty line above them, but it should be consistent, whichever you choose I feel like.

std::deque<chirp::Chirp> read_chirps = service_.read(request->chirp_id());
for (chirp::Chirp c : read_chirps) {
chirp::Chirp* chirp_pointer = reply->add_chirps();
const chirp::Chirp& added_chirp = c;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const should start with a k and also these chirps can be declared outside of the loop and then filled in once you enter the loop

while (keep_monitoring) {
std::chrono::seconds seconds = std::chrono::duration_cast< std::chrono::seconds >(std::chrono::system_clock::now().time_since_epoch());
std::chrono::microseconds useconds = std::chrono::duration_cast< std::chrono::microseconds >(std::chrono::system_clock::now().time_since_epoch());
std::deque<chirp::Chirp> found_chirps = service_.monitor(request->username(), initial_time);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these three can all be declared before the loop

initial_time.set_useconds(useconds.count());
for (chirp::Chirp c : found_chirps) {
if(read_chirps.find(c.id()) == read_chirps.end()){
chirp::Chirp* this_chirp = new chirp::Chirp();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this_chirp could be declared before while loop


private:
// interface for grpc calls to key value store
KeyValueClient clientInterface;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs an underscore after its name

std::cout << "Make sure the parent id actually exists" << std::endl;
}
}
else {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should fix this throughout the codebase.


ServiceLayer::ServiceLayer(KeyValueClientInterface* key_value_connection) {
store_ = key_value_connection;
const std::deque<std::string>& chirp_count = store_->get("chirp_count");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite -- k is only for true constants, not just vars that have the const keyword.

ServiceLayer::ServiceLayer(KeyValueClientInterface* key_value_connection) {
store_ = key_value_connection;
const std::deque<std::string>& chirp_count = store_->get("chirp_count");
if(chirp_count.size() == 0){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space after if (everywhere).

store_->put("chirp_count", "0");
}
}
bool ServiceLayer::registeruser(const std::string& username) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add blank line.

error_chirp.set_id("ERROR");
return error_chirp;
}
my_id = chirp_count.at(0);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move this object construction code to a helper?

}
}

return found_chirps;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I mention above, it doesn't apply to all vars that have the const keyword, only those that are truly constants.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants