What class name should I use for an Adapter Pattern adaptor? - adapter

Let's assume I've got a class SomethingDAO which I need to adapt to an interface SomethingProvider.
What should I call the adapter class?

SomethingDaoToProviderAdapter or SomethingProviderToDaoAdapter seems clear to me and I would suggest this.

Related

Dart - global constants design - Class constructor Constants._()

I'm using a Dart package and need to extend or otherwise change some of the state in a singleton class called Constants, i.e. a class with a private constructor. It appears I have to change the singleton to extend/subclass it. Having poured over their code, I admire their work and want to avoid changing their code. Is their another way to add some constants and change some of the values of the static const's in their Constants._() class? I'm new enough to Dart to be missing something obvious, so don't be shy about giving me obvious advise. I know I can change the class to have a public const constructor and then I'm able subclass it. Is a mixin the way to tackle this?
Thanks in advance for any help.

Making class out of another class smart (Obj-C)?

I have a class written in Objective-C and I want to have another similar one. Except for few details. Is there any smart way of copying class implementation and making another class? I'd like to change few things, but ctrl+c + ctrl+v sounds so unintuitive.
Regards
PS. edit: I have multiple classes to implement, also I'd like to have neat solution for future.
Use class inheritance.
Implement class A with the common functionality
Derive classes B and C from A to add functional differences.
Take a look at Classes Inherit from Other Classes.
If you like to simply add a method without subclassing, see Categories Add Methods to Existing Classes. But be aware what you shouldn't do with categories!
If you like to change values, add appropriate properties to the interface declaration.

Symfony: trying to overwriting a method of a symfony class

i want to overwrite a method of
symfony/lib/plugins/sfDoctrinePlugin/lib/form/sfFormDoctrine.class.php.
I think a good way could be writing again the method in the form class
where i need that method.
In that case if i need that method in other form class should i write
again the new method, so i would break the rule DRY...
So is there any better way?
Regards
Javi
You should be using BaseFormDoctrine if this is a Doctrine specific method or BaseForm if you want the method to apply to all forms. These form classes are provided specifically for this purpose.
Piggybacking on Colonel Sponz's answer, I've done this many times by extending the class I want to override. By extending the class, you don't have to duplicate anything. In the method(s) you want to customize, just add your customized code and then call parent::method_name() to execute the same method of the super class. You get all the benefits of both. Calls to methods that don't exist in the subclass will execute against the super class.
It should be noted that this strategy is basic OOP stuff and isn't limited to Symfony or even PHP.
You could create a new class that inherits from sfFormDoctrine that redeclares the methods you need and then use your new class in place of sfFormDoctrine wherever you need that method.

Ambiguity with class and model

I'm trying to define a "Product"-class for my model (.edmx), and I have it in the same folder as the model.
I get: Ambiguity between 'MVCTest.Models.Product.ProductID' and 'MVCTest.Models.Product.ProductID' error
What's needed to do so I can define my classes correctly?
/M
Have you tried using "Partial class"? Only really appropriate if it's an extension of the product class I guess.
If this is not what you were looking for then let us know with more information or even code snippets.
You could always separate out by namespace. Have one class in one namespace. Although having the same class with the same properties is a bit unusual, and suggests that you need to refactor and create some form of inheritance as griegs suggested.

How to use JEDI TJCLHashMap classes?

I'm trying to use TJCLHashMap family of classes, but apparently this class has no useful public methods. All methods are "protected". How to use this class? Although JCL comes with some samples, I seem to miss something. A basic example would be great.
You should use the interfaces declared in JclContainerIntf.pas. The classes in JclHashMaps implement those interfaces.
Take a look at jcl\examples\common\containers\hashing\HashingExample.dpr for a few examples (integer, strings, objects, etc.)
Extend it and add public methods that call the protected methods internally?

Resources