composite

Solving design involving multiple inheritance and composite classes in c++

半腔热情 提交于 2019-12-03 07:19:05
I have struggled with this design problem for some time. I will do my best to explain what I am trying to do and the various approached that I have seen, what I am trying and why. I work in a scientific computing environment where I deal with the same kinds of objects repeatedly. Imagine a galaxy which contains solar systems, each solar system contains planetary systems and each planetary system contains moons. To this end I think of the situation as a “has a” situation, and thus I have used composition to give the galaxy access to its solar systems, and each solar system access to the

composed_of in Rails - when to use it?

╄→尐↘猪︶ㄣ 提交于 2019-12-03 06:59:08
问题 When should you use ActiveRecord's composed_of class method? 回答1: personally, i think this is useful when you have objects which are not stored in database, as shown in the database, e.g. temperature, gps location, balance, etc. You might ask then why those are not stored in the database? In the database we only store a value, but if we want to attach useful, relevant methods to that value, for e.g. in the case of temperature, we might need methods like to_fahrenheit , to_celsius , is_boiling

composed_of in Rails - when to use it?

北城余情 提交于 2019-12-02 21:43:05
When should you use ActiveRecord's composed_of class method? personally, i think this is useful when you have objects which are not stored in database, as shown in the database, e.g. temperature, gps location, balance, etc. You might ask then why those are not stored in the database? In the database we only store a value, but if we want to attach useful, relevant methods to that value, for e.g. in the case of temperature, we might need methods like to_fahrenheit , to_celsius , is_boiling_point? , etc in the case of gps location, we might need methods like distance_from(point) , route_to(point)

composite inheritance: how to assign a final field at sub-class constructor which depends on 'this' value (backward reference)?

≡放荡痞女 提交于 2019-12-02 07:06:20
I use composite classes to group functionalities. But, the class A (with composite A1), got inherited by B (with composite B1), and a behavior existent at A1 is going to be adapted at B1, but the final a1 must be a B1 instance for this to work. Obs.: I have ways to make sure the composite instantiation happens properly (only by its composite partner). Unable to assign a B1 object to a1 final field: class finalFieldTestFails{ class A1{ A1(A a){} } class A{ protected final A1 a1; A(){ this.a1 = new A1(this); } A(A1 a1){ this.a1 = a1; } } class B1 extends A1{ B1(B b){ super(b); } } class B

Composite design pattern: how to pass results from one component into another?

妖精的绣舞 提交于 2019-12-02 02:35:20
问题 I have the following code: interface IService { void Execute(); } class ServiceA : IService { public void Execute() { ... } } class ServiceB : IService { public void Execute() { ... } } class ServiceComposite : IService { List<IService> _services = new List<IService>(); public ServiceComposite() { _services.Add(new ServiceA()); _services.Add(new ServiceB()); } public void Execute() { foreach (IService service in _services) { service.Execute(); } } } The problem is that ServiceB depends on

Composite design pattern: how to pass results from one component into another?

风格不统一 提交于 2019-12-02 00:20:11
I have the following code: interface IService { void Execute(); } class ServiceA : IService { public void Execute() { ... } } class ServiceB : IService { public void Execute() { ... } } class ServiceComposite : IService { List<IService> _services = new List<IService>(); public ServiceComposite() { _services.Add(new ServiceA()); _services.Add(new ServiceB()); } public void Execute() { foreach (IService service in _services) { service.Execute(); } } } The problem is that ServiceB depends on some results from ServiceA. My idea is to create container class for storing the results, then inject it

Fluent NHibernate Composite ID table problem

廉价感情. 提交于 2019-12-01 23:44:55
I'm kinda new to nhibernate and i ran into a problem. I have the following tables: Table 1: Table Name: Users, Column 1: ID, Column 2: Name Table 2: Table Name: Missions, Column 1: ID, Column 2: Description Table 3: Table Name: UserToDoMissions, Column 1: UserID, Column 2: MissionID, Column 3: Rank Here is the code: MissionMap: public class MissionMap : ClassMap<Mission> { public const string TableName = "tblMissions"; public const string c_id = "achID"; public const string c_name = "achName"; public MissionMap() { Table(TableName); Id(x => x.ID).Column(c_id).Not.Nullable(); Map(x => x.Name)

SWT ScrolledComposite cutting off information.

本小妞迷上赌 提交于 2019-12-01 20:26:32
I'm making an application that has many lines of data coming back from a Database stub(which will become an Oracle database), and for some reason the scroll bar stops at about the 500th element. I'm wondering if there's anyway to have all the elements show within the scroll bar. I'm assuming here that you're using Windows, because there is a fairly general problem with scrollbars on Windows: the maximum value is a short int, 32,768. Therefore, if the height of the inner composite of a ScrolledComposite is greater than 32,768 pixels, the composite will be clipped. I haven't found a robust way

Why are there no decent examples of CompositeCell in use within a CellTable?

烂漫一生 提交于 2019-12-01 19:13:49
问题 I have scoured GoogleCode, GWT ShowCase, GWT Developer Notes, and Google Groups for some inkling as to how to get/set values of a CompositeCell. There is no one definitive example that explains how to use it within a CellTable. Let's stare at some code... first an abstract class... public abstract class ToggleableGrid<T> extends CellTable<T> { private static final String DEFAULT_TABLE_WIDTH = "100%"; private static final DisplayMode DEFAULT_MODE = DisplayMode.VIEW; protected void setDefaults(

Hibernate how to use a constant as part of composite foreign reference

橙三吉。 提交于 2019-12-01 19:08:12
问题 I have a master table A with a composite primary key, consisting of two columns. One of these columns is a constant ("THE CONSTANT VALUE" in the code below). This table definition looks like the following: @Entity public class Master { @Id @Column(name = "SIGNIFICANT_KEY") private String realKey; @Id @Column(name = "CONSTANT_KEY") private String constantPartKey; } I have a detail table B, referencing master table A using only one (non-constant) column. I want to implement usual ManyToOne and