首页 \ 问答 \ UML类图中的关系如何继承?(How relations in UML class diagram inherit?)

UML类图中的关系如何继承?(How relations in UML class diagram inherit?)

我想知道关联,依赖关系和这种关系如何在UML中继承(或者说,一般来说)。 所以,在这种情况下:

  ┌──────────┐                                        ┌──────────┐
  │  ClassA  │                                        │  ClassB  │
  ├──────────┤                                        ├──────────┤
  │          │─────────"One kind of relation"────────>│          │
  ├──────────┤                                        ├──────────┤
  │          │                                        │          │
  └──────────┘                                        └──────────┘
        ^
       /┬\
        │
        │
        │
        │
  ┌─────┴────┐
  │  ClassC  │
  ├──────────┤
  │          │
  ├──────────┤
  │          │
  └──────────┘

注意:

  • ClassA-ClassC属于泛化关系,箭头是实心的
  • ClassA-ClassB属于[依赖,关联,聚合,组合]之一
  • Unicode很酷,但使用编辑器字体看起来好多了:)

我的问题是,这些关系如何继承? 例如,当ClassA依赖于ClassB时,ClassC是否依赖于ClassB? 等等

谢谢。


I was wondering how associations, dependencies and such relations inherit in UML (or let's say, in general). So, in a situation like this:

  ┌──────────┐                                        ┌──────────┐
  │  ClassA  │                                        │  ClassB  │
  ├──────────┤                                        ├──────────┤
  │          │─────────"One kind of relation"────────>│          │
  ├──────────┤                                        ├──────────┤
  │          │                                        │          │
  └──────────┘                                        └──────────┘
        ^
       /┬\
        │
        │
        │
        │
  ┌─────┴────┐
  │  ClassC  │
  ├──────────┤
  │          │
  ├──────────┤
  │          │
  └──────────┘

Note:

  • ClassA-ClassC is in a generalization relation, the arrow is meant to be solid
  • ClassA-ClassB is in one of [dependency, association, aggregation, composition]
  • Unicode is cool, but looked much better with the editor font :)

My question is, how do these relations inherit? For example, when ClassA is dependent on ClassB, will ClassC depend on ClassB? etc.

Thank you.


原文:https://stackoverflow.com/questions/1988500
更新时间:2023-11-30 20:11

最满意答案

Firebase JavaScript客户端始终检索完整节点。 它无法仅检索密钥。

如果只想检索公司的密钥/名称,则必须将它们存储在单独的节点中。

{
  "companyList" : {
     "compkey1" : {
        "url1":"somelink1",
        "url2":somelink2
     },
      "compkey2" : {
         "url1":"somelink1",
         "url2":"somelink2"
     }
  },
  "companyKeys" : {
     "compkey1": true,
     "compkey2": true
  }
}

Firebase(以及许多其他NoSQL数据库)中的一个常见建议是以您的应用程序需要读取数据的方式对数据建模 。 在上面的示例中,您似乎需要阅读公司密钥列表,因此您应该建模。

注意: Firebase REST API确实有一个shallow=true参数,该参数只返回键。 但我建议通过不同的方式对数据进行建模来解决问题。


The Firebase JavaScript client always retrieves complete nodes. It has no option to retrieve only the keys.

If you want to retrieve only the keys/names of the company, you'll have to store them in a separate node.

{
  "companyList" : {
     "compkey1" : {
        "url1":"somelink1",
        "url2":somelink2
     },
      "compkey2" : {
         "url1":"somelink1",
         "url2":"somelink2"
     }
  },
  "companyKeys" : {
     "compkey1": true,
     "compkey2": true
  }
}

A common recommendation in Firebase (and many other NoSQL databases) is to model your data in a way that your application will need to read it. In the above example, it seems like you need to read a list of company keys, so that is what you should model.

Note: the Firebase REST API does have a shallow=true parameter that will return only the keys. But I recommend solving the problem by modeling the data differently instead.

相关问答

更多
  • obj.key只有在对象字面上被称为key时才有效,如下所示: { key: "foo" } 你想要的是obj[key] ,它将根据变量值的字典查找而不是文字引用来查找键的值。 obj.key would only work if there were a key in the object literally called key, like this: { key: "foo" } What you want is obj[key], which will look up the v ...
  • 我知道了。 显然你不需要把()。 所以我改变了 var key = childSnapshot.key(); 至 var key = childSnapshot.key; 它工作。 I got it. Apparently you do not need to put the (). So I changed var key = childSnapshot.key(); to var key = childSnapshot.key; and it worked.
  • 既然你没有分享必要的代码,我会假设你正在做这样的事情: ref!.queryOrdered(byChild: "text").observe(.value, with: { (snapshot) in print("\(snapshot.value)") }) 在Firebase位置上执行查询时,会根据查询返回有关项目顺序的信息。 当您观察值事件时,快照将包含键,值和子级的顺序。 但是,当您将请求转换为snapshot.value属性时,必须将所有信息转换为字典。 每个孩子的关键字和价值都经历了这 ...
  • 在for循环中,将dataSnapshot更改为snapshot 。 for(final DataSnapshot snapshot : dataSnapshot.getChildren()){ arrayAdapter.notifyDataSetChanged(); String barcode = (String) snapshot.child("barcode").getValue(); String name = (Str ...
  • 如果超过50%的密钥位于0和最大密钥之间(正好您的情况为一个零元素),则Firebase会将您的字典对象转换为数组。 https://www.firebase.com/docs/ios/guide/understanding-data.html#section-arrays-in-firebase Firebase transforms your dictionary object to an array if more than 50% of keys are between 0 and maximum ...
  • 当您对Firebase数据库执行查询时,可能会有多个结果。 所以快照包含了这些结果的列表。 即使只有一个结果,快照也会包含一个结果列表。 因此,您需要遍历返回的快照的子项以获取单个结果。 mThisUsersPosts.addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { for (Dat ...
  • 将您的函数更改为如下所示以检查值是否存在: init(snapShot: FIRDataSnapshot){ self.name = (snapshot.value as? NSDictionary)?["name"] as? String ?? "" // ... continue for other values } 然后,您不需要检查值是否为Null(因此没有错误): ref.child("users").observe(.childAdded, with: { (snap ...
  • 您可以使用Firebase的$变量来禁止所有未指定的子项。 有关保护数据的Firebase指南,请参阅以下示例: { "rules": { "widget": { // a widget can have a title or color attribute "title": { ".validate": true }, "color": { ".validate": true }, // but no other child paths are ...
  • Firebase JavaScript客户端始终检索完整节点。 它无法仅检索密钥。 如果只想检索公司的密钥/名称,则必须将它们存储在单独的节点中。 { "companyList" : { "compkey1" : { "url1":"somelink1", "url2":somelink2 }, "compkey2" : { "url1":"somelink1", "url2":"somelink2" ...
  • 不幸的是,正如@rhari提到的那样,你必须进行另一个查询....当我使用firebase进行“连接”时,我发现有用的是使用RxJava ...可能会有类似下面的内容(例如你可以在你的适配器中使用then来填充ListView / RecyclerView) public Observable getProjects(String userId) { return getProjectKeys(userId).flatMap(projectKey -> getProject(pro ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)