Welcome Guest, Not a member yet? Register   Sign In
Not OO profficient - can you suggest relevant tutorials?
#11

[eluser]esra[/eluser]
[quote author="fdog" date="1206175347"]I don't recommend Java since it's not that good with OO. Java has a bit too much C/C++ influence.
Try learning Python or Ruby. It would be easier to dive into PHP's OOP when you learn any of those languages. You'll even be a little disapointed with CI poor OOP Tongue[/quote]

I use C/C++/C# much of the time for my day job as well as PHP5 and in some cases Perl and Scheme. Once you learn OOP for one language, it's fairly easy to relate what you know to other languages. Once you know OOP fundamentals, it's also possible to do object oriented programming in something like C by creating your own library of object oriented classes to wrap C code. Many of us were doing something similar with PHP long before the lack of OOP support in the language became an issue. When it comes down to it, OOP is really a way of solving problems by thinking in an object-oriented fashion.

OOP in PHP5 is a blend of ideas from several languages. If your intent is to use PHP5 and PHP6 in the future and you don't have much time to get over the learning curve, it makes sense to learn OOP the PHP way. If you're looking for a book, you might take a look at 'PHP5 Objects, Patterns, and Practice' by Matt Zandstra. You might do a web search beforehand. I believe that he has a blog to support his earlier book and articles. This book was recently released and most of the first edition was sold out before the book hit the stores. I have not read this particular book but have read many of his articles posted on the web. It should be a good read based on the easy-to-follow narative of his earlier work. I'm not sure if this book is suitable for someone learning OOP from scratch. I would advise finding a copy in a book store and read a few pages to see if you can follow the topic matter.

In the past, PHP was never taken seriously as an object oriented language. For this reason, we don't see a large number of OOP-related books in book stores. I think we will see this change over the next year or so. But in the mean time, there are a number of PHP4 and PHP5 open source projects that attempt to use OOP approaches as much as possible. You can learn a lot by looking at the OOP coding approaches and the coding styles applied in these applications. For PHP5 OOP approaches, the Claw framework on tigris.org svn is a good example. The use of abstract classes and interfaces in this framework is interesting because the author was proficient in Java prior to writing Claw. Since PHP5 borrowed the interface approach used in Java, the code provides some examples of using interfaces in a very structured manner where multiple classes are implemented from a single interface. The Claw distribution also includes a PDF book. For PHP4, take a look at the recent Joomla 1.5 release which is a MVC-based CMF (content management framework). There are some good ideas in this CMF, some of which we've seen implemented in contributions for CI (e.g., Khaos Event Manager in the Ignited Code forum which is a sleeper because many CI users do not recognize its full potential).
#12

[eluser]esra[/eluser]
For some people, it becomes easy to understand OOP by relating the approach to something they already know. For example, there are a lot of graphic designers in the CI community who need a PHP infrastructure for designing sites. They use CI because it is well documented and it's fairly easy to overcome the learning curve, in the least case for simple sites or to use as a testbed for developing templates.

Graphic designers usually think in terms of overlapping objects. Font glyphs and graphic shapes (primitives) such as rectangles, spheres, and elipses could be thought of as objects. These objects can be reused and superimposed over other objects to create new objects. In some cases, graphic designers might create intermediate files, sometimes called clipart, which they can reuse in other graphic designs. The general idea is to reuse as much of their earlier work as possible in the creation of new designs. This fundamental approach also applies to using OOP in a programming language--you create objects which can be reused over and over again when creating new objects. In programming, we use a lot of techy terms like inheritance and polymorphism to describe the general approaches we use when applying OOP. Graphic designers tend to perform similar operations naturally in a casual way as a matter of artisan technique.

Take the case of a company logo. A graphic designer might take a copy of an existing font file and modify the design of selected glyphs in order to create a custom logo for their customer. The modified font gylphs in the new file could be said to be inheirted from a parent file and called a separate font style. Something similar might occur by taking stock clippart, breaking apart the graphic object groups and primitves, and making minor to major changes in order to create a custom graphic. It could be said that the new piece of clipart was inheirted from a parent piece of clipart.

The above is just an example. Many of us probably use object oriented approaches in other fields of endeavor without really recognizing we are. Part of learning OOP is relating what we have learned in the past to programming with objects.
#13

[eluser]Ebot Ndip-Agbor[/eluser]
@esra
You have said it all. I suggested Java earlier because I came to php from Java, and the OOP in php was curtains. :-)




Theme © iAndrew 2016 - Forum software by © MyBB