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

August 24: Pointers Part 5 #17

Open
iennae opened this issue Aug 17, 2020 · 0 comments
Open

August 24: Pointers Part 5 #17

iennae opened this issue Aug 17, 2020 · 0 comments

Comments

@iennae
Copy link
Contributor

iennae commented Aug 17, 2020

Let's talk more about pointers! We've been working on a linked list in Go (https://github.com/osscda/lets-go-project) using pointers over the last 3 weeks (#10, #12, #14, #15 ), and we're going to continue that discussion this week.

Last week:

  • Talked about different way to implement the item struct to keep track of total items in the list
  • Review of tests
  • Introduced slices: go built in method of list []TYPE .. list of type so list of strings with []string {}
  • Updated testing
  • Introduced range: range works on maps and lists.
  • Talking about arrays and slices differences. Fixed sizes for arrays, program won't compile if specify out of bounds index.
  • Introduced error interface
  • Introduced export - captilizing it available for use for anyone else using the library. used with IndexNotFoundError struct
  • Introduced fmt.Sprintf doesn't print to standard out, returns it as a string (S)
  • Returning nil as a pattern to say there was no error
  • Introduced profiles in VS Code, workspace specific so you can check in launch.json and figure out debugging/extensions that are needed
  • Reviewed gopl problems:
  • removed unreachable code
  • anytime we export something (public code) we should have documented in comments because it ends up in the official go documentation. added comments for all the reported problems.
  • built replace function and added testing

Agenda

  • Talk about functional programming
  • Call method with receiver nil
  • Build Delete function
  • Build Insert function

Notes

  • range gives us an index and the value, use
    _ explicitly not caring about something
    idx if care about the index (or other applicable name)

  • %d - holder for decimal

  • documentation for the printing in use with testing -> https://pkg.go.dev/fmt?tab=doc

  • Talked about differences in the struct and the meta about talking about the package itself.

  • The challenge of indices and where you want

  • Lots of repeating code, refactor!

  • Implement getItemAtIndex

  • if you are returning more than one thing (), if just one you don't need ()

  • cached tests

  • creating helpers for tests

checkLength(1) 
checkLength(2)

  • Implement Delete
    Delete has a lot of boundary conditions. What if list has a single element, what if the list is nil.
  • Pattern of putting the error handling within test for TestDelete

Rules of the Stream

  • Comments and questions are always welcome in the chat.
  • No question is too basic or "stupid" to ask in the chat.
  • Tangents are accepted!
  • No sorries needed.
  • Please submit issues for new topics of interest in our repo!
@iennae iennae changed the title Pointers Part 5 August 24: Pointers Part 5 Aug 17, 2020
@iennae iennae mentioned this issue Aug 24, 2020
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

No branches or pull requests

1 participant