Dysan
04-22-2008, 05:27 PM
Hi, how do you know that the code you have written is the most efficient, and there aren't better ways to code it?
|
Click to See Complete Forum and Search --> : PHP Code Dysan 04-22-2008, 05:27 PM Hi, how do you know that the code you have written is the most efficient, and there aren't better ways to code it? sstalder 04-23-2008, 01:44 PM Think about it this way.. There is usually always a better way to code what you have coded. So the answer is you might never know. You can benchmark your scripts if your that worried about it. Ultimater 04-23-2008, 08:19 PM As long as it gets the job done, anything is called for. (ninja's motto) In otherwords, it doesn't matter how efficient it is as long you can break your script into modules and manage it easily by focusing on one module at a time rather than inflexible unorganized spaghetti code. The modules themselves can be spaghetti code just like any function, however the function or module needs to get the job done reliability so it is reusable and dynamic. Any code can be spaghetti code as long as you won't ever have to come back and alter it. You can even encode the module with Zend and trash the original source if you know you will never have to alter it ever again. The main this is that within your main PHP file, the code should be readable, easy to manage, dynamic, flexible, powerful, efficient and reliable. Anything else save for include (http://us2.php.net/manual/en/function.include.php). PHP, unlike JavaScript, is about making the biggest library possible so everything is at your fingertips. Even if you won't even use it, as long as it is in a file somewhere on your server, it is there if you ever need it. In JavaScript however, you don't want to load 100 external scripts at once since this will only add lag and increase the chance of errors being encountered as well as the change of script collusion. PHP is a completely different world since the user has to navigate around the system. see Model-view-controller (http://en.wikipedia.org/wiki/Model-view-controller) webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |