Why pure OOP, just for the sake of doing pure OOP

Lately all I have seen is the "Pure OOP is the way to go mentality" without much reasons to back up why its beneficial. I write OOP code, but I don't write overly verbose, bloated and cluttered OOP code either. I attend Zendcon, I have my PHP certification, I read PHP blogs on a daily basis, I have had multiple OOP discussions with other developers, but in the end I still ask the question, "Why do you spend so much time writing and separating your objects? When in the end its unnecessary as you are not extending them in the future anyways."

Before I begin, I want to do a quick review on how I got onto this topic. It started a few days ago when Brandon Savage posted his article Why Great Development Tools Don't Seem To Be Written In PHP, in which I agreed with him. Further into the comments, many users mentioned the PHP bug tracker Arbit Tracker. After downloading the source and browsing the code, I came to the following conclusion and posted this comment on Brandons entry:

After looking at Arbit... Why do people always need to use SO MANY files and classes to do such a basic task? Its unbelievable how bloated some projects can get. There is a thing with being to modular.

Just take a guess at how many files are required for a basic issue tracker... just guess. There are 2,077 files and 402 folders, and remember this is still an alpha version so that can grow even larger. Basically my first reaction was "Seriously? Do we really need all these files and classes to create a simple and basic bug/issue tracker". I have nothing against Arbit, nor the developers (They know there PHP for sure), but there is something terrible wrong about this in my opinion. This is a "3rd party script that is installable on a users machine", yet looks like a full blown framework and application. When I download a script to install on my machine, I want it to be lightweight, usable, easy and customizable. I find something really wrong about this when it takes this many classes to do such a basic task, and on top of that it requires multiple dependencies like EZ Components and CouchDB (and from what I could find, this wasn't even in the source! Now add more files into the final count). After my comment everyone seemed to post the same response: "Well of course, its a pure OOP project", and "This is what happens when you do it in true OOP", and "Nothing beats an OOP setup!".

I mentioned that a project does not need an abstract, an interface or even an exception for every class in its system, and I received this lovely little response.

If you want superior software then you use the standard and that (just) happens to be object oriented methodologies.

Drop object oriented methodologies and you drop way too many other natural benefits to software development; so enough of your bullsh*t okay?

I find this response laughable. Please tell me what those natural benefits are? To expand on classes if you want to customize it or create your own? To extend them even further? Dependency Injection? Multiple other reasons... You get my point. That's what abstract and interfaces are for. So why create them when YOU KNOW you will never extend them further, or even bother creating child classes. It seems everyone is in this mentality of "Ill do pure OOP just for the sake of doing OOP."

I can see when abstract and interfaces are required, like Zend Framework for example, but even then its overkill. Very rarely does anyone ever extend or use the abstract/interfaces in Zend. I've worked at many jobs and on many projects that utilized Zend, and have even worked with individuals that do the "Pure OOP" approach, and still I have not seen them extend objects like they are supposed to be, or use OOP to its fullest. I can only recall very few instances when people actually extended the objects, and it was primarily for Auth classes to customize to fit their application.

Another thing I dislike about pure OOP approaches is the amount of code you have to write to do such basic tasks. Take for example the routing components of Zend:

$this->getRouter()->addRoute('user', new Zend_Controller_Router_Route('user/:username', array('controller' => 'user', 'action' => 'info')));

I mean, whats so difficult about the following approach (below)? Why do you need to create a whole new object as an argument, when the object is just going to be a toArray() anyways and set as a property? Oh I know, its because you want to maybe use a Route_Regex class, or a Route_Hostname class. Now my question is, why would those even need to be their own class? Because they each do a different purpose and have their own methods that overwrite the abstracts? I guess that's where we disagree then. I honestly don't see a reason why these should be "split" up. The Router should manage all routes and package the class appropriately. Breaking up the classes isn't being "Pure OOP", its just being overly modular.

Say and think what you wish, but there's nothing wrong with the following piece of code either. But you'll probably find something wrong with static methods as well, seeing as how it doesn't add any OOP functionality.

Router::addRoute('user', 'user/:username', array('controller' => 'user', 'action' => 'info'));

I also have a problem with the amount of getters and setters I see everywhere. Have you not heard of __call, __get, __set, __isset, or __unset? But I digress, that topic is for another entry at another time.

I'll stop ranting now, its a matter of preference. Id also like to note that CakePHP (a non-pure OOP approach, but still OOP) has the same functionality and customization as Zend and Symfony (both pure OOP approaches). So why do you think Cake is inferior to the others? Personally, I think it has more beneficial and useful functionality.

Sorry for the lack of activity

Its been over a month since I posted an entry and even longer then that since it was a CakePHP entry. My goal was to post on average two entries a week, or at most 10 entries a month, but I have failed to do that so I am sorry. I mainly have been absent because of my new job I started on November 2nd, and it has been taking up most of my time and day. Furthermore, I haven't worked in CakePHP for months, seeing as how I have no new projects or features to add to my existing ones. I still haven't upgraded to 1.3!

However, I recently started on another CakePHP project and will hopefully have a few more topics to talk about. Lastly, you may have heard me mention on Twitter that I started building my own framework, which is 100% true. As of right now, the framework has a fully functional Controller and View system, but is missing a Model/database. For the Model aspect, I think I will be going down the Doctrine adapter route, and possibly building my own later on.

Here are just a couple of features currently implemented in the system: Routing, Environments, Controller containers (similar to Zend modules), Class dependencies (not really injection, you'll have to see an example), Registry (Factories and config injection), Lazy loading dependencies, Hooks and callbacks, Debugging and error logging, Exception handling, App global configuration, and has been built using a modular system. What does a modular system mean you ask? Well it basically means that you can use your own script or any 3rd party script in place of the default module. For example, you can use the frameworks view engine, or you can configure it to use a Twig or Smarty adapter engine very easily. The same goes for helpers, libraries, models (Doctrine adapter), extensions, etc. The only modules that can not be changed are the controller and core classes that are used to run the framework.

I'm pretty happy with my self and how this framework came along so far, and I will be showing some code snippets at a later time. Besides all that, I will try my best to start posting actively again!

Facebook Usernames: Proof web users are morons

So if you recently logged into your Facebook, you would notice the new Facebook Usernames. These usernames work like any site, where you get to pick your unique url, I'm surprised it hasn't been implemented sooner! But the sad sad sad thing is, is the comments posted by the Facebook users. I have never seen such a cesspool of moronic and illiterate users in my life, no wonder all web developers "dumb down the UI". Currently the blog has 60,000+ comments and 45,000+ likes, but what I to talk about is all the complaints the users are supplying. Lets just list out a few right now.

  • Stop turning into another Myspace
  • Now how will I be able to search/find people I know
  • Usernames will make it harder to remember people

First off I would like to say, WHAT THE *%#?!? Honestly, I never knew how stupid users can be. It's obvious none of these users know a single thing about the web, SEO, networking or the benefits of this implementation.

Stop turning into another Myspace

This is the most ludicrous comment of them all, and it makes up for a good 85% of the comments. Since when did Myspace start the username in the url system? Thousands of websites implement this feature and it has been around nearly since the beginning of the internet. Personally, I think the unique urls are a crux in the web world and should be implemented on any site that has user generated content or social community aspects. This just proves how narrow minded and web illiterate common users are.

Now how will I be able to search/find people I know

Usernames ARE NOT THE SAME as your regular name, the usernames are ONLY FOR THE URLS. You can still search for anyone on Facebook with their regular first and last name OR their username. I fail to see how someone can be this stupid to not understand that.

Usernames will make it harder to remember people

Again, let me reiterate... Usernames ARE ONLY FOR URLS. So let me ask you this, do you remember everyone's current URL right now? This is my URL, and a guess at what my new one will be:

http://www.facebook.com/profile.php?id=672639577&ref;=profile
http://www.facebook.com/miles.johnson

Now how the *%@$ is that more difficult to remember? I know damn well you don't remember everyone's user id, now stop complaining.

I could keep going on about Facebooks users, but I don't want to write a book. I slowly lose faith in web development and the direction it will be heading if all users are like this. I'm done ranting, I feel sorry for you Facebook.

Fresh websites, Fresh updates

Well its been a while since I have posted anything useful, and I'm sorry for the lack of activity. I actually have many post ideas up on my whiteboard, its just that I have been extremely busy lately. Tomorrow I will be going on a week long cruise to Canada, so I have been preparing for that all week. Besides preparing for my trip, I have been working on two of my own websites, I will review them both below. Both of which are CakePHP applications... for your information, hah.

GameSync

http://www.gamesync.com

This is a personal project I started on over a year ago. I wanted to create a online interactive social community that is geared towards gaming and the competitive scene. It has many of the features a social community has, and on top of that has a fully robust gaming and activity system. Its something you need to try out for yourself, so please sign up! I am also looking for help (volunteered would be best) on this site, as well as searching for investors.

Starcraft 2 Armory

http://www.sc2armory.com

About 2 years ago I launched a fansite for the game Starcraft 2. Since then it has grown tremendously (just hit 10 million views!) and I recently decided to redesign it. In that process, I also decided to rebuild the whole system in CakePHP from the ground up, check it out! Oh and by the way, I am the #1 unofficial fansite for Starcraft 2... of course!

Anywho, once I get back from my vacation, I promise to put out more posts then I am now. With 2 websites out of the way, I will have so much free time. Hats off to that!

21 years young

So its my 21st birthday today, time flies by fast. I remember being only 16 and learning PHP, and now its 5 years later and I am pretty proud of where I am. But anyways, I will be celebrating at Dave & Busters, playing some video games and having a beer. Just want to say hi to everyone out there reading this, and a premeditated thank you to everyone wishing me a happy birthday!

Stay tuned for a few new tutorials I have planned for the coming week.

My `09 Resolutions

A big happy new years to you and everyone else! This last year was kind of a bust for everyone, I even went through some rough times. I actually moved back home literally 5 hours ago (sad I know!) because I recently quit my job, the economy fell and I couldn't afford rent any longer. But there is nothing wrong with that, lets hope that the coming year will bring great things for everyone. And with this new year comes many new years resolutions, to say the least, here are a few of mine!

  • Finish this website (there are things I really want to release, but its not ready!)
  • Work more on special projects
  • Hang out with friends I haven't seen much lately
  • Get my corporation and taxes settled (ugh I know)
  • Write more tutorials and tips
  • Learn CakePHP extensively, its fun!

There are other resolutions made, but like everyone else, a few of them are personal. But I posted the following in hopes that if I slack, someone out there reading them and noticing will be disappointed with me, and I don't want that! Now to keep up with these resolutions and see them through, and the same goes for you! I wish you all a happy new years and good luck with everything your doing and the paths you are taking.

5 reasons why L4D zombies aren't classic zombies

Left 4 Dead, the fast-paced zombie smashing game recently released from Valve. You are one of four survivors who have to make their way through many different environments. Your obstacles? Hordes of zombies. Other obstacles? Hunters who can leap distances, Smokers who can ensnare and drag you with your tongue, Boomers who vomit zombie-attracting bile, massive hulking Tanks who can smash you in a single blow and bitchy period Witches. Yes this sounds like loads of fun, destroying large amounts of zombies. But how zombie are they really?

1 - No biting

This was a pretty easy one. The classic zombie is usually the result of some sort of infection, in that once an individual dies, the infection takes affect and they rise from the dead. Once a newly undead, the zombies infect other targets by biting them. If the target was not devoured by the zombies hunger, they will eventually die and convert. But now in L4D there is no biting what so ever, only clawing and smacking. When someone is downed, the zombies simply crowd that survivor and flail their arms. Where is the biting, tearing, ripping, dismembering and so on?

A short clip from the great comedy, Shaun of the Dead (bad quality, sorry), simply shows how the zombies should be ripping you apart.

2 - No gruesome walking corpses

Why do all the zombies in L4D have all their limbs? Why are there no guts hanging out of their stomach? All the zombies are fully clothed and have all their limbs, boring. The only similarity to classic zombies is the gray skin, the bloody mouth (but how, there's no biting!) and the frankenstein expression. It would be an awesome idea to have a wide variety of zombies. Some of them can be missing an arm, or maybe two! Others may have one leg or no legs and must crawl to you with their hands (ala Dead Space) to attack. Lastly it would be graphically pleasing if a select few zombies had their innards hanging out and around their body.

3 - No rising out of the ground

This mainly applies to the 3rd chapter of Death Toll (at the church) but could also apply to other areas in the other stories. When I first walked into the grave, I was expecting the zombies to rise out of their graves and surround us. But instead, I was sadly let down and faced another "typical horde". Still, this type of feature would be fun and show homage to the cult classics. It does though contradict the idea of an "infection", but Im going based on zombie ideals.

4 - Freak out from fire

This was another thing in the game that seemed out of place, but I understand its purpose for gameplay. Simply put, zombies have no real physical feeling and can sustain massive damage (excluding having the head destroyed) but keep on trotting forward. A mere molotov cocktail or wave of fire would not cause the zombies to freak out and run around confused. It just means you would have flaming, hungry zombies chasing your ass.

5 - Die without destroying the head

This is another thing that's "good" for gameplay but I'm still going to point it out there. In every classic zombie film, the only way to kill a zombie is to, and I quote, "remove the head or destroy the brain". But just imagine here for a second... an unexpected horde appears, your cower into a corner and let your auto-shottie sing. You mow down a wave of zombies but merely blast off some arms or legs but they keep crawling forward. In a list ditch effort you melee bash the oncoming zombies skulls in. End imagination.

Notice - I am in no way bashing L4D, I actually play this game way more then I should. I just got a bit curious on the ideology behind the L4D zombies against the classic zombies. Enjoy!

A Fresh New Beginning

It has been such a long time since I've had a personal website up. My last website (www.mileswjohnson.com) has been up for quite a few years and has been through many versions, I believe the last version was 5. But I felt that the site wasn't going in the direction I wanted, so I decided to start over with a new domain and design. And here I am, a fresh new beginning.

This website will house a blog that I plan to update on a daily or weekly basis with topics ranging from web design, gamin and even business. I also have quite a few open source PHP scripts that I will be unveiling in the near future. I hope you enjoy my writings as much as I enjoy posting them.