PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
It is currently Thu Dec 13, 2018 7:15 am

All times are UTC - 5 hours

Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sat Aug 06, 2005 11:33 pm 
Forum Newbie

Joined: Sat Aug 06, 2005 5:45 pm
Posts: 21
Hi everyone,

I hope to get help with TDD and unit testing, especially with web development.

I've been lurking around Sitepoint forums and have recently found my way here. I am very admiring of McGruff's knowledge and many insightful posts on Sitepoint. I am glad there is a unit-testing forum run by McGruff here.

I got interested about TDD and unit testing from all those posts on Sitepoint. I bought and read Kent Beck's Test Driven Development: By Example. I also browsed through lastcraft's website. In addition, I tried out JUnit as I'm a little better at Java than PHP (Just simple stuff like the Money examples).

Now I'm having trouble starting using TDD and unit-testing in my own project. I would like to create a MVC type framework to drive my web sites. I do not want to use established frameworks, such as Mojavi, because I don't want too many features. I want basically barebones features that I need and extendability so I can add in things I need later.

So, my dilemma is as follows. Where do I start?

I know of concepts such as MVC, Page Controllers, FilterChains, TemplateView, Database abstraction... and that's what I'm aiming for, but I also heard that I shouldn't be bogged down with these concepts in the beginning?

Anyways, I'm just a little confused and not too sure if I'm going down the right path. I guess that's the trouble with learning by myself, I never know if I'm doing anything correctly.

What's a good starting point to start TDD-ing this type of project? I do not have much actual project experience since most of my programming experience comes from university courses and I have not completed university yet.

Any and all help is appreciated.



 Post subject:
PostPosted: Sun Aug 07, 2005 12:14 am 
DevNet Resident
User avatar

Joined: Fri Aug 16, 2002 8:57 am
Posts: 1834
Location: Watertown, MA
Welcome! Sounds like your in the same situation as a few of us... All hoping to gain knowledge from McGruff :)

If I were starting from scratch, I think I would start from the Controller side (either Front or Page) and grow towards the user-visible webpages -- especially as your seeing to develop a framework. If you were seeking an application, I'd probably start more at the Model end and let the application/interface grow up around it. But I'm a relative novice at TDD....

 Post subject:
PostPosted: Sun Aug 07, 2005 2:58 am 
DevNet Master

Joined: Thu Jan 30, 2003 9:26 pm
Posts: 2893
Location: Glasgow, Scotland
Welcome to the forums :) The php tags aren't always this messed up - should have it sorted out soon.

You'll give me a big head - but it's nice to get some feedback. Don't take anything I say as gospel though. The real heavy-hitters are over on sitepoint. What I want to do here is encourage some interest in unit testing and help people get started as best I can. It's the single most important thing I've ever learned as a programmer.

With TDD you can jump in anywhere in the design. I would tend to start right at the top which means figuring out some kind of Front/Page/Application controller framework. A request object and a ChainOfResponsibility works for me - see here.

I think the key is maybe to always watch out for new responsibilities. If methods get too big split them up (I start looking over my shoulder around 7-8 lines). If the class isn't looking very cohesive spawn a new class (which you can initially mock for testing then implement later). If you've already got experience with patterns that will help to avoid bad design decisions which have to be torn up later. Really the whole point of TDD is to avoid making big upfront designs, letting things evolve in little steps, but you can't avoid some.

XP encourages programmers to be very focussed on the client requirements. You code just what you need to pass tests which express these requirements, and move on. So, it might help if you think of an specific application to build and work through that.

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group