Should I use multiple classes for game?

前端 未结 5 1417
悲&欢浪女
悲&欢浪女 2020-12-14 23:24

I\'m considering making a text-based RPG-type program in PHP as both a holiday project and a chance to learn more about PHP and OOP. (Maybe not the best choice in language,

5条回答
  •  生来不讨喜
    2020-12-14 23:52

    You should read about S.O.L.I.D.
    These are the 5 basic principles of OOD (Object Oriented Design):

    S ingle Responsibility Principle
    O pen Closed Principle
    L iskov Substitution Principle
    I nterface Segregation Principle
    D ependency Inversion Principle

    http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod

    By the way, if you want to use inheritance just to extend some properties and methods, you can do this by using Composition instead of Inheritance. Inheritance should be used to add polymorphic behaviour to you class structure.

提交回复
热议问题