V
V
Valery Semenov2011-07-03 01:20:29
Design patterns
Valery Semenov, 2011-07-03 01:20:29

What design pattern is this

There are several entities
category, article, event (special article), page template,

despite the fact that they are completely different entities, they have common properties - “text content”, “picture”, “summary”, “update time”. They also have individual properties - “event date”, “event link” (for an article), etc.

Each property has a number of methods for working with them. For example, a number of methods for working with an image, a number of methods for working with text. etc.

the idea arose to write the architecture of entities as a set of primitive parameter classes. And the parameter class (for example, “image” or “text”) encapsulates the methods specific to this parameter. Thus, the event class is a set of parameters - “text”, “picture”, “event time”, and the article class is “text”, “picture”, “summary”, “event link”

In all the variety of patterns, I suppose that there is a similar or even just such a pattern to which I have arrived in my reflections. If anyone knows what pattern is in question, please tell me its name.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
T
Timur Shemsedinov, 2011-07-03
@MarcusAurelius

… despite the fact that they are completely different entities, they have common properties… They also have individual properties…

This pattern is called OOP :) Namely, the use of abstract classes and inheritance. I advise you to read good old literature like Gradi Butch.
each property has a number of methods for working with them. For example, a number of methods for working with an image, a number of methods for working with text. etc.

And this is where the architectural error creeps in. Your classes belong to the domain and, therefore, class methods must implement the business logic of the domain. You do not start storing a file descriptor, a timeout or some kind of handler in the data of the "article" class. Of course, mixing data related to the technological features of the system and data of the subject area is bad. But for some reason it occurred to you to mix the logic of the subject area and completely service methods for processing pictures or texts there. To do this, you need to make separate classes, and then the utility classes will execute methods on the domain classes and you will be conceptually happy.
the idea arose to write the architecture of entities as a set of primitive parameter classes

You can, of course, invent something high-level based on OOP, but that's only if that architecture makes your program easier, increases code reusability, makes code easier to maintain, or improves other characteristics.

G
gl00k, 2011-07-03
@gl00k

It appears to be a linker pattern, although I could be wrong.

W
Weageoo, 2011-07-03
@Weageoo

It looks like normal inheritance.

O
Ololesha Ololoev, 2011-07-03
@alexeygrigorev

Either inheritance from abstract classes (c++), from interfaces (java, C#), or duck typing in scripting languages ​​(python, groovy, etc).
In general, there are SOLID principles (http://en.wikipedia.org/wiki/Solid_%28object-oriented_design%29), in which the letter I means ISP - interface segregation principle (http://en.wikipedia.org/wiki /Interface_segregation_principle). This is what it is.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question