Jump to content

Recommended Posts

can someone please help me understand the concept how to implement the "Domand Driven Design" strategy in PHP ?

ok let's say for example I have a user and a user got multiple addresses.

so the user got e.g

 


class User {

    public $userId;
    public $name;
    public $age;

    public function setUserId($userId) {
        $this->userId = $userId;
    }

    public function getUserId() {
        return $this->userId;
    }

    public function setName($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }

    public function setAge($age) {
        $this->age = $age;
    }

    public function getAge() {
        return $this->age;
    }

}

 

Then  Address got e.g

class Address {

	public $addressId;
	public $country;
	public $city;
	public $zip;

	public function setAddressId($addressId) {
		$this->addressId = $addressId;
	}

	public function getAddressId() {
		return $this->addressId;
	}

	public function setCountry($country) {
		$this->country = $country;
	}

	public function getCountry() {
		return $this->country;
	}

	public function setCity($city) {
		$this->city = $city;
	}

	public function getCity() {
		return $this->city;
	}

	public function setZip($zip) {
		$this->zip = $zip;
	}

	public function getZip() {
		return $this->zip;
	}
}

 

 

So how to apply the concept of the Domain Driven Design here ?

Link to comment
https://forums.phpfreaks.com/topic/309726-ddd-concept-help/
Share on other sites

"Domain driven design" is a term made up by a guy who wanted to publish the first My Big Book of Buzzwords about it. The gist of it is that the models in your application reflect how the business needs to work.

So the question is how the user and the addresses fit into the business. Which I can't possibly know on your behalf.

That line of thought will bring you to the same set of questions other development strategies will bring you to: how do users and addresses relate to each other? You fill in the sentence "  (one | many)   user(s) have  (one | many)  address(es)".

Link to comment
https://forums.phpfreaks.com/topic/309726-ddd-concept-help/#findComment-1572751
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.