Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Factory Method..

Former Member
0 Likes
1,471

Hi Experts!!

What is Factory Method ?

Please give me one example for factory method.

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,156

hi,

Factory methods (or factory classes) are used if you (as developer of the factory method/class) want to keep control about how instances of classes are created.

In addition, factory methods are used if groups of classes have to be instantiated at the same time and you do not want to burden this complexity on to the developer using this classes.

Examples for factory methods and classes are:

CL_PT_EMPLOYEE=>GET_EMPLOYEE (employee instance)

CF_RECA_MESSAGE_LIST=>CREATE (message handler)

CL_WB2_DOC_FACTORY=>CREATE_DOC (create different types of documents -> sales order, purchase order, etc)

Please note that factory methods are a design pattern and, by no means, specific to ABAP-OO.

I can highly recommend the book

Head First Design Patterns

in order to learn the basics of design patterns.

Do reward if helpful

9 REPLIES 9
Read only

Former Member
0 Likes
1,157

hi,

Factory methods (or factory classes) are used if you (as developer of the factory method/class) want to keep control about how instances of classes are created.

In addition, factory methods are used if groups of classes have to be instantiated at the same time and you do not want to burden this complexity on to the developer using this classes.

Examples for factory methods and classes are:

CL_PT_EMPLOYEE=>GET_EMPLOYEE (employee instance)

CF_RECA_MESSAGE_LIST=>CREATE (message handler)

CL_WB2_DOC_FACTORY=>CREATE_DOC (create different types of documents -> sales order, purchase order, etc)

Please note that factory methods are a design pattern and, by no means, specific to ABAP-OO.

I can highly recommend the book

Head First Design Patterns

in order to learn the basics of design patterns.

Do reward if helpful

Read only

0 Likes
1,156

Hello Anee

The original quote can be found here:

In addition you may have a look at the following threads:

Regards

Uwe

Read only

GrahamRobbo
SAP Mentor
SAP Mentor
0 Likes
1,156

Hi Anee,

please do not reward plagiarism. Make sure you give any points to Uwe and not the person who failed to acknowledge the original source.

This will help make SDN a much more useful, and happier, place.

Cheers

Graham Robbo

Read only

0 Likes
1,156

Hi Mr Robinson,

Well my understanding of SDN is that we need to share our limited resources to suffice the requirements of each other

and in the process we try to give answers out of our own ability as well as search the web to get the appropriate answer

so as to increase our knowledge base as well as answer the post

I dont find anything wrong in searching for the new things I dont know and learning new things.

may be you are a genius and you know everything and you dont need to consult any books or online material.

well this is my approach to enhance my skills

and i dont call it Plagiarism

also have a look at the rules of posting before writing post with obnoxious vibes

have a look about whats given in the rules of posting.

"Search the forums, the articles, the blog posts and the Frequently Asked Questions (FAQ) in the Wiki for your topic."

Use Proper Language

"The language that you use in the forum should not hurt the co-SDNer or BPXer. Please don't use curse, slang, inappropriate or otherwise offensive language. Every professional has the responsibility to maintain good relationship/environment around. This is a community but a professional one please keep that in mind as you converse with others here. Any abuses should be reported to the moderators if no acceptable resolution can be found."

Better be more selective in your choice of words while posting

Read only

0 Likes
1,156

Hello Graham

Anee did it as you recommended.

@Anee: Another important reason why to use factory methods or classes is to hide the complexity of instantiation from the developer. This is particularly important if the instantiation does not only create a single instance but an entire group of related instances (for more details refer to the recommended book about design patterns).

Regards

Uwe

Read only

0 Likes
1,156

Thanks Uwe!!

For valueable answer.

Thanks

Anee

Read only

0 Likes
1,156

You are copying somebody else's work, pasting it as if it was your own answer, demand reward for it, and now even start complaining once you have been caught?

That's really incredible, you should be ashamed of yourself.

In the end experts like Uwe will be scared away from posting here, then the whole place might as well be shut down.

I have reported your post as plagiarism.

Have a nice day

Thomas

Read only

0 Likes
1,156

Hello Sharad

You may not call it plagiarism but it is indeed.

Perhaps you may have a look at

Instead of being rewarded for doing a good search job you are blamed for - call a spade a spade - plagiarism.

I appreciate being cited because it shows to me that my answer are reusable.

If you had quoted the original I would not have replied because with the original quote the question would have been addressed (even though there is much more to learn about the factory pattern). And you would have been rewarded rightfully...

Regards

Uwe

Read only

0 Likes
1,156

I was right - it is a much happier place.