我有一个数据库,人们可以同时成为雇员、客户和公司成员。 我的行政管理系统允许我编辑<代码>Person 、Employee
、Customer
和-Member
上独立页的物体。
现在,我能够打电话到
我确实理解,雇员、客户和成员在没有个人的情况下就存在,因此,我想我应当创建一个新的类别:
我有一个数据库,人们可以同时成为雇员、客户和公司成员。 我的行政管理系统允许我编辑<代码>Person 、Employee
、Customer
和-Member
上独立页的物体。
现在,我能够打电话到
我确实理解,雇员、客户和成员在没有个人的情况下就存在,因此,我想我应当创建一个新的类别:
如同继承问题一样。 您有<代码>Person,但可以以更具体的措辞描述此人,例如。 Employee
or Customer
.
通常以目标为导向的方案拟订工作,你从基类开始(例如,<代码>Person/code>,然后在扩大子类时添加特性。 因此,<代码>Person可有名称、。 雇员人数(代码>) 客户代码>。
What you could do is implement a decorator pattern, and just keep building on your Person
class. I m not sure how you re currently building people s profiles in your current application, but it would look something as follows in pseudo code:
<?php
$id = intval($_GET[ person_id ]);
$employee = new Employee(new Person($id));
届时将转至<代码>。 雇员()类别与雇员特有的额外财产和方法相关。
A couple of friends was discussing the use of inheritance and how to check if a subclass is of a specific type and we decided to post it here on Stack. The debate was about if you should implement a ...
Hi I have two classes, one called Instruction, one called LDI which inherits from instruction class. class Instruction{ protected: string name; int value; public: Instruction(string ...
I ve not used C++ in a while, and I ve become far too comfortable with the ease-of-use of real languages. At any rate, I m attempting to implement the Command pattern, and I need to map a number of ...
Suppose I have some code like this: class Base { public: virtual int Foo(int) = 0; }; class Derived : public Base { public: int Foo(int); virtual double Foo(double) = 0; }; ...
What is your opinion of this design decision? What advantages does it have and what disadvantages? Links: Embedding description
I want to extend the FileReference class of Flex to contain a custom property. I want to do this because AS3 doesn t let me pass arguments to functions through event listeners, which makes me feel sad,...
I have the following class structure: class InterfaceA { virtual void methodA =0; } class ClassA : public InterfaceA { void methodA(); } class InterfaceB : public InterfaceA { virtual ...
Consider the Java code below, what would happen if there were no paintComponent method in JPanel class? ... import javax.swing.JPanel; public class ShapesJPanel extends JPanel { public void ...