您是否推荐用于点网中小型数据库应用程序的程序方法软件开发?

发布于 2024-09-07 21:03:37 字数 901 浏览 7 评论 0原文

作为软件开发行业的新人,我尝试使用不同的方式来发展我的编程技能。我发现的一种方法是通过阅读其他作者的代码来实现这一点。

当我开始开发时,我想对任何应用程序使用面向对象的设计范例。首先,我从小型数据库编程项目开始,例如酒店管理、薪资、销售应用程序等。然而,在我的课程中,当我在互联网上搜索源代码时,我发现许多程序员在互联网上以程序化的方式为此类小型应用程序开发源代码。尽管他们使用 vb dot net 或 C#(面向对象语言),但他们尝试遵循程序,例如在一个类中定义所有全局方法和变量,然后为特定操作从特定形式调用访问方法。

例如,对于图书馆管理应用程序,设计可能如下所示

   //one global class for whole method and variable definition
Class globals {
//define  public variable and public function such as
//connection to db code
Public  void storebooks() 
{//code for storing books to db
}
Public  void  storeusers
{ //code for storing users to db
}
.
.
//code for searching books  …etc
}

然后,表单使用特定的全局方法和变量进行操作,就像 vb6 中的模块声明一样。

我的问题是,当我尝试执行应用程序时,我尝试使用 oop 方法通过定义类对象、属性等来执行此操作。 那么我的方向正确吗?我应该使用面向对象的方法(尽管很小)来开发这些类型的应用程序,还是应该坚持使用我在网络上找到的上述类型代码(过程方式)?

请详细解释何时使用 oop 方法以及何时使用过程(如果适用)。我的目的也是为了培养我作为毕业生的软件开发技能

谢谢

As a new entry to the software development industry I tried to develop my programming skill using different ways. One way I found out is as many suggests by reading code from other authors.

When I begin to develop, I want to use objected oriented design paradigm for any application. As a start I begin with small database programming project such as hotel management, payroll, sales application…etc. However, in my course when I searched in internet for source codes, I find out many programmers develop their source code in internet in procedural way for these type of small application. Although they use vb dot net or C# (objected oriented languages), they try to follow procedural such as they defining all global methods and variable in a one class then they call access the method from a particular form for a particular action.

E.g. for library management application the design may look like this

   //one global class for whole method and variable definition
Class globals {
//define  public variable and public function such as
//connection to db code
Public  void storebooks() 
{//code for storing books to db
}
Public  void  storeusers
{ //code for storing users to db
}
.
.
//code for searching books  …etc
}

Then a form uses a particular global method and variable for its operation just like module declaration in vb6.

My question is when I try to do the application I try to do using oop methodology by defining class object, attributes …etc.
So am I on the right direction? Should I develop these type of application using objected oriented methodology (although small) or I should stick to the above type code I found on the web (procedural way)?

Please explain me in detail when to use oop methodology and when to use procedural if applicable in that respect. My intention is also to develop my software development skill as a graduate

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

那伤。 2024-09-14 21:03:37

其实程序开发并没有什么问题。您可以用它编写漂亮且可维护的应用程序。然而,您经常看到的是将过程实践应用于面向对象语言。

一个原因可能是程序员刚刚来自非 OO 语言(如 C),并试图将他的知识适应新语言。也可能是因为应用程序非常简单,所以程序方法最适合。

我认为一个有效的方法是确定您想要创建哪种类型的应用程序。如果您知道,您可以选择所需的平台和语言。但这并不总是可能的,因为平台和语言已经被定义(由管理层等定义)。

编写一个纯面向对象的应用程序并不像看起来那么容易。特别是找出您的领域模型(您的应用程序设计所基于的)可能很困难。但根据我的经验,一旦有了这个模型,创建一个面向对象的应用程序(无论大小)就相当容易了。当然,了解所有流程(用例、流程/过程(!))非常重要,以便能够定义模型中的关系。

面向对象的最大陷阱是过度设计。数百个带有继承之类的类。这样做您最终会得到臃肿的应用程序,而这些应用程序的功能并不值得这样做。

长话短说:让自己清楚 OO 的本质和其他范式的本质,并考虑什么最适合您想要构建的应用程序。作为练习,您还可以创建面向对象和过程的应用程序,看看您可以从中学到什么。

就我自己而言,我几乎总是在 C#(或 Java)应用程序中使用 OO,甚至是简单的应用程序。模型的深度也根据复杂性和可维护性而变化。通常我会用几个选项来制作原型,然后决定我的最终设计(建议:总是绘制/设计你的模型!)。但我仍然不相信面向对象范式适合所有情况。

There is in fact nothing wrong with procedural development. You can write nice and maintainable applications with it. However what you often see is applying procedural practices to an OO language.

A cause can be that the programmer just comes from non-OO language like C and try to adapt his knowledge to a new language. It can also be that the application is so simple that the procedural approach fits best.

A valid approach in my opinion would be to determine what kind of application you want to create. If you know that you can choose a desired platform and language. But this is not always possible as the platform and language are already defined (by management or so).

To write a pure OO application is not so easy as it seems. Especially find out your model of the domain (on which you base your application design) can be difficult. But once you have this model in my experience it is fairly easy to create an OO application, small or big. Of course it is very important to know all the flows (use cases, processes/procedures(!)) to be able to define the relations in your model.

The big pitfall for OO is over design. Hundreds of classes with inheritance and stuff like that. Doing that you will end up with bloated applications for functionality that does not deserve this.

To make this long story short: make for yourself clear the nature of OO and the nature of other paradigms and consider what is best for the application you want to build. As a practice you can also create an application both OO and procedural and see what you can learn from this.

Speaking of myself I almost always use OO for applications in C# (or Java), also simple ones. The depth of the model varies also depending of complexity and maintainability. Usually I prototype with several options and after that decide about my final design (advice: always draw/design your models!). Still I don't believe the OO paradigm fits all.

烛影斜 2024-09-14 21:03:37

尽管“面向对象编程与过程式编程”的争论仍然存在,但我怀疑对于这样的小项目是否会进行真正的方法论分析。

许多做简单 ERP 项目的程序员都有程序背景(Visual Basic <= 6,甚至 COBOL),并不真正理解面向对象模型。因此,他们使用 OO 语言作为某种“面向组件”的系统(即,他们仅将预构建对象用于 GUI,而不用于程序逻辑)。

结果是这些小软件的维护是一场噩梦。然而,即使正确应用 OOP,它们也将是一场噩梦,因为通常这些程序没有设计,缺乏正式的规范,有疯狂的时间表等等。因此,程序员遵循“先编码,后思考”的方法论。

Although the debate "OOP vs procedural programming" is still alive, I doubt that for such small project a real methodology analysis is taken.

Many programmers that do simple ERP projects have a procedural background (Visual Basic <= 6, or even COBOL) and don't really understand the Object Oriented model. Therefore they use OO languages as some kind of "component oriented" system (i.e. they use prebuilt objects just for the GUI and not for the program logic).

The result is that these small softwares are a nightmare to maintain. However they would be a nightmare even with OOP correctly applied, because usually this programs don't have a design, lacks formal specification, have crazy schedules ans so on. So the programmer falls in the "code first, think later" methodology.

牛↙奶布丁 2024-09-14 21:03:37

关于程序开发演变为面向对象设计的一个很好的资源是一本名为“重构”的书在 Visual Basic 中”,作者:Wrox Publishing。

它通过一些示例,您可以快速为小的、可管理的问题编写程序解决方案,只是让您的客户要求修改和日益复杂的改进,而这反过来又会受益于面向对象开发的更自主的性质。

虽然本书不一定是各种开发策略和实现的概述,但它通过重构的迭代过程很好地对比了不同的技术。

A great resource for looking at procedural development evolving into object-oriented design is a book called "Refactoring in Visual Basic" by Wrox Publishing.

It goes through examples where you might quickly code procedural solutions to small, manageable problems only to have your customer ask for revisions and increasingly complex improvements, which in turn would benefit from the more autonomous nature of object-oriented development.

While this book isn't necessarily an overview of various development strategies and implementations, it does an excellent job of contrasting different techniques through the iterative process of refactoring.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文