Tony Marston. Programmer fish or Troll?

Tony Marston is a troll.
He doesn’t understand the difference between a pattern and a methodology. If anyone writes him and says they find patterns useful, he will immediately assume you use patterns as a methodology (like him).

I mean why else would you write an article called “design patterns are dead”.

First a little cliff notes. Tony Marston wrote a full-stack framework for building CRUD applications. The code is mediocre. He did an excellent job cataloging his components into a sort of pattern language others may learn from. He called these “transaction patterns” which I will refer to as “CRUD patterns”.

Each one describes a particular user story in the application, such as listing records. The same things have occurred in my applications, for instance having to let the user re-assign child records when deleting a parent record. So these are indeed patterns.

Then what is my beef?
He repeatedly contradicts himself while spewing biased mis-information. Let me show you exactly what he is doing.

Tony Writes
Because a "transaction" contains elements from a collection of different low-level design patterns it can be said to exist at a higher level. A "transaction pattern" is therefore a method of providing a description of this collection of design patterns which are used to satisfy the requirements of a user transaction.
http://www.tonymarston.net/php-mysql/design-patterns-are-dead.html

[A1] Tony Marston admits CRUD patterns are a way of cataloging a system just at a higher level of abstraction then design patterns. His framework uses them (design patterns and transaction patterns both).

Now here’s what he starts to get on my nerves
Tony Writes:
What you cannot do with Design Patterns
They are supposed to have more than one implementation, with different implementations of the same pattern having something in common with all the others. But if each implementation of a design pattern is supposed to be unique, where exactly is the pattern? If nothing is being shared between one implementation and another, then how can there be a recurring pattern?
Woah woah woah, come on Tony. You know what a pattern is. You wrote another article about just that:

In just another article Tony wrote:
A pattern provides a solution schema rather than a fully-specified artifact or blueprint. You should be able to reuse the solution in many different implementations, but in a way that its essence is still retained. A pattern is a mental building block.
* A pattern addresses a recurring design problem that arises in specific design situations and presents a solution to it.
* Patterns document existing, well-proven design experience.
* Patterns identify and specify abstractions that are above the level of single classes and instances, or of components.
* Patterns provide a common vocabulary and understanding for design principles.
* Patterns are a means of documenting software architectures.
* Patterns support the construction of software with defined properties.
* Patterns help you build complex and heterogeneous software architectures.
* Patterns help you manage software complexity.

Tony continues..
This provides us with the following definition
A pattern for software architecture describes a particular recurring design problem that arises in specific design contexts, and presents a well-proven generic scheme for its solution. The solution scheme is specified by describing its constituent components, their responsibilities and relationships, and the ways in which they collaborate.

http://www.tonymarston.net/php-mysql/design-patterns.html

[A2] In this statement Tony is doing a good job of showing how design patterns are useful because new programmers can learn about why experienced programmers are doing what they do. It provides advanced programmers a means to communicate with each other.

New requirement Tony is inventing that all patterns must meet?
Design patterns meet every one of those requirements he listed, but now all of the sudden he says a “pattern” must meet some new definition of the word “pattern” he just invented….

Tony wrote:What you cannot do with Design Patterns
Patterns or templates are supposed to have the following characteristics
- They are supposed to have more than one implementation, with different implementations of the same pattern having something in common with all the others. But if each implementation of a design pattern is supposed to be unique, where exactly is the pattern? If nothing is being shared between one implementation and another, then how can there be a recurring pattern?
- Parts of the original implementation are supposed to be abstracted out into a pattern which can be reused, thus making all subsequent implementations easier than the first. With software programs the reusable element is program code, but if there is no code which can be shared, if each implementation is unique, then where exactly is the pattern? Where is this reusability? If there is just as much effort required to create all subsequent implementations of a design pattern as there was with the first, then nothing is being reused, nothing is being shared. If that is the case then does a pattern actually exist?

http://www.tonymarston.net/php-mysql/design-patterns-are-dead.html

Then in email Tony Writes:
Something cannot be called a "pattern" or "template" unless it has a element
of re-usability. This requires that subsequent implementations take less
time than the initial implementation. If each implementation of a "design
pattern" takes just as long as the first because there is absolutely nothing
that can be re-used then the use of the term "pattern" is inappropriate.

Why all of the sudden are you adding this new requirement Tony? I wrote him and he provided no rationale justification. I asked him if his CRUD patterns used any design patterns (see A1 – Tony Marston uses design patterns). He said no. I told him about some of my architecture that is similar to his “list 1″ component. I mentioned I dont need List 1 – 10 or whatever because I have hook methods and a plugin architecture using observers (these are both 2 design patterns). He immediately switched into “my code is better than yours” defensive mode and stated about all the hooks he was using in his application. Haha tricked him. So tony here’s my new requirement for your vocabulary:

All hook methods must use bait method to catch a fish variable with the rod and reel component

Pretty silly if we just started adding new requirements for your method to be called a “hook”.

What am I saying here?
They’re just freaking words. Useful terms that establish a vocabulary programmers can use to communicate (see A2 – Tony originally defines a design pattern as a useful vocabulary). But then he feels the right to go off and write an article entitled “Design patterns are dead” and makes wild assertions:

- Design Patterns are the wrong level of abstraction
- What you cannot do with Design Patterns

How can he make such assertions?

Tony Wrote
I have said that I don't use design patterns, and I have given my reasons why. I have also written about CRUD patterns and why, in my opinion, that I think they are better.

I think he’s the only one using “that” logic.
In email Tony wrote
I already used my data dictionary to generate the table
classes from the database schema, so it was then a simple task to include
the facility to generate transactions from predefined transaction patterns.
If you cannot do the same thing with design patterns then this proves that
transaction patterns provide a higher level of reusability and therefore
productivity, which in turn means that transaction patterns are superior to
design patterns. Using that logic, why on earth should I want to use
something which is obviously inferior?

Reading what he wrote is like reading a carpenter’s writing who writes about why a drill is “better” than a saw. They are just different tools. They are not mutually exclusive tools, and in fact they don’t even solve any of the same problems. They don’t even really share a common applicability. So how can one be “better”? They don’t compete. Transaction patterns use design patterns (A1)

Not mutually exclusive!
Since they both solve different problems, I argue that each one is better at something different, at the cost of sucking at everything else. Design patterns excel at being a common vocabulary between programmers. I can talk to anyone else writing Enterprise applications (such as a version control system), and both terms are useful to us. With Tony’s CRUD patterns, I can talk about things at an even higher level, I can talk about specific screens within a CRUD application. But Tony’s CRUD patterns are of no use to me when writing a social network, for example.

So if Tony is going to say his patterns are better than design patterns he should at least state what and why. He does not though. He simply argues the definition of the word “pattern”. In talking with him he says we should not use names of design patterns to name components in our code, because design patterns obviously have no use. Why then would Tony use a “hook” in his code? Is he a programmer or a fisherman?

He is just a troll.

No New Programmers Allowed, E-Douches only
Tony Writes in e-mail:
I consider design patterns to be as much use as a "painting by numbers" kit
for novice artists. How many professional artists do you know who still use
such kits? None! Why? Because once they become proficient they don't need
them, just as proficient cyclists don't need training wheels.

As you can see he flip flops opinions, makes wild assertions, and when asked if he thinks design patterns could help new programmers program better he wrote the previous and following statements, which clearly indicates that he does not want anyone else to learn. My opinion is that he has a superiority complex or does not care that he is spreading mis-information so that he can make sales of his “radicore framework”.

I wrote and Tony replied
> Let's say you went golfing with Tiger Woods (I'm assuming you don't
> golf, if not substitute with some obscure sport like curling). If Tiger
> told you to just step up to the tee and swing, you probably would not
> be able to hit the bar as far him. Golfers have broken down their
> knowledge into patterns, like stance patterns, backswing patterns,
> follow thru patterns, that takes years of education and practice to
> master at his level of expertise.

The trouble is that different practitioners of an art (and programming is an
art, not a science) have different explanations as to what makes them good
at what they do, but what works for one person may not work for another. If
a person does not have the basic talent for an art form to begin with then
it does not matter what technique you try and teach him - he will always be
a failure.

Tony Writes
I certainly would not look at a piece of code and say "This looks pretty. I shall give it a name".

You have already sleighed new programmers entering the field. I am not surprised you would not be interested in analyzing the things you do or why you do them. You have already “mastered” them in your mind.

Tony Marston. Troll.

Ps > this post has been made in satire of his “crazy headlines” writing style. Maybe he should write a pattern on language on this next.

Posted in Programming | 7 Comments

Windows Vista / “restricted mode”. Why I will not purchase Windows 7.

Today Windows Vista booted into “restricted mode”, all I could access was FireFox (my default browser). See when Vista came out I went down to the store and picked up a copy of “Ultimate” for $300. Later I found out it was the upgrade. Being a power user I am always changing hard drives (when SSDs came out, and then 3 months later when my $400 solid state drive crashed I had to switch drives again). Just installing on a new drive is a pain. Everytime I try to install I get “this product key is for users with existing installations of XP only”. Which I DID have an existing installation of XP, 4 years ago when I bought this thing.

So it is pretty well known you can just leave the serial blank, and install as a trial. But then you get nagging activation prompts. Where does this leave users who discarded their old XP disks or simply do not feel a paying customer should have to go thru the hassles put in place to stop the pirates? Well, we are basically relegated to becoming pirates ourselves.

So I downloaded a “crack” that supposedly activated my machine (and believe me I tried to call support to get them to remedy my issue first, they basically give you a nice “fuck you”). So today I boot up and get presented with a nice “restricted mode” where they launched FireFox to the “buy windows” page. I thought to myself “but I already bought windows, based on the fact you are doing this to me there is no way I am NOT going to go out of my way to stop microsoft from getting a single more penny from me or anyone I know. But I regress).

Since I was already in a web browser I figured I would try to visit various websites. The whole internet worked. I could even visit piratebay.org and launch utorrent. Great I thought, I’ll find some crack and we’ll be set. Only problem is in “restricted” mode they limit the number of running programs. Trying to run more then just 2 or 3 programs I would get “no quota available”. I had no access to cntrl+alt+ delete or the start menu or any of those features.

Well this was starting to suck. Long story short here is the process I found that worked, to activate windows and get me out of “restricted mode”. As per these instructions, I edited the registry key. I will break it down step by step.

  • Click “File” -> “save page as” in your web browser, a save dialog opens up
  • In the text field that says “File Name” type “C:/Windows/system32″ (without the quotes, and press enter)
  • Under File Types choose all files, in file name again type cmd.*, you should see cmd.exe, right click and run as aministrator, if you get a quota error exit open programs and try again
  • Type “regedit” into the command prompt and press enter. If you get errors close running programs such as your web browser and retry.
  • # Navigate to this path:
    ** HKLM\SOFTWARE \Microsoft\Windows NT\CurrentVersion\SL
    # Double-click SkipRearm and change the value to 1. Close regedit
  • Back in cmd.exe run the command “slmgr -rearm” (without quotes), about 45 seconds later you will get a success dialog, it will be out of focus and you could miss it, since you have no taskbar. If you get errors from this command after running it multiple times it most likely worked the first time!
  • You can type explorer.exe now to get a new task bar, but must reboot to remove quota restrictions
  • Download a windows crack and patch your machine ASAP. Use this Vista Activation.exe http://isohunt.com/torrent_details/50285146/windows+activation?tab=summary

That’s it folks, it sucks it came down to this, but Microsoft gave us no other choice. They actively went out of their way to inconvenience a paying customer, first they spent their development resources implementing the above pain in the ass techniques, rather than fixing bugs that were present in XP and didn’t get fixed with the upgrade to vista. Why not develop a product instead of a licensing scheme, Microsoft? They actively went out of their way to not put any language on the box informing me what I was going to get for my $300 purchase. They actively went out of their way to train their phone support teams to reject requests for help bypassing above mechanisms.

I run a software business myself, I think they should be allowed to charge an arm & leg if they want to. Where they cross the line is treating a paying customer this way, it is consumer fraud. Now, contrary to my intentions, people other than legitimate paying users may end up stumbling upon my instructions and bypassing their activations too. I’m sure piracy has it’s costs, but Microsoft forgot to factor in the costs of throwing out the baby with the bath water.

I was looking forward to Windows 7, but now I will not be purchasing it legitimately. I encourage anyone to follow in my footsteps. I would recommend to anyone to not obtain Windows 7 thru legitimate lawful ways.

Update: Microsoft sends me a copy of Windows 7 after 1 year of my life wasted bitching at them

Posted in Uncategorized | 1 Comment

PHP Pitfalls, common causes of bugs

Crazy E_NOTICE behavior

.
Turns out

$foo = null;
count( $foo['bar'] );

is Valid!

.. Where as..

$foo = array();
count( $foo['bar'] );

Will blow up your application in your face (will trigger E_NOTICE errors ). Which we actually want to happen (if we are good developers). You want to know about these types of problems so you can figure out why the incorrect values were passed. There problem is the NULL you would want to know about more so than the array(), in my opinion.

Special characters in array keys

I had a user who was running a .csv file through a third party program to “fix his new line characters”. For some reason he was having trouble using my CSV import functionality. It turns out this third party program was introducing some kind of non-printable characters that weren’t showing up in any program. Furthermore when I ran print_r() on my array I got output like this:

Array(
  ['foo'] => 'baz',
  ['foo'] => 'bat'

After lost hours and hours I copied and pasted that print_r trace into an email I was composing to someone. The email client showed a special character (in the real example the array indeces differed because one used the letter “s” and the other had some kind of s with a squiggly line over it.)

The moral of this story is non a-zA-Z0-9 can make it into your array indexes.

Include Paths

Lets say you have a folder /app/ and a folder /foo/.

If you created the files:
/app/main.php
/app/include.php
/foo/include.php

and in /app/main.php you wrote:

include( 'include.php' );

Which would you expect to be included? The middle one right? Well if /foo/ is on your include_path think again. For maximum forwards compatibility ALWAYS use absolute paths. Hint: dirname( __FILE__ )

Do you have any more examples of common PHP pitfalls? Post a comment and let me know.

Posted in PHP, Programming | Leave a comment

PHP Auto Test – Automatically monitor your project for changes and run your unit tests

I read about stakeout.rb but read that it might not work on windows. Rather then waste time even trying I just ported it to PHP, and started to make it object oriented.

I have posted the code on devnetwork

Using this you can just work on your files, and keep PHPAutoTest open in another window. It will run your tests as needed. A couple features include customizable delay times, (sleep for as long as you need between file scans), customizable log levels, and ability to override various template methods such as runTests() (which is where you put your test runner invocation).

Posted in Uncategorized | Leave a comment

Starting Stopping and Restarting Cruise Control

I just spent the last hour trying to figure out how to start/stop cruise control as needed. I am setting up cruise controll with phpundercontrol and I was able to get the web interface to load, but using kill all and ps aux and killing cruise control would actually stop cruisecontrol but it appeared as if it left dependencies running, particularly ‘jetty’. When I would restart cruise-control it would not start back up, it would spew out java errors.

Supposedly pressing cntrl+c is supposed to stop cruisecontrol. It turns out the default cruisecontrol.sh needs to be edited. After removing a ‘&’ from one of the EXEC calls towards the bottom of the file, pressing control + c gives me:

2009-11-08 02:38:36.862::INFO: Graceful shutdown SelectChannelConnector@0.0.0.0:8080
2009-11-08 02:38:36.863::INFO: Graceful shutdown org.mortbay.jetty.webapp.WebAppContext@6d3d7254{/dashboard,file:/opt/cruisecontrol/webapps/dashboard/}
2009-11-08 02:38:36.863::INFO: Graceful shutdown org.mortbay.jetty.webapp.WebAppContext@5d1d20d3{/cruisecontrol,file:/opt/cruisecontrol/webapps/cruisecontrol/}
2009-11-08 02:38:36.863::INFO: Graceful shutdown org.mortbay.jetty.webapp.WebAppContext@23562c67{/documentation,file:/opt/cruisecontrol/webapps/documentation/}
2009-11-08 02:38:36.864::INFO: Graceful shutdown org.mortbay.jetty.webapp.WebAppContext@6e7d3050{/cc-config,file:/opt/cruisecontrol/webapps/cc-config/}
2009-11-08 02:38:37.789:/dashboard:INFO: Destroying Spring FrameworkServlet 'spring-exceptions'
2009-11-08 02:38:37.790:/dashboard:INFO: Destroying Spring FrameworkServlet 'spring-tabs'
2009-11-08 02:38:37.790:/dashboard:INFO: Destroying Spring FrameworkServlet 'spring-ajax'
2009-11-08 02:38:37.791:/dashboard:INFO: Destroying Spring FrameworkServlet 'spring-pages'
2009-11-08 02:38:37.793:/dashboard:INFO: Shutting down Log4J
2009-11-08 02:38:37.823:/dashboard:INFO: Closing Spring root WebApplicationContext
2009-11-08 02:38:37.927::INFO: Shutdown hook complete

I can then run ./cruisecontrol.sh again to start it back up. This thwarted the need for me to set up init.d scripts, I found a few bloggers were doing it that way but their init.d scripts were literred with calls to dependencies I just couldn’t setup right on my distro. daemon_log_message, daemon_start_stop, which belong to the LSB linux standard base library “init-tools”. Which I installed but those commands were not found. Luckily I found the simple fix, and unlucky it took an hour plus.

Posted in Uncategorized | Leave a comment

We should have “table interfaces”

When doing concrete table inheritance, it would be neat if we had table interfaces, like some sort of integrity constraint that made sure tables adhered to the same fields and column types.

If I extend a class and accidentally make its property public when it’s super class had it private, I get an error. We should be able to enforce these kinds of constraints on our data, which is just as important as our code.

Posted in Uncategorized | Leave a comment

Just imported my SVN history on data shuffler into google code

Now anyone can checkout, review changes, or browse source code online.

Hopefully this will be the first step of many in turning data shuffler into a real open source project. For those who do not know data shuffler implements the data mapper pattern

Posted in Uncategorized | Leave a comment

Mantis Time Tracking

The new RC for Mantisbt has a basic time tracking system. I found the documentation however did not detail how to actually enable the time tracking system

After seeing dhx’s comment here: http://www.mantisbt.org/bugs/view.php?id=10552 I figured out is an option you have to enable (wish they would have just turned it on by default, or at least included documentation).

Just open config_inc.php and enable.


/*****************
* Time tracking *
*****************/

/**
* Turn on Time Tracking accounting
* @global int $g_time_tracking_enabled
*/
$g_time_tracking_enabled = ON;

/**
* A billing sums
* @global int $g_time_tracking_with_billing
*/
$g_time_tracking_with_billing = OFF;

/**
* Stop watch to build time tracking field
* @global int $g_time_tracking_stopwatch
*/
$g_time_tracking_stopwatch = ON;

Posted in Uncategorized | Leave a comment

The ‘yes’ command

So I was trying to copy some files recursively from one folder into another, to updated a WP install. The -f option ( –force ) on the cp command was not working. Then I found out about the yes command

for instance if the command you are trying to run keeps prompting you to overwrite some file, just do

yes | your command

Posted in Linux | Leave a comment

Conflicting Model Overrides in Magento Extension Architecture

I have been using Magento for about one year. I have written one successful commercial extension ( for automotive ecommerce )

Lately, one of my clients informed me of incompatibilities between the SQLiReverse cross selling module extension and my extension.

Digging further I saw that both modules overrode the same block. No problem I thought, the Abstract Block dispatches an event ( _prepareLayout ) I could hook into. See my forum post. It worked. But not time to celebrate yet!

After that was fixed we found out that both modules still overrode the same Model class, catalog/product. This was something that tied my brain cells in a knot a few months ago, I was thinking what happens if two modules override the same class? I quickly swept that thought under the carpet though because, well there are tons of extensions and you didn’t hear a lot about these sorts of problems, but I digress, the problem was real.

Doing a little googling for “conflicting magento extension” I found a few links
http://blog.velite.de/mxperts-jquery-extension-and-conflicting-overrides/
I know it’s very common to override core classes within Magento extensions. I just asked myself what happens if two or more extensions override the same core class. To test what happens, I created a little extenstion with a block class which overrides the Mage_Page_Block_Html_Head class (just like the jQuery extension does). As I already supposed, only one override has effect in this case.

http://inchoo.net/ecommerce/magento/observer-pitfalls-of-building-serious-modules-in-magento/
What are your thoughts on the issue of multiple modules overriding the same class? Currently, if two modules override the same block (eg. sales_order_grid), only one of changes will actually take effect. This is obviously going to be a huge problem as more and more development is done and users are installing many modules to enhance the functionality of their store.

The best solution offered was to manually merge the code. YEAH RIGHT!!

So I hacked up an extension to allow multiple model overrides. Here you go kiddies. vehiclefits.com/multiOverride.zip

Will edit post in few minutes with technical details.

OK, SO here is the rundown of how this works.

Model/Config/Element.php overrides Mage_Core_Model_Config_Element
It changes a method extendChild() which is defined in Varien_Simplexml_Element
Initially, as of Magento 1.3.x, this method is responsible for merging various xml items. When it encounters a duplicate there is code to unset the already defined config, in such a way that only the last loaded configuration will take affect, the result… modules stomp on each other. I had to change a few places and this was the most difficult part because it gets called 1,000s of times, making it very hard to debug in my debugger, and the code works in an ass-backwards way as is. I added a 3rd parameter which is used to only apply this behavior for configurations within a tag parent, without this it would break other core code. The end result is that an array of classes are built up, instead of a single string that gets overwritten. Because Magento casts the simplexml objects to strings this array is non-intrusive ( for model rewrites at least. ):
$className = (string)$config->rewrite->$class; ( line 1010 Core/Model/Config.php )

Model/Config.php overrides Mage_Core_Model_Config
it adds a method for getting all “possible” classes, basically all class names the core class has been overridden with.

The abstract model gets overridden, such that when an undefined method is called, it loops thru the array of class names various modules tried to override. It instantiates each class in order and copies the object’s properties to the newly instantiated object. It then checks to see if the method that was called and caught by __call is present on that overridden class’s object. If it is present, it calls the method and execution returns, otherwise it continues looping thru the other class names that could have been “implied”, instantiates each Model as a different class, until it finds the method it needed.

Without this hack Magento’s extension / plugin architecture is quite stovepipe. My guess is that this hack will be eventually included within Magento’s core code; and noone will thank me :-( … well I hope not

One down-side to this approach although, is that if 2 modules tried to override the same method on the same class, obviously you still have an issue of one module stomping on another. In that rare(r) case, you would want to definitely consider patching both modules with liberal application of apply template method. An ideal solution would be if an event was inflected at the startup and shut-down of every model call, although I’m not sure what the performance implications of triggering 100,000 events for a single page load would be.

Posted in E-Commerce, PHP, Programming | 12 Comments