Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

shaikh709's avatar

How do you determine if the code quality is good or how can I write code in good way?

I'm self taught developer. I usually make anything I can imagin but at the end of the day. I don't like the way my code works. I tried to learn design pattern but unable to make sense of it in my project. So, What can i do to program in better way or how can make my code quality good?

I love the way laravel looks and works. Its clean, easy and simple. I want to see that kind of structure in my projects. Please tell me what should I do ?

Thank you.

0 likes
6 replies
alenabdula's avatar
Level 13

I don't like the way my code works.

If it works, it's good enough.

Best way to improve is to work on what you have for extended time, see what gives you trouble and research how to improve it by solving for that specific issue. Don't overthink it. Keep it simple. Less code is always better, so try refactoring pieces of code that seem convoluted and are hard to understand of what's happening. Possibly, extract pieces of functionality to functions and give them names.

When you're working, for the most part code makes sense, but 4-5 months down the road even you will have hard time understanding what's happening, and it will take you some time to figure out, so comment the shit out of your code and give names to things.

Just keep building things, I'm also self-taught, and I can't tell you how many times I've coded dashboard for my blog... :)

1 like
lara30453's avatar

Understand OOP.

If you understand OOP, you will write code in a better more structured way. My lecturer said that learning a language is not key, but understanding how to design applications, how to structure modules and the relationships between these modules.

Then, start exploring design patterns. it will take time, but over time you will start seeing where to use these patterns to clean up code.

It not the most in depth explanation, but it should point you in a good direction.

1 like
lara30453's avatar

@alenabdula I agree.

I cannot count the amount of times I have taken an application and started from scratch to build it better. Every time, it comes out better.

Also, try prototyping. build the app and get it working, then create the final version based off of that design but refactor. This way, you will see bad design decisions in the prototype and be able to act upon them.

jlrdw's avatar

Along with code quality, make sure you understand security, and properly implement it. Pretty code can still be unsecure, ugly code can still be secure. Other than that, use normal conventions, like Taylor and Jeffrey teaches, and you should be alright.

1 like
Evgenii's avatar

Install php code sniffer & php mess detector. Moreover, you can integrate it with your editor so it highlights the code for you. The first one is responsible for overall code style, the second tool is about code logic.

1 like

Please or to participate in this conversation.