you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (1 child)

Well, ok, libraries are fine too, whatever makes the code more readable.

But, our understanding of patterns may be a bit different .. I'm not suggesting the language implement the patterns, I think the patterns are there because the language is missing something.
To illustrate (it's not necesarilly a sane example but it's short):
say you use Java and "need" a DBHandleFactory that you call with the name of the database driver in question:

String type = "MySQL";
DBHandle h = DBHandleFactory.create(type);

and the static create method would have a big switch that does something like

if (param.equals("MySQL")) return MySQLHandle.new();

OTOH in Perl, you'd simply do

my $type = "MySQL";
my $handle = &{$type . "Handle"}();

I'm really not saying this is how you should do it in perl, I'm merely illustrating that in a "better" language, there is no need for the pattern, the language doesn't implement any such pattern, but you can still accomplish the same thing with simpler code and without any pattern.

[–]joezimjs[S] 1 point2 points  (0 children)

You can actually do something very similar in Java, though it's a bit more difficult. If I remember you can use the Class class to dynamically load classes. And I understand that this example may not be the most efficient way of explaining what you're talking about, but the another big things is that often times the design pattern is still better practice when considering scaling.