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

Lab6 #469

Closed
wants to merge 2 commits into from
Closed

Lab6 #469

wants to merge 2 commits into from

Conversation

CameronSchafer
Copy link
Contributor

@CameronSchafer CameronSchafer commented Jun 21, 2019

Fixes #470

Review of colleague's PR #265

Changes proposed in this PR:

  • Add puppy struct with CRUD functionality
  • Add test cases using testify suite

@codecov
Copy link

codecov bot commented Jun 21, 2019

Codecov Report

Merging #469 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #469   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          46     47    +1     
  Lines         776    833   +57     
=====================================
+ Hits          776    833   +57
Impacted Files Coverage Δ
06_puppy/CameronSchafer/main.go 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b95ac4d...6471a77. Read the comment docs.

CreatePuppy(*Puppy) int
ReadPuppy(int) *Puppy
UpdatePuppy(*Puppy)
DeletePuppy(int)
Copy link
Collaborator

Choose a reason for hiding this comment

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

These interface functions do not return error at all. Wonder how does function caller know something is wrong, e.g. id not found?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yup please fix.

Copy link
Contributor

@juliaogris juliaogris left a comment

Choose a reason for hiding this comment

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

Time to split your code over several files IMO.
Add some errors handling.

CreatePuppy(*Puppy) int
ReadPuppy(int) *Puppy
UpdatePuppy(*Puppy)
DeletePuppy(int)
Copy link
Contributor

Choose a reason for hiding this comment

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

Yup please fix.

store sync.Map
}

type Storer interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

move to storer.go or types.go file.

store map[int]Puppy
}

type SyncStore struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

move to syncstore.go file along with its implementation

value string
}

type MapStore struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

move to mapstore.go file along with its implementation

}

func (m *MapStore) CreatePuppy(p *Puppy) int {
m.store[p.pid] = *p
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO Create Puppy should provide the ID (the client/user of your package typically would not know what ID's are available). However you can make a case for the client providing the ID if you wish. In that case you need to check that the ID isn't already in use and return an error otherwise please.

}

// using the sync map store + methods
func usingSyncMap(pups []Puppy) {
Copy link
Contributor

Choose a reason for hiding this comment

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

usingSyncMap and usingNormMap look nearly identical.
pull store initialisation out and pass map|sync store via interface argument along with puppy slice to a
managePuppies(s Stoerer, pups []Puppy) function or similar.

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

Successfully merging this pull request may close these issues.

Lab 6 - CRUD Puppy interface
5 participants