我最近花了很多时间来执行我编写的各种SW组件的详细UML设计.回顾一下我最近完成的事情,并将其与我第一次学习UML时的情况进行比较,我发现我现在几乎严格使用聚合和组合关系,并且几乎放弃了"香草"非定向/定向关系.我当然仍然使用泛化和实现,但这些与上面的明显不同,并不被视为此问题的一部分.
在我看来,聚合/组合意味着"香草"联想的含义相同,等等.聚合和组合自然意味着一个方向,任何现代UML程序仍然允许您在聚合/组合关系上定义多重性并将动词应用于关系.那时,我认为香草协会的目的不大.
我理解有些人很难理解聚合和组合之间的区别.在早期,我有点难以理解他们的差异,我相信混淆是我使用香草协会的部分原因.我现在处于这样的地步,我看到很少或没有使用香草协会,并且实际上不喜欢看到它们被使用,因为我相信它们会留下一些问题(特别是两个对象之间强大或弱的生命周期关系).我相信香草协会唯一的实际用途是当你对手头问题的理解还没有发展到足以确定聚合和成分之间的生命周期差异时.在这种情况下,最好至少表明关系存在,然后当您更好地理解手头的问题时,您可以回来并适当地改变它.
长话短说,我相信人们使用香草协会的绝大多数时间,他们可以更准确地描述为聚合,有时作为一个组合.在我的信念中,我是非常错的吗?我错过了什么吗?让我听听吧!
我正在学习核心数据,特别是在聚合方面.
当前我想做的事情:在一些标准上计算表中与多对关系的记录数与反向关系.
目前我这样做:
NSExpression *ex = [NSExpression expressionForFunction:@"count:"
arguments:[NSArray arrayWithObject:[NSExpression expressionForKeyPath:@"ddname"]]];
NSPredicate *pred = [NSPredicate predicateWithFormat:@"ddtype == 'Home'"];
NSExpressionDescription *ed = [[NSExpressionDescription alloc] init];
[ed setName:@"countDDEvents"];
[ed setExpression:ex];
[ed setExpressionResultType:NSInteger16AttributeType];
NSArray *properties = [NSArray arrayWithObject:ed];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setPredicate:pred];
[request setPropertiesToFetch:properties];
[request setResultType:NSDictionaryResultType];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"DDEvent" inManagedObjectContext:[self.currentAccount managedObjectContext]];
[request setEntity:entity];
NSArray *results = [[self.currentAccount managedObjectContext] executeFetchRequest:request error:nil];
NSDictionary *dict = [results objectAtIndex:0];
NSLog(@"Average birthdate for female heroes: %@", [dict objectForKey:@"countDDEvents"]);
Run Code Online (Sandbox Code Playgroud)
它来自jeff …
让我们说我们有3层项目.数据库,业务,Web和聚合pom.
Project
|-DB
| |-pom.xml
|-Business
| |-pom.xml
|-pom.xml
Run Code Online (Sandbox Code Playgroud)
所有模块都可以一起发布和分支,因此Aggregator pom配置为为所有子模块分配相同的版本.我们有以下版本:
DB-0.1-SNAPSHOT
Business-0.1-SNAPSHOT which depends on DB-0.1-SNAPSHOT
Web-0.1-SNAPSHOT which depends on Business-0.1-SNAPSHOT
Run Code Online (Sandbox Code Playgroud)
这样做时release:prepare,所有版本都更新为0.1,但是准备失败,因为还没有DB-0.1依赖.
一种解决方案是为每个模块创建不同的项目,并逐个释放它们,同时使用versions:use-releases插件将依赖项更新为0.1
但我不喜欢这个想法,因为它需要大量的配置和脚本.所以,我更喜欢使用的聚集和释放与单个命令所有模块,但问题是,正如我上面写的,当发布插件试图建立Business-0.1没有DB-0.1在版本库中.
有没有办法管理这些项目间的依赖关系?
谢谢.
UPD:
甚至安装目标失败.
我正在使用maven 3.0.2并发布插件2.1
aggregation dependency-management maven multi-module maven-release-plugin
Hive有这个相当不错的Array类型,在理论上非常有用,但是当涉及到实践时,我发现很少有关于如何用它做任何类型的操作的信息.我们在数组类型列中存储一系列数字,并且需要在查询中对它们进行求和,最好是从第n个元素到第m个元素.是否可以使用标准HiveQL或是否需要UDF或客户映射器/缩减器?
注意:我们在EMR环境中使用Hive 0.8.1.
我有多个类,我总是在定义表的主键的字段上使用相同的注释,例如:
@Id
@Type(type = "uuid-binary")
@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid2",
parameters = { @Parameter(
name = "uuid_gen_strategy_class",
value = "org.hibernate.id.UUIDGenerationStrategy")
})
@Column(name="PROFILE_ID", unique = true)
@NotNull(message = "we have one message" , payload =Severity.Info.class)
private UUID profileId;
Run Code Online (Sandbox Code Playgroud)
现在我正在寻找一种方法,在我进行验证时将所有这些注释聚合到一个单独的注释,比如注释聚合,即我可以将@NotNull和@Size从(javax.validation.constraints)聚合到以下注释"Name" .
package org.StudentLib.CustomeAnnotations;
import …
@Target( {FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER})
@Retention(RUNTIME)
@Constraint(validatedBy = {})
@Documented
@NotNull
@Id
@Size(message = "The size of the name should be between {min} and {max} caracters",
min = 1, max = 50,
payload …Run Code Online (Sandbox Code Playgroud) 我在使用Stream API找到一个好的方法/实现时遇到以下困难:
我有一个元素列表,每个元素由一个字符串和一个整数组成.现在我喜欢按字符串值对元素进行分组,然后对于每个组,我希望得到与该组相关的元素的整数值之和.
示例:我有以下3个要素:
("GroupA", 100) ("GroupA", 50) ("GroupB", 10)
Run Code Online (Sandbox Code Playgroud)
因此,我希望得到一个由以下两个(键,值)对组成的映射:
("GroupA, 150) ("GroupB, 10)
Run Code Online (Sandbox Code Playgroud)
我不知道如何解决这个问题.到目前为止我想出的最有希望的是:
elements.stream().collect(Collectors.groupingBy(e-> e.getGroup()))
.merge(group, elementsOfTheGroup, (...));
Run Code Online (Sandbox Code Playgroud)
但我不确定要插入哪个函数作为merge方法的最后一个参数.但我不知道我是否应该使用合并方法.
对此最优雅的实现是什么?
我的映射如下:
PUT places
{
"mappings": {
"test": {
"properties": {
"id_product": { "type": "keyword" },
"id_product_unique": { "type": "integer" },
"location": { "type": "geo_point" },
"suggest": {
"type": "text"
},
"active": {"type": "boolean"}
}
}
}
}
POST places/test
{
"id_product" : "A",
"id_product_unique": 1,
"location": {
"lat": 1.378446,
"lon": 103.763427
},
"suggest": ["coke","zero"],
"active": true
}
POST places/test
{
"id_product" : "A",
"id_product_unique": 2,
"location": {
"lat": 1.878446,
"lon": 108.763427
},
"suggest": ["coke","zero"],
"active": true
}
POST places/test
{ …Run Code Online (Sandbox Code Playgroud) 我在使用聚合框架从 MongoDB 读取文档时遇到问题:我的结果中总是出现空 ID。这仅适用于具有复合 ID 的文档。我尝试了各种版本的 spring-data-mongodb (1.10.12, 2.0.7),结果相同。
实体定义类
@Document(collection="entities")
public class MyEntity {
static class CompositeKey implements Serializable {
private String stringKey;
private Integer intKey;
public CompositeKey(String stringKey, Integer intKey) {
this.stringKey = stringKey;
this.intKey = intKey;
}
public Integer getIntKey() {
return intKey;
}
public String getStringKey() {
return stringKey;
}
public String toString() {
return "{" + stringKey + " - " + intKey + "}";
}
}
@Id
private CompositeKey id;
private String param;
public …Run Code Online (Sandbox Code Playgroud) 我想在我的项目域层(Clean MVVM )中实现单一职责原则。
我有大约 200 个不同的用例,管理起来非常繁忙。现在我正在考虑创建一个UseCaseManager可以为我提供所需的UseCase基于Input&Output对象的对象。
我尝试了一种方法,但看起来不太好。我提到了一些示例代码,请帮助我如何将所有用例聚合到一个 UseCaseManager。
用例1:
public class ActualUseCase1 extends AsyncUseCase<Object3,Object4> {
public ActualUseCase1(SchedulerProvider schedulerProvider) {
super(schedulerProvider);
}
@Override
public Flowable<Object4> buildUseCaseFlowable(Object3 input) {
return Flowable.just(new Object4());
}
}
Run Code Online (Sandbox Code Playgroud)
用例2:
public class ActualUseCase2 extends AsyncUseCase<Object1, Object2> {
public ActualUseCase2(SchedulerProvider schedulerProvider) {
super(schedulerProvider);
}
@Override
public Flowable<Object2> buildUseCaseFlowable(Object1 input) {
return Flowable.just(new Object2());
}
}
Run Code Online (Sandbox Code Playgroud)
用例管理器:
public interface UseCaseManager<In, Out> {
<T> T getUseCase(In …Run Code Online (Sandbox Code Playgroud) single-responsibility-principle use-case aggregation clean-architecture interactors
麻烦是这个。
假设我们有一个可以使用以下方法生成的 Pandas df:
month=['dec','dec','dec','jan','feb','feb','mar','mar']
category =['a','a','b','b','a','b','b','b']
sales=[1,10,2,5,12,4,3,1]
df = pd.DataFrame(list(zip(month,category,sales)),
columns =['month', 'cat','sales'])
print(df)
| month cat sales |
|--------------------|
| 0 dec a 1 |
| 1 dec a 10 |
| 2 dec b 2 |
| 3 jan b 5 |
| 4 feb a 12 |
| 5 feb b 4 |
| 6 mar b 3 |
| 7 mar b 1 |
Run Code Online (Sandbox Code Playgroud)
那么让我们假设我们想按月计算每个类别。
所以我们去做类似的事情
df=df.groupby(['month','cat']).sales.sum().reset_index()
print(df)
| month cat sales |
|--------------------|
| …Run Code Online (Sandbox Code Playgroud) aggregation ×10
java ×2
aggregate ×1
annotations ×1
arrays ×1
associations ×1
composition ×1
core-data ×1
count ×1
distance ×1
duplicates ×1
group-by ×1
hadoop ×1
hive ×1
interactors ×1
iphone ×1
java-stream ×1
maven ×1
mongodb ×1
multi-module ×1
pandas ×1
python ×1
single-responsibility-principle ×1
spring ×1
uml ×1
use-case ×1