hello friends welcome to reach goals today there is an interesting interview
question that is how a great EP should be and I'm going to talk about its best
practices the first one is a piece should be easy to learn easy to use what
does it mean is there are hundreds and thousands of APA and if you are not able
to learn that and if you are not able to utilize it it is going to be useless
right so you had to rewrite an AP in such a way it can be easily learned and
it can be easily used let me give an example for example if you want to
create an account napier should be named like you know create account or if you
want to have an AP like delete account it has to be luckily it account it
should not have any fancy terms or names which is not easily understood by the
any of the users right and the second one is APA should be hard to misuse so
let's say you define an AP and it is very clear it is has to be exposed to
the third party vendors or be within your company right so you should write
in such a way it should not be misused for example if you write an APA to
delete an account it should be specific to an user where you are going to delete
it let's say delete the code you have to give the user ID let's say given a you
expose an AP in such a way you can delete account and if you don't provide
any ID or anything as a parameter to delete there is a possibility that APA
can be misused misused and all that cons can be deleted so you have to be very
careful when you define those kind of an EP ice right so the next one is AP
should fail fast so this is one of the very interesting thing let's say you
have a method which has hundreds of lines now you came to know that at the
95th line or 96th line AP fails or there is a issue in your code write this so
there is no reason for going up to 95 lines and getting it failed right so
what actually does to bitterness it has to be failed as silly as possible so
failing at the compile time is much better rather than rather than you know
we're going to fail at the run time so you have to be very clear the epa should
fail fast to make sure that AP is perfectly placed in all the ways right
next a piece should have good names names should be self-explanatory right
so this is very common thing it's a very easy easy to learn thing right ABA
should have a good names so for example you are writing an EPS and to send an
email or a send a message it should have something like send message or if you
are checking the status of an account it should have something like check status
right so if it is not able to easily understood then it is going to be it's
not going to helpful for any others to make use of it right so that is what I
meant APA should have good names name should be self-explanatory and the other
one is AP should be split into modules let's say you have a application and you
have n number of functionalities and if you are not splitting up the APS into
the modules it is very hard to refactor when there is an e so that is why it's
like a divide-and-conquer you have an EPA you split into modules so that it
can be easily to lysed by somebody else right so this is another interesting
line like you know when in doubt you have to leave it right so if you are in
a doubt and if you are adding some functionalities and it is very difficult
to remove later right so let's say if you remove it it it is going to impact
all the user who are already using those he pees so that is why I am saying that
when in doubt just leave it you can add but you cannot but it is difficult to
remove it later right so the next one is maximize your information hiding don't
let information leak in logs or exception sometimes you would have seen
an EPA somebody's writing like you know there is an exception happening in the
do today's database and they would say the database name or the field name in
that exception message so it's it's easy for the hackers to understand what is
your database and what kind of fields are using it right so you should not let
ap to leak the information similarly if you are writing some logs you should
make sure that you are not writing user information or user email into the logs
so it's just it's like a PA a complaints right so that is that should not be used
like that that's what I meant maximize information hiding don't let
information leaks in the logs and exceptions so the other point is
minimize coupling between AP so if you have a lot of VPS and you always would
have seen that multiple ApS are interacting with each other right so if
you have too much of couplings that if you want to refactor your ap
very difficult that's why you had to minimize the coupling between the EPS so
that it can be used very efficiently the next one is document as much as possible
for the users to understand so whenever you write an a pH should be
self-explanatory right so if somebody reads the EP APA they should be able to
understand what the EP is for how it is meant and how it can be utilized so you
have to document in such a way anybody even we don't understand the software
applications it has to understand the EP and make it realize make it to licensing
the EPS etcetera right the next one I have is keep performance in mind while
designing the EP right so this is a very important thing right let's say you
write in APA and you are to make sure the EP is perfectly test to meet the
latency to to see whether ap is performing well utilizing the memory to
the best of its ability etc right if you're not looking into the performance
and then the AP is really going to become a useless and nobody is going to
use it right so keep in mind whenever you write an EP the performance is a
handle and you are testing the performance as well to when you are
publishing to some other third party are to the external vendors right that's it
a hell thanks for watching if you have any comments you can put in the comment
section and make sure you're subscribing to get some more informations about
these videos thank you