我无法创建实现面向对象概念的清晰画面,虽然我知道大多数的面向对象的概念。为什么?面向对象、概念、画面、清晰

2023-09-02 10:35:13 作者:吖頭9s霸氣

我一直在做一些我自己的项目,并且不要有任何indrustial曝光。目前我使用简单的方法来发展与微不足道的面向对象方法的小型应用程序,如创建一个通用类,它使用的功能有点用的构造函数的多态性数据库的功能,​​但我真的不能够想到如何实现使用OOP整个项目的逻辑。

I have been working on some of the projects of my own and dont have any indrustial exposure. Currently i use simple approach for developing small applications with negligible OO approach like creating a common class for database functions using polymorphism of functions little bit use of constructors but i dont really able to think of how to implement whole project logic using OOP.

我知道什么是接口,抽象类,密封类等哎呀概念和头脑非常清晰的画面。但问题是,当和我应该如何实现面向对象严重,我应该。

I know what are interface, abstract class, sealed classes and other oops concepts and very much clear picture in mind. But problem is that when and how should i implement OOP heavily where I should.

我是否需要学习的实时应用程序及其案例研究,如果是的话,请参阅我从那里我可以阅读一些网站或书籍/电子书,并且可以能够实现它们。

Do i need to study real time applications and their case studies, if so please refer me some sites or books/e-books from where i can read them and can be able to implement them.

目前我觉得自己不完整的,而编程。我实现数据库和它的大部分元器件effeciently,但一个孩子试图使用OOP。

Currently i feel myself incomplete while programming. I implement database and most of its components effeciently, but a kid while trying to use OOP.

我看过很多例子,试图做一个了解OOP状,例如,汽车如。所有这几样。 他们r GUD明确的概念,但还不足以在现场的一些项目来落实

I have read many examples that tries to make one understand OOP like shape eg, car eg. all these kind of. They r gud to clear concepts but not enough to implement in some live project

推荐答案

在学习运用面向对象的第一步是收集常见funcitonality和数据为类。起初,你会不会做大量的工作,但你会好起来的。在code杂志最近的一篇文章有关返朴归真EX presses这一点。

The first step in learning to apply OOP is to gather common funcitonality and data into classes. You will not do a great job at first, but you will get better. A recent article in Code Magazine about getting back to basics expresses this well.

开始试图使(类将成为)实对象重新present实实在在的事情在您的解决方案。 (有一个奇特的名字这一点,但它也是非常基本的。)这不是制作工具类方便,主题相关的功能。尽量安排事情,这样调用该对象的方法时,保持在你的对象中的数据可以节省您的参数。认为,这将作为存在于社会现实的个人事物的对象。人格化他们。安排的事情让你不担心什么,你正在使用的功能,同时正在进行中的类。

Start attempting to make (classes that will become) real objects that represent real things in your solution. (There a fancy name for this, but it's also very basic.) This is NOT making utility classes of handy, thematically related functions. Try to arrange things so that the data maintained in your objects saves you parameters when calling methods on that object. Think of the objects that will exists as real individual things in a community. Personify them. Arrange things so that you're not worried about what's going on in the classes while you're using their functionality.

我会不要担心所有的这些设计模式在第一。最好先练习,你已经学会了基本的面向对象的概念。围绕这些模式导致了很多人跳过真正思考面向对象的理念,而不是试图干扰他们的情况到pre-打包计划。阅读设计模式为娱乐和想法。后来,你要真正研究并尝试具体实施其中的一些。

I would not worry about all these design patterns at first. Better to first practice the basic OOP concepts that you have learned. Focusing on these patterns causes a lot of people to skip really thinking about the philosophy of OOP and instead try to jam their situation into a pre-packaged plan. Read about "design patterns" for entertainment and ideas. Later, you'll want to really study them and attempt to specifically implement some of them.

总之,你不得不跳,并开始应用你所学到的。你需要你做一些好的前做出一些可怜的设计,所以不用担心。

In short, you have to jump in and start applying what you have learned. You need to make some poor designs before you make some good ones, so don't worry about it.

修改响应来自提问评: 我认为,下一步可能会集中在关系的你的类之间。一旦你使用你的逻辑,一个Customer对象,例如,你应该花没有努力获得相关订单对象。使属性 oCustomer.Orders ,返回名单,其中,排序> 。 (这是AC#示例)。在这个属性得到所有客户的订单,把它们放在列表对象,在案件的财产被再次调用私有变量维护它,并返回该列表对象。如果你已经做到了这一点,寻找下一个最困难的新的东西去尝试。也许你需要经常寻找客户至上作出的命令的日期。然后,创建一个继承自收藏℃的订单类,排序> 来替换你的基本名单,其中,排序> ,并添加物业一阶。然后,你可以做 VAR FirstOrderDate = oCustomer.Orders.FirstOrder.OrderDate

Edit in response to comment from questioner: I think the next step might be to concentrate on the relationships between your classes. Once you are using a Customer object in your logic, for example, you should have to spend No Effort getting the related Order object. Make a property oCustomer.Orders, that returns List<Order>. (This is a c# example.) In this property get all that customer's orders, put them in list object, maintain it in a private variable in case the property is called again, and return that list object. If you have already done this, look for the next hardest new thing to try. Perhaps you need to often find the date a customer first made an order. Then, create an Orders class that inherits from Collection<order> to replace your basic List<order>, and add the property FirstOrder. You can then do var FirstOrderDate = oCustomer.Orders.FirstOrder.OrderDate.

请尝试做的接下来最难的新事物。继承和添加成员。制作与子类的基类。重写基类成员。使用并获得良好的自定义集合。

Keep trying to do the next hardest new thing. Inherit and add members. Make a base class with child classes. Override base class members. Use and get good with custom collections.

这是正在使用的对象模型了解。当你看到的东西的直观和易于使用的,不喜欢的!早在我的职业生涯,我不得不大量使用MS-Word对象模型,这是直观和容易。当我做了我自己的图书馆,我试图复制该感觉;效果还不错。

Learn from the object models you are using. When you see something intuitive and easy to use, do like that! Early in my career I had to extensively use the MS-word object model, which was intuitive and easy. When I made my own libraries, I tried to duplicate that feel; the results were good.

最后,研究在 模式 。虽然我劝你不要过分敬畏他们,他们是思想的重要来源,最重要的的东西,尝试。 (知道了常见的模式的名字是良好的沟通的目的也。)例如,当你看到的插件模型,接口的概念将真正意义。

Eventually study the patterns. As much as I advise that you not be over-awed by them, they are a great source of ideas and most importantly stuff to try out. (Knowing the names of common "patterns" is good for communication purposes also.) For example, when you see the plug-in model, the concept of interfaces will really make sense.