many times people complain that they have learned programming syntax but they do not know how to
build a logic when it comes to solving real life problems based on my 15 years of programming
experience i am going to share with you 10 tips of logic building or thinking in programming
these tips will allow you to take a real problem and build a solid efficient logic
when you're writing your program the first one is divide and conquer
let's say you have this excel file which has base and width of various triangles your job is to find
the area of all these triangles now if you want to write this program in python what you should do is
divide this big problem into bunch of small problems so the first thing you will do is
you will write a simple function which can find an area of a triangle then you test it and if
it works now you have created a small piece for your bigger project so you now put that aside
then you write a second function which will read this file line by line and it returns
a list of objects which has bayes and width you know these are the triangle dimensions
and then you write a third function which will combine the triangle area and read file together
and it will do the end job which is finding the area of all the triangles
so now essentially what you did is as a programmer now you are being a plumber so you are having
these different pieces nuts and bolts so you are creating those things and then you're joining them
together so you know think of programmers as plumbers where they join different pieces together
in a way that you can create like a pipeline you know where the water flows easily or whether data
flows easily and at one end you give your input at the other end you get the output in a desired
format so when you're joining these different pieces together think about a flowchart you
probably know about flowcharts so you are creating your logic into small pieces and then you are
building a flowchart to join these pieces together so that your program can give you expected output
there are various benefits of this divide and conquer methodology
first of all when you get a big project as a human you might get overwhelmed you might
think oh how am i going to solve these issues and when you divide this into small sub tasks
and you focus on only one task at a time you don't get mental fatigue also when you write let's say
one single function of finding triangle area and when it works it gives you that mental reward
so building small pieces making them work getting that mental reward is extremely important
the second tip is writing on a note and also discussing with your friends on a
whiteboard these friends could be your college friends or your colleagues
whenever i um i am working on any prog program i always uh first think about logic using norton pan
so i think about what data structures i'm going to use what kind of for loops i am
writing and so on and i will not it down in a paper and then once i think that this logic is
final enough i translate that into a working code you can also discuss with your colleagues
on a whiteboard because when you do idea brainstorming on whiteboard you might come up
with a better logic if you just do it on your own you might write a functioning program but it might
not be the most efficient or most performant program when you discuss with your friends
uh they throw different ideas maybe you want to use one data structures but your friends might
suggest using some different data structures so writing on note and white boarding with colleagues
extremely important the next tip is making wise use of data structures and algorithms you cannot
become a better programmer if you don't know about data structures and algorithms they are like they
are everywhere it doesn't matter which programming language you are using if you think about list
hash map they are there in all programming languages you cannot escape them
and when you know how to use the data structures efficiently you can write better program for
example i have this code where i have a bunch of customers and i want to retrieve unique
countries from these customer records now i can do that using a list data structure and it will work
but is that the most efficient approach because in list you are collecting all these countries but
in the end you have to write a function to remove duplicates but if you know about set then you know
that set allows only unique elements so if you use set here instead as shown in this program you
will be writing much better code so see having our knowledge on set data structure became very useful
so similarly if you know diverse set of data structures it's going to be super useful i have
a complete tutorial playlist on data structures and algorithm in python so i would suggest you
follow that algorithms are crucial as well you're talking about short sorting algorithms there are
so many sorting algorithms and based on your situation using one or the other might be better
sometimes people use hybrid approach of using two sorting algorithms for a given problem so all this
knowledge of data structures and algorithms will allow you to write efficient code the next one
is using google stack overflow and platforms like discord and slack channel to your advantage
sometimes let's say i'm doing a list transformation in python from one
list i am generating the other list and if i am a new python programmer i might write a for loop but
if you google it on stack overflow you will find an answer which will be using list comprehension
as a new python programmer let's say you did not know about list comprehension but when you
do google or stack overflow you are finding these new features and better ways of writing your code
same thing applies with discord and slack channels i have a discord community where i have different
channels for python data science and all that and people are discussing various ideas brainstorming
it so when you post your question that okay i'm writing this code here what is the best way to
write this logic then there will be experts who will give the opinion and you can learn lot of
useful tips by interacting with these experts either on discord stack overflow or any other
programming community the next one is pair programming if you're in college you can do pair
programming with your friends in the same class or if you are in company you can do pair programming
with your colleagues many companies have this pair programming sessions so pair programming is
one person is writing code the other person is watching and he's giving the ideas so this is
like two people writing code at the same time and then you make a turn by doing this uh you will
be using two brains instead of one in figuring out the logic this is similar to white boarding
but in white boarding you're not writing a code you're brainstorming idea before writing the code
in pair programming you are actually writing the code and trust me it is extremely useful
because when two brains think about logic uh they give a critic on each other's ideas
and you can refine the logic and you can make your program better next one is starting with simple
and then optimizing it later many times when we have a difficult problem we keep on thinking about
best solution and we get stuck we might spend five hours just in thinking that's not good
you should come up with a very primitive solution just make it work and then think about optimizing
it can i use some different data structure can i use different for loops or different code block
to make this working program more better so that it performs efficiently space wise
time complexity wise and also number of lines of the code is reduced the next item is
learning from others code open source github etc has become very popular nowadays and you can find
the code for most of the python libraries or even javascript libraries online this is the
code written by experts the best programmers in the world world and when you read their code
you also learn a lot of tips for example here is a function for escalant logistic multinomial loss
now if you want to implement less multinomial loss function yourself
maybe you can read this code and get some tips on how you can write this function in a better way
by reading other people's code on github not only you are learning tricks on data structures
but you are learning tricks on how to do program management how to do automated testing how to do
deployments or how to set up jenkins pipeline you're learning so many valuable skills when
you read other people's code especially open source and open source contribution is also
one of the things you can do and with that we can move on to the next step which is code reviews now
code reviews there are two aspects you yourself can read uh do code review for others so if you
have a friend in a college or a colleague in a team offer them that you can do their code review
when you read other people's code you are learning those amazing tricks which you might not be aware
about i have had recent experiences where you know uh when in python when you do a split on a string
i always used to get that output in a list but then when i read some when i was reviewing some
other person code uh he was doing that using a tuple and i learned that oh using a tuple is
probably a better way so by doing other people's score review i learned some trick which made my
programming better the other second aspect of code review is you ask other people to review your code
and they give their critic and feedback and of course they will tell you a lot of tips that
you might not be aware about so be open minded when someone is giving a critic on your code
don't take it personally this is an opportunity for you to improve take every single feedback in
a positive way and try to learn as much as you can next one is competitive programming people think
think that competitive programming is only to crack interviews no when you are solving the small
competitive code you are building literally small weapons which you can put in your arsenal
and when you are working on a bigger project you can use those small little weapons
these weapons are small tricks maybe a way you learnt to sort an array in an efficient way or
write a for loop to solve a specific problem you learn all these small tips or techniques
or strategies when you are participating in competitive programming right now there are
many websites such as lit code gigs for gigs you will just google competitive coding and you'll
find so many websites if you want to become better programmer have a habit of solving let's say one
competitive programming problem every day or every week let's say if you solve one problem every week
still in a year you will solve 52 problems in year or two you will become so much better
the last and the most important tip is projects projects projects work on diverse set of projects
work on projects which requires you to do data mining let's say if you're in data science field
work on a project to write a scalable backend node.js server if you're working on web
application or mobile app if you want to become a better programmer you have to remember 2p practice
and patience working on this projects you need to have a lot of patience and when you work on
diverse set of projects you will cover different areas of computer science and you will build this
diverse set of skills so have a lot of patience do not give up keep on working i hope these 10 tips
allows you to build a better logic or thinking skills and programming please apply those tips
and let me know what you find also if you know any other tip which i have failed to cover in
this video please post in a video comment below i try to respond to as many comments as possible
i have a discord community where there are so many ideas and brainstorming going on people answer
questions uh people post about job posting there is career guidance channels there are various
channels so please make sure you join the discord community also subscribe to this channel and share
it with your friends i have videos on different career guidance for example i have video on
how you can become expert in python starting from very beginning and python is so easy that
anyone can learn it if you are a mechanical engineer or an mba you do not have a background
of programming you can still learn python and become an expert trust me this is possible
i was going to teach python in a nearby library as a volunteer event and i saw an eight-year-old kid
doing a python programming and he was too good there was a 70 year old lady as well
i see so many people across the various age groups and various backgrounds
they learn uh programming and they can become better so do not have this bias that oh i don't
have this background and i cannot learn it programming is an amazing thing anyone can
learn it and i have videos on how you can start as a beginner and learn programming i also have
video by the way on how we can ma earn money by doing programming online so watch those videos
so those videos have some real examples the people whom i have met and who have earned so much money
by learning programming so please watch it out i'll see you in the next video thank you