oop - Which design pattern does this? -


I have a small question about design patterns

I have 2 classes which They are very similar to class (theory), they primarily work in the same way and work, but now they have different characteristics. I want to make a cover which exposes the expressed properties of 2 squares, I remember that there was a pattern for it, but I was looking at this book and just did not get it. What I'm trying to do basically is map attributes, although I often use the same method (save) for each of my classes after collecting their data on different tables I do not want to write a complete code for each couple of those classes, because there are lots of things going to happen.

I will add a simple example to make myself more clear

Let me introduce this 2

  class of material theory - record {Int content_id; Date of making date; revised date; Int number_click; Content_translations translations []; } Class Content_translations increases theory; {Int translation_id; Int content_id; String language; String content; String title; }  

As you can see, 1 content may contain Content_translations because it works with a specific A very repetitive task is being created for translation. I need a certain content which I want to merge this 2 sections in order to avoid modifying any of the 2 sections.

I am trying to keep a class which I tell (if better at runtime) classes I have and they merge them, if I give an example of certain material (this Calls the classes of the new class) and if I call the saved () method, I have to call it on both objects, I remember that there is a pattern like this, but I do not remember the name.

What I'm trying to do here is basically the following, suppose I give the example of a stream (the class I am trying to create)

< P> So if I do this, I can get my content and the same translation in English, and I too

  $ section = new section ('1', 'en') I can use the properties of both; Resonate $ section- & gt; Number_clix; Counterpart $ section- & gt; Title;  

And if I modify any of them and call the save () method

  $ section = new section ('1' 'En'); $ Section- & gt; Number_click = $ section-> Number_clock + 1; $ Section- & gt; Title = "new title"; $ Section & gt; Save ();  

This will call the saved () method on each of my 2 contained sections (content and content_translation), so information is stored on 2 separate tables, now if I do this

$ section = new section ('1', 'es'); $ Section- & gt; Title = "title" espaƱol "; $ section> Save ();

This will only change the content_translations object sin I instanced the 'es' version of my object.

Hope you can help me :) And thanks in advance

In fact its Do not have a design pattern - you have to use your analytical skills on it. / P>

If you have the same method but there are different fields, then I attributes type , to differentiate between them.

If There are only a few types, you can potentially multiply, but if you want to add more than, say, 10.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -