English 中文(简体)
动态设计模式
原标题:dynamic design pattern

我有一个叫Employee的班子。 在课堂内,一种称为“代理人”的方法 斜体并交还了一批所有代理人及其相应的身份证和其他资料。

Array{              
  [0] => Array{
     [0] => code
     [1] => id  
     [2] => name    
     [3] => role
  }
}

我将这扩展到两个称为生产和薪金的班级。 这两门课程都使用“Employee.getAgentsByHierarchy()”和指所有代理人和ONE额外数据/领域。

因此,当我称之为“生产”。

Array{              
 [0] => Array{
    [0] => code
    [1] => id   
    [2] => name 
    [3] => role
    [4] => production_figures_in_digits
 }
}

当我打电话给薪金时,这是应该回来的:

Array{              
 [0] => Array{
    [0] => code
    [1] => id   
    [2] => name 
    [3] => role
    [4] => payroll_figures_in_digits
 }
}

我怎样做这种设计?

我的解决办法是,在从生产类别或薪给类中抽查被点人时,将参数纳入 get剂ByHierarchy()方法,以便了解哪些数据可以返回。 但是,我认为,这样做不是欧佩组织做事的方法,因为如果有一个新类别,则会延续下去。 销售量,即必须硬编码,才能再次满足新类别的需求。

PS。 我是新的设计模式,请原谅我写标题。

问题回答

在理想的面向目标的书面申请中,家长永远不应关心子女班的行为。 其继承的子女必须遵守母阶级的合同。

因此,雇员阶层不应担心存在生产、工资或从雇员类别继承的任何其他类别。

理想的情况是: 在生产和薪给(或今后任何其他儿童类别)中,应优先于等级制,以将具体针对他们的信息纳入阵列。

如果<代码>production有减少政变的信息,就如上。

Production.fetchAll() {
    Employee.getAgentsByHierarchy();
    Production.getFiguresInDigits();
    // some method to combine them then return
}

和<代码>。 薪金/编码





相关问题
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 ...

热门标签