Difference between Inheritance and Composition
Are Composition and Inheritance the same? If I want to implement the composition pattern, how can I do that in Java? ...
Are Composition and Inheritance the same? If I want to implement the composition pattern, how can I do that in Java? ...
Hi there. After a couple of weeks reading on this forum I thought it was time for me to do my first post. I'm currently rereading Code Complete. I think it's 15 years since the last time, and I find that I still can't write code ;-) Anyway on page 138 in Code Complete you find this coding horror example. (I have removed some of the ...
Context: I'm developing a WPF application which will contain a lot of different "screens". Each screen contains a which on its turn contains all the visual elements. Some elements trigger events (e.g., checkboxes), a screen has individual resources, etc. The main application is "wrapper" around these screens: it contains a menubar, to...
Hi Let's say I have some Control that has been disabled. It contains a bunch of elements, but I want one of those child elements to remain enabled. Something like this: <ContentControl IsEnabled="False"> <Border> <Button Content="Button" IsEnabled="True"/> </Border> </ContentControl> So in this example, the Button's ...
Hi All, I am trying to concatenate two video files with the gnonlin components of the gstreamer. The pipeline I am using is gst-launch-0.10 gnlcomposition { gnlfilesource name="s1" location="/home/s1.mp4" start=0 duration=2000000000 media-start=0 media-duration=2000000000 gnlfilesource name="s2" location="/home/s2.mp4" start=2000000...
I am developing a Rails 1.0 application (I can't upgrade, it's a strange situation) for which I am trying to use the :composed_of functionality. I have a class called StreetAddress: class StreetAddress attr_reader :address, :address2, :city, :state_id, :zip_code def initialize(address, address2, city, state_id, zip_code) @addr...
I would like to set up a foundation of classes for an application, two of which are person and student. A person may or may not be a student and a student is always a person. The fact that a student “is a” person led me to try inheritance, but I can't see how to make it work in the case where I have a DAO that returns an instance of pers...
What are the advantages/disadvantages of Option 2 over 1 in this example? Option 1 (Inheritance): public class SalesList : List<Sales> { //methods that add extra behavior List<Sales> } Option 2 (Composition): public class SalesList { private List<Sales> _list; //methods that add extra behavior to List<Sales> } ...
Currently, I am dealing with multiple layers of composition in my application. We read data from database for ProductLocations and put them into a Solver object. In another query we read multiple SalesActivities connected to product locations which needs to be placed in an object deep within the correct ProductLocation object. I end up ...
I am relatively new to MEF so I don't fully understand the capabilities. I'm trying to achieve something similar to Unity's InjectionMember. Let's say I have a class that imports MEF parts. For the sake of simplicity, let's take the following class as an example of the exported part. [Export] [PartCreationPolicy(CreationPolicy.NonShare...
I have the following simplified model in Grails: A DataBlock consists of a number of sorted ConfigPreset objects. In ConfigPreset I have static belongsTo = [dataBlock: DataBlock] and the DataBlock class contains: List presets static hasMany = [presets: ConfigPreset] DataBlock() { addToPresets(new ConfigPreset()) } The over...
What is a good pattern for sharing data between related views?. I have an application where 1 form contains many small views, each views behaves independently from each other more or less (they communicate/interact via an event bus). Every so often I need to pass the same objects to the child views. Sometimes I need this same object to...
Hi, Are there any alternatives to Prism for UI composition (region management etc.)? Thank you. ...
Aggregation: the object exists outside the other, is created outside, so it is passed as an argument (for example) to the construtor. Ex: People – car. The car is create in a different context and than becomes a person property. Composition: the object only exists, or only makes sense inside the other, as a part of the other. Ex: People...
I'm new Ruby but been a .net dev for many a year. I want to implement composition within a couple of my model to make sure they are as loosely coupled as possible but have no idea where to start, or if this is really needed and I'm still thinking to much like a .net dev. Can anyone give me some pointers on where to start. Cheers Colin ...
If I have a Matcher[A] how do create a Matcher[Iterable[A]] that is satisfied only if each element of the Iterable satisfies the original Matcher. class ExampleSpec extends Specification { def allSatisfy[A](m: => Matcher[A]): Matcher[Iterable[A]] = error("TODO") def notAllSatisfy[A](m: => Matcher[A]): Matcher[Iterable[A]] = allSati...
I'm rather taken with MEF and plan to use it to build a demo application to load different tabs. I am a begineer at MEF and WPF and although MEF is loading the assemblies I'm stuck at loading the controls into the TabItem I have created. My code looks a bt like this .. foreach (var page in pages) { ...
Hi, I have the following scenario in Silverlight 4: I have a notifications service Snippet [InheritedExport] public interface INotificationsService : IObservable<ReceivedNotification> { void IssueNotifications(IEnumerable<ClientIssuedNotification> notifications); } and and implementation of this service Snippet [PartCreationP...
UPDATE: My original question wasn't quite clear. I'm looking for the name of the principle that code like the example below violates. (I've updated the code example to better resemble the scenario I'm talking about. The original code example I included can be found at the bottom. This was a poorly chosen example because it illustrated a...
Hi, I'm trying to figure out, whether input bindings for CompositeProcesses and AtomicProcesses in OWL-S can be defined externally. Example The OWL-S CompositeProcess has the rdf:ID "CompositeProcess". The two OWL-S AtomicProcesses are identified by "AtomicProcess_1" and "AtomicProcess_2" respectively. Each OWL-S Process has one inpu...