一个简单的员工类:OOP研究 [英] A simple employee class : OOP Study

查看:47
本文介绍了一个简单的员工类:OOP研究的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我真的想要掌握OOP的概念,因为它适用于C#。


我正在考虑设置一个简单的员工上课,但我有点想象这个课程应该是什么样子。我希望

有人可以简单地概述一下我设想的课程。

喜欢:


基本上我是设想一个名为Employee的类:


我想它会有很多属性(?),如:

EmployeeID

LastName

FirstName

地址

城市



ZipCode




我想我会有AddNew(),Update(),Delete()方法。


这是一个好的利用课程的地方?如果是这样的话,基本的

基础设施对于班级来说会是什么样的?


我已经通过了几个教程,但它们非常基础并且使用的东西

喜欢Dogs和firehydrants作为对象示例,不能很好地转换为商业对象用途。


对不起基本问题。


我非常感谢任何回复。

RSH



I am really trying to grasp the concept of OOP as it applies to C#.

I am looking at trying to set up a simple Employee Class but I am having
trouble conceptualizing what this class should look like. I was hoping
someone might be able to simply outline what I envision my class to look
like:

Basically I am envisioning a Class called Employee:

I imagine it would have many properties(?) such as:
EmployeeID
LastName
FirstName
Address
City
State
ZipCode
etc.

I imagine I would have AddNew(), Update(), Delete() methods.

Is this a good place to utilize a class? If so what would the basic
infrastructure look like for the class?

I have been through several tutorials but they are very basic and use things
like Dogs and firehydrants as object examples which don''t translate well
into business object uses.

Sorry for the basic question.

I greatly appreciate any responses.
RSH


推荐答案

首先想到的是,你应该真的有一个班级,那就是

只包含所有员工,称为员工 - 该班级

会有一个索引器找到真正的员工..而且这是在这个

课程中,你会有一个Insert()/ Update()/ etc ..

换句话说,Employee类将包含有关

的所有信息。然后,另一个名为Employees的类可以包含

链接到Employee类的实例,并填写每个人的特定

信息。

这有帮助吗?


" RSH" < WA ************* @ yahoo.com>在消息中写道

新闻:e5 ************** @ TK2MSFTNGP15.phx.gbl ...
First thing that comes to mind, is you should really have a class, that does
nothing but contain all of your employees, called Employees - that class
would have an "indexer" to get to the actual employees.. and it''s in this
class, that you''d have an Insert()/Update()/etc..

In other words, the Employee class would contain all the information about
exactly one employee. Then, another class, called Employees, could contain
links to instances of Employee classes, filled out with the specific
information for each person.

Does that help?

"RSH" <wa*************@yahoo.com> wrote in message
news:e5**************@TK2MSFTNGP15.phx.gbl...

我我真的试图把握OOP的概念,因为它适用于C#。

我正在尝试建立一个简单的员工类,但是我很难理解这个类看起来应该是什么喜欢。我希望有人可以简单地概述一下我设想我的班级看起来像

基本上我想象一个叫做员工的班级:

我想它会有很多属性(?)如:
EmployeeID
LastName
FirstName
地址
城市
状态
ZipCode


我想我会有AddNew(),Update(),Delete()方法。

这是一个利用课程的好地方吗?如果是这样的话,基本的基础设施对于班级来说会是什么样子?

我已经完成了几个教程,但它们非常基础并且使用像狗和消防栓这样的东西作为对象示例对于基本问题我很抱歉。

对不起基本问题。

我非常感谢任何回复。
RSH


I am really trying to grasp the concept of OOP as it applies to C#.

I am looking at trying to set up a simple Employee Class but I am having
trouble conceptualizing what this class should look like. I was hoping
someone might be able to simply outline what I envision my class to look
like:

Basically I am envisioning a Class called Employee:

I imagine it would have many properties(?) such as:
EmployeeID
LastName
FirstName
Address
City
State
ZipCode
etc.

I imagine I would have AddNew(), Update(), Delete() methods.

Is this a good place to utilize a class? If so what would the basic
infrastructure look like for the class?

I have been through several tutorials but they are very basic and use
things like Dogs and firehydrants as object examples which don''t translate
well into business object uses.

Sorry for the basic question.

I greatly appreciate any responses.
RSH



这很有意义,但基本结构会是什么样子?


我试图理解代码的样子。从概念化到代码,我有一段艰难的时间。例如,员工(或字段)的每个属性

必须设置为(对于典型的Employee表,这将是很多代码

!):

private int employeeId;

public int EmployeeID

{

get

{

返回employeeId;

}

设定

{

employeeId = value; < br $>
}

}


private int lastName;

public int LastName

{

get

{

返回lastName;

}

set

{

lastName = value;

}

}

等.. ......


" RCS" < RS **** @ gmail.com>在留言中写道

新闻:EC **************** @ newssvr22.news.prodigy.net ...
That makes a lot of sense but what would that basic structure look like?

I''m trying to understand what the code would look like. I''m having a tough
time going from conceptualization to code. For example does each property
of an employee (or field) have to be set like (that would be a lot of code
for a typical Employee table!):
private int employeeId;
public int EmployeeID
{
get
{
return employeeId;
}
set
{
employeeId = value;
}
}

private int lastName;
public int LastName
{
get
{
return lastName;
}
set
{
lastName= value;
}
}
etc.....

"RCS" <rs****@gmail.com> wrote in message
news:EC****************@newssvr22.news.prodigy.net ...
First想到的事情是,你应该真的有一个班级,它只会包含你所有的员工,称为员工 - 这个班级会有一个索引器。找到真正的员工..而且这是在这门课上,你会有一个Insert()/ Update()/等等。

换句话说,Employee类将包含有关
的所有信息。然后,另一个名为Employees的类可以包含指向Employee类实例的链接,并填写每个人的特定
信息。

这有帮助吗?
RSH < WA ************* @ yahoo.com>在消息中写道
新闻:e5 ************** @ TK2MSFTNGP15.phx.gbl ...
First thing that comes to mind, is you should really have a class, that
does nothing but contain all of your employees, called Employees - that
class would have an "indexer" to get to the actual employees.. and it''s in
this class, that you''d have an Insert()/Update()/etc..

In other words, the Employee class would contain all the information about
exactly one employee. Then, another class, called Employees, could contain
links to instances of Employee classes, filled out with the specific
information for each person.

Does that help?

"RSH" <wa*************@yahoo.com> wrote in message
news:e5**************@TK2MSFTNGP15.phx.gbl...

我真的很想掌握OOP的概念,因为它适用于C#。

我正在尝试设置一个简单的Employee Class,但是我很难理解这个类应该是什么样子。我希望有人可以简单地概述一下我设想我的班级看起来像

基本上我想象一个叫做员工的班级:

我想它会有很多属性(?)如:
EmployeeID
LastName
FirstName
地址
城市
状态
ZipCode


我想我会有AddNew(),Update(),Delete()方法。

这是一个利用课程的好地方吗?如果是这样的话,基本的基础设施对于班级来说会是什么样子?

我已经完成了几个教程,但它们非常基础并且使用像狗和消防栓这样的东西作为对象示例哪些不能很好地转化为商业对象用途。

对不起基本问题。

我非常感谢任何回复。
RSH


I am really trying to grasp the concept of OOP as it applies to C#.

I am looking at trying to set up a simple Employee Class but I am having
trouble conceptualizing what this class should look like. I was hoping
someone might be able to simply outline what I envision my class to look
like:

Basically I am envisioning a Class called Employee:

I imagine it would have many properties(?) such as:
EmployeeID
LastName
FirstName
Address
City
State
ZipCode
etc.

I imagine I would have AddNew(), Update(), Delete() methods.

Is this a good place to utilize a class? If so what would the basic
infrastructure look like for the class?

I have been through several tutorials but they are very basic and use
things like Dogs and firehydrants as object examples which don''t
translate well into business object uses.

Sorry for the basic question.

I greatly appreciate any responses.
RSH




我不想告诉你这个RSH,但它会占用大量的代码

无论你选择什么努力。 OOP不是一个千篇一律的实践它

需要耐心和勤奋才能完全实现。

必须为你的字段编写属性访问器(gets; sets;)只是

与编程领域相关的东西。你可以添加到VS中的几个加载项可以简化现场访问器的实现

,但最后你必须编写代码。如果你使用VS 2005

,你可以使用prop。片段,它将为您写一些访问代码

。如果你正在使用VS 2003我

鼓励你看看

ReSharper( http://www.jetbrains.com/resharper/) 。它创建了字段

访问器以及更多。


快乐编码!

I hate to tell you this RSH but it is going to take allot of code with
whatever endeavor you choose. OOP is not a cookie cutter practice it
requires patience and diligence on your part to be fully implemented.
Having to write property accessor for your fields (gets; sets;) is just
something that comes with the territory of programming. There are
several add-ins you may add to VS that can short-cut the implementation
of the field accessor but in the end you will have to write code. If
you are using VS 2005 you can use the "prop" snippet and it will write
some of the accessor code for you. If you are using VS 2003 I
encourage you to look at
ReSharper(http://www.jetbrains.com/resharper/). It creates field
accessor and a whole lot more.

Happy Coding!


这篇关于一个简单的员工类:OOP研究的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆