9

i'm using DDD architecture in my project and I need to create a class to generate a GUID to use in another class.

This class that generate my GUID is a Infrastructure Service or a Infrastructure Helper?

How I know when a class is a Helper or a Service?

Acaz Souza
  • 8,311
  • 11
  • 54
  • 97

2 Answers2

8

Service able to serve some clients, and often this is a SOA specific entity. Helper provides a set of methods which commonly are pure functions.

From my point of view if a class which provides the GUID generation functionality stores or uses this GUID for further needs - it is a Service class, otherwise I would say it is a Helper because simply work by principle do and forget / generate and forget.

Often if you can make method a static method - this is a helper method, it does not depends on any class state and does not affect it as well.

sll
  • 61,540
  • 22
  • 104
  • 156
  • Is it okay to put Helper classes in a seperate Helper package (i'm talking about Java in this case) – W.K.S Jun 05 '13 at 16:04
2

Glad you found an answer but you might want to rethink the question itself. What is 'Helper'? There is no such pattern or stereotype in DDD or anywhere else. Take a look at this answer. [Something]Helper is usually a sign of SRP violation or just a bad naming. For example if your language/framework does not provide Guid generation (which is highly unlikely) you can create your own GuidGenerator class. The name should reflect responsibility.

Community
  • 1
  • 1
Dmitry
  • 17,078
  • 2
  • 44
  • 70