(upbeat techno music)
- This is one of my favorite trick questions.
A big part of engineering is being able
to explain your solution,
how it works and why it works better
than some other solution.
Hands-on coding is absolutely critical, yes,
but it is incomplete unless you can explain a technique
to somebody else before you implement it.
I also ask this question
since I want to know as a hiring manager,
can you explain your ideas to somebody more senior than you,
or less senior than you?
And, you know, I've often found
that when you explain your ideas to somebody else,
you question their effectiveness and you ask yourself
if they are indeed the best way to solve the problem.
It makes you a better engineer and a better communicator.
Here are some techniques I've used to answer this question.
First, ask questions.
So you can provide an informed answer
in the absence of clear and concise information,
ask questions, make assumptions.
Good engineering answers always start with "Why?'
Second, use examples.
Associate your new ideas to something
from the real world people already understand.
And third, ask for feedback.
It is often easy to get lost in the deep technical concepts
and the weeds and lose sight of the needs of the customer.
Keep your answer focused on the needs of the customer
and bring them with you.
Most of us learn by first associating new concepts
with things we already understand,
and then using this new knowledge
to take us to a place we desire to go to.
You will want to structure your answer in a way
that helps your ideas become visual and tactical
and bring the listener along with you.
Let's look at a sample answer to this question,
and I'll be right back with some feedback.
- Inheritance lets us inherit different attributes
and methods from another class.
Polymorphism uses those methods to perform different tests.
This allows us to perform a single action in different ways.
So you can create a parent class
that has several definitions of data types and functions
that can be used by the child class,
that inherit from the parent class, hence the name.
These child classes can then override
some of the definitions of the data types and functions.
Polymorphism then lets you programmatically decide
which data types and functions to use.
For example, think of a parent class called Season
that has a method called AreDaysHot,
so that the method reflects the question
that's answered when invoked from elsewhere in the code.
Subclasses of season could be summer, winter, fall,
and they all have their own implementation of AreDaysHot,
to reflect that summers have hot days,
winters have cold days, and fall's are a mix.
However, when you need to print something generic like,
"It's a beautiful day,"
you could create that capability in the parent class,
instead of repeating that in each of the child classes.
This is how inheritance allows for efficiency, and.
So, then when you want to print a message
that's customized to that particular season,
you'd call the appropriate child class.
This is how polymorphism uses automation
to avoid redundant automation.
It helps save time, helps create clean code.
Is that, is that good?
You need more?
- This was a very efficient and clinical answer.
The very beginning of the answer explains conceptually
that these concepts are intended
to make programming more efficient.
Associating polymorphism and inheritance
to something everyone relates to, like seasons, is smart.
All seasons have commonalities and differences,
making them a perfect use case.
As an aside, showing how you can cluster common code
in the parent class,
while letting child classes handle special cases explains
these concepts practically.
This is useful since your audience is your student,
in this case.
The candidate asked if they had any questions,
which is always a good thing since it's allows you
to course-correct, if required.
Remember, a key part of problem solving is think
about getting from A to B efficiently
and keeping the customer in mind.
Starting with concepts, building a practical example,
asking questions, is part of that journey.
(smooth jazz music)