1

I am working on a php web application, it handles a lot of things from collecting votes to registering new users. Traditionally I have done things like this using 20+ pages, but as a challenge to myself I set out to see how much I could get done with a single page. Everything appears to be working well and that got me thinking what are the pros and cons of this type of approach? Thanks for your input!

user2464339
  • 43
  • 1
  • 5

2 Answers2

2

You're describing the basic arguments between procedural and objects/methodization.

Can you make one giant page that will do EVERYTHING? Sure.

Will it run super fast? Probably. Functions have some overhead to them.

Will you be able to maintain the codebase? Maybe... Or maybe people rue the day you learned to code

Writing methodized takes more time up front but you rarely ever have to repeat yourself and you can better digest what your code is actually doing, instead of trying to dig out where a variable was set, discovering it was actually set 4 times, and trying to figure out what it's doing on lines 2478 and 5492. Not that this has happened to me or anything.

Community
  • 1
  • 1
Machavity
  • 30,841
  • 27
  • 92
  • 100
1

I think the big pro is user experience. But to get that to the top, you should not reload the page, but communicate with the server using ajax.

Single page does not mean single file. The best for maintainability is to have a file for each class. Also think MVC, this will help you to structure the code and avoid spaghetti code.

Lorenz Meyer
  • 19,166
  • 22
  • 75
  • 121