Skip to main content

Questions tagged [template-method]

Template Method is an Object Oriented design pattern that let's a subclass implement particular steps of an algorithm defined in the superclass.

0 votes
1 answer
503 views

I've started working on a C# codebase. There are three services which run the same set of steps of three kinds of objects, each returning IResult: public IResult FooService(Foo foo) { ... } public ...
hyperfiction's user avatar
1 vote
2 answers
263 views

I have a conceptual question about SW design. I prepared the following example: One abstract base class: internal abstract class BaseFamilyObject { // //... // internal abstract ...
Jack's user avatar
  • 21
4 votes
3 answers
371 views

Do we have pattern, which is opposite to Template Method? I mean, in base class we define parts of algorithm and abstract method which implements algorithm. Then in derived class, in that abstract ...
Yurii N.'s user avatar
  • 341
1 vote
3 answers
113 views

Suppose I'd like to implement the templating pattern, but the only real differences between the subclasses are their choices of some invariant dependencies. Is there a drawback to preferring this ...
kinbiko's user avatar
  • 111
2 votes
0 answers
137 views

Motivation: (Skip to "The Problem" if you don't need motivation for it) As a project for myself, I'm writing an expression parser for certain kinds of mathematical expressions, and I'm using the ...
Umer Amjad's user avatar
0 votes
2 answers
562 views

Assume we have the following class: class Foo { public: void func() { _func1(); _func2(); } private: virtual void _func1(); virtual void _func2(); }; This class, from one ...
undermind's user avatar
  • 117
2 votes
3 answers
966 views

EDIT: note I want a static compile time method, when I know exactly what needs to go where at compile time. I often find myself having multiple functions which follow the same pattern, but only a ...
Krupip's user avatar
  • 1,347
12 votes
4 answers
9k views

Similarities and differences between the two: Template Method Relies on inheritance. Defines the steps of an algorithm, and leaves the task of implementing them to subclasses. Factory Method Relies ...
Maria Ines Parnisari's user avatar
2 votes
1 answer
855 views

I was going over some old code and found the following peculiar naming convention at a template method implementation. // TEMPLATE METHOD // Checks condition and fail fast if condition is met. // ...
kouretinho's user avatar
3 votes
5 answers
919 views

I want to model some mathematical structures. For this purpose I want to define an interface, an abstract class for general purpose algorithms and concrete implementations of that class (I have three ...
Johannes Hahn's user avatar
1 vote
2 answers
253 views

I want to do some initialization in child class constructor and pass result to super(). But Java doesn't allow any processing in child class constructor before super() call. Whats a good way to ...
mzlo's user avatar
  • 141
0 votes
1 answer
204 views

I've recently been looking into using JavaScript for templating and I was wondering about the legibility of using this approach. I understand that JavaScript templating is a very common and much ...
Brummy's user avatar
  • 13
1 vote
1 answer
3k views

Template method pattern is commonly implemented with abstract classes. interface Algorithm { void perform(); } abstract class AlgorithmBase implements Algorithm { abstract void step1(); ...
Dalija Prasnikar's user avatar
1 vote
1 answer
89 views

I have a virtual method that returns a collection of items that must be unique. I want to make sure that it will be obvious when overriding the method. What is the best way to do this? Here is an ...
Den's user avatar
  • 4,887
0 votes
2 answers
4k views

I'm working on a webshop (used to be for just one product, expanding it to multiple products and multiple shops hooked up to one backoffice, can't use PrestaShop because of compatibility). We send 3 ...
66h3m3ab's user avatar
  • 119

15 30 50 per page