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?

Genadinik
  • 509
  • 1
  • 3
  • 11
  • 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 02: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 02:49

2 Answers2

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.

Rein Henrichs
  • 13,112
  • 42
  • 66
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?

Demian Brecht
  • 17,555
  • 1
  • 47
  • 81