OO PHP explanation For a braindead n00b

前端 未结 7 1860
轮回少年
轮回少年 2020-12-15 09:05

I\'ve been writing PHP for about six years now and have got to a point where I feel I should be doing more to write better code. I know that Object Oriented code is the way

7条回答
  •  温柔的废话
    2020-12-15 09:55

    A warning is at place: you won't learn OO programming without learning OO design! The key concept is to define the functions operating on your data together with the appropriate data. Then you can tell your objects what to do, without having to query their contents.

    Surely take a look at the "Tell, don't Ask" philosophy, and the "Need to know" principle (aka the "Law of Demeter") is a very important one, too.

提交回复
热议问题