spaghetti to mvc

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: spaghetti to mvc

Post by Christopher »

pytrin wrote:Dude, stop being so cryptic :P
How come he's subjective and you're objective? we are all subjective since we apply our own reasoning when making design decisions. Those reasoning are influenced by our experience, knowledge and personal opinions.
I said above I thought "good" was objective, he countered that it was subjective.

Sure we are subjective, but certainly we can be objective too. But if this is a discussion of our opinions about the quality of the source code, then all you can do is listen to others opinions and perhaps learn something.

But my bigger point is that some programmer's opinion of the source code is not much of a metric of what is "good." The main reason for software is to be useful to users. The qualities of the source code can help development, maintenance, etc. But, those qualities are often very relative to the team developing the software.

After years of hearing that WordPress or some other popular application's code sucks -- and the complainers can't understand how it is so popular/useful because it can't be maintained or is insecure -- you would think that the complainers might start to question their own opinions about code.
(#10850)
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: spaghetti to mvc

Post by Eran »

It's true that wordpress as a software product is a great success, but Spectra was judging its architectural design and not its marketing brilliance or great UI.
While its true that end-users shouldn't care, us being developers we do care about more than the end result of software. I think you would agree too that wordpress can stand more than a few improvements to its design.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: spaghetti to mvc

Post by alex.barylski »

You judge software subjectively, so of course you could make it better in your opinion ...
How is software that:

1. Ran faster
2. Used less memory
3. Had less security holes
4. Had less bugs

subjective???

Technically speaking that it about the only way to prove something is better than something else...facts are not debatable...they are simply a matter of fact. :P
I have a challenge for you PC, if you will - rewrite wordpress using procedural code only, and see if you could do better
Good software design can be accomplished in any language or any style (Assembler, Procedural, OOP, etc). To answer your question outright...absolutely I could write it better using nothing but functions... :P
The main reason for software is to be useful to users. The qualities of the source code can help development, maintenance, etc. But, those qualities are often very relative to the team developing the software.
Then why are you so critical of others software design? Why? Because you realize that software is "better" when good practices are followed...
After years of hearing that WordPress or some other popular application's code sucks -- and the complainers can't understand how it is so popular/useful because it can't be maintained or is insecure -- you would think that the complainers might start to question their own opinions about code.
I admit it's partial frustration/jealousy that fuels my zest for complaining about crappy software...but I have a passion for this industry and a passion for writing perfect software. I know I'll never write perfect software but I can strive for perfection (technically) every day I am alive...

IMHO the more technically perfect a software source is...the "better" it is. Whether software is useful or not...is subjective but there is no disputing the fact that some software is better implemented than others. WordPress is not a good example of professionally developed software.
but Spectra was judging its architectural design and not its marketing brilliance or great UI.
Precisely...again what forum are we in??? :P

Cheers,
Alex
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: spaghetti to mvc

Post by Christopher »

pytrin wrote:It's true that wordpress as a software product is a great success, but Spectra was judging its architectural design and not its marketing brilliance or great UI.
While its true that end-users shouldn't care, us being developers we do care about more than the end result of software. I think you would agree too that wordpress can stand more than a few improvements to its design.
All software could use a few improvements. If you ask the developers of that software they will provide you with a much longer and better ToDo list of what is really needed than any of us on the outside. But needing a few improvements nothing compared to the utility that an application like WordPress provides to truly millions of users. Again, I think the definition of "good" given by some here is simply "my opinion." I know that my opinion would not be worth much to the WorkPress developers.

I think programmers have an unrealistically good opinion of their own software and an unrealistically bad opinion of their others software. I know that my software is not as good as WordPress'. I know how difficult it is to get software to that level. I would wager that if we submitted an application from each of us and WordPress to an independent panel that our code would be judged poorer that WordPress'. We programmers are notorious for thinking that we are brilliant. I have yet to meet one who is.
(#10850)
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: spaghetti to mvc

Post by Eran »

First you say
I think programmers have an unrealistically good opinion of their own software and an unrealistically bad opinion of their others software.
But then you say
I know that my software is not as good as WordPress'.
So either you are very special and the rest are ego-maniacs or maybe that's like, your opinion, man ;) (to quote the big lebowsky)

Of course developers have ego, everybody has ego. Do we let our ego get in the way of our judgement? I think that's for each of us to decide for himself.

I have encountered software packages that I considered of the highest quality (for example Zend Framework, ezComponents) and packages way down the quality scale (phpBB, wordpress). When I say quality I am not referring to individual style preferences, I'm talking about how hard was it for me to configure, extend, maintain and work with those packages. This is not in comparison to my own code (I never said anything about the quality of my own code, that was Spectra), this is my opinion as someone with hands on experience with those packages.

For me, I totally understand why wordpress is a great success - it's an end-user product, meaning its not for developers but for content creators. User experience is the most important aspect of GUI based software, and as long as it "just works" the internals are of no concern to end-users.
I would wager that if we submitted an application from each of us and WordPress to an independent panel that our code would be judged poorer that WordPress'
I never compared wordpress to my code, I'm not in a good position to judge that. But when I compare it the Zend Framework for example, on the grounds of software design, extendability and good practices - I believe any serious panel would find the ZF to be a much higher quality product. If you disagree on this, I hope you can at least present concrete arguments to why this is not the case.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: spaghetti to mvc

Post by alex.barylski »

If you ask the developers of that software they will provide you with a much longer and better ToDo list of what is really needed than any of us on the outside
A codebase is a direct reflection of the programmers abilities and understanding of best practices, etc...there is no indication Matt was much more than a weekend warrior/cowboy programmer when began implementing WordPress or forking it from b2.
Again, I think the definition of "good" given by some here is simply "my opinion." I know that my opinion would not be worth much to the WorkPress developers.
I'm not disputing that...but you keep bending the topic in that direction. :P

I am saying: Technically speaking...wordpress is a horrible example of best practices, good design, etc...

The proof is in the pudding so I'm not sure where "opinion" comes in...

It's insecure, buggy and mangled with SQL PHP XHTML JS with very little (if any) separation of concerns.
think programmers have an unrealistically good opinion of their own software and an unrealistically bad opinion of their others software
To some degree, sure. But that is why I posted a challenge of re-writing WordPress. I'm confident it can be done better "technically" speaking...that is retain complete backwards compatibility (tables, user interface, etc) all the while:

1. Running faster
2. Using less memory
3. Less bugs
4. More secure

And probably even trim the source code in SLOC a little

Those are 4 (maybe 5) quantifiable metrics...they are numbers which are undisputable and are good indications of an "improved" code base.

If programmer A consistently writes more code programmer B (because he types faster and thinks faster) technically speaking in that regard he's a better programmer...of course if his code has more bugs then at that point it becomes subjective as to who is the better developer.

1. Do you favour more code production?
2. Do you favour more rock solid code?

Personally I would opt for #2 but in a financially motivated software factory writing more code would quite possibly be more important. That is subjective, but that is *not* what I am saying.

I think it's safe to say that if users were awre of the bugs/security issues of current day WordPress and then given an identical alternative which fixed all those issues, security holes, etc...

They would be more than willing to switch, having more confidence in their product. :)

Which is why I thought it a good idea to re-write/re-factor the codebase into something "better".
I know that my software is not as good as WordPress'
Again your being vague here (software and good) do you mean from an End user perspective? Do you mean codebase maintainability and stability? Achiveing WordPress market success was mostly good luck and timing, like most projects that succeed in this industry.
I know how difficult it is to get software to that level.
What 50K lines? Dude...they have a team of developers who work on that project...

I was the sole developer for several projects when I worked at Intersomething and I managed fine and those codebases were not pleasant although more logical division than WordPress, so it was tolerable.

So apparently I know what it's like to get projects to that level as well...and there is little reason for projects to be that buggy, insecure, etc outside of ignorance to change or not understanding the benefits.
I would wager that if we submitted an application from each of us and WordPress to an independent panel that our code would be judged poorer that WordPress'. We programmers are notorious for thinking that we are brilliant. I have yet to meet one who is.
Who said anything about being brilliant? I just said I could do it "better" -- big difference. ;)
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: spaghetti to mvc

Post by Eran »

that is retain complete backwards compatibility
What about plug-ins? they are a huge part of wordpress success and appeal. How are you going to support plug-ins that rely on the old structure?
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: spaghetti to mvc

Post by alex.barylski »

What about plug-ins? they are a huge part of wordpress success and appeal. How are you going to support plug-ins that rely on the old structure?
Plugins by their very nature (otherwise they aren't plugins they are core hacks distributed as individual modules) would utilize an interface which should make the usage of existing plugins as no hassle issue.

The templates are nothing more than PHP/XHTML scripts that call upon certain WordPress API:
http://codex.wordpress.org/Plugin_API wrote:Note: this information applies to WordPress Versions 1.2 and higher. Before Version 1.2, modifications were called "hacks" and involved editing the source code of WordPress itself.
I assume then so long as I implemented the interfaces existing plugins should just work...which is why it would be important to maintain backwards compatability with the table schema...there are probably countless plugins that directly query the tables without using an API.

Which shows to go you that WordPress was designed poorly. Plugins are/should be completely ignorant of the data store and/or schema.

Cheers,
Alex
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: spaghetti to mvc

Post by Eran »

I wouldn't be asking this if it was as simple as implementing an API. Having a concrete API demonstrates good design, which wordpress as you've said, does not. Most of those plug-ins use directly all of wordpress' core functions - meaning you'd have to preserve not just the schema, but also all the old functions names and scoping issues (many of those plugins call upon global variables that could come from anywhere).
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: spaghetti to mvc

Post by alex.barylski »

but also all the old functions names and scoping issues (many of those plugins call upon global variables that could come from anywhere).
Good lord...are you serious? The task becomes impossible to retain backwards compatability then...at least those which use GLOBALS, etc...I suppose I could support GLOBALS, etc...just keep all that code in a legacy.php or something. Or re-write the plugins...which would probably make the most sense.

I rest my case...WordPress is a hack and a horrible example of excellent code. :P

Cheers,
Alex
User avatar
Syntac
Forum Contributor
Posts: 327
Joined: Sun Sep 14, 2008 7:59 pm

Re: spaghetti to mvc

Post by Syntac »

Wait, so now this thread is about WordPress? (Yeah, late, I know.)
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: spaghetti to mvc

Post by josh »

You can write code that is maximally cohesive, minimally coupled, logically divided into non inter-dependent modules, following all principles of TDD, etc.. the code might be able to do 5 million features that solve user needs, but something as simple as the color of a banner ad used for marketing could make or break the whole project. A project is not just the code, I think the root of the disagreement is not realizing the project itself and the code base are 2 separate entities. Saying a code base is "good" within the context of a project would imply that the code meets the requirements of the project, today. Extensibility tomorrow is another issue, which solves the developers needs, not the users ( unless the TAM is other developers, for marketing laymen thats Total Addressable Market ). although implicit to a good design it's obvious extensible code in itself is of no value to the end user in wordpress' case. Saying the project is good would imply good marketing, not only high user adoption but high user satisfaction, etc..

The codebase being "good" means it meets the project's requirements in a "good" fashion. Thus, a codebase is only more or less applicable to an arbitrary application. If a project requirement is that I need a plugin system that can evolve without plugin clients refactoring their code, that is a "good" requirement. Implementing the requirement with a good design serves the developer not the end user, granted if the developer doesn't serve himself first then the codebase might fall out of sync with the project. If the user's don't care about this feature I just wasted my time, and although MY opinion of my codebase has gone up overall, the most important features have not been updated which is "bad" in the collective opinion of your TAM

I think good is objective, but only if given proper context. The correct context is subjective. "success" is also both subjective / objective depending on the context. Are we talking successful in implementing the requirements, financial success, success in reaching a % of user base adoption, success in failure ( success measured in metrics of not accomplishing a negative goal ), etc.. Success can be measured objectively only if given a metric to quantify which end of the spectrum is "good".

Saying "good" is objective would be ignoring the fact that different projects have different styles :wink:

That being said, you will realize this thread has become quite pointless, not to mention :offtopic:
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: spaghetti to mvc

Post by Christopher »

pytrin wrote:First you say ... But then you say ... So either you are very special and the rest are ego-maniacs or maybe that's like, your opinion, man ;) (to quote the big lebowsky)
But I'm not the one who called anyone's code crap or claimed I could rewrite it better. I think saying that WordPress or phpBB are "way down the quality scale" is not understanding the difficulty of building applications with that level of functionality and polish. Plus, comparing frameworks and applications is not really fair -- they are different in many, many ways.

Ultimately there is a lot written above that says that your opinions of what is "good" is contrary to what the world says is "good." And obviously I have some of the same understanding of best practices that you guys do. But you seem to be saying negative things about solutions like WordPress' plugins or phpBB's mods that are in reality quite brilliant solutions. They have enabled thousands and thousands of people to do very interesting stuff. I continue to think there are some blinders on here about the domain of "good."
jshpro2 wrote:That being said, you will realize this thread has become quite pointless, not to mention :offtopic:
I think I said as much many posts back. ;)
(#10850)
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: spaghetti to mvc

Post by josh »

User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: spaghetti to mvc

Post by Christopher »

And we go from off topic to way off topic! :)
(#10850)
Post Reply