Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am a native PHP developer, and have been for about a year or so. I love PHP and it was very easy for me to learn, but I have developed some bad habits along the way due to never having a formal education in programming. It's pretty easy to get the job done in PHP without writing the best code.

I am looking to work more with another language; not because I don't like PHP but because I want a clean slate to learn programming fundamentals. I am looking to stay with web development, so Ruby or Python seem to be where I'm leaning, though I am open to other suggestions. The more important question is, how do I approach learning this new language to really become a good programmer rather than a guy that can "get the job done"?

share|improve this question

closed as not constructive by gnat, Walter, Glenn Nelson, GlenH7, StuperUser Jan 29 '13 at 16:07

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

    
An idea could be to take an online course on programming (there are many available online, and they are free). After you have learned good programming patterns and practices, you can (try to) apply them in any programming language. –  Giorgio Jan 29 '13 at 13:20
add comment

2 Answers

up vote 6 down vote accepted

The best introduction to programming professionalism that I know of is a book called The Pragmatic Programmer. It discusses various aspects of software development, and is useful to learn what you don't know. It's also small and easy to digest compared to a more complete (hur hur hur) book like Code Complete.

For web development, your next step is to learn about the Model-View-Controller pattern. Building a small project using a framework like Yii, or CodeIgniter should allow you to get the hang of it.

The most important idea behind MVC is separation of concerns. If you separate your code well, then changes to one part of a program won't affect other parts negatively.

Your code will spend about 80% of it's lifetime in maintenance mode. That's when you have to go back to fix bugs or add new features. After a year, you won't remember what you coded any more. (I don't remember what I coded last month.) The more readable and well-structured your code is, the better for future you. Code readability is very important.

Documenting your project is important too! You don't want to try to remember what the database password used to be. Write all the login and hosting details down in a secure location.

Finally, learning new languages (plural!) will help you become a better programmer. I like Python, so I suggest you start with that, but you should learn Ruby too. (I am. The syntax seems a bit idiosyncratic.)

Also, if you are so inclined, the Tao of the Hacker may prove enlightening.

share|improve this answer
    
+1 for Pragmatic Programmer. I'd give you another +1 for recommending learning multiple languages, but I can't. –  Stephen Orr Jan 29 '13 at 9:18
    
The Pragmatic Programmer looks like a great read, thanks for that! As for MVC, I use Codeigniter currently on most of my PHP projects. I love the MVC pattern, but I find myself relying on the libraries of the framework too much. For now, I'm going to learn Ruby and Rails while reading the book you suggested. –  PHPguy Jan 29 '13 at 17:14
    
Relying on libraries is a good thing. Don't reinvent the wheel. –  Gustav Bertram Jan 30 '13 at 6:53
add comment

You can learn to program in a cleaner way with Php.

Start by using a framework if you're not doing that already; read some code from big-scaled and well-reputed Php applications. You should also study design patterns and try to apply them.

In any case, having a clean code doesn't come automatically from using some language or tool; it's something you have to work on.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.