0%

This is my learning notes from the course - Mastering C++ Standard Library Features.

Shared Pointers and Weak Pointers

  • the concept of shared ownership
  • What std::shared_ptr and std::make_shared are
  • What std:: weak_ptr is
  • Run-time overhead

Shared Ownership

The reasons of using shared ownership:

  • Some resources need to be shared between multiple owners
  • After acquisition of a resource, multiple objects can take/lose ownership of it
  • When a resource has no more owners, it is automatically release
  • Useful where there isn’t a clear lifetime for a particular resource (for example might depend on run-time conditions)
    Read more »

Interviewing - What the Numbers Say

  • 60% of interviewers decide on an candidate in the first 5-15 minutes
  • On average, 250 people apply for an open job
  • Behavioral interviewing is said to be 55 percent predictive of future on-the-job behavior, while traditional interviewing is only 10 percent predictive
  • 60-80% of companies use phone interviews to determine whether to bring a candidate on-site

The first 5-15 minutes

60% of interviewers decide on an candidate in the first 5-15 minutes.

The implication for that is it’s really important that you have a very clear elevator pitch, describing your experience, why you are a good fit of the role, and very importantly why you are interested in this specific opportunity. Typically, it’s 4 min for face-to-face interview and 2 min for phone interview.

Read more »

This is my learning notes from the course - Mastering C++ Standard Library Features.

std::unique_ptr

  • Resources and “unique ownership”
  • What std::unique_ptr and std::make_unique are?
  • How move semantics make std::unique_ptr possible?
  • Run-time overhead

Resources and “Unique Ownership”

  • Every *”resource”* needs to be acquired and then released
  • Dynamic memory, files, and threads are all examples of resources
  • *”Unique ownership”*: there is only a single owner of a particular resource, who is responsible for both its acquisition and release
  • Access to the resource is only possible through its owner
    Read more »

This is my learning notes from the course - Mastering C++ Standard Library Features.

What Problem Do Smart Pointers Solve?

  • problems with manual dynamic memory allocation
  • why new/delete are considered harmful

Problems with Manual Dynamic Memory Allocation

Before C++11, dynamic memory management in C++ has been traditionally done through the use of the new and delete keywords.

The example below shows that the new keyword allocates memory for a foo instance, constructs it, and returns a pointer to the newly-allocated memory location.

The delete keyword destroys the instance of foo allocated at the address f, then reclaims the dynamically allocated memory for future reuse. In addition, delete keyword also calls the destructor if the class instance you’ve created on the heap, which might be very important if the destructor has some critical side effects.

Read more »

What Critical Thinking is NOT?

  • Not (necessarily) criticizing anything
  • It’s weighing, not “winning” (sophistry)
    • I am my mind in action, not my current views
  • Not “perfect” thinking
  • Many fine activities are not critical thinking
    • Reading stories
    • Games, puzzles
    • Goofing off
    • Any habitual activity

Critical Thinking

  • Critical thinking is the method tool of comparing two or more things using reasons / evidence.
  • Evidence is the most powerful type of reason for support
  • A lot of other things we do are not critical thinking - which is perfectly OK
  • It’s not “winning”, it’s weighing, deliberating
    Read more »