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
最满意答案
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.
-
Firebase按顺序获取数据(Firebase getting data in order)[2022-10-26]
既然你没有分享必要的代码,我会假设你正在做这样的事情: 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 ...
-
从Firebase获取数据(Get data from Firebase)[2022-04-07]
如果超过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 ...
-
使用Firebase ios获取数据(Fetch data with Firebase ios)[2022-01-17]
将您的函数更改为如下所示以检查值是否存在: 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 ...