Grupos de Google ya no admite nuevas publicaciones ni suscripciones de Usenet. El contenido anterior sigue siendo visible.

OOPHP online tutorials

Visto 27 veces
Saltar al primer mensaje no leído

Richard Heathfield

no leída,
24 jun 2015, 16:03:3024/6/15
a
Frequently I find myself writing *almost* the same PHP code for a number
of tasks, but with tiny differences. For example:

User: create, retrieve, amend, delete
Group: create, retrieve, amend, delete
UserPermission: create, retrieve, amend, delete
GroupPermission: create, retrieve, amend, delete
DiaryEntry: create, retrieve, amend, delete
EmbeddedImage: create, retrieve, amend, delete

and so on. At present, I'm more or less doing copy-paste-edit, which I
can't help but notice is a terrible way to do things, and it strikes me
that an object-oriented approach would be more efficient.

I don't particularly want to get locked into any one framework, because
I can't guarantee that that framework will be installable on whatever
server will be managing the site, but "vanilla" OO PHP seems to me to be
the way to go.

Are there any excellent but gentle introductions to OO PHP out there on
the Web?

--
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within

bramante

no leída,
24 jun 2015, 17:38:1924/6/15
a
Il 24/06/2015 22:03, Richard Heathfield ha scritto:
> Frequently I find myself writing *almost* the same PHP code for a number
> of tasks, but with tiny differences. For example:
>
> User: create, retrieve, amend, delete
> Group: create, retrieve, amend, delete
> UserPermission: create, retrieve, amend, delete
> GroupPermission: create, retrieve, amend, delete
> DiaryEntry: create, retrieve, amend, delete
> EmbeddedImage: create, retrieve, amend, delete
>
> and so on. At present, I'm more or less doing copy-paste-edit, which I
> can't help but notice is a terrible way to do things, and it strikes me
> that an object-oriented approach would be more efficient.
>
> I don't particularly want to get locked into any one framework, because
> I can't guarantee that that framework will be installable on whatever
> server will be managing the site, but "vanilla" OO PHP seems to me to be
> the way to go.
>
> Are there any excellent but gentle introductions to OO PHP out there on
> the Web?
>

create a class and extend it and override the method that you have
necessary.

you can create a class name USER

with methods that are common for all your other object

and after extend it

"group extend user"

and ovveride or create method that are particural for this object.

for example
the class USER can have a "create" method that call the private general
method for insert the data into db, you can extend the base class to
GROUP where you can ovveride only the "create" method and not write any
code for the insert data into db.

for do this you should abstract the concept of your object.

Bye

Jerry Stuckle

no leída,
24 jun 2015, 23:21:4424/6/15
a
On 6/24/2015 4:03 PM, Richard Heathfield wrote:
> Frequently I find myself writing *almost* the same PHP code for a number
> of tasks, but with tiny differences. For example:
>
> User: create, retrieve, amend, delete
> Group: create, retrieve, amend, delete
> UserPermission: create, retrieve, amend, delete
> GroupPermission: create, retrieve, amend, delete
> DiaryEntry: create, retrieve, amend, delete
> EmbeddedImage: create, retrieve, amend, delete
>
> and so on. At present, I'm more or less doing copy-paste-edit, which I
> can't help but notice is a terrible way to do things, and it strikes me
> that an object-oriented approach would be more efficient.
>
> I don't particularly want to get locked into any one framework, because
> I can't guarantee that that framework will be installable on whatever
> server will be managing the site, but "vanilla" OO PHP seems to me to be
> the way to go.
>
> Are there any excellent but gentle introductions to OO PHP out there on
> the Web?
>

I would give you some excellent advice about what to do (I taught OO for
12 years to corporate employees on three continents and have been doing
it for almost 30 years in a number of languages, including PHP since it
started trying to implement OO). But you've already shown you wouldn't
appreciate such advice, so I'm not going to bother.

I like to help those who want to help themselves. I don't help trolls
or those who support trolls, especially when they don't take the time to
understand the entire history.

Maybe Pointed Head can give you some advice. You seem to like him so much.

--
==================
Remove the "x" from my email address
Jerry Stuckle
jstu...@attglobal.net
==================

Richard Heathfield

no leída,
25 jun 2015, 4:12:4725/6/15
a
On 25/06/15 04:21, Jerry Stuckle wrote:
> On 6/24/2015 4:03 PM, Richard Heathfield wrote:

<snip>

>> I don't particularly want to get locked into any one framework, because
>> I can't guarantee that that framework will be installable on whatever
>> server will be managing the site, but "vanilla" OO PHP seems to me to be
>> the way to go.
>>
>> Are there any excellent but gentle introductions to OO PHP out there on
>> the Web?
>
> I would give you some excellent advice about what to do

But, roughly translated, you don't know of any such tutorials. It was
kind of you to reply, though. Thank you. Anyone else?

Thomas 'PointedEars' Lahn

no leída,
25 jun 2015, 5:11:4025/6/15
a
Richard Heathfield wrote:

> Frequently I find myself writing *almost* the same PHP code for a number
> of tasks, but with tiny differences. For example:
>
> User: create, retrieve, amend, delete
> Group: create, retrieve, amend, delete
> UserPermission: create, retrieve, amend, delete
> GroupPermission: create, retrieve, amend, delete
> DiaryEntry: create, retrieve, amend, delete
> EmbeddedImage: create, retrieve, amend, delete
>
> and so on. At present, I'm more or less doing copy-paste-edit, which I
> can't help but notice is a terrible way to do things, and it strikes me
> that an object-oriented approach would be more efficient.

It would be more efficient when writing the code, but not when executing the
code. You always pay for the generality of an approach by its reduced
runtime efficiency and memory efficiency. But it is worth it, literally.

> […]
> Are there any excellent but gentle introductions to OO PHP out there on
> the Web?

Yes.

<http://www.catb.org/~esr/faqs/smart-questions.html>

--
PointedEars
Zend Certified PHP Engineer
Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.

Thomas 'PointedEars' Lahn

no leída,
25 jun 2015, 5:18:5825/6/15
a
Richard Heathfield wrote:

> On 25/06/15 04:21, Jerry Stuckle wrote:
>> On 6/24/2015 4:03 PM, Richard Heathfield wrote:
>>> Are there any excellent but gentle introductions to OO PHP out there on
>>> the Web?
>>
>> I would give you some excellent advice about what to do
>
> But, roughly translated, you don't know of any such tutorials.

That is your misinterpretation of what he wrote.

Also, I strongly recommend to you that, when you are quoting (and you
should), you should always quote in a way that the original meaning of the
text is preserved. For example, it is inappropriate to cut a sentence or
paragraph in the middle when that would change the meaning of the statement
that the sentence or paragraph is making. And if you think that omitting
text is warranted, it is required to mark the omission by “[…]” or “[...]”.
One of the exceptions to this rule can be seen above.

Richard Heathfield

no leída,
25 jun 2015, 6:12:4525/6/15
a
On 25/06/15 10:08, Thomas 'PointedEars' Lahn wrote:
> Richard Heathfield wrote:
>
<snip>

>> Are there any excellent but gentle introductions to OO PHP out there on
>> the Web?
>
> Yes.
>
> <http://www.catb.org/~esr/faqs/smart-questions.html>

Right. I didn't post what I'd already tried. Sorry about that.
(Incidentally, I have just now been through ESR's entire document
point-by-point, and that seems to be the only way that I fouled up.)

So here's what I found in the group's archives:

* http://www.w-p.dds.nl/tinyunit.htm (which doesn't meet my needs
because it's too abstract and focused too much on one specific task,
unit testing).
* http://php.net/OOP (OOP in PHP 4) and http://php.net/OOP5 (OOP in PHP
5), neither of which meet my needs because they focus on syntax (which I
accept I'll need to learn) without explaining how one would go about
using OO PHP in a sensible way, which is at the heart of my requirement.

Those were, really honestly truly, the only apparently relevant
suggestions I could find.

Here's what I found on the Web:

*
http://code.tutsplus.com/tutorials/object-oriented-php-for-beginners--net-12762
which, again, is syntax-based rather than oriented towards how to use
OOP to shortcut the development process.

*
http://www.killerphp.com/tutorials/object-oriented-php/downloads/oop_in_php_tutorial.pdf
- again, this focuses on elementary syntax rather than on how to make
OOP pay its way.

* http://www.tutorialspoint.com/php/php_object_oriented.htm - yet again,
this focuses on elementary syntax, not on using OOP to cut down on
repeated code.

I looked for the FAQ for this group, but couldn't find one. Is there one?

My question may not have been 100% smart, but I don't think it was
exactly riddled with dumbness. I hope I have now demonstrated that I
have at least tried to find my own answer. I'm beginning to suspect that
the real answer is that there is no tutorial out there that meets my
needs. I hope I'm wrong. Am I?

Richard Heathfield

no leída,
25 jun 2015, 7:01:2025/6/15
a
On 25/06/15 10:15, Thomas 'PointedEars' Lahn wrote:
> Richard Heathfield wrote:
>
>> On 25/06/15 04:21, Jerry Stuckle wrote:
>>> On 6/24/2015 4:03 PM, Richard Heathfield wrote:
>>>> Are there any excellent but gentle introductions to OO PHP out there on
>>>> the Web?
>>>
>>> I would give you some excellent advice about what to do
>>
>> But, roughly translated, you don't know of any such tutorials.
>
> That is your misinterpretation of what he wrote.

Yes, I must apologise to Jerry. It was a rather crude and inappropriate
attempt at reverse psychology.

>
> Also, I strongly recommend to you that, when you are quoting (and you
> should), you should always quote in a way that the original meaning of the
> text is preserved.

That has always been my habit, but on this occasion I fell short (and
yes, it was deliberate, and yes, it was wrong, and yes, I regret it).

<snip>

Thomas 'PointedEars' Lahn

no leída,
25 jun 2015, 8:06:0925/6/15
a
Richard Heathfield wrote:

> On 25/06/15 10:08, Thomas 'PointedEars' Lahn wrote:
>> Richard Heathfield wrote:
>>> Are there any excellent but gentle introductions to OO PHP out there on
>>> the Web?
>> Yes.
>>
>> <http://www.catb.org/~esr/faqs/smart-questions.html>
>
> Right. I didn't post what I'd already tried. Sorry about that.
> (Incidentally, I have just now been through ESR's entire document
> point-by-point, and that seems to be the only way that I fouled up.)

<http://www.catb.org/~esr/faqs/smart-questions.html#prune>

Also:

Talk is cheap. Show me the code.
—Linus Torvalds

> So here's what I found in the group's archives:
>
> * http://www.w-p.dds.nl/tinyunit.htm (which doesn't meet my needs
> because it's too abstract and focused too much on one specific task,
> unit testing).
> * http://php.net/OOP (OOP in PHP 4) and http://php.net/OOP5 (OOP in PHP
> 5), neither of which meet my needs because they focus on syntax (which I
> accept I'll need to learn) without explaining how one would go about
> using OO PHP in a sensible way, which is at the heart of my requirement.

You did not ask how to learn OOP, but OOP with PHP, and that chapter is
precisely about that. *Of course* it is tied to the syntax elements
required to create objects with PHP.

PHP uses class-based inheritance. I find the chapter in the PHP manual
rather instructive, and would have referred you to it; but I had learned OOP
(with Turbo Pascal, Object Pascal in Delphi, and Microsoft Visual C++)
before I learned PHP (3), and have also used several other OOPLs since then.

> Here's what I found on the Web:
>
> *
> http://code.tutsplus.com/tutorials/object-oriented-php-for-beginners--net-12762
> which, again, is syntax-based rather than oriented towards how to use
> OOP to shortcut the development process.

Not a bad start.

> *
> http://www.killerphp.com/tutorials/object-oriented-php/downloads/oop_in_php_tutorial.pdf
> - again, this focuses on elementary syntax rather than on how to make
> OOP pay its way.

Appears to be well written, although class names should begin with a capital
letter (“Person”, not “person”), and camel-case is more common in PHP for
method names and formal parameters (“setName”, not “set_name”). And avoid
“==” in favor of “===”.

> * http://www.tutorialspoint.com/php/php_object_oriented.htm - yet again,
> this focuses on elementary syntax,

NAK.

> not on using OOP to cut down on repeated code.

ISTM you are actually asking for “OOP 101”. Sorry, this newsgroup is not
it.

> I looked for the FAQ for this group, but couldn't find one. Is there one?

I do not know (I know that <news:de.comp.lang.php> has one). What exactly
have you searched for?

> My question may not have been 100% smart, but I don't think it was
> exactly riddled with dumbness. I hope I have now demonstrated that I
> have at least tried to find my own answer. I'm beginning to suspect that
> the real answer is that there is no tutorial out there that meets my
> needs. I hope I'm wrong. Am I?

Mu.

Jerry Stuckle

no leída,
25 jun 2015, 8:09:4325/6/15
a
On 6/25/2015 4:12 AM, Richard Heathfield wrote:
> On 25/06/15 04:21, Jerry Stuckle wrote:
>> On 6/24/2015 4:03 PM, Richard Heathfield wrote:
>
> <snip>
>
>>> I don't particularly want to get locked into any one framework, because
>>> I can't guarantee that that framework will be installable on whatever
>>> server will be managing the site, but "vanilla" OO PHP seems to me to be
>>> the way to go.
>>>
>>> Are there any excellent but gentle introductions to OO PHP out there on
>>> the Web?
>>
>> I would give you some excellent advice about what to do
>
> But, roughly translated, you don't know of any such tutorials. It was
> kind of you to reply, though. Thank you. Anyone else?
>

Oh, I know of some very good tutorials. And I know of even better ways
for you to get up to speed. But they way you've acted, it's not worth
my time looking them up.

Just remember your action s have consequences, too.

Richard Heathfield

no leída,
25 jun 2015, 8:20:5925/6/15
a
On 25/06/15 13:02, Thomas 'PointedEars' Lahn wrote:
> Richard Heathfield wrote:
>
<prune>
>
>> So here's what I found in the group's archives:
>>
>> * http://www.w-p.dds.nl/tinyunit.htm (which doesn't meet my needs
>> because it's too abstract and focused too much on one specific task,
>> unit testing).
>> * http://php.net/OOP (OOP in PHP 4) and http://php.net/OOP5 (OOP in PHP
>> 5), neither of which meet my needs because they focus on syntax (which I
>> accept I'll need to learn) without explaining how one would go about
>> using OO PHP in a sensible way, which is at the heart of my requirement.
>
> You did not ask how to learn OOP, but OOP with PHP, and that chapter is
> precisely about that. *Of course* it is tied to the syntax elements
> required to create objects with PHP.

Yes, *of course* it is, but the syntax is relatively trivial, and there
is no shortage of tutorials explaining the syntax. As I tried to explain
from the very first, what I'm looking for is some kind of guide to
*using* OOP to reduce the amount of copy-paste-edit programming I'm
having to do.

<snip>

> ISTM you are actually asking for “OOP 101”. Sorry, this newsgroup is not
> it.

I'm aware that this newsgroup isn't it, but I was hoping someone in this
newsgroup might know where it is.

>> I looked for the FAQ for this group, but couldn't find one. Is there one?
>
> I do not know (I know that <news:de.comp.lang.php> has one). What exactly
> have you searched for?

Because I was looking for the FAQ for comp.lang.php, I searched using
the following two search terms: faq comp.lang.php

The hits I got were:

https://groups.google.com/forum/#!forum/comp.lang.php (the Google Groups
front end to this newsgroup, so not an FAQ)

http://www.justskins.com/forums/wiki-like-faq-for-172071.html (a
discussion, over ten years old, about how nice it would be if there were
an FAQ for this group)

http://php.net/support.php (which recommends this group, but doesn't
cite an FAQ for this group)

http://faqfclphp.free.fr/ (but I don't speak French)

at which point I felt I'd reached diminishing returns.

<snip>

Richard Heathfield

no leída,
25 jun 2015, 8:33:2825/6/15
a
On 25/06/15 13:09, Jerry Stuckle wrote:

<snip>

> Just remember your action s have consequences, too.

I realise that. I'm comfortable with all that I've posted in this group,
except for Message ID <mmgd39$61m$1...@dont-email.me> for which I have
already posted an apology.

Christoph M. Becker

no leída,
25 jun 2015, 8:51:0425/6/15
a
Richard Heathfield wrote:

> On 25/06/15 13:02, Thomas 'PointedEars' Lahn wrote:
>
>> ISTM you are actually asking for “OOP 101”. Sorry, this newsgroup is not
>> it.
>
> I'm aware that this newsgroup isn't it, but I was hoping someone in this
> newsgroup might know where it is.

I just found <https://github.com/marcelgsantos/learning-oop-in-php>.

HTH

--
Christoph M. Becker



Richard Heathfield

no leída,
25 jun 2015, 8:56:4725/6/15
a
Thank you, Christoph. That page looks like a veritable treasure trove.
It will take some time to work through it to find out whether it has
what I need (and it seems inconceivable that it doesn't!) but even if it
doesn't it still likes like I will learn an immense amount from it so,
one way or the other, I am very grateful to you for pointing it out to me.

Thomas 'PointedEars' Lahn

no leída,
25 jun 2015, 9:42:2225/6/15
a
Richard Heathfield wrote:

> On 25/06/15 13:02, Thomas 'PointedEars' Lahn wrote:
>
> <prune>

There was a hint in there.

> […] As I tried to explain from the very first, what I'm looking for is
> some kind of guide to *using* OOP to reduce the amount of copy-paste-edit
> programming I'm having to do.

And as I pointed out, at least one of the tutorials that you have found is
providing that, and that you have not been reading carefully enough.

>> ISTM you are actually asking for “OOP 101”. Sorry, this newsgroup is not
>> it.
>
> I'm aware that this newsgroup isn't it, but I was hoping someone in this
> newsgroup might know where it is.

All over the Nets. However, PHP is probably not the best language to learn
OOP from the ground up. Today I would recommend Python for that instead.

>>> I looked for the FAQ for this group, but couldn't find one. Is there
>>> one?
>> I do not know (I know that <news:de.comp.lang.php> has one). What
>> exactly have you searched for?
>
> Because I was looking for the FAQ for comp.lang.php, I searched using
> the following two search terms: faq comp.lang.php

OK. When in doubt, put the search terms in double-quotes as appropriate.

> The hits I got were:
>
> [irrelevant hits]
>
> http://www.justskins.com/forums/wiki-like-faq-for-172071.html (a
> discussion, over ten years old, about how nice it would be if there were
> an FAQ for this group)

| […] Though we have sites like www.php-faq.com (by Matthew Schroebel), […]

It is down now, but it is in the Internet Archive. The most recently
archived version does not appear to have a section on OO PHP, though.

> […]
> http://faqfclphp.free.fr/ (but I don't speak French)

You can still try a machine translation (Google Translate & friends).

Likewise with the FAQ of the German-speaking PHP newsgroup. And German is
my native language, so I could tell you if the machine translation into
English is correct.

Just do not play stupid, OK?

Richard Heathfield

no leída,
25 jun 2015, 9:54:4725/6/15
a
On 25/06/15 14:39, Thomas 'PointedEars' Lahn wrote:
> Richard Heathfield wrote:
>
>> On 25/06/15 13:02, Thomas 'PointedEars' Lahn wrote:
>>
>> <prune>
>
> There was a hint in there.

It escaped me. My apologies for that.

>
>> […] As I tried to explain from the very first, what I'm looking for is
>> some kind of guide to *using* OOP to reduce the amount of copy-paste-edit
>> programming I'm having to do.
>
> And as I pointed out, at least one of the tutorials that you have found is
> providing that, and that you have not been reading carefully enough.

I'll take a closer look.

<rest of article read, but snipped because I have no comment to make on it>

> Just do not play stupid, OK?

Oh, I'm not *playing* stupid, I assure you. :-)
0 mensajes nuevos