English 中文(简体)
是否允许根据装货单相互储存物体?
原标题:Is it okay to allow objects to be stored in each other depending on loading order?
  • 时间:2011-09-26 06:35:37
  •  标签:
  • php
  • oop

我有一个物体,代表我的网站上的用户账户,另一个物体,作为主账户的附属物,使用户能够在该网站上操作某些主要功能,即全面运行的储存。

我一直代表这一关系:

Class Account {
    $id
    $store // this is the store object
    $email
    $password
    $status

    get_store() // loads the store
}

Class Store {
    $id // unique store id
    $store_name
    $store_info

    post_item()
}

迄今为止,这一直是巨大的工作,但当我寻找或集中储存这种方式时,我需要通过账户反对进入仓库。

我愿通过该仓库进入账户物体,将这一进程减半。

这是否给ALSO造成问题,使得一个美元账户的物体能够储存在 $子里,就在我想要装上另一条路面的时候?

允许这种双向装载的例子如下:

Class Account {
    $id
    $store // this is the store object
    $email
    $password
    $status

    get_store() // loads the store
}

Class Store {
    $id
    $account // this is the account object
    $store_name
    $store_info

    get_account() // loads the account
    post_item()
}
最佳回答

这是一种共同的因素。 你们必须知道的唯一一点是,如果你把一个物体与另一个物体联系起来,例如,当把仓库换成一个账户时,你必须保证该仓库也将回到该账户,反之亦然。

进一步读:

问题回答

暂无回答




相关问题
Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

JSON with classes?

Is there a standardized way to store classes in JSON, and then converting them back into classes again from a string? For example, I might have an array of objects of type Questions. I d like to ...

Object-Oriented Perl constructor syntax and named parameters

I m a little confused about what is going on in Perl constructors. I found these two examples perldoc perlbot. package Foo; #In Perl, the constructor is just a subroutine called new. sub new { #I ...

Passing another class amongst instances

I was wondering what is the best practice re. passing (another class) amongst two instances of the same class (lets call this Primary ). So, essentially in the constructor for the first, i can ...

Where can I find object-oriented Perl tutorials? [closed]

A Google search yields a number of results - but which ones are the best? The Perl site appears to contain two - perlboot and perltoot. I m reading these now, but what else is out there? Note: I ve ...

热门标签