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 have already done a PHP project, and I did a number of things pretty wrong :)

I just had all pages as scripts with php mixed in with html. I also wasn't using a framework like cakephp. And I didn't really use objects, nor had any sort of test suite. :)

This time around I want to get it right. What should I do in terms of good practice approaches? And what am I ok not using? Any suggestions? Tips?

share|improve this question
    
All the things you mention are good -- is there something particular you're asking after here? Project organization, coding style, class design? Documenting well also helps, etc. –  Joseph Weissman Sep 16 '11 at 2:31
    
@Joe I guess it feels a bit overwhelming to figure out how to do all those at the same time. Was just looking for some guidance I guess. –  Genadinik Sep 16 '11 at 2:49
add comment

2 Answers

up vote 2 down vote accepted

From what you've provided, it's difficult to offer anything other than general guidelines.

  • SOLID principles of OO design and best practices such as those found in Kent Beck's Smalltalk Best Practice Patterns
  • an architecture that is appropriate for your domain and well understood by you and/or your team (MVC, for example)
  • mature frameworks or libraries with an eye to familiarity, community engagement, documentation, stability, etc
  • a coding style that favors consistency, readability and maintainability
  • a commitment to automated testing and/or TDD
  • a modern version control system (git, mercurial)
  • a willingness to treat PHP like a real language and not just a collection of cobbled-together HTML templates
  • most importantly, a process that is iteratively self-evaluating and self-improving

Edit: Finally, don't try to do too much at once. Make a change, give it time to set in, and evaluate that change. Keep what works.

share|improve this answer
add comment

Honestly, just do it. Every project you undertake is going to yield a whole whack of new learnings. The definition of "getting it right" changes with every new project completed. It's honestly a never-ending evolution.

Just do it.

Try using a framework for your next project, see how they recommend doing things. If you're feeling particularly ambitious, try using a different framework (or even another language) for your subsequent project. The more you expose yourself to different methodologies, the more you learn. It's absolutely up to you whether or not you agree with those practices.

Key here is not to let past errors stand in your way or overwhelming you to the point you don't do anything because you're worried about making mistakes.

Edit: While I couldn't agree more with Rein's answer, I've found that in the process of doing things with packages and frameworks done by people smarter and more experienced than you, a lot of his points are learned without you actively having to learn them. Makes sense hopefully?

share|improve this answer
    
We learn best from our mistakes. –  Rein Henrichs Sep 16 '11 at 2:58
    
@Rein: Absolutely :) And it sticks better than reading about someone else's mistakes. –  Demian Brecht Sep 16 '11 at 2:59
    
Although you miss out on the schadenfreude that way. –  Rein Henrichs Sep 16 '11 at 3:02
    
Haha.. True enough.. But then again, that's what this forum and SO are for, no? ;) –  Demian Brecht Sep 16 '11 at 3:03
    
I'm pretty sure that's secretly why we're all here... –  Rein Henrichs Sep 16 '11 at 3:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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