luke101 Posted June 15, 2008 Share Posted June 15, 2008 Hello, Just wanted to know if there is anything out there or any technique that prevents speghetti code in php? I am really considering .NET because the maintainence is so much easier. But i am really trying to find a reason to use PHP because I know the support is much better. So do you guys know anything or way to prevent speghetti code? Quote Link to comment https://forums.phpfreaks.com/topic/110324-love-php-but-hate-speghetti-code/ Share on other sites More sharing options...
Sulman Posted June 15, 2008 Share Posted June 15, 2008 By speghetti code I guess you mean code appearing all over the page for different reasons? In that case OO techniques would reduce this or alternatively look at smarty templates. These templates abstract the PHP code giving a clear definition between the business layer and the user interface. Quote Link to comment https://forums.phpfreaks.com/topic/110324-love-php-but-hate-speghetti-code/#findComment-566049 Share on other sites More sharing options...
Barand Posted June 15, 2008 Share Posted June 15, 2008 As VB.NET supports GOTO, it's a spaghetti coder's heaven. It's down to the coder, or in-house coding standards. If you don't want it, don't write it. Impose structured coding or OOP. Quote Link to comment https://forums.phpfreaks.com/topic/110324-love-php-but-hate-speghetti-code/#findComment-566050 Share on other sites More sharing options...
joecooper Posted June 15, 2008 Share Posted June 15, 2008 use a program called HAPedit. it colour codes things, and i tend to find it very useful i also comment on EVERY line so i can look back on it if need be. keep inner-code indented for IF's etc php supports functions, which is just the same as goto? Quote Link to comment https://forums.phpfreaks.com/topic/110324-love-php-but-hate-speghetti-code/#findComment-566059 Share on other sites More sharing options...
Sulman Posted June 15, 2008 Share Posted June 15, 2008 php supports functions, which is just the same as goto? Not quite. As I recall goto will skip any code inbetween. A function call in PHP will continue code execution from where the function was called after it has finished doing the function. Quote Link to comment https://forums.phpfreaks.com/topic/110324-love-php-but-hate-speghetti-code/#findComment-566062 Share on other sites More sharing options...
shlumph Posted June 15, 2008 Share Posted June 15, 2008 I've been trying to learn the Zend Framework, and it seems to do a great job of separating everything. It's a bit overwhelming at first, if you're used to writing PHP procedurally. Quote Link to comment https://forums.phpfreaks.com/topic/110324-love-php-but-hate-speghetti-code/#findComment-566076 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.