Repository Pattern and multiple related core entities or business objects - one repository or more?
Date : March 29 2020, 07:55 AM
Hope this helps We have been doing a lot of thinking recently at my work and came across a few articles that helped us visualize and design our repositories in a consistent manner. From what we found out one of the better practices is to create one repository per aggregate root. An aggregate root would be an Entity type where you need to reference that entity type to reach child value types. Only an Entity type could be queried from the database and any child Value types would need to be traversed from the Entity.
|
Chaining methods using generics and compositon
Tag : chash , By : Mariocki
Date : March 29 2020, 07:55 AM
wish helps you I'm trying to model series of "phases" C#, where each phase has an input and output, and where they can be chained together, with the output of phase 1 becoming the input of phase 2. I thought it might look something like this, but I didn't know what to use in place of the ???. , You could try with two classes: public class OutputOfPhase<TOutput>
{
}
public class Phase<TInput, TOutput> : OutputOfPhase<TOutput>
{
private OutputOfPhase<TInput> prerequisite;
public Phase(OutputOfPhase<TInput> prereq, Func<TInput, TOutput> work)
{
/* ... */
}
}
Phase<int, long> p1 = new Phase<int, long>(null, p => p * 1000L);
Phase<long, double> p2 = new Phase<long, double>(p1, p => p / 2.0);
|
how to prove the associative law of the compositon operation (.) in Haskell
Date : March 29 2020, 07:55 AM
should help you out say , , You can define the composition operator yourself as follows: (.) :: (b -> c) -> (a -> b) -> a -> c
g . f = \x -> g (f x)
lhs = h . (g . f)
= \x -> h ((g . f) x) -- substitution
= \x -> h ((\y -> g (f y)) x) -- substitution
= \x -> h (g (f x)) -- beta reduction
rhs = (h . g) . f
= \x -> (h . g) (f x) -- substitution
= \x -> (\y -> h (g y)) (f x) -- substitution
= \x -> h (g (f x)) -- beta reduction
|
How to do train composition - compositon of classes
Tag : java , By : kokok13
Date : March 29 2020, 07:55 AM
I hope this helps you . Im not sure about what are you asking, but I will try to give you my aproximation: You need to create a composite object where every object has an unique ID and need to pass some validations.
RollingStock freightCoach = StoregeManager.getFreightCoach();
RollingStock specialCoach = StoregeManager.getSpecialCoach();
RollingStock dieselEngine = StoregeManager.getDieselEngine();
// Check if they are null or throw an exception if has no more elements. Maybe from BBDD or from where you want
Composer.compone()
.add(dieselEngine)
.add(freightCoach)
.add(specialCoach)
.build()
public class Composer {
private StoregeManager storeManager; //Injected or initialized, as you want.
private static Train train;
public Composer build(){
train = new Train;
return this;
}
public Composer add(RollingStock rs) {
if(rs.isValid(train))
train.add(rs);
return this;
}
public RollingStock[] build() {
storageManager.ckeckTrain(train);
return train;
}
}
|
overloaded member function error while doing compositon c++
Date : March 29 2020, 07:55 AM
|