The 2 Best Coding Tips I Ever Learnt



This content originally appeared on DEV Community and was authored by Frank

You shouldn’t be scared of writing “bad code.” When you plan every variable name, overthink every function, and have to know/research the “perfect” way to solve problems before even writing a single line. You get frustrated and end up wasting time with barely any progress.

In my three years and counting in my software engineering journey, I’ve consumed lots of information and read books from experts in the software development world. Two tips changed how I approach every programming challenge and also changed my programming journey.

# TIP 1: FIRST MAKE IT WORK, THEN REFACTOR.

Phase 1: Make It Work

Here your only goal is functionality. Don’t worry about elegant solutions, perfect naming conventions, or optimization. Write code that solves the task, even if it’s messy, repetitive, or inefficient.

The benefits are immediate:

  1. Build Momentum: You see progress quickly, which keeps you motivated.
  2. Provides Feedback: Working code tells you if your approach is viable.
  3. Creates a foundation:- You will have something tangible to build upon.
  4. Reduces Anxiety: The pressure to be perfect is removed.

Phase 2: Refactor and Improve:

Once you have working code, now you can make it better. This is where you:

  1. Clean up the structure and improve readability.
  2. Optimize performance where needed.
  3. Add proper error handling.
  4. Improve naming conventions. The beauty of this approach is that you can experiment with improvements knowing you can always fall back to the version that works.

Let’s look as an example
Let’s say you’re building a simple calculator. In phase 1, you might write:

Code examples 1
It works. Now in Phase 2, you might refactor to

Code examples 2
Phase 2 has the same functionality as Phase 1, but it has a cleaner implementation and better error handling.

# TIP 2: READ CODE MORE THAN YOU WRITE

As a developer, you’ll spend more time reading code than writing it. Whether you’re debugging, adding features to existing projects, or trying to understand a new codebase, reading comprehension should be your most valuable skill.

The benefit of reading code is writing better code. It’s like learning a new language. You don’t become fluent by only practicing speaking—you need to read books, listen to native speakers, and immerse yourself in well-crafted examples of the language in action.

How To Read Code Effectively

  1. Study Open Source Projects: Pick popular projects in your preferred language or framework. Start with smaller and well-maintained repositories. And please don’t try to understand everything at once; focus on files or functions that solve problems similar to what you’re looking for.
  2. Analyze Code You Admire: Find developers whose work you respect and study their code.
  3. Read Your Own Old Code: It might be stressful, I know, but it’s incredibly valuable. Compare code you wrote six months ago to what you’d write today. You’ll be amazed at how much you’ve improved.
  4. Participate in Code Reviews:– Whether giving or receiving feedback, code reviews are goldmines for learning. You’ll see different approaches to solving the same problems and learn from your teammates’ expertise.

WHAT TO LOOK FOR

When reading code, pay attention to:

  1. How experienced developers structure their files and organize their logic.
  2. Common patterns and naming conventions in your field.
  3. How they handle errors and edge cases.
  4. How they break complex problems into smaller, manageable pieces.

These two tips create a powerful feedback loop.

The cycle works like this:

Write working code → Read quality code → Improve your code → Repeat

Each iteration makes you better, and the process becomes increasingly natural and enjoyable.

If you enjoyed this, like it, comment on it, and share it with a friend.


This content originally appeared on DEV Community and was authored by Frank