Chaining Methods

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

alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Chaining Methods

Post by alex.barylski »

That is the problem with ambiguities in an industry which has few standards I guess. Considering most software is project-ware and developed adhoc...it's of little surprise that anyone might refer to one technique as something entirely different.

For instance, the thread on modified pre-order traversal...

Both those methods...remind me a lot of singly and doubly linked lists

I guess the difference being that a linked list is a data structure not nessecarily an algorithm...whereas that sitepoint article focuses more on implementatoin specifics using SQL.

I say Tomato you say Tomato...heh...that doesn't work as well when written in text, does it? :P

Chaining methods, fluent interfaces...from what I can tell they are effectively the same thing...just differentlingo used in different projects/languages, etc.
webaddict
Forum Commoner
Posts: 60
Joined: Wed Mar 14, 2007 6:55 am
Location: The Netherlands

Re: Chaining Methods

Post by webaddict »

PCSpectra wrote:That is the problem with ambiguities in an industry which has few standards I guess. Considering most software is project-ware and developed adhoc...it's of little surprise that anyone might refer to one technique as something entirely different.
True, it is of little surprise. Nevertheless, we (php programmers) tend to use terms `stolen` from other languages, fluent interfaces is one of them. It's hard to understand why explanations of terms can be so ambiguous in "our world", considering the terms mean the same thing in other languages.
PCSpectra wrote:Chaining methods, fluent interfaces...from what I can tell they are effectively the same thing...just differentlingo used in different projects/languages, etc.
You can discuss on that, really. I'll just write what I think of them: a fluent interface is an interface (thus all public methods) which is defined to be used fluently. That means the writer of this fluent interface will have to consider his methods will be chained together. That results in a different interface than one would normally write.

Chaining methods however is a requirement in a language to use fluent interfaces fluently. It's nothing more than the ability to return an object from a method and then using that object in the next call.
PCSpectra wrote:I say Tomato you say Tomato...heh...that doesn't work as well when written in text, does it? :P
No. No, it doesn't. Nevertheless, naming is important for programmers, since we don't want to code everything to prove our point, or show what you mean. Same thing with design patterns, by the way. There was a topic on sitepoint recently where someone built a Row Data Gateway, as defined by Martin Fowler and he named it a Data Mapper, stating:
The data mapper is a layer that sits in between the individual row object and the database, It's not what you (cuberoot) make it out to be.
According to Fowler's definition the intented job of a Data Mapper is to make sure objects aren't aware of the database structure, let alone which table(s) their properties belong in. This has lead to quite a few offtopic posts, so I think people should be careful when using existing names to express something else. Perhaps it would help to have a website where all definitions are freely availiable. Oh wait, we already have Wikipedia ;)
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Chaining Methods

Post by alex.barylski »

That results in a different interface than one would normally write.
Thats a good point.
No. No, it doesn't. Nevertheless, naming is important for programmers
I would personally take that a step further and say it's "everything" to programmers. I cannot stand functions named so generic it would mean anything. Ugh...
According to Fowler's definition the intented job of a Data Mapper is to make sure objects aren't aware of the database structure, let alone which table(s) their properties belong in. This has lead to quite a few offtopic posts, so I think people should be careful when using existing names to express something else. Perhaps it would help to have a website where all definitions are freely availiable. Oh wait, we already have Wikipedia
The problem is, in all honesty, who is to say Fowler is right? It took me sometime and tons of reading his material and others to eventually conclude he probably knew what he was talking about. Listening to arborint and frequently arguing led me to formalize my understanding of design patterns, some of them anyways.

If you program in anything MSDN you are exposed to patterns, but implicitly. Sure you call a function called registry or service locator, etc but until you reada book on patterns those are just names.

Like you call index.php the application engine, Joe Schmoe calls it the front controller, Amanda Panda call's it the boot loader and I call it the application entry point. Each is correct, depending on how you implement the system I suppose.

The real problem with patterns is they are so vague and easily mis-interpreted, as they are designed to fit your development style, not force you into solving a problem a certian way like a framework.

Someone can read a single article on MVC and write an article of their understanding, which only further perpetuate the mis-conception of what MVC is or whatever pattern it might be.

I have disscussed and asked countless questions on here, CodeProject, SitePoint, etc related to MVC and it's clear to me, even the pattern experts aren't really 100% sure what goes where, because often it really depends on your implementation.

People should be careful when using existing names, I agree. The problem with that theory is, a "data mapper" is fairly generic, easily assumed and to understand. I might implement a data mapper system which wraps a data access layer and call it a data mapper.

We should (as an industry) take after medical sciences in this regard and use hard to pronounce, fancy descriptive words based on Latin or Greek to uniquely describe patterns. This way, only the elitie few who study patterns for years and years and become familiar with past works can introduce new patterns in an umabiguous way.

Instead of data mapper. Perhaps a fancy word like:

Datum Delego

Which Google tells me means:

Single unit of data in transfer. Hmmm...that is even more vague so I guess you'd have to be a language expert to construct new words to accurately reflect the purpose of design patterns, cause clearly medical science doesn't just find the english equivlentants and replace them with Latin. :lol:
User avatar
allspiritseve
DevNet Resident
Posts: 1174
Joined: Thu Mar 06, 2008 8:23 am
Location: Ann Arbor, MI (USA)

Re: Chaining Methods

Post by allspiritseve »

webaddict wrote:Oh wait, we already have Wikipedia ;)
Wikipedia can be wrong too... I prefer Fowler even if it's solely because he doesn't contradict himself.
PCSpectra wrote:The problem is, in all honesty, who is to say Fowler is right?
Quite a few people say he's right, and probably moreso than any other single source, so I'd say his definitions are pretty much standard whether you agree with them or not.
webaddict wrote:Perhaps it would help to have a website where all definitions are freely availiable.
I've considered making a section on my site devoted to some specific patterns, and giving multiple interpretations. Particularly, I think whole working PHP examples of activerecord, table/row data gateway, and data mapper (with the differences between them noted) would be useful, especially if they are given equal consideration and a list of strengths/weaknesses. I'm sure if one were to comb sitepoint for all of kyberfabrikken's examples, it wouldn't be that hard...
webaddict
Forum Commoner
Posts: 60
Joined: Wed Mar 14, 2007 6:55 am
Location: The Netherlands

Re: Chaining Methods

Post by webaddict »

allspiritseve wrote:Wikipedia can be wrong too... I prefer Fowler even if it's solely because he doesn't contradict himself.
PCSpectra wrote:The problem is, in all honesty, who is to say Fowler is right?
Quite a few people say he's right, and probably moreso than any other single source, so I'd say his definitions are pretty much standard whether you agree with them or not.
Well, put simply, he is right untill we say he's wrong. He has written a lot of specifications for design patterns and unless people start saying that his definitions are wrong, they must be right. Afaik, most people take Fowler and the Gang Of Four as their starting point, which makes those resource the correct resources. I really think that his definitions can be considered the standard.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Chaining Methods

Post by alex.barylski »

I think you misunderstood me a bit. :D

I wasn't personally suggesting what Fowler says is mumbo-jumbo. What I meant by that statement was, "who" is to say Fowler is right, in the sense that Fowler says one thing and his legions of minions interpret it their own way then argue in forums about MVC because that's how Fowler said it. When in reality a majority of people still misunderstand MVC especially those in a web environment.

Considering that web MVC is implemented almost always as a passive view implementation of MVC and not classical (with all the dependencies that only make sense in desktop environments) and yet when most people explain MVC to their peers they always throw in those classical dependencies or refer to MVC and not web MVC or passive view as Fowler puts it.

If you don't understand how or why classical MVC and web MVC (passive view) are different and you are developing with the latter and describing the former, all the while citing Fowler's articles, etc...

My point was...who then...is to say Fowler is correct when they themselves are often incorrect in quoting Fowler? He himself says MVC is often the most quoted and incorrectly quoted pattern...make sense? :)

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

Re: Chaining Methods

Post by Christopher »

PCSpectra wrote:The problem is, in all honesty, who is to say Fowler is right?
It is a little bit of twisted logic to say that those who read Fowler cannot prove him right because they do not fully understand him. I also think you are twisting what patterns are. Patterns are not solutions ... they are insights into solutions.

I think if you are dealing with Fowler on a right or wrong level you are really missing the depth of his thinking. Whether it is Fowler or guys like Booch, Evans, Gamma, etc. -- their thinking is on a whole other level. Each time I reread them I get a new understanding of some facet of the problems and solutions they discuss. OOP and patterns are really the science part of computer science. They present the best thinking, models and practices to solve software problems. They are not true or right ... they are the state of the art.
(#10850)
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Chaining Methods

Post by alex.barylski »

It is a little bit of twisted logic to say that those who read Fowler cannot prove him right because they do not fully understand him. I also think you are twisting what patterns are. Patterns are not solutions ... they are insights into solutions.
That was partially what I intended to get across, believe it or not. :)
I think if you are dealing with Fowler on a right or wrong level you are really missing the depth of his thinking. Whether it is Fowler or guys like Booch, Evans, Gamma, etc. -- their thinking is on a whole other level. Each time I reread them I get a new understanding of some facet of the problems and solutions they discuss. OOP and patterns are really the science part of computer science. They present the best thinking, models and practices to solve software problems. They are not true or right ... they are the state of the art.
Yes, absolutely, that wasn't my point at all. I wasn't disputing any of those guys understanding of computer science. What I was saying, is that "who" should or can say Fowler is right or wrong...when they are so freqently misquoted.

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

Re: Chaining Methods

Post by Christopher »

PCSpectra wrote:What I was saying, is that "who" should or can say Fowler is right or wrong...when they are so freqently misquoted.
Again, I don't think they misquote in disagreement. I, like most people, just have a shallow understanding of many of these concepts -- we understand the big idea but not all the depth and nuance.
(#10850)
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Chaining Methods

Post by alex.barylski »

Again, I don't think they misquote in disagreement. I, like most people, just have a shallow understanding of many of these concepts -- we understand the big idea but not all the depth and nuance.
Fair enough. Although I wouldn't say you (like most people) have a shallow understanding of patterns. Your probably the most pattern obsessed person I know. ;)
Post Reply