自身特点

  1. 业务逻辑的协助类,本身不具有任何的业务逻辑;
  2. 成员属性均为私有,每个属性均有get/set方法;

示例,代码使用php,所以我们也可以称之为:POPO(Plain Ordinary PHP Object)

<?php

class Person
{
    private string $name;
    private int $age;

    /**
     * @return string
     */
    public function getName(): string
    {
        return $this->name;
    }

    /**
     * @param string $name
     * @return $this
     */
    public function setName(string $name): Person
    {
        $this->name = $name;
        return $this;
    }

    /**
     * @return int
     */
    public function getAge(): int
    {
        return $this->age;
    }

    /**
     * @param int $age
     * @return $this
     */
    public function setAge(int $age): Person
    {
        $this->age = $age;
        return $this;
    }
}

Architecture
0 声望0 粉丝

知其然, 更要知其所以然~


« 上一篇
String操作
下一篇 »
Golang协程