0

I'm referring to the pattern (aka Universal Design Pattern) as discussed in this blog post

Universal Design pattern

I guess I'm not entirely clear how to use this in practice. And how it works to accomplish operations or tasks.

In particular regarding this explanation

It's the core API for any collection that maps names to values:

get(name)
put(name, value)
has(name)
remove(name)

There are typically also ways to iterate over the properties, optionally with a filter of some sort.

Are the keys the name? And what are the values?

And how do you perform operations? Where are instructions for performing tasks and operations on data stored? and how are they called? Are the embedded into the 'values' as classes?

  • It seems that the "Universal Design Pattern" may refer to different subject than the "Properties Pattern" – umlcat Jan 19 '15 at 17:28
  • @umlcat No I think the author of that blog is referring to them both to mean the same type of pattern. He just calls it universal because it appears everywhere. – erotavlas Jan 19 '15 at 17:37
  • 1
    Note that this is technically an anti-pattern - it's an implementation of dynamic typing, and even the author of the blog post agrees that avoiding it is a good idea. By making every aspect of the object mutable, you have no guarantees about what states it can be in. – Doval Jan 20 '15 at 3:46
2

Yes, the Keys are the name or identifier of each property.

You may add a changeValue method.

This pattern is also known a the Dynamic Object Design Pattern.

Example (Pseudocode):

void Example()
{
  KeyValueList MyControl = new KeyValueList();
    MyControl->put("id", "MyControl");
    MyControl->put("x", 34);
    MyControl->put("y", 125);
    MyControl->put("height", 200);
    MyControl->put("width", 250);
    MyControl->put("filled", false);

  MyWindow->insertControl(MyControl);
} // void Example()

As you may check in the previous example, is common to use a list that store key value items, where there the keys are of string types, and cannot be duplicated. The values may be stored as an type specific for each value, like integer or logical.

Or can be used as string, similar to H.T.M.L. or X.M.L. attributes, like this example:

Example (Pseudocode):

void Example()
{
  KeyValueList MyControl = new KeyValueList();
    MyControl->put("id", "MyControl");
    MyControl->put("x", "34");
    MyControl->put("y", "125");
    MyControl->put("height", "200");
    MyControl->put("width", "250");
    MyControl->put("filled", "false");

  MyWindow->insertControl(MyControl);
} // void Example()

Both, cases are optional.

The example is generic, identifiers and types, can change from library or programming language.

This Design Pattern is commonly used in programming languages that are not Object Oriented, (like "functional" or "procedural"), to emulate objects.

Is also used in Programming Languages that are already Object Oriented, but, the properties are statically designed, and cannot be added or removed at execution.

Cheers.

  • Why can't properties be added or removed at execution when using an Object oriented language? – erotavlas Jan 19 '15 at 19:14
  • @erotavlas Some Progr. Langs. are just designed with predefined properties, the programmer can change their value – umlcat Jan 19 '15 at 23:01
  • BTW thanks a lot for mentioning the alternative name for this pattern (dynamic object pattern)- that alone helped me find some great resources online (along with alternative terms such as dynamic object model and adaptive object model). I was having a hard time finding any information using the other name (properties pattern) in my searches. – erotavlas Jan 20 '15 at 1:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.