是否有任何结构化方法来定义隐喻以简化程序的复杂性

发布于 2024-08-20 18:39:33 字数 487 浏览 13 评论 0原文

很抱歉,如果这看起来是一个模糊的问题,但它已经困扰我一段时间了。

在我的日常工作中,我编写的一些代码变得非常复杂。并不是说它通常非常技术性,而是问题域本身是一个处理空间数据以及许多其他事物的复杂问题。我很确定我的保密协议会禁止我透露我正在做的事情的任何细节,所以不幸的是,我必须保持这个非常笼统的内容。

现在,我完全赞成降低复杂性,因此我会尽可能找到正确的抽象,但是有什么方法可以通过明确不处理手头的实际问题而是使用一些隐喻来进一步减少复杂性可以对其进行操作,然后转化为我想要的实际结果吗?

当然,由于该领域本身是如此复杂,..我尝试过但失败了(很多次!)找到正确的比喻:-(

所以我的问题是,是否有人已经完成了这项工作并发现(甚至一半 )找到)一种结构化的方法来推断一组给定的编程问题的适当的隐喻或启发式?

再次,如果这看起来有点奇怪,我很抱歉我只是想找到成为更好的程序员的新方法。

提前致谢。

Sorry if this seems like a hazy question but it's something that's been bugging me for a little while.

In my day job, some of the code I write gets pretty complex. Not that it's usually very technical but the problem domain itself is a complex matter dealing with spacial data amongst many other things. I'm pretty sure my NDA would prohibit me from giving any details of what I'm working on so, unfortunately, I'll have to keep this pretty general.

Now, I'm all for reducing complexity so I try to find the right abstractions when I can but is there any way to reduce it further by explicitly not dealing with the actual matter at hand but rather some metaphor that could be operated on and then translated into the actual result I want later?

Of course, since the area is so complicated in itself,..I've tried but failed (many times!)to find the right metaphor :-(

So my question is, has someone already done this work and found (or even half found) a structured way to extrapolate an appropriate metaphor or heuristic for a set of given programming problems?

Again, my apologies if this seems like a bit of an odd question. I'm just trying to find new ways of being a better programmer.

Thanks in advance.

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

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

发布评论

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

评论(1

偏爱自由 2024-08-27 18:39:33

所以我的问题是,是否有人已经完成了这项工作并发现(或
甚至一半找到)一种结构化的方法来推断适当的
对于一组给定的编程问题的隐喻或启发式?

我可能已经开始回答你的问题了。这由多个抽象级别组成;多个域的描述;以及以特定方式应用“建模”技术——与通常的建模方式截然不同。我相信,总体方法就是您所寻求的 - 它给出了可操作的隐喻,然后转化为实际结果。它基于许多已发布的方法,并严重依赖其中一些途径和方法。

以下内容受到这些警告的约束:

  1. 这在很大程度上是“正在进行的工作”。
  2. 我一直受到贬低性的评论,称我是“架构宇航员”,这意味着我与真实系统开发的本质脱节。这是这项工作正在进行的原因之一 - 我当前的项目旨在验证这个概念,并证明它具有真正的实用性。为了做到这一点,我需要使用我的方法开发一个具有足够规模和复杂性的系统,这通常是单个开发人员无法实现的。我只是完成了这种概念验证开发的一部分。
  3. 虽然我描述的概念源自对复杂问题领域(声纳接触跟踪系统和芯片设计系统)的考虑,但我的示例涉及一个更简单的领域 - 基本上是一个受规则系统约束的信息系统。规则库不仅包括有关域的规则,还包括有关其他规则的适用性的规则。
  4. 从你的问题来看,我怀疑我是从与你相反的方向来讨论这个问题的。您要求一种方法来为一组给定的编程问题推断出适当的隐喻或启发式 - 对我来说这意味着从编程问题开始。我的动力来自于分析方面——试图找到并制定描述所提议的系统的方法,以便它可以作为一个真实的系统来实现。
  5. 当我使用“模型”和“建模”这两个词时,我指的是如下所述的建模。此描述与这些术语的常见用法有些不同。

这种方法所需的三个主要组成部分是:

多个域

我对域的定义比通常采用的更广泛:

域是一个独立的真实的、假设的或抽象的世界
由一组不同的物体和现象组成,这些物体和现象的行为遵循
域的规则和策略特征。有问题
分析。域是开发时一个有用的考虑单位
复杂的系统。

根据这个定义,系统内有多个域需要考虑,通常当开发人员提到域时,他们指的是问题(或应用程序)域(以下称为P)。然而,对于这种方法,系统的任何方面或系统开发都是建模的潜在主题。这包括系统架构(A);系统生产工件(代码、制作脚本、数据库模式等)(C); DBA职能;等等。通过隐喻接近P需要开发几个这样的领域 - 与隐喻以及从隐喻到现实世界模型或代码实现的转换相关开发系统中的现实世界。当开发多个这样的模型时,它们都被开发到相同程度的范围和精度。

多层次抽象

为了描述问题和系统,不仅要建模P,还要建模适当的更高抽象层次。因此,选择用来描述 P 的隐喻被建模(M)。以类似的方式,对 A (F) 的形式进行建模,如果认为有必要,则进行转换过程在 PC 之间使用 A (<强>R)。因此,我们可以抽象出问题领域;抽象抽象等等。

多个模型的应用类似于分色——它们相互叠加,系统必须满足所有层的所有描述(“完整图片”)。这又与常见的建模方式不同,常见的建模方式往往通过精心设计原始模型以纳入不同的约束来满足多种要求。当所有架构域都有效地应用于所有问题域的所有元素时,这具有特殊的含义。

建模

我所说的建模与更常用的建模方法在以下方面有所不同:

  1. 模型的主题很可能因领域而异。这与初始模型是其他模型的详细阐述的建模形成鲜明对比。事实上,模型有效性的一个测试是它代表了 DRY 原则的极端版本​​ - 如果某事物在多个地方定义,则表明模型存在缺陷。这扩展到所考虑的所有领域,因此系统的构建方式仅在一处定义。
  2. 域一旦建模,就可能是相当静态的。抽象级别越高,改变的可能性就越小。
  3. 模型的范围可能比传统开发的模型要窄得多,而且要深入得多。与传统建模相比,特定领域内的对象可能更少;但这些模型必须是完整的,并且有一些测试可以表明模型的完整性(显然,人们永远无法证明系统描述是完整的)。
  4. P 采用 M 定义的术语进行描述。该模型可以表示为图表、OO 表示、数学公式或任何适合领域M 的形式。

以下示例源自我的概念验证项目,可能会为我上面的描述提供一些内容。我列出了我的一些领域,以及领域模型的候选内容。

  • P [车辆、单位、动作、疲劳、速度...]
  • P1 [规则、适用性、状态、优先级...](附属问题域)
  • M [对象类型、属性、关系、域...]
  • A [事件、表、列、数据库域、类...]
  • F [持久化机制、处理......]
  • C [数据库模式、源代码、SQL 脚本、构建脚本,...]
  • R [形式主义、转换、映射...]

这种方法至少有一个主要缺点 - 管理层可能会认为开发模型所涉及的工作是非生产性的,没有产生真正的可交付成果。

这个答案的来源多种多样,但很大程度上依赖于以下人的著作:

  1. 迈克尔·杰克逊的结构化编程;系统分析;和问题域描述。
  2. Shlaer-Mellor 通过转换而非细化进行系统开发的方法。
  3. 肯尼迪卡特方法咨询公司。

So my question is, has someone already done this work and found (or
even half found) a structured way to extrapolate an appropriate
metaphor or heuristic for a set of given programming problems?

I may have the start of an answer to your query. This consists of multiple levels of abstraction; descriptions of multiple domains; and the application of "modelling" techniques in a particular way - really rather different from what is normally done in modelling. The overall approach is, I believe, what you are seeking - it gives metaphors that are operated on, and then translated into the actual result. It is based on a number of published approaches, and relies heavily on some of these approaches and methods.

What follows is subject to these caveats:

  1. This is very much "work in progress".
  2. I have been on the receiving end of derogatory comments that I am an "architecture astronaut", with the consequent implication that I am out of touch with the nitty-gritty of real system development. This is one of the reasons this is work in progress - my current project is designed to validate this concept, and demonstrate that it has real utility. In order to do this I need to develop a system of sufficient scale and complexity, using my approach, that would normally be out of reach of an individual developer. I am only part way through such proof of concept development.
  3. While the concepts I describe are derived from consideration of complex problem domains (sonar contact tracking system, and chip design systems), my examples relate to a simpler domain - basically an information system, constrained by a rules system. The rules base includes not only rules about the domain, but also rules about the applicability of other rules.
  4. I suspect, from your question, that I am coming to it from the opposite direction to you. You ask for a way to extrapolate an appropriate metaphor or heuristic for a set of given programming problems - which to me implies starting with the programming problems. My impetus has been from the analysis side - trying to find and formulate ways of describing a proposed system so that it can be implemented as a real system.
  5. When I use the words "model" and "modelling" I mean modelling as described below. This description is somewhat different from common usage of these terms.

The three main consituents needed for this approach are:

Multiple domains

My definition of a domain is wider than that normally adopted:

A domain is a separate real, hypothetical, or abstract world inhabited
by a distinct set of objects and phenomena that behave according to
rules and policies characteristic of the domain. In problem
analysis.the domain is a useful unit of consideration when developing
complex systems.

Under this definition, there are multiple domains for consideration within a system, Often when developers refer to a domain, they mean the problem (or application) domain (referred to hereafter as P). However for this approach, any aspect of the system, or system development is a potential subject for modelling. This includes the system architecture (A); system production artefacts (code, make scripts, database schemas, etc) (C); DBA functions; etc. To approach P via metaphor requires development of several such domains - relating to the metaphor and transformations from the metaphor to a model of the real world, or to the code realisation of the real world in the developed system. When multiple such models are developed, they are all developed to the same degree of scope and precision.

Multiple levels of abstraction

To describing a problem and system, one models not only P, but also models appropriate higher levels of abstraction. Thus the metaphor chosen to describe P is modelled (M). In a similar way, the formalism of A (F) is modelled, and if deemed necessary the transformation process between P and C using A (R). So one abstracts the problem domain; abstracts the abstraction and so on.

The application of multiple models is similar to colour separations - they lie on top of each other, and the system has to meet all the descriptions (the "complete picture") of all the layers. Again this differs from common ways of modelling which tend to meet such multiple requirements by elaborating the original model to take in the different constraints. This has particular implications when all of the architecture domains are effectively applied to all the elements of all the problem domains.

Modelling

What I mean by modelling differs from more usual approaches to modelling in the following respects:

  1. The subject matter of the model is highly likely to be different from domain to domain. This contrasts with modelling where initial models are elaborations of other models. Indeed, one test of the validity of a model is that it represents an extreme version of the DRY principles - if something is defined in more than one place, it indicates a deficiency in the model. This extends to all domains under consideration, so the way the system is built is defined only in one place.
  2. A domain, once modelled, is likely to be fairly static. The higher the level of abstraction, the less likely it is to change.
  3. The scope of a model is likely to be much narrower, and much deeper than those conventionally developed. There are likely to be fewer objects within a particular domain than in conventional modelling; but these models must be complete and there are tests which give some indication of the completness of the model (obviously, one can never prove that a system description is complete).
  4. P is described in terms defined by M. The model might be expressed as diagrams, OO representations, mathematical formulae, or whatever is appropriate for the domain M.

The following example, derived from my proof of concept project, may give some flesh to my descriptions above. I list some of my domains, together with candidate contents of the domain models.

  • P [Vehicles, units, movements, exhaustion, speed...]
  • P1 [Rules, applicability, states, priorities...] (a subsidiary problem domain)
  • M [Object types, attributes, relationships, domains...]
  • A [Events, tables, columns, database domains, classes...]
  • F [Persistence mechanism, processing,.....]
  • C [Database schemas, source code, SQL scripts, build scripts,....]
  • R [Formalisms, transforms, mappings...]

There is at least one major disadvantage with this approach - the work involved in developing the models can be seen by management as non-productive, with no real deliverables being produced.

The sources for this answer are many and varied, but do rely heavily on works by:

  1. Michael Jackson on structured programming; system analysis; and problem domain descriptions.
  2. The Shlaer-Mellor method of system development by transformation rather than elaboration.
  3. The Kennedy-Carter method consultancy.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文