Uncategorized

Best Practices for Logic Building to Become a Pro Coder

Logic is the fundamental key to become a good programmer. You might be getting frustrated when you don’t get logical programming or your logic is not working. Well, I understand your situation. I was also in the same boat until I tried various strategies of logic building. 🙁

This blog is for you if you are the one who repeatedly says this statement that “I can’t use logic in programming.” Or “I can’t learn programming because my logic is poor.” With this blog, I am now going to share a few hacks with you that can help you build your logic. You should try and practice these things as soon as possible to improve your problem-solving and logic-building skills. But, firstly, you need to learn a programming language.

Top skills that can help in building logic

  1. Are you lacking interest!!!

Yes, you read right! How much you used to like coding? And how hard it is to motivate yourself for the coding? Can you answer these two basic questions? Your interest in coding lies in your why! When you first thought to start coding, your reason was probably one of the following:

  • Having fun
  • Building something that makes other’s life better

What is your reason now?

  • Earning money!
  • Surviving!
  • You don’t really know!

The why here is what really motivates you in the long term. The what (coding) is just a means to an end. Reframe your current why to why you really started coding and remind yourself of it every day. If you’re in a job that doesn’t fulfill you, do everything you can to find a better one.

Not being motivated seems to be a big problem for many programmers. It’s normal that you’re not always motivated, but if that’s always the case you’re doing something wrong. We all started coding because it was cool and fun, but over time we are overrun by deadlines, bugs, and angry clients (if trying some freelancing). That is also part of the game, but in these times, it is important to remember why you really started. Ensure to always remind yourself of this will increase your long-term motivation by a lot.

2. Data Structures

A data structure is a data organization, management, and storage format that enable efficient access and modification, that is, linked list, binary search tree, hash tables, and many more. Data structures can be improved by learning, understanding, implementing, and especially practicing. Here’s one blog at Hackerearth that can help you understand this point better.

3. Algorithms

Algorithms are at the core of successful and efficient programming practices. An algorithm is a step-by-step method of solving a problem, that is, FizzBuzz, Fibonacci series, and there are a lot more algorithms that even you can build your own but try to practice toughest algorithms. See, you did it! You have two solutions to think algorithmically and avoid bumfuzzle:

  1. Breaking the problem down
  2. Building the solution up

Start from the simplest task of sorting 10 numbers. As it says, order them and arrange them accordingly.

4. Design Patterns

Design patterns are typical solutions to the commonly occurring problem in software design. As per FreeCodeCamp, It is said that every coder should know 3 types of design patterns:

  • Creational: These patterns are designed for class instantiation. They can be either class-creation patterns or object-creational patterns.
  • Structural: These patterns are designed with regard to a class’s structure and composition. The main goal of most of these patterns is to increase the functionality of the class(es) involved, without changing much of its composition.
  • Behavioral: These patterns are designed depending on how one class communicates with others.

5. Programming Paradigm

A programming paradigm is a style or a way of programming that is, procedural programming, logical programming, object-oriented, functional programming, etc. Programming paradigms are a way to classify programming languages based on their features. By avoiding certain techniques, it can make it easier to understand the program’s behavior. It also helps in understanding the logic of a computation without talking about its control flow.

6. Competitive Programming

Competitive programming is all about solving problems that are revolving around algorithms and data structures as quickly as possible. Competitive programming, in other words, is choosing any well-known programming language and challenging yourself against it. It basically deals with real-world problems. How can you challenge yourself? The answer is: by writing code with dexterity by digging the technical terms and creating big solutions through the shortest codes possible. Sounds interesting, right!

7. Mathematics

My goodness! I know but mathematics is very compulsory for building logic. (Why! Why! Why!) Mathematical intelligence is really important in building logic. You are not required to be a mathematics expert, but solving a certain amount of mathematical problems is what is required. (Ahh! What a relief!) You can solve brain puzzles and riddles, play board games to develop both strategic thinking and logical-mathematical intelligence, or simply solve the mathematics theorems.

8. Recursive Programming

Recursive programming is a method where problems are solved by repeatedly calling a function on sub-instances of the problem. Recursive programming is like circular reasoning. It’s like giving instructions recursively.

Example:

  1. Normally, you will follow the below steps:
    1. Initialize the problem
    1. Process the value
    1. Check the results
  2. Recursive programming will do the following:
    1. Check the results
    1. Point out the process to get the same result
    1. Get the problem

It might seem tough at the beginning, but if you are used to it then you will really enjoy doing it.

9. Dynamic Programming

Dynamic programming is mainly an optimization over plain recursion.

10. Refactoring your Code

Assume if you wrote a recursive function with O (n2) complexity. If you refactor that code and try to apply dynamic programming techniques then definitely you can improve the time complexity of your codebase. So, it is advised to always refactor your code.

11. Solve new problems daily

Once you solve a particular problem, don’t repeat it more than three to four times. Your brain has to prepare itself for the new challenges to reduce the response time and get the logic in programming. Get exposure to real-life problems and it will help you to write code for the new challenging situations.

12. Moving on level by level

Understand this; logic building is not a voodoo that can be gained in a click. It takes time! Practice enough at the easy level then move to some intermediate program. Again move to the next level or more complex problem and solve a lot of problems. Many websites are there like GeeksforGeeks, HackerRank, CodeWars, CodinGame, etc. to practice and improve the logic.

13. Divide problems into chunks

Firstly, try to understand the complete problem and find out what exactly needs to be done. Think about the problem carefully and write down on paper what steps you need to take in order to solve a problem. Think about all the case scenarios, steps, input, or variables that you need to take in order to solve it.

14. Check other people’s code

Do you know, by reading other’s code, you’ll improve your own code? Yes, but only if you have done it properly. Check code written by other developers on StackOverflow, GitHub, and learn from it. You eventually need to think over it and use your brain or logic to solve a problem and get the correct solution. It also helps you find out the easier solution or various methods for the same problem. If you are working in a peer group on the same project, then check their code. Working on some real-life projects gives you more exposure and experience to become better at programming.

Here’s how you can do it:

  1. Understand: Don’t focus too much on the details yet. Start having a browse and try to figure out what the various bits of the code are trying to do.
  2. Implement: After you understood what the code does, think of a way how you could use it in your own programs.
  3. Refactor: Is the code dirty or smelly? Why not refactor it! Refactoring even chunks of code can really take your understanding to the next level.
  4. Take notes: Do not waste on what you have learned. Write down in your note-taking app whatever you have learned from this code snippet.

15. Play video games!

Mark Zuckerberg, the CEO, and founder of Facebook credits video games with his success in the field of programming. Look below what he says:

Here are the benefits of gaming for the coders:

  • It boosts learning and memory
  • It enhances cognitive flexibility and mental prowess
  • It improves problem-solving skills
  • It improves multi-tasking skills
  • It improves concentration and attentiveness
  • It nurtures and molds social skills

Gamers must be happy reading this tip. 🙂 Well, video games are one of the leading hobbies among software developers and programming nerds across the world. I, myself have seen programmers playing with rubic cubes all the time. In other words, there are some decent video games behind every successful engineer (Mark Zuckerberg is at the top of the list). Of course, video games can never impart in you the most fundamental skill that is coding. However, they will inspire you to learn and become more tech-savvy in the field of programming.

Time for some TEDx motivation!!

TED talks show in a short span of time how to think like a true developer/problem solver. Knowing how to code is great, but knowing how to THINK is more important. Well, if in case, you are still lacking motivation for the logic building to become a pro coder, I have curated a list of TEDx talks that any beginner coder or a programmer of any level can watch:

  • Thomas Suarez:  A 12-year old App Developer.

If you’ve ever thought that you’re too young or old or inexperienced to start coding, then, let this little young boy change your mind.

  • Elon Musk: The future we’re building.

He’s one of the greatest innovators who have proved that programming is not just about code. It’s about dreams.

  • Linus Torvalds: The mind behind Linux.

His TEDx talks explore his mindset and motivations that pushed him to be an engineer and an open source advocate.

  • Kevin Slavin: How algorithms shape our world.

The author argues that we live in a world designed for and controlled by algorithms.

  • Linda Liukas: A delightful way to teach kids about computers.

Linda helps kids to see computer machines to be tinkered with!

  • Tim Urban: Inside the mind of a master procrastinator

Tim encourages us to reveal our procrastinations before it is too late.

  • Nick Bostrom: What happens when our computers get smarter than we are?

Bibliophiles or Bookworms, I’ve something for you too!

Bibliophiles, here are the 7 must-read books for the developers:

  • Clean Code [Robert C. Martin]

This book explains various principles, patterns of writing clean code. It also consists of lots of coding examples, exercises, and real-time case studies of writing clean code. This book is not a one-time read, but a guide or reference for writing clean code.

  • Code Complete [Steve McConnell]

It is a software development book that encourages developers to continue past code and fix programming and the big design upfront and waterfall models.

  • Think Like A Programmer [V. Anton Spraul]

The real challenge of programming is not learning a language’s syntax but learning to creatively solve problems so you can build something great. This book teaches you what other introductory books often ignore, that is, how to think like a programmer.

  • The Passionate Programmer [Chad Fowler]

Fowler makes a great point about how as a programmer or coder we should be setting out sights to be as great as we can be, rather than just good enough to hold on to a job.

  • The Pragmatic Programmer [David Thomas, Andrew Hunt]

This book has been praised by developers. This book not only covers coding but also teaches you how to lead the lifestyle of a programmer. Every coder should read this book in the early career so that you won’t be reinventing the wheel.

  • Clean Architecture [Robert C. Martin]

As the name suggests, this book explains how to architect software including principles and disciplines in writing software, designing principles of component separation, data management, programming paradigms, and much more.

  • Refactoring [Martin Fowler]

Every coder should have ended up refactoring some code sometimes and you end up doing lots of refactoring in the future too. So, it is better to learn refactoring the right way.

—————————————————————————————————————–

Pro Tip: “First solve the problem, and then write the code.” [John Johnson].

 In simple words, work on the solution out on paper in bits or small steps, then write the code for it. Don’t get tangled in the code first! It will only make you bumfuzzle!

——————————————————————————————————————

Last but not least, practice is the key to the logic building.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *