3

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?

2
  • 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. Commented Sep 16, 2011 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
    Commented Sep 16, 2011 at 2:49

2 Answers 2

2

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.

2

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?

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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