Day 02 - Coding with the right mindsets

Day 02 - Coding with the right mindsets

I didn't spend much time on coding today, instead, I checked a few videos talking about mindsets which would help me learn efficiently during my coding journey, and also some principles I should apply to my codes.

Here are what I learnt today:


Growth Mindset

American psychologist Carol Dweck and her colleagues’ research has found a very simple belief about ourselves that guides and permeates nearly every part of our lives. This belief limits our potential or enables our success. It often marks the difference between excellence and mediocrity.

In brief, what mentality we face difficulties probably defines what degree of success we can get in our lives.

This is what Professor Dweck said in her TED talk - The power of believing that you can improve:

Before, effort and difficulty made them feel dumb, made them feel like giving up, but now, effort and difficulty, that's when their neurons are making new connections, stronger connections.

Fixed mindset v.s. Growth mindset

The main difference between the two:

  • Fixed mindset: desire to look smart

  • Growth mindset: desire to learn

When you are trying to prove yourself smart but encounter failure or challenges, you will take it as proof of 'you are a dump'. You will lose confidence and try to avoid any of them.

On the opposite, if you take any failure or challenge as a chance to learn, an opportunity to improve yourself, you will embrace them, and see effort as the path to mastery.

The right mindset to learn to code

This research reminds me, as a beginner learning to code, of how we should face challenges during our learning journey.

We should see every problem as a way to learn something new, a step closer to mastery, but not a fact to prove 'you are a bad developer'. Only in this way, we could persist confidence and continue on our path towards becoming professional developers.


Principles of good codes

As a developer, we should always bear in mind some rules of thumb while working on our codes. To maintain good quality in your codes, here are some of the principles you should at least try to apply:

1. Single Responsibility Principle (SOLID)

Every class, module, or function in a program should have one responsibility/purpose in a program. As a commonly used definition, "every class should have only one reason to change"

2. Keep It Simple Stupid (KISS)

It was Albert Einstein who said:

If you can’t explain it, you don’t understand it well enough.

What Einstein was driving at was a particular application of “keep it simple, stupid”.

Simplicity is key when you are coding. The easier something is to understand and use – the more likely it is to be adopted and engaged with.

3. Test-Driven Development (TDD)

Test-driven development (TDD) is a software development process relying on software requirements being converted to test cases before the software is fully developed, and tracking all software development by repeatedly testing the software against all test cases.

Don't remember to set up unit tests for your programme, these would make it easier when you come back a few months or years later to update your codes.

4. Don't Repeat Yourself (DRY)

"Don't repeat yourself" (DRY) is a principle of software development aimed at reducing the repetition of software patterns.

Keep your code clean and practical by abstractions or using data normalization to avoid redundancy.

5. Model View Controller (MVC)

Model–view–controller (MVC) is a software architectural pattern commonly used for developing user interfaces that divide the related program logic into three interconnected elements.

This is done to separate internal representations of information from the ways information is presented to and accepted from the user.


Summary

It is not enough for me to just memorise all of these mindsets or principles. How to apply them to my daily coding is also essential. The only thing I am sure of is that it would take months or even years of practice to become natural.

Did you find this article valuable?

Support Terry Cheng by becoming a sponsor. Any amount is appreciated!