text:
When Toronto FC visited Seattle back on April 30, it got drubbed 3-0, so you know the squad was looking forward to the Sounders heading north of the border for some retribution.
Coming in though, Toronto had gone seven games without a win. Seattle wasn't feeling too much more confident thanks to injuries and inconsistent play.
Fredy Montero, speaking of inconsistent play, walked onto the pitch with a six-game goalless streak, one away from his career record. The Sounders manager Sigi Schmid had benched Montero earlier in the season in hopes it would rekindle his goal-scoring touch. That hadn't worked, so for this match Schmid had promised a more roaming role for Montero along the front line.
Early movement from the Sounders had Mike Fucito hit the post in the second minute but Toronto piled on the pressure in the final minutes of the first half when Joao Plato forced Kasey Keller to make a diving deflection in the 36th minute and then missed on a shot at the final minutes.
The second half started out with Seattle playing more aggressive, at least until the 49th minute. That was the moment Seattle's best defender Jhon Kennedy Hurtado collected his second yellow card of the match and was forced to head for the locker room.
Seattle has played eight previous matches a man down. Its record for these matches was an ominous 0-6-2. Things didn't look good when you're looking at 41 minutes of short-handed play without your best defender and against a team looking to break their winless streak.
The Sounders changed its formation to a 4-4-1 and focused on working the set pieces. It was able to frustrate the much more aggressive Toronto team, working a 0-0 draw beautifully. It wasn't pretty and Toronto had many more chances to break the draw but Seattle weathered the storm. Towards the end of regulation, the Sounders even managed to push the ball up, counter attacking the increasing desperation of the home team.
In the 89th minute, Mauro Rosales moved to take a pass from Erik Friberg and was fouled by Toronto defender Oscar Cordon. As the seconds of regulation ticked away, Montero lined up to take the free kick 28 yards from the goal.
Montero calmly and surely stroked a shot that cleared the wall and left Toronto keeper Stefan Frei gaping and grasping as the ball buried itself in the net. From that point it was a matter of holding on for four added minutes for Seattle to get out of town with 3 points.
Seattle managed that very well, especially considering it was down a man, consistently working the ball down into the corner and keeping it away from an increasingly frustrated Toronto team.
Man of the Match:
The choices are many, as every player had to work twice as hard when JKH had to leave. I have to give it to Fredy Montero though. Not only did he end his drought, he did it with a gorgeous goal, a definite goal of the week candidate.
When the whistle finally sounded, the Sounders finally won a short-handed match, one on the road in a very hostile place. The win takes their record to 6-4-7 with 25 points, solidly in third place in the west.
The New York Red Bull visits Qwest Field on Thursday, followed by New England coming on Sunday.
Photo credit: J.P. MOCZULSKI/THE ASSOCIATED PRESS/CANADIAN PRESS
Powered by Sidelines


text:
americans on tours to america
18 Dec 2007 perthbeachgirl said
- About
- USA and Canada
- travel advice
- 0 people like this
- Add to discussion 3 comments so far
20 Dec 2007 Hayley said
I'm a Canadian going on a US tour…you wouldn't be able to see this much on your own for the prices! Besides, kinda nice to see your own backyard before venturing beyond! <!--graemlin:;)-->
- 0 people like this
I just finished a Grand Southern and it was at least 85-90% Australians. A couple of Englanders and New Zealanders but nearly all Australian.
- 0 people like this
Want to respond to this comment? You need to be signed in as a Contiki.com Community member first.

subset: commoncrawl


text: I like pretty things. Not pretty as in rainbows and glitter, but beauty in the dark. So when I saw these designer pieces I had to share. Clothing can be truly spectacular and breathtaking. Clothing can be beautiful. These designers whether they intended to or not tapped into their inner Dark Soul and produced some beautiful clothing.


text:
White Heath Gay bars and clubs by distance
- The Clark Bar (13.4m) The Clark Bar is not a gay club, but they are always gay-friendly to boys and girls alike... busiest nights are Tuesday (Karaoke),...more
- Chester Street (C Street) (13.7m) 2 bars, pool tables, dance floor. A large crowd of males, females, and transgendered. Usually a small cover, no drink specials....more
White Heath Gay Bars and Clubs from ClubFly
ClubFly provides a gay bar, club, nightlife and GLBT center mapper for White Heath, Illinois and the rest of the USA. White Heath gay bars and clubs are mapped in your gayborhood with ratings, tags, videos, tips, transit/walking directions, and driving directions.


text:
The Horse Forum
- Horse Breeding
- - Marestare Check
Marestare Check Low alert on Sonesta farm's Moon. Looks like she'll go tonight. Sonesta Farms Cam 1 There is another low alert. I think it was on Pacific Minis. I can't look through all of them tonight. Going to bed soon. BTW I can't believe the Queen Vanner mare foaled without me! Ugh. |
Did you see the Mare step on her foal last night... that scared me. and then the mare was in so much pain (well thats what it looked like) they had to give her a shot to calm down because she was literally laying down and getting right back up and when she was standing she was all tensed up in the hindend, she looked like she was going to sit down. But I seen the foal walking so I think that all is well! |
No but I read through the posts on here after it happened. I'm glad everything was ok. Just goes to show you how fast things can go wrong! Right?! |
They're wrapping her tail now. She's looking a bit restless and nosing at her tummy |
and scratching her rear against the wall : ) |
She's still hanging in, moving around a lot though |
She looks close |
Yepp the poor thing looks very uncomfortable |
Sorry to double post. Someone just came in and signaled something to the camera. Not sure what they were trying to say though. At least she has someone with her :) |
Yeah, I felt so bad for the mare last night that I was watching, she was in ALOT of pain!!!! |
All times are GMT -4. The time now is 12:50 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
vBulletin Security provided by
vBSecurity v2.2.2 (Pro) -
vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
User Alert System provided by
Advanced User Tagging (Pro) -
vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.


text:
Wollman Ranch Hutterite Colony near Elgin, North Dakota, was founded in 2000 as a division from the Ayers Ranch Hutterite Colony. In 2012 the Wollman Ranch Hutterite Colony was aDariusleutcolony. The minister was John Wollman and the manager was Daniel Wollman.
Additional Information
Location: Elgin, North Dakota (coordinates: 46.548889, -101.7675 [46° 32' 56" N, 101° 46' 03" W])
Address: 6435 60th St., Elgin, ND 58533
Telephone: 701-584-3200
Author(s) | Bert Friesen |
Date Published | June 2013 |
Cite This Article
MLA style
Friesen, Bert. "Wollman Ranch Hutterite Colony (Elgin, North Dakota, USA)." Global Anabaptist Mennonite Encyclopedia Online. June 2013. Web. 30 Mar 2017. http://gameo.org/index.php?title=Wollman_Ranch_Hutterite_Colony_(Elgin,_North_Dakota,_USA)&oldid=86221.
APA style
Friesen, Bert. (June 2013). Wollman Ranch Hutterite Colony (Elgin, North Dakota, USA). Global Anabaptist Mennonite Encyclopedia Online. Retrieved 30 March 2017, from http://gameo.org/index.php?title=Wollman_Ranch_Hutterite_Colony_(Elgin,_North_Dakota,_USA)&oldid=86221.
©1996-2017 by the Global Anabaptist Mennonite Encyclopedia Online. All rights reserved.


text:
Ubatuba road trip down from Trindade...
Trip Start
Mar 24, 2010
Trip End
We were still staying at the backpackers in Trindade, so the next day we had the car again and ruise back down to the beaches of Ubatuba. Steve surfed at Praia de Felix and we had lunch down on the Praia Grande (main beach, with heaps of resturants right on the sand). We the went driving down on the beach at Ubatuirium. Jenna had her very first go driving a manual left hand drive car, and we enjoyed another picture perfect sunset.
Seeing we were in the part of Brazil were Cacha�ia is mainly produced, we thought it would be wrong to not visit a good old fastashioned distillery. So the way home we turned downed a little dirt road and headed into the darkness until we found Cochica Ca�ihcaia Distillery. We were so happily greeted by a very old dark Brazilian man, who was the Ca�hica maker. As we were the only ones there, i guess he thought he would take us on a tour of the still, fermentation tanks, ageing barrels and back into the bar. Our very interested, yet confused faces didnt seem to phase him one bit, as he passionatly explained the process to us in Portuguese. We didnt understand one word, but jeez was it was an impressive set up!


text: Mixing bass-heavy hiphop or electronic music? Reveal 802 has you covered. Make no mistake, this is the ultimate near-field monitor for Low-End lovers, resting on decades of experience in loudspeaker research. The custom 8 inch woofer and 1 inch tweeter tell you exactly what is going on in your mix through the finely tuned active crossover filter. Combine this with a new 100 watt bi-amp module and you get rock-solid bass at any volume. Tannoy Reveal 802 Active Studio Monitor Features


text:
Athlete of the Week
Haley McCusker
McCusker set the pace offensively for Pilgrim in its 18-4 victory over Warwick Vets last Thursday. McCusker scored six times in the game, leading the Pats to their first ever win over their cross-town rival.
"It's really exciting," McCusker said. "It kind of gets annoying losing. It's great to be winning."


text:
Comedian Michael Malone is a larger than life performer who delivers heavy-hitting punchlines with the weight of a veteran and the heat reserved only for the country's hottest up and coming comics.
Known best for his top-10 selling comedy album debut on iTunes and "rubber face," Malone is a force to reckon with in the comedy world. His blistering humor and irreverent views on life, love and personal tragedy have earned him recognitions such as Campus Activities Magazine's Top Comedy Performer of 2013 and "Hot Comic to Watch in 2013" and winner of the prestigious 33rd Annual Seattle International Comedy Competition in 2012.
Michael Malone been featured on the Bob and Tom Radio and TV, made appearances on WGN TV, National Lampoon's Operation Comedy Tour, NBC TV, XM Sirius Satellite radio and the CW. He also has two top-ten selling comedy albums on iTunes. Check out www.MaloneComedy.com for videos, tour dates, and tons of exclusive content.


text:
A few years ago I caught a triple bill featuring Willie Nelson, Ray Price and Merle Haggard. It was a great show. Willie was Willie, Ray was the consummate smoothie, and Merle nearly shocked the corndog out of my hand.
In his early 70s then and looking like Abe Lincoln's backwoods brother, Haggard kept pulling out hit after hit. Those who thought it began with "Mama Tried" and ended with "Okie from Muskogee" couldn't be more wrong. Meanwhile, his guitar playing was jazzy and jagged; and all these years I had the man figured for a mere strummer.
There will be no shortchanging the grizzled country star after David Cantwell's astute and entertaining "Merle Haggard: The Running Kind" (University of Texas, 282 pages). In it, the music writer mixes biography with incisive critical assessments to deliver a full portrait of the man, his music and the forces that shaped them.
Haggard has released more than 80 albums over the past half century (not counting nearly as many anthologies) and scored 38 number one country hits. The 76 year old is still out there touring and is scheduled to perform at this year's Grammy Awards ceremony. Instead of producing what he calls a doorstop biography of "the Hag," Cantwell has given us a monograph of sorts, focusing heavily on the hits-laded first half of the artist's career. The goal, he writes, is to put Haggard in his proper historical and social context.
The title, "The Running Kind," gives us a sense of Cantwell's guiding premise. He provides an in-depth look at the upbringing the singer was eager to escape from, summoning John Steinbeck, Dorothy Lange and Woody Guthrie in order to paint a picture of the singer's early days in Dust Bowl-era California. As a young man, Haggard, often in trouble, was sentenced jail for a brain-dead 1957 robbery attempt, and after trying to escape landed in San Quentin. There, he acted the punk, until coming into contact with a death row inmate and deciding perhaps he needed to change his life. Haggard was paroled in 1960 and within five years was taking aim at the top of the country charts.
One fact comes shining through "The Running Kind": Haggard doesn't like to be pinned down, able to throw down a stomping country backbeat as part of the Bakersfield sound or fiddle around with some bluegrass or croon some gospel, the man has traveled many musical roads. Warm as a Lone Star left in the sun when he delivers a haunting ballad, Haggard can seem rather prickly in person: a defiant, live-free-or die-type spoiling for a fight. He's often branded as part of the outlaw country movement of the 1970s, but after his early years he had a fraught relationship to his identity as an ex-con. Cantwell points out that of the 300 songs Haggard recorded early on for Capitol, only about 13 have to do with being behind bars.
"The Running Kind" also looks into Haggard's "Muskogee Moment," when the number one hit referencing the decent and patriotic ways of a small Oklahoma town became the singer's theme song. Some members of Haggard's band remember the song's genesis being inspired by a few passed-around hits of the demon weed as the tour bus rolled through Oklahoma. No matter how it came about, "Okie from Muskogee" became a huge single and an anthem to hippie haters and rightward leaners everywhere. The song became an early example of identity politics, and Haggard soon got used to mixing it up concerning the big topics of the day.
"As much as any American musical artist, and certainly as much as any country artist, Haggard, in his music, has intersected with the great issues of his times – those surrounding class and race, war and peace, and, most of all, freedom," Cantwell writes.
The book tracks along Haggard's major albums, interjecting bits of his life story along the way. Cantwell's knowledge of the country icon's catalog is that of a hardcore fan, but his critical stance is clear-eyes and objective. He recounts the high times when the Hag could seemingly do no wrong, as well as his lost decade of the 1990s, when the hot country radio format pushed the old man aside in favor of guys with hats and gals named Shania. Also of interest is a short chapter where Cantwell compares and contrasts the lives and careers of Hag and his contemporary Johnny Cash.
"Merle Haggard: The Running Kind" gives this singular country artist his due and treats fans to a deep and appreciative trek through his songs.
Now, where'd I put that corndog?
John Winters writes about books for GateHouse Media. He lives in Massachusetts. Always more at johnjwinters.com / FB johnjwinters / @jjw12562


text:
There are few books on the subject of Tequila that are considered classics. The Book Of Tequila by the late, great Bob Emmons, stands out as the most essential for any student of agave spirits. I consider Emmons the first, true Tequila Journalist. He was the first American author to demystify the much maligned Mexican […]
Posts Tagged 'sustainability'
Embajador Tequila: Framework for The Future
August 15th, 2016 M.A. "Mike" Morales
[Transportation, room and board were provided to M.A. "Mike" Morales by Embajador Tequila in order to research this article. No monetary compensation was received and no guarantee of a favorable article was given by M.A. 'Mike" Morales or Tequila Aficionado Media. This article was written by, and is the opinion of, M.A. "Mike" Morales.] Open […]
Sotol and Sustainability
September 24th, 2010 Lisa Pietsch
The sustainability of Don Cuco Sotol as described by company president, Jaclyn Jacquez Leo. Never miss and article or review again – Subscribe now! * indicates required Email Address * Email Format html text View previous newsletters.


text:
Zogz provides cloud based e-commerce and fulfilment solutions to a wide spectrum of businesses from small stores with just a few products, to stores with tens of thousands of products.
Zogz e-commerce fully integrates with many third party platforms such as Amazon and Google Shopping. We can provide warehouse integration allowing you to manage your orders from a single interface.
We integrate with many UK couriers to speed up label printing and the pick and dispatch process. To find out more, please use the contact form to get in touch.


text:
Are you still using opendir() to loop through folders in PHP? Doesn't that require a lot of repetitive code everytime you want to search a folder? Luckily, PHP's glob() is a much smarter solution.
Here's an example of echoing out some information from a folder, using the traditional opendir() function.
$dir = "/etc/php5/"; // Open a known directory, and proceed to read its contents if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { echo "filename: $file : filetype: " . filetype($dir . $file) . "\n"; } closedir($dh); } }
That should look somewhat familiar. We can massively shorten the code above with:
$dir = "/etc/php5/*"; // Open a known directory, and proceed to read its contents foreach(glob($dir) as $file) { echo "filename: $file : filetype: " . filetype($file) . "
"; }
Isn't that much easier? Eager to learn how the method works? If yes, then let's get on with it.
glob() supports a total of two arguments, with the second argument being optional. The first argument is the path to the folder, however, it's a bit more powerful than that.
Step 1. The First Argument
This first argument supports a pattern. This means that you can limit the search to specific filetypes or even multiple directories at the same time by using multiple asterixes "*". Let's assume that you have a website that allows users to upload images (just because I read this). Each user has his/her own folder within the folder "userImages." Inside these folder are two additional folders, called "HD" and "TN," for high definition (full-sized) images, and for thumbnails. Let's imagine that you want to loop through all your users' "TN" folders and print the filenames. This would require a relatively large snippet of code if you were to use open_dir(); however, with glob(), it's easy.
foreach(glob('userImages/*/TN/*') as $image) { echo "Filename: " . $image . "
"; }
This will search userImages/any/TN/any and will return a list of the files that match the pattern.
Filename: userImages/username1/TN/test.jpg Filename: userImages/username1/TN/test3.jpg Filename: userImages/username1/TN/test5.png Filename: userImages/username2/TN/subfolder Filename: userImages/username2/TN/test2.jpg Filename: userImages/username2/TN/test4.gif Filename: userImages/username3/TN/styles.css
We can even take things a step further, and be more specific by including a file format in our foreach statement:
foreach(glob('userImages/*/TN/*.jpg') as $image) { echo "Filename: " . $image . "
"; }
Now, this will only return Jpegs.
Filename: userImages/username1/TN/test.jpg Filename: userImages/username1/TN/test3.jpg Filename: userImages/username2/TN/test2.jpg
It gets even better. What if, for instance, you require Jpegs, but also Gifs; nothing else? Or what if you want to print only folder names? This is where the second argument comes into play.
Step 2. The Second Argument
The second argument is, as mentioned previously, optional. It does, however, provide a very nice set of optional flags. These will allow you to change the way your glob() behaves.
- GLOB_MARK: Adds a slash to each directory returned
- GLOB_NOSORT: Return files as they appear in the directory (no sorting)
- GLOB_NOCHECK: Return the search pattern if no files matching it were found
- GLOB_NOESCAPE: Backslashes do not quote metacharacters
- GLOB_BRACE: Expands {a,b,c} to match 'a', 'b', or 'c'
- GLOB_ONLYDIR: Return only directory entries which match the pattern
- GLOB_ERR: Stop on read errors (like unreadable directories), by default errors are ignored
As you see, the potential requirements that we noted at the end of Step 1 can easily be fixed with GLOB_BRACE:
foreach(glob('userImages/*/TN/{*.jpg,*.gif}', GLOB_BRACE) as $image) { echo "Filename: " . $image . "
"; }
which will return this:
Filename: userImages/username1/TN/test.jpg Filename: userImages/username1/TN/test3.jpg Filename: userImages/username2/TN/test2.jpg Filename: userImages/username2/TN/test4.gif
If we wish to only print subfolder names, we could use GLOB_ONLYDIR:
foreach(glob('userImages/*/TN/*', GLOB_ONLYDIR) as $image) { echo "Filename: " . $image . "
"; }
which will print:
Filename: userImages/username2/TN/subfolder
Conclusion and One More Example
This method has been available since PHP 4.3, however, it's not used very often, strangely. I didn't learn it until quite late myself. Now, I often use glob() when loading plugins into my framework:
foreach(glob('includes/plugins/*.php') as $plugin) { include_once($plugin); }
That's all; I hope you enjoyed this quick tip, and let me know if you have any questions!
Envato Tuts+ tutorials are translated into other languages by our community members—you can be involved too!
Translate this post


text:
3rd December 2006
Amended 10th March 2017
Quite often I see a question in a newsgroup or forum along the lines of: What is this thing called 'OOP'? What is so special about it? Why should I use it? How do I use it?
. The person asking this type of question usually has experience of non-OO programming and wants to know the benefits of making the switch. Unfortunately most of the replies I have seen have been long on words but short on substance, full of airy-fairy, wishy-washy, meaningless phrases which are absolutely no use at all to man or beast.
Having created 1000's of programs using non-OO languages, and another 500+ using the OO features of PHP I feel more than qualified to add my own contribution to the melting pot. According to some OO 'purists' I am not qualified at all as I was not taught to do things 'their' way and I refuse to follow 'their' methods. My response to that accusation is that there is no such thing as 'only one true way' with OOP just as there is no such thing as 'only one true way' with religion. People tell me that my methods are wrong, but they are making a classic mistake. My methods cannot
be wrong for the simple reason that they work
, and anybody with more than two brain cells to rub together will tell you that something that works cannot be wrong just as something that does not work cannot be right. My methods are not wrong
, they are simply different
, and sometimes it is a willingness to adopt a different approach that separates the code monkeys from the engineers.
One reason why some people give totally useless answers is that it was what they were taught, and they do not have the intelligence to look beyond what they were taught. Another reason is that some of the explanations about OO are rather vague and can be interpreted in several ways, and if something is open to interpretation it is also open to a great deal of mis
-interpretation. If you do not believe that there is widespread confusion as to what OO is and is not then take a look at Nobody Agrees On What OO Is. Even some of the basic terminology can mean different things to different people, as explained in Abstraction, Encapsulation, and Information Hiding. If these people cannot agree on the basic concepts of OOP, then how can they possibly agree on how those concepts may be implemented.
As a first step I shall debunk some of the answers that I have seen. In compiling the following list I picked out those descriptions which are not actually unique to OOP as those features which already exist in non-OO languages cannot be used to differentiate between the two.
OOP is a programming paradigm that uses abstraction to create models based on the real world. It provides for better modeling of the real world by providing a much needed improvement in domain analysis and then integration with system design.
Rubbish. OOP is no better at modeling the real world than any other method. Every computer program which seeks to replace a manual process is based on a conceptual software model of that process, and if the model is wrong then the software will also be wrong. The conceptual model is created as an analyst's view of the real world, and the computer software is based solely on this conceptual model. OOP does not guarantee that the model will be better, just that the implementation of that model will be different. You should also consider the fact that it would be totally impractical to model the whole of the real world as it is simply too vast and too complicated. It is only ever necessary to model those parts which are actually relevant to your current application, and it is the exercise of deciding what is and is not relevant which decides if your abstraction is correct.
Bear in mind that unless you are developing software which directly manipulates a real-world object, such as process control, robotics, avionics or missile guidance systems, then some of the properties and methods which apply to that real-world object may be completely irrelevant in your software representation. If, for example, you are developing an enterprise application such as Sales Order Processing which deals with entities such as Products, Customers and Orders, you are only manipulating the information about those entities and not the actual entities themselves. In pre-computer days this information was held on paper documents, but nowadays it is held in a database in the form of tables, columns and relationships. An object in the real world may have many properties and methods, but in the software representation it may only need a small subset. For example, an organisation may sell many different products with each having different properties, but all that the software may require to maintain is an identity, a description and a price. A real person may have operations such as stand, sit, walk, and run, but these operations would never be needed in an enterprise application. Regardless of the operations that can be performed on a real-world object, with a database table the only operations that can be performed are Create, Read, Update and Delete (CRUD). Following the process called data normalisation the information for an entity may need to be split across several tables, each with its own columns, constraints and relationships, and in these circumstances I personally think that it would be wiser to create a separate class for each table instead of having a single class for a collection of tables.
The article Don't try to model the real world, it doesn't exist puts forward an interesting viewpoint.
The term "abstraction" is also open to interpretation, and therefore mis-interpretation, as discussed in Understand what "abstraction" really means. This is why some people's abstractions look more like the work of Picasso when what is required should look like the work of Michelangelo.
That is why it is possible to create software that does A, B and C but it is useless to the customer as it does not also do X, Y and Z. The real world may contain X, Y and Z but the analyst did not include it in his model either because he did not spot it or because the customer failed to mention it in his Specification Of Requirements (SOR). I know because I have encountered both situations in my long career.
Not everyone agrees that direct real-world mapping is facilitated by OOP, or is even a worthy goal; Bertrand Meyer argues in Object-Oriented Software Construction that a program is not a model of the world but a model of a model of some part of the world; "Reality is a cousin twice removed".
The power of object-oriented systems lies in their promise of code reuse which will increase productivity, reduce costs and improve software quality.
Rubbish. This implies that code re-use is possible in OOP and not possible in non-OOP. Using OOP does not guarantee that more reusable code will be available as reusability depends on how the code is written, not the language in which it was written. It is possible to produce libraries of reusable modules in any non-OO language (I know, because I was doing just that with COBOL in 1985) just as it is possible to produce volumes of non-reusable code in any OO language.
It does not matter on the capabilities of the language as it is possible to have the same block of code duplicated in 100 places in any language. It is also possible, in any language, to put that block of code into a reusable module and call that module from those 100 places.
The one thing that OO languages have which procedural languages do not is inheritance. This allows code to be defined on one class (the superclass) and then inherited by any number of other subclasses. The subclass then combines everything in the superclass with whatever is defined within itself. Unfortunately too many programmers totally misuse this feature and create complex multi-level class hierarchies which become so messy that they abandon the idea of inheritance in favour of Object Composition.
One of the early promises of OOP that I heard many years ago was that it would be possible for a software vendor to produce a library of pre-written classes, and for other developers to use these "off the shelf" classes instead of creating their own custom versions and thus "re-inventing the wheel". This dream never materialised, which just goes to prove that OOP promises much but delivers little.
The source code for an object can be written and maintained independently of the source code for other objects. Once created, an object can be easily passed around inside the system.
Rubbish. The concept of modular programming has existed in non-OO languages for many years, so this argument cannot be used to explain why OO is supposed to be better than non-OO. Just as it is possible in any language to hold the source code for an entire application in a single file, it is just as possible, in any language, to break that source code into smaller modules so that the source code for each module can be maintained and compiled independently of all other modules.
Besides, any software which consists of multiple classes is automatically "modular" as each class can be considered to be a self-contained "module". The critical factor is how well each module or class is designed.
If a particular object turns out to be problematic, you can simply remove it from your application and plug in a different object as its replacement. This is analogous to fixing mechanical problems in the real world. If a bolt breaks, you replace it, not the entire machine.
Rubbish. This is the same as modularity where the source code for any individual module can be modified, recompiled and inserted into the application without having to touch any of the other modules.
By interacting only with an object's methods, the details of its internal implementation remain hidden from the outside world.
In the first place implementation hiding was never one of the aims of OOP, it is merely a by-product of encapsulation. The outside world can see the method names which can be used on a object, but not the code which exists behind those method names.
In the second place implementation hiding is not unique to OOP, nor did it suddenly appear because of OOP. In any language, whether it is object oriented, procedural, functional, or whatever, when you write a function or procedure (and remember that a class method is nothing more than a procedural function within a class) all you are exposing to the outside world, including programmers who write code which calls that function, is the function's signature, as in:
$return = functionName(arg1, arg2, ..., argX); // procedural $return = $object->functionName(arg1, arg2, ..., argX); // object oriented
Here you are identifying three things:
The only thing which is not exposed is the code that is executed when the function is called. You know what the function does but not how it does it. You know what data goes in and what data comes out, but not what code is executed in the middle. In other words how that function is implemented, the actual code which is executed, is hidden from view. The documentation which comes with the function library should describe what the function does so that the programmer can decide if that function is the right one to call, and how to call it, but the actual code behind the function name is still hidden. The documentation may provide a listing of the source code, and the actual source code may be provided for the programmer to view and possibly modify, but as far as the function's signature goes the implementation is effectively hidden. This means that at any time you could install a new version of that function with a modified implementation and, provided that the function's signature did not change, you would not have to change any code which calls that function. This means that the implementation of a function could change at any time but the calling program would not know that it had changed. The implementation is "hidden", so how can the calling program possibly know that it has changed?
A lot of people assume the misunderstanding regarding implementation hiding then go one step further and say that because the data is part of the implementation then the data must be hidden as well. This is how they justify the use of the visibility options of public, private and protected which in turn necessitate the user of getters (accessors) and setters (mutators). These people do not realise that there is a fundamental difference between "implementation" and "information":
The act of encapsulation is supposed to put an entity's methods and data inside a capsule, but nowhere does it say that the walls of the capsule should be opaque. Nowhere does it say that the data inside the capsule should be hidden from view. Nowhere does it say that an object's data cannot be accessed directly without the use of a separate API. It is only the code behind the object's API which is hidden from view, not the data contained within the object itself.
It is possible to access an object's data in two ways:
$foo = $object->foo;
or $object->foo = $foo;
$foo = $object->getFoo();
or $object->setFoo($foo);
While some programmers say that the use of getters and setters to access an object's data should be mandatory, there are others who have a different opinion, as shown in Why getter and setter methods are evil and Getters/Setters. Evil. Period.
Message passing is the process by which an object sends data to another object or asks the other object to invoke a method.
Rubbish. The way that an object's method is invoked in an OO language is identical to the way in which a function or procedure in a non-OO language is invoked. If the language supports both non-OO functions and object methods (as PHP does) the method of invocation is called "calling", not "message passing". In fact in some languages it is necessary to specify the word "call" when invoking a subroutine.
non-OO: $result = function(arg1, arg2, ...) OO: $result = $object->function(arg1, arg2, ...)
The result of each invocation is exactly the same - the caller is suspended while control is passed to the callee, and control is not returned to the caller until the callee has finished.
I have worked with messaging software in the past and I can tell you quite categorically that they are completely different. A true messaging system has the following characteristics:
A common example of an asynchronous message system is an email. You send an email, and it goes it the recipient's queue. While you are waiting for a reply you can do other things, but every now and then you check your inbox for a reply.
Activating a method on an object is exactly the same as calling a function, and works as follows:
As you can see the mechanics of activating a method in an object is exactly the same as calling a non-OO function and nothing like sending a message in a messaging system.
Each object can be viewed as an independent little machine with a distinct role or responsibility.
Rubbish. It depends entirely on how the module was written, and not the language in which it was written. It is possible to write independent modules in a procedural language such as COBOL, just as it is possible to write non-independent modules in an OO language.
The problem with "separation of responsibilities" is that different people have a different interpretation as to what it actually means. To some people the database operations such as SELECT, INSERT, UPDATE and DELETE require their own objects whereas others (like myself) put them all together in a single data access object (DAO). Some programmers may have a separate DAO for each table in the database while others (like myself) may have a single DAO which can deal with any and all database tables for a specific DBMS. Before you can separate any responsibilities you must first identify what those responsibilities are, and this is a design decision which is totally separate from the language in which the design is ultimately implemented.
The Single Responsibility Principle (SRP) was first defined by Robert C. Martin who said the following:
How do you separate concerns? You separate behaviors that change at different times for different reasons. Things that change together you keep together. Things that change apart you keep apart.
GUIs change at a very different rate, and for very different reasons, than business rules. Database schemas change for very different reasons, and at very different rates than business rules. Keeping these concerns (GUI, business rules, database) separate is good design.
Creating separate components for the GUI, business rules and database access is not restricted to OOP. This is in fact a description of the 3-Tier Architecture which I first encountered in a non-OO language called UNIFACE.
In all my many years of experience the only project that I have ever been involved in which failed to be implemented due to "technical difficulties" was one where the system architects were OO "experts" who knew everything there was to know (or so they thought) about this "separation of responsibilities". They designed a system around design patterns which had a different module for each responsibility, and this resulted in a design with at least ten layers of code between the UI and the database. This made the creation of new components far more complicated and convoluted than it need be, and it made testing and debugging an absolute nightmare. The result was far too expensive for the client, both in time and money, so he pulled the plug on the whole project and cut his losses. A pair of components which took 10 days to build using these "new fangled" OO techniques took me less than an hour to build using my "old fashioned" non-OO methods. So much for the superiority of OO.
Besides, any software which consists of multiple classes/modules automatically has "separation of concerns" as each class/module can be considered to be "concerned with" or "responsible for" a particular entity. The critical factor is how well each class/module deals with the requirements of its entity.
OOP is easier to learn for those new to computer programming than previous approaches, and its approach is often simpler to develop and to maintain, lending itself to more direct analysis, coding, and understanding of complex situations and procedures than other programming methods.
Rubbish. This is just marketing hype. Every new language/tool/paradigm is supposed to be better than everything else, but it rarely is. It is not what you use but how you use it that counts, and I have personally witnessed where an "old" language, when used by competent programmers, regularly outperformed a "new" language which was advertised as being more productive by several orders of magnitude.
A person's ability to learn something is often limited by the quality of the teachers or teaching materials, and I'm afraid that too much of what is being taught is too complicated, too inefficient, and more likely to lead to project failures than successes. Too often the teachers insist that there is "only one way" to do OOP, and that is where I most strongly disagree. I have successfully migrated to OOP by ignoring all these so-called "experts" and drawing on my years of experience with non-OO languages.
Someone once told me that OOP is not as simple as taking a procedural function and wrapping it in a class. I disagree. It *IS* that simple. The only "trick" is placing related functions in the same class (this is called encapsulation), then adjusting them to deal with the state which can be maintained within an object. The really clever thing that you can do with classes is to extend a parent or abstract class into a number of subclasses through inheritance. You can also have a function/method which is available in objects which are instantiated from different classes, which gives you polymorphism. I have seen too many examples where classes have been created with the wrong mix of functions, either related functions not being in the same class, or classes containing functions which are not actually related. I have seen inheritance over used so much that the resulting class hierarchy is really difficult to maintain and enhance. I have seen programmers use every OO feature or construct which is available in the language for no better reason than to impress other programmers with their ability to write obscure code, the theory being that the more obscure it is the more OO it is. They seem to think that if it is too simple then you are not doing it right. These people have obviously not heard of the KISS principle.
Object Oriented Programming is a mode of software development that modularizes and decomposes code authorship into the definition of actors and actions.
This is so vague it is meaningless, and therefore of absolutely no use at all.
'Late' refers to the fact that the binding decisions (which binary to load, which function to call) are deferred as long as possible, often until just before the function is called, rather than having the binding decisions made at compile time (early).
Rubbish. Whether such binding takes place early or late does not separate OOP from non-OOP. It is possible to have a non-OO language which offers late binding, but that does not magically turn it into OO. Conversely, a language which supports classes, encapsulation, inheritance and polymorphism is suddenly not OO simply because it only offers early binding.
As you can see, the above descriptions are either too vague or not specific to OOP, so they cannot be used as distinguishing features.
A computer language can be said to be Object Oriented if it provides support for the following:
Class | A class is a blueprint, or prototype, that defines the variables (data) and the methods (operations) common to all objects of a certain kind. |
Object | An instance of a class. A class must be instantiated into an object before it can be used in the software. More than one instance of the same class can be in existence at any one time. |
Encapsulation | The act of placing data and the operations that perform on that data in the same class. The class then becomes the 'capsule' or container for the data and operations.
Note that this requires ALL the properties and ALL the methods to be placed in the SAME class. Breaking a single class into smaller classes so that the count of methods in any one class does not exceed an arbitrary number is therefore a bad idea as it violates encapsulation and makes the system harder to read and understand. Please also refer to What Encapsulation is not. |
Inheritance | The reuse of base classes (superclasses) to form derived classes (subclasses). Methods and properties defined in the superclass are automatically shared by any subclass.
Please also refer to What Inheritance is not. |
Polymorphism | Same interface, different implementation. The ability to substitute one class for another. This means that different classes may contain the same method names, but the result which is returned by each method will be different as the code behind each method (the implementation) is different in each class.
Note that this does NOT require the use of the keywords "interface" and "implements" as these are totally optional in PHP. All that is required is that different classes implement the same method name with the same signature. Please also refer to What Polymorphism is not. |
A class defines (encapsulates) both the properties (data) of an entity and the methods (functions or operations) which may act upon those properties. Neither properties nor methods which can be applied to that entity should exist outside of that class definition.
When I came to learn OOP in late 2001 and early 2002 the resources which were available on the internet were very small in number and far less complicated. All I had to go on was a description of what made a language object oriented in Object Oriented Programming from October 2001 which stated something similar to the following:
Object Oriented Programming is programming which is oriented around objects, thus taking advantage of Encapsulation, Polymorphism, and Inheritance to increase code reuse and decrease code maintenance.
To do OO programming you need an OO language, and a language can only be said to be object oriented if it supports encapsulation (classes and objects), inheritance and polymorphism. It may support other features, but encapsulation, inheritance and polymorphism are the bare minimum. That is not just my personal opinion, it is also the opinion of the man who invented the term. In addition, Bjarne Stroustrup (who designed and implemented the C++ programming language), provides this broad definition of the term "Object Oriented" in section 3 of his paper called Why C++ is not just an Object Oriented Programming Language:
A language or technique is object-oriented if and only if it directly supports:
- Abstraction - providing some form of classes and objects.
- Inheritance - providing the ability to build new abstractions out of existing ones.
- Runtime polymorphism - providing some form of runtime binding.
OO theory is constantly being expanded to include more and more concepts, and these concepts are becoming more and more complicated. As languages are modified to include these add-on concepts newcomers to these languages become convinced that it is these add-ons which define what OO is. I totally disagree. OOP does not require the use of any of these optional extras, so it is wrong to say that a program is not OO simply because it does not use them. It would be like saying that a car is not a car unless it has climate control and satnav. Those are optional extras, not the distinguishing features, and not having them does not make your car not a car. It would also be incorrect to say that a car is a car because it has wheels. Having wheels does not make something a car - a pram has wheels, but that does not make it a car, so having wheels is not a distinguishing feature.
That is why I say that such things as "modularity", "reusability" and "messaging" are not features which distinguish an OO language from a non-OO language for the simple reason that they already existed in some non-OO languages. That is why I say that using some of these later additions, these optional extras, to OO languages does not make your code "more" OO. If you write programs which are oriented around objects then your code is object oriented, and you are an object oriented programmer. It's as simple as that. But it is how you implement the concepts of encapsulation, inheritance and polymorphism to achieve strong cohesion, loose coupling and the elimination of redundancies which really matters. It is the ability to produce code which has increased reusability and decreased maintainability when compared to previous paradigms which determines if your implementation is effective or not. If I can write effective software quicker and cheaper with a procedural language than you can with your OO language, then I'm afraid that it is you the programmer who has failed. It is not a failure in the language because I personally have made the move from non-OO languages to an OO-capable language and can produce identical software faster and cheaper than I could before. The failure is in the way that modern programmers are being taught to write OO code. There is too much emphasis on following academic principles instead of getting the job done in the most cost-effective manner, which is supposed to be the production of cost-effective software for the benefit of the paying customer.
I highlighted the phrase when compared to previous paradigms deliberately. You cannot say that something is better than all its alternatives unless you actually have some of those alternatives available for comparison. Today's programmers who have never written software in a non-OO language have nothing to compare against, so how do they know that what they are doing is better? I have several decades worth of experience in writing database applications in non-OO languages, so I am more able than most to make that comparison. I develop nothing but database applications for use by the enterprise, and I judge the effectiveness of a language by how productive I can be in that language. For each table in the database I usually have to create a family of forms in order to view and maintain the contents of that table, and as I have moved from one language to another the amount of time taken to build that familly of forms has decreased.
Note that I also created my own frameworks in each of those languages, so this would also have contributed to my levels of productivity.
I created my OO framework in PHP 4 because PHP 4 had what was necessary according to the available definition at that time to write OO programs. This OO framework enabled me to create applications at a faster rate than my earlier frameworks in other languages simply because it had higher levels of reusability, which therefore increased both its speed of development and its maintainability. I have therefore used the concepts of OOP and achieved the objectives of OOP, so what justification do these young upstarts have for telling me that my implementation is wrong?
Among these "optional extras" which have nothing to do with a language being OO or not are:
There is an additional list of "optional extras" at A minimalist approach to Object Oriented Programming with PHP.
As these are optional extras I am merely exercising the option to not use them. Some people say that my minimalist approach to OOP, the fact that I use nothing but encapsulation, inheritance and polymorphism, means that I am not a "proper" OO programmer. Yet with my approach I can still achieve high reusability and low maintenance, so why am I wrong?
A better way of trying to explain the differences between non-OO and OO programming is to actual examples.
A function is defined as a self-contained block of code. Each function name "fName" must be unique within the application.
function fName ($arg1, $arg2) // function description { .... return $result; } // fName
A class method is defined within the boundaries of a class definition. Each class name "cName" must be unique within the application. Each class may contain any number of functions (also known as "methods"), and the function name "fName" must be unique within the class but need not be unique within the application. In fact, the ability for different classes to share common function/method names is a requirement of polymorphism.
class cName { function fName ($arg1, $arg2) // function description { .... return $result; } // fName } // cName
In his article The Object-Oriented Thought Process the author Matt Weisfeld states the following:
Difference Between OO and Procedural
This is the key difference between OO and procedural programming. In OO design, the attributes and behavior are contained within a single object, whereas in procedural, or structured design, the attributes and behavior are normally separated.
It is important to note that neither a function nor a class can be accessed until the function/class definition has been loaded.
Calling a function is very straightforward:
$result = fName($arg1, $arg2);
Calling a class method is not so straightforward. First it is necessary to create an instance of the class (an object), then to access the function (method) name through the object. The object name must be unique within the application.
$object = new cName; $result = $object->fName($arg1, $arg2);
A function does not have to be instantiated before it can be accessed, therefore only one copy (or instance) is said to exist at any one time.
A class method can only be accessed after it has been instantiated into an object (unless it has been defined as a static method, see below), and it is possible to create multiple instances (objects) of the same class with different object names.
$object1 = new cName; $object2 = new cName; $object3 = new cName;
Although it is possible to access a static method without first creating an object, this is no better than accessing a non-class function. As it is not actually using an object it cannot be considered part of object oriented programming.
A function has only a single point of entry, and that is the function name itself.
An object has multiple points of entry, one for each method name.
A function by default does not have state, by which I mean that each time that it is called it is treated as a fresh invocation and not a continuation of any previous invocation.
An object does have state, by which I mean that each time an object's method is called it acts upon the object's state as it was after the previous method call.
It is possible for both a function and a class method to use local variables, and they both operate in the same way. This means that the local variables do not exist outside the scope of the function or class method, and any values placed in them do not persist between invocations.
It is possible for a function to remember values between different invocations by declaring a variable as static
, as in the following example:
function count () { static $count = 0; $count++; return $count; }
Each time this function is called it will return a value that is one greater than the previous call. Without the keyword static
it would always return the value '1'.
Class variables which need to persist outside of a function (method) are declared at class level, as follows:
class calculator { // define class properties (member variables) var $value; // define class methods function setValue ($value) { $this->value = $value; return; } // setValue function getValue () // function description { return $this->value; } // getValue function add ($value) // function description { $this->value = $this->value + $value; return $this->value; } // add function subtract ($value) // function description { $this->value = $this->value - $value; return $this->value; } // subtract } // calculator
Note that all class/object variables are referenced with the prefix $this->
as in $this->varname
. Any variable which is referenced without this keyword, as in $varname
, is treated as a local variable.
Note also that each instance of the class (object) maintains its own set of variables, so the contents of one object are totally independent of the contents of another object, even it is from the same class.
Here are some practical examples which demonstrate Encapsulation, Inheritance and Polymorphism.
Encapsulation | The act of placing data and the operations that perform on that data in the same class. The class then becomes the 'capsule' or container for the data and operations.
Note that this requires ALL the properties and ALL the methods to be placed in the SAME class. Breaking a single class into smaller classes so that the count of methods in any one class does not exceed an arbitrary number is therefore a bad idea as it violates encapsulation and makes the system harder to read and understand. Putting all methods which are related into the same class leads to high cohesion whereas putting related methods into separate classes leads to low cohesion. Please also refer to What Encapsulation is not. |
Every application deals with a number of different entities or "things", such as "customer" "product" and "invoice", so it is common practice to create a different class for each of these entities. At runtime the software will create one or more objects from each class definition, and when it wants to do something with one of these entities it will do so by calling the relevant method on the relevant object.
The data held within each object at runtime cannot remain in memory for ever, so it is written out to a persistent data store (a database) with a separate table for each entity. There are only four basic operations which can be performed on a database table (Create, Read, Update, Delete) so I shall start by creating a method for each one.
class entity1 { // class properties var $dbname; // database name var $errors = array(); // array of error messages, indexed by field name var $fieldarray; // associative array of name=value pairs var $fieldspec; // array of field specifications var $numrows; // number of database rows affected var $primary_key; // array of field names which make up the primary key var $tablename; // table name // class methods function __construct () // constructor { $this->tablename = 'entity1'; $this->dbname = 'foobar'; $this->fieldlist = array('column1', 'column2', 'column3', 'column4'); $this->primary_key = array('column1'); } // __construct // class methods function getData ($where) // read data from the database which satisfies the selection criteria in $where { .... return $this->fieldarray; } // getData function insertRecord ($fieldarray) // create a database record using the contents of $fieldarray { .... return $this->fieldarray; } // insertRecord function updateRecord ($fieldarray) // update a database record using the contents of $fieldarray { .... return $this->fieldarray; } // updateRecord function deleteRecord ($fieldarray) // delete a database record identified in $fieldarray { .... return $this->fieldarray; } // deleteRecord } // entity1
Please note the following:
Each of these classes therefore acts as a 'capsule' which contains both the data for an entity and the operations which can be performed upon that data. This is 'encapsulation'.
Inheritance | The reuse of base classes (superclasses) to form derived classes (subclasses). Methods and properties defined in the superclass are automatically shared by any subclass.
Please also refer to What Inheritance is not. |
After writing and testing a class to deal with 'entity1' I copied it and made it work for 'entity2'. I then compared the two classes to see what code was common and could be shared, and what code was unique and could not be shared. I then transferred all the common code into a separate class known as a 'superclass'.
superclassFirstly, to create the superclass, I changed the class name and the constructor to the following:
class Default_Table { // class properties .... // class methods function Default_Table () // constructor { $this->tablename = 'unknown'; $this->dbname = 'unknown'; $this->fieldlist = array(); $this->primary_key = array(); } // Default_Table function getData ($where) .... function insertRecord ($fieldarray) .... function updateRecord ($fieldarray) .... function deleteRecord ($fieldarray) .... } // default
This class cannot be used to instantiate a working object as it does not refer to a database table which actually exists, so it is what is known as an 'abstract' class.
Secondly, I altered each table class to remove the common methods and properties, and included the keyword extends
to force inheritance from the superclass.
include 'default.class.inc'; class entity1 extends Default_Table { function entity1 () // constructor { $this->tablename = 'entity1'; $this->dbname = 'foobar'; $this->fieldlist = array('column1', 'column2', 'column3', 'column4'); $this->primary_key = array('column1'); } // entity1 } // entity1
When a subclass is instantiated into an object that object will contain all the properties and methods of the superclass as well as those of the subclass. If anything has been defined in both the superclass and the subclass, then the definition from the subclass will be used.
In my current development environment the superclass contains several thousand lines of code, but there is only one copy of this code which is inherited by several hundred table classes. Inheritance is therefore a powerful mechanism for making one copy of common code accessible to many objects instead of having multiple copies of that common code.
Polymorphism | Same interface, different implementation. The ability to substitute one class for another. This means that different classes may contain the same method names, but the result which is returned by each method will be different as the code behind each method (the implementation) is different in each class.
Note that this does NOT require the use of the keywords "interface" and "implements" as these are totally optional in PHP. All that is required is that different classes implement the same method name with the same signature. Please also refer to What Polymorphism is not. |
Polymorphism can only be employed where the same method names exist in several classes. The code within the method may be inherited from a parent class, or it may be totally different. This means that the same method can be used on different objects, but the results will be different.
For example, take a series of classes called 'Customer', 'Product' and 'Invoice'. One practice I have seen which makes polymorphism impossible is to incorporate the entity name into the method name, as in:
The problem with this approach is that the object (the controller in MVC) which communicates with each table object (the model in MVC) needs to know the method name before it can open up that channel of communication. If each model has a unique set of method names then it must have a unique set of controllers to communicate with it.
My approach is to use a standard set of method names for standard operations, as in:
This is made easier as these methods are defined in the superclass and made available to each subclass through inheritance.
The advantage of this is that I can have one standard controller for each standard function, and this controller can work with any table class in the system. This is far better than having a separate set of controllers for each table class.
Here is some example code from one of my controllers:
.... include "$table.class.inc"; $object = new $table; $data = $object->getData($where); ....
The contents of $table
and $where
are made available at runtime.
The significant point is that the name of the class (database table) is not hard-coded into the controller, it is passed as an argument at runtime. Only the method names are hard-coded, but as these method names exist within every table class by being inherited from the superclass they will always work. So, if the class name is 'Customer' the controller will obtain data from the 'Customer' table, if it is 'Product' it will obtain data from the 'Product' table, and so on.
I am often berated by my critics, of which there are more than few, for not understanding what OOP really means. This simply boils down to the fact that they have extended the basic principles of OOP to include their personal interpretations, and they have developed rules which govern how these interpretations should be implemented.
Let me make it quite clear that I do not care for these personal interpretations, and I certainly do not care for these rules.
I disagree with all the following statements:
This is a popular misconception, but the fact that one leads to the other does not mean that they are the same thing.
Another way of putting it is that the process of abstraction identifies individual components within an application, while encapsulation is the act of creating a class for each component.
The differences between encapsulation and abstraction are discussed more in Mistaking Encapsulation for Abstraction by Kevin Buchanan.
This is a meaningless statement as "implementation hiding" is not restricted to encapsulation, and neither is it restricted to OO languages. This was not the aim of encapsulation, nor is it a unique or distinguishing feature of encapsulation. It is a universal property of all languages and all paradigms, as described in OOP is about information hiding.
Just because "information" and "implementation" have similar sounds, it does not follow that they also have similar meanings. It is also untrue to say data is part of the implementation, therefore implementation hiding automatically means data hiding
. This is wrong for the simple reason that implementation is code while information is data. Data is not code, so information is not implementation.
If you think that I am the only person who thinks that encapsulation has nothing to do with information hiding then take a look at the following:
As a consequence of the "Encapsulation means information/data hiding" rule some programmers insist that it also means that the visibility of each piece of data should be changed from "public" to "private". This means that instead of
$foo = $object->foo; $object->foo = 'bar';I should use:
$foo = $object->getFoo(); $object->setFoo('bar');
This is because the 'get' and 'set' methods (also known as 'accessors' and 'mutators') provide the opportunity to execute some additional code when the data is being retrieved or inserted.
Considering that I do not even acknowledge that the rule exists in the first place, why should I be bound by additional consequential rules?
It should also be noted by experienced programmers that there are not just two methods of retrieving data from and inserting data into an object. There is actually a third - on the method signature itself. Consider the following statement:
$output = $object->doSomething($input);
is data going in, and $output
is data coming out. Neither of these variables can have their visibility downgraded from "public" for the simple reason that they are part of the method signature and therefore cannot be hidden. This means that I can put data into and get data out of an object without having to reference a class variable, public or not, hidden or not.
There is also no rule that says each class property must be a scalar value, so I can use an array if I want to. This can be especially useful when dealing with data associated with relational databases as they deal with rows and columns, and arrays are the perfect mechanism as they can deal with any number of columns from any number of rows. It is possible for the sql SELECT statement to exclude some of the table's columns, or it may include columns from other tables via a JOIN. This method is much more flexible because I don't have to code the names of any columns in any getters and setters. The Controller object injects the entire HTTP request into the Model object as a single array, and the View object retrieves all the data from the Model as a single array.
There is a golden rule in programming that you must never trust any data which is supplied by a user - it should always be validated or filtered before it gets written to the database. While I agree with this rule (now there's a surprise!) I do not like the follow-on rule which states As you must be using setter methods it follows that you must validate the user input within the setter method.
I don't use setters therefore I cannot validate within setters. That does not mean that the data goes unvalidated, it just means that I perform my validation in a different manner. All data goes into the object as an array, and all data gets passed to the data access object (DAO) as an array so that it can be written to the database. But it only gets to the DAO after it has been validated, and that is done by passing the entire array through a validation object. If there are any validation errors then the whole array gets thrown back to the user with a suitable error message and never gets as far as the database.
Some programmers say that if you have more than N methods in a class (where N is a completely arbitrary number) then you class is too big and unmanageable. They say that such a class must surely be breaking the Single Responsibility Principle. They say that you should break that class down into smaller subclasses as they are easier for the programmer to get his brain around.
Firstly, encapsulation requires that all the data and all the operations that can be performed on that data are placed in the same class. If you use multiple classes then you are breaking encapsulation.
Secondly, if a class requires 100 methods then it requires 100 methods. If a programmer cannot deal with 100 methods in a single class then how can he possibly deal with all those methods spread across multiple classes with the additional complexity of extra code which would then be required to pass control to another class just to deal with another operation, or a different facet of the same operation?
Thirdly, you can take the idea of "lots of small methods" too far end up with an unmaintainable mess. As a prime example I was recently forced to use a certain email library, and when I downloaded it I found it had over 140 classes, each in its own file, spread across 24 directories and subdirectories. When I came to step through it with my debugger in order to track down what I thought was a minor problem I spent over 30 minutes stepping through line after line of code which didn't actually do anything useful. All it was doing was instantiating object after object and jumping from one object method to another. Most of these methods contained just a single line of code, and very little of this code was actually associated with constructing and sending the email. If that is your idea of "best practice", and you are teaching this idea to others, then all I can say is "God help us!"
The definition of polymorphism should be easily understood by everyone, yet there are some people who even manage to screw this up. I recently answered a question in the 'Dynamic form generation' thread in the comp.lang.php newsgroup in which a comedian called Jerry Stuckle said:
You've got a *partial* definition. Polymorphism is only applicable when the two classes have a parent/child hierarchy, and the child class has a method of the same name (and in some languages, the same parameter list) as the parent. When there is no parent/child relationship (as in the case of two different database tables), there is no polymorphism.This was my reply:
The definition of polymorphism does NOT state that the classes have to exist in a parent/child hierarchy, only that they have the same method signature. Having said that, it is usually the case that the two classes ARE related. You obviously haven't used an abstract table class which is inherited by every concrete table class. All my concrete table classes have instant access to all the methods and properties which are defined just once in the abstract class.To which Jerry responded:
I've used them much longer than you've even known they existed. When you have a class derived from the abstract class, there is a parent/child relationship. But there is no such relationship between two classes derived from the same one. Once again you show you have no knowledge of OO. Polymorphism cannot exist without inheritance - which requires a parent/child hierarchy.This was my reply:
Yes it can. Polymorphism simply requires that the same interface exist in more than one class. That may come from inheritance, or it may not. It *IS* possible to define the same interface more than once without inheritance. Each one of the 200 concrete table classes in my application is derived from the same abstract table class, so each one of those 200 classes is a sibling of the other, and "sibling" implies a relationship.To which Jerry responded:
So there is a sibling relationship? Once again you prove how you don't understand the concept of polymorphism.Later on he said:
You can have the same interface in more than one object WITHOUT inheritance, but that is not polymorphism.
So, according to Jerry Stuckle, a self-proclaimed "expert", polymorphism is restricted by the following rules:
Incorrect. What happens if the parent class is an abstract class and cannot be instantiated? If it cannot be instantiated then you cannot call any of its methods. If you cannot call any of its methods then it is not a candidate for polymorphism.
Polymorphism is not restricted to just two classes, it can be any number. All that is required is that two or more classes have the same method signatures so that at run-time one class can be substituted for another. The mechanism by which they have the same method signature is irrelevant.
Incorrect. There is nothing in a method call which says that it is only allowed if the method is inherited, only that the method exists.
Not only is it possible for multiple classes to share common method names without inheritance, I have actually implemented this in my framework. My Data Access Object (DAO) can be instantiated from one of several different classes - one each for MySQL, Postgres, Oracle and SQL Server - and none of these classes is derived from a parent class. Yet they have common method names, and when any of these methods is called there is no error message telling me "You cannot call a method which is not inherited!".
Incorrect. If several classes are defined as "siblings", then it means that they all have the same parent. If I have 200 concrete table classes which inherit from the same abstract table class then all those concrete classes will inherit all the method names defined in the abstract class. At run-time I can substitute any one of these siblings with any other and the code will work. It has worked in my framework for 10 years, so don't try to tell me that it doesn't.
If multiple classes have the "same interface, different implementation" then the conditions for polymorphism exist whether you like it or not. If you have invented additional rules then you are wrong for inventing those rules. I am most definitely *NOT* wrong for refusing to follow those additional rules.
Inheritance is a technique which allows you define methods and their implementations in one class (superclass), then to reuse those methods in another class (subclass) simply by using the extends keyword. The subclass then becomes a combination of what is in the superclass plus whatever is defined within itself. The article Pragmatic OOP by Ricki Sickenger says the following:
OOP is supposed to be a practical way to organize a program into hierarchies of objects where similar objects can inherit behavior from each other and override that behavior when necessary.
A problem with inheritance is that it can be used incorrectly. The above article contains the following:
A Car and a Train and a Truck can all inherit behavior from a Vehicle object, adding their subtle differences. A Firetruck can inherit from the Truck object, and so on. Wait.. and so on? The thing about inheritance is that is so easy to create massive trees of objects. But what OO-bigots won't tell you is that these trees will mess you up big time if you let them grow too deep, or grow for the wrong reasons.
One problem encountered with the overuse of inheritance is when the superclass contains a method which does not apply in a subclass. This problem led to the creation of the Liskov Substition Principle. It also led to the idea of Favour Composition over Inheritance.
In Object Composition vs. Inheritance I found the following description:
Most designers overuse inheritance, resulting in large inheritance hierarchies that can become hard to deal with. Object composition is a different method of reusing functionality. Objects are composed to achieve more complex functionality. The disadvantage of object composition is that the behavior of the system may be harder to understand just by looking at the source code. A system using object composition may be very dynamic in nature so it may require running the system to get a deeper understanding of how the different objects cooperate.
However, inheritance is still necessary. You cannot always get all the necessary functionality by assembling existing components.
Interestingly enough the same article also contains this:
The disadvantage of class inheritance is that the subclass becomes dependent on the parent class implementation. This makes it harder to reuse the subclass, especially if part of the inherited implementation is no longer desirable. ... One way around this problem is to only inherit from abstract classes.
The way to avoid problems with inheritance is therefore to avoid deep hierarchies, and to inherit only from abstract classes wherever possible. As I only develop database applications my software never interacts with objects in the "real world", just objects in a database. Every object in a database "is-a" table, so I created an abstract table class to contain the methods that could be applied to any database table, and inherit from this class to create a separate concrete table class for each table in my database. My abstract table class is quite large as there is a lot of processing which could be done on each table, and as I have over 350 concrete classes this results in a large amount of code which is reused through inheritance.
There are a surprising number of people who hold the opinion that object oriented programming is totally different from procedural programming, and that it requires a totally different way of thinking and a different way of writing code. There are even those who say that if you do not utilise OO concepts in the "proper" way then even though you may be using objects you are nothing more than a procedural programmer, where the term "procedural" is used as an insult. Take a look at the following articles:
The article Pragmatic OOP by Ricki Sickenger contains the following:
I have met programmers who believe that anywhere there is a conditional statement in OO code, there is cause to subclass, "because that is the OO way!". And they will defend it against any pragmatic reasoning. So anywhere you see an if/then/else or a switch statement, you should find a way to break the logic into seperate objects to avoid the logic. The dogma here is that conditional statements complicate things and are not strictly OO, so they must be minimized and preferable erased.
In Are You Still Debugging? the author Yegor Bugayenko says the following:
Code is procedural when it is all about how the goal should be achieved instead of what the goal is.
A method is procedural if the name is centered around a verb, but OO if it is centered around a noun.
In this post a person called Fasda said the following:
The key you need to focus is THE WAY YOU THINK A SOLUTION.
In procedural you thinks solutions as writing a recipe, step by step. First do that, then that, and continue with...
In OO you think solutions as "people asking favors to others" -> Objects and Messages only. Try to use some pure OO language to stop thinking on if, while, for and all those keywords so common in procedural.
The article Getters/Setters. Evil. Period. contains the following quote from David West:
Step one in the transformation of a successful procedural developer into a successful object developer is a lobotomy.
I do not share any of these opinions.
In his article All evidence points to OOP being bullshit John Barker says the following:
Procedural programming languages are designed around the idea of enumerating the steps required to complete a task. OOP languages are the same in that they are imperative - they are still essentially about giving the computer a sequence of commands to execute. What OOP introduces are abstractions that attempt to improve code sharing and security. In many ways it is still essentially procedural code.
In his paper Encapsulation as a First Principle of Object-Oriented Design (PDF) the author Scott L. Bain wrote the following:
Object Orientation (OO) addresses as its primary concern those things which influence the rate of success for the developer or team of developers: how easy is it to understand and implement a design, how extensible (and understandable) an existing code set is, how much pain one has to go through to find and fix a bug, add a new feature, change an existing feature, and so forth. Beyond simple "buzzword compliance", most end users and stakeholders are not concerned with whether or not a system is designed in an OO language or using good OO techniques. They are concerned with the end result of the process - it is the development team that enjoys the direct benefits that come from using OO.
This should not surprise us, since OO is routed in those best-practice principles that arose from the wise dons of procedural programming. The three pillars of "good code", namely strong cohesion, loose coupling and the elimination of redundancies, were not discovered by the inventors of OO, but were rather inherited by them (no pun intended).
Cohesion is the degree to which the responsibilities of a single module/component form a meaningful unit. Hign cohesion is considered to be better than low cohesion.
Coupling is the degree of interaction between two modules. Loose coupling is considered to be better than tight coupling.
Elimination of redundancies is aimed at reducing multiple copies of the same information or logic and now goes under the name Don't Repeat Yourself (DRY).
Other best practices which evolved in procedural languages, but which are still relevant in the OO world are the KISS and YAGNI principles.
This tells me several things:
This also tells me that OOP can be adequately supported in procedural languages (such as PHP and COBOL) which have had the necessary syntax added in to enable encapsulation, inheritance and polymorphism without replacing the original syntax with something which is more OO-like. For example, if a procedural language allows a statement such as $result = uppercase($string)
it would seem to be overkill to replace it with $result = $string->uppercase()
. The result is exactly the same, but a lot of effort has been expended just to do it differently.
When some people say that OO programming is completely different from procedural programming they are making a fundamental mistake. OO programming is exactly the same as procedural programming except for the addition of encapsulation, inheritance and polymorphism. The only difference between these two paradigms is that one supports encapsulation, inheritance and polymorphism while the other does not. Just as it is possible to produce spaghetti code (unstructured branching using GOTO) in a procedural language it is also possible to produce ravioli code (too many small classes) or lasagne code (too many layers) in an OO language. Using the features that the language provides will not guarantee "good" code, it is how you make use of those features which is the deciding factor.
OO theory is constantly being expanded to include more and more concepts, and these concepts are becoming more and more complicated. As languages are modified to include these add-on concepts newcomers to these languages become convinced that it is these add-ons which define what OO is. I totally disagree. OOP does not require the use of any of these optional extras, so it is wrong to say that a program is not OO simply because it does not use them. It would be like saying that a car is not a car unless it has climate control and satnav. Those are optional extras, not the distinguishing features, and not having them does not make your car not a car. It would also be incorrect to say that a car is a car because it has wheels. Having wheels does not make something a car - a pram has wheels, but that does not make it a car, so having wheels is not a distinguishing feature.
As has already been stated in What OOP is you need to be using a programming language that supports encapsulation, inheritance and polymorphism, and you need to use these features in a way that creates more reusable code. The more reusable code you have the less you have to write, which in turn means the less code you need to read and maintain.
Many people use different words to describe what OOP is supposed to mean, but the problem with words is that they are slippery. Like Humpty Dumpty proclaimed in Lewis Carroll's Through the Looking Glass:
When I use a word, it means just what I choose it to mean -- neither more nor less.
If you take the words used by the originators of OOP and apply different meanings to those words, then others take your words and apply different meanings to them, then you can end up with something which is nothing like the original, as immortalised in that children's game called Chinese Whispers.
There are only three features which really differentiate an Object Oriented language from a non-OO language, and these are Encapsulation, Inheritance and Polymorphism. Everything else is either bullshit or hype. Object Oriented Programming is therefore the use of these features in a programming language. High reusability and low maintainability cannot be guaranteed - that depends entirely on how these features are implemented.
Some people accuse me of having a view of OOP which is too simplistic, but instead of saying that my view is "more simple than it need be" surely it can also mean that their view is "more complex than it need be"? As a long-time follower of the KISS principle, which has a more modern variant in Do The Simplest Thing That Could Possibly Work. I know which view I prefer, and I also know which view is easier to teach to others.
© Tony Marston
3rd December 2006
10 Mar 2017 | Added What Inheritance is not
Added OOP requires a totally different thought process. |
29 Apr 2012 | Added Popular misconceptions. |
10 Apr 2012 | Added Optional Extras. |
17 Jun 2010 | Amended What OOP is to include a reference to a definition provided by Bjarne Stroustrup. |


text:
In the winter of 1920, a quirky bequest draws Morrie Morgan back to Butte, Montana, from a year-long honeymoon with his bride, Grace. But the mansion bestowed by a former boss upon the itinerant charmer, who debuted in Ivan Doig's bestselling The Whistling Season, promises to be less windfall than money pit. And the town itself, with its polyglot army of miners struggling to extricate themselves from the stranglehold of the ruthless Anaconda Copper Mining Company, seems—like the couple's fast-diminishing finances—on the verge of implosion.
These twin dilemmas catapult Morrie into his new career as editorialist for the Thunder, the fledgling union newspaper that dares to play David to Anaconda's Goliath. Amid the clatter of typewriters, the rumble of the printing presses, and a cast of unforgettable characters, Morrie puts his gift for word-slinging to work. As he pursues victory for the miners, he discovers that he is enmeshed in a deeply personal battle as well—the struggle to win lasting love for himself.
Brilliantly capturing an America roaring into a new age, Sweet Thunder ($27.95) is another great tale from a classic American novelist.
Often called the dean of writers about the American West, Ivan Doig is the author of such national bestsellers as The Whistling Season and The Bartender's Tale. His work has been translated into Spanish, Japanese, German, and Finnish, and his honors include seven regional booksellers awards, the Evans Biography Prize, and the Wallace Stegner Award, among others. He lives in Seattle.
A beloved character brings the power of the press to 1920s Butte, Montana, in this latest from the best storyteller of the West


text:
Get started
Please follow these instructions to install your trial product.
1. Open the installer
Double click to install the Akamai Download Manager.
2. Install the Akamai Download Manager
Save the Akamai DLM.exe file on your desktop and then click on the file to Install Akamai download manager.
3. Install Technical Communication Suite
(2017 Release)
Download the 30 day trial of Technical Communication Suite (2017 Release).
If you experience issues, try restarting the download.
Make the most of the free learning assets and training material.
Let our experts show you how to use your tools optimally. Join us for free webinars.
Need help?
Access the help knowledgebase. Get started
Get in touch with customer support : Contact us
Technical Communication Suite (2017 release) : System requirements
Contact Tech Comm team : email@example.com
Interested in trying our other products?


text:
Neufchatel Cheese
I have a recipe that specifically calls for Neufchatel cheese. What's the difference between this cheese and regular cream cheese? Can one be substituted for the other? —A.K., Torrance, California
Neufchatel cheese is a soft unripened cheese that originates in France. The American version, which is similar to cream cheese, is made from pasteurized milk and cream. American Neufchatel is slightly lower in calories than cream cheese and has slightly more moisture. Regular cream cheese can be substituted for Neufchatel cheese, especially in recipes for dips and spreads, with good results. You may notice a slightly different texture in cooked products.
© 2017 RDA Enthusiast Brands, LLC


text:
Aqtöbe or Aktöbe (both: əktöˈbĕ) [key], formerly Aktyubinsk əktyōˈbĭnsk, city (1993 est. pop. 264,000), NW Kazakhstan, on the Ilek River and the Kazalinsk RR. Aqtöbe has an important ferroalloy plant and chromium complex based on nearby ore deposits. Founded in 1869, the city grew rapidly with the expansion of metallurgical industries during World War II.
The Columbia Electronic Encyclopedia, 6th ed. Copyright © 2012, Columbia University Press. All rights reserved.


text:
Winning child beauty pageants is hard. In the midst of increasingly fierce competition, parents turn to expensive outfits, caffeinated beverages, and even human breast milk to gain that extra edge. Why bother even showing up if you're going to risk anything less than perfection?
Breast milk, you say? Duh, breast milk. Those untrained in the ways of child beauty might not know this, but that magical, milky victory elixir turns losers into winners and blows "go go juice" right out of the developmentally appropriate water.
At least, according to one mom named Holly who was featured on last night's Toddlers and Tiaras. Because she's allergic to failure, she still breast feeds her three-year-old daughter Natali—(Your first clue she's a genius: how she spells her kid's name)—despite the fact that she's old enough to execute complex, Mexican-inspired choreography on her own.
"As a mom, I just feel like I should do everything I possibly can to protect Natali and give her everything she needs to win," explains Holly of the decision to keep her on the sauce. "And if other people don't like it, they just don't have to look."
Do you hear that, haters? If the brilliant, golden light given off by all that winning blinds you, you may simply avert your eyes and continue on your losery way. It's not her fault if you're not willing to do whatever it takes to be the breast. Now, if you will excuse them, these glorious winners have a plastic trophy to polish and a $50 Claire's gift card to spend.
(Via HuffPost)