Design Patterns in ABAP.
Hi,
I want to know about the Design Patterns in ABAP.
Regards,
Sourav
hi sourdi
Below are the list of Design pattern in abap .
Singleton: ensuring single class instantiation
Adapter: making class interfaces compatible
Factory: encapsulating object creation
MVC: decoupling business logic from the view
Facade: providing a simplified interface
Composite: treating individual objects and compositions uniformly
Decorator: forming a dynamic chain of components to be used as one by the client
regards
chinnaiya P
Similar Messages
-
Design Pattern and ABAP Objects
Hello Friends,
I would like to know, if ABAP Objects can be used to do pattern oriented programming ?
For example GANG of four has provided almost more then 30 design pattern ( MVC, singelton, Obserable, FACADE,,,etc) can we implement patterns using ABAP ??
Many thanks
Haider SyedHi,
Take a look at the following site:
http://patternshare.org/
It has all the basic patterns from the GOF and a lot more. I can recommend the ones from Martin Fowler but be sure you start with the ones from the GOF.
All patterns are described by using UML so it's very easy to translate them into ABAP OO code.
Regarding your other question. For the observer pattern I used an interface which the SAP had already created if_cm_observer and created my own abstract observable class. The observable class is nearly a 100% copy of the java.util. one
regards
Thomas -
Is abap thread safe? Some question in Singleton pattern in ABAP
Hi Grus,
I have a very basic question but really make me headache...
Recently I am learning the design pattern in ABAP and as you know in JAVA there is a key word "Synchronized" to keep thread safe. But in ABAP, I didn't find any key words like that. So does that mean ABAP is always a single thread language? And I found that there is a way looks like "CALL FUNCTION Remotefunction STARTING NEW TASK Taskname DESTINATION dest" to make multi-thread works. As you can see it use the destination, so does that mean actually the function module is always executed in a remote system, and in every system, it is always single thread?
Could you help me on the question? Thanks a lot, grus
And here comes up to my mind another question...It's a little bit mad but I think it may works....What if I set every attribute and method as static in the singleton class...Since as you can see it is already a singleton so every attribute in it should be only one piece. So then I don't even need to implement a get_instance( ) method to return the instance. Just call "class_name=>some_method( )" directly then singleton is achieved...What do you think?
BR,
SteveSteve,
I've the same question, few days ago I tried to use the singleton in ABAP. In Java programming is possible to use the same reference in two sessions or programs, sharing attributes, methods and all data, but I could not do in ABAP.
In my test I created a program with one global class using the singleton pattern, so I expected that when I run my program and see the reference returned after the get_instance method it should be equal to the same program run in another session, but the ABAP will create a new reference and instantiate again.
So I deduced that the only way to share it between sessions in ABAP is using the ABAP Shared Memory Objects.
I can be wrong, but I think that ABAP use a thread by user session (Each window) and we can't change it.
Best regards. -
Get instance method and design pattern
Hi All,
1. I New to abap objects and i read the help and some stuff from the forum,
l like to now more about design pattern in abap objects,
2. I saw in some abap class the use of method of GET_INSTANCE i think it's from factory pattern , what is the pros. and cons to use this method ,when i should consider to use it ?
Thanks in Advance
NinaHello Nina
A very good introduction into design patterns is the book "Head First: Design Patterns". Here you will find many good reasons why and when to use the factory pattern.
You should use the factory pattern when
- you want to prevent "direct" instantiation (i.e. using a public CONSTRUCTOR method) by the developer
- you want to hide the complexity of instantiation from the user of the class
- the instantiation creates an implementation of an interface and you want to keep control of which implementing class is returned
Regards
Uwe -
Design Patterns in Dynamic Programming
I mentioned this on a thread some time ago - that many of the GoF patterns disappear in languages such as Lisp, but didn't have the reference handy. Came across it again today so I thought I'd post the link:
http://www.norvig.com/design-patterns/
Petehi sourdi
Below are the list of Design pattern in abap .
Singleton: ensuring single class instantiation
Adapter: making class interfaces compatible
Factory: encapsulating object creation
MVC: decoupling business logic from the view
Facade: providing a simplified interface
Composite: treating individual objects and compositions uniformly
Decorator: forming a dynamic chain of components to be used as one by the client
regards
chinnaiya P -
[BOOK] What's the best book about DESIGN PATTERN
Hi Guys,
by experience, what's the best book for you concerning the Design Pattern in Abap. I mean :
Quality,
Comprehensiveness,
Clearness,
Amount of chapter,
etc.
Thank for advices.
Rachid.Dear Rachid,
This is rank 1 book, but u have learn online also. So many websites are there. example search: OO Design patterns ZEVOLVING.
Regards,
Abbas. -
hi all,
can any one send me the Design patterns used for ABAP objects programming in ABAP. eg mvc and sample code which uses the design patterns
cheers
senthilOf course that program is not an object design pattern
(Its just a little ABAP Objects syntax demo that I wrote years ago
I don't know about a list of OO design patterns implemented in ABAP Objects.
A very simple one, a Singleton might look like this:
<b>* cl_singleton: Eager Variant
CLASS cl_singleton DEFINITION FINAL
CREATE PRIVATE.
PUBLIC SECTION.
CLASS-METHODS: class_constructor,
get_singleton RETURNING VALUE(singleton)
TYPE REF TO cl_singleton.
PRIVATE SECTION.
CLASS-DATA singleton TYPE REF TO cl_singleton.
ENDCLASS.
CLASS cl_singleton IMPLEMENTATION.
METHOD class_constructor.
CREATE OBJECT singleton.
ENDMETHOD.
METHOD get_singleton.
singleton = cl_singleton=>singleton.
ENDMETHOD.
ENDCLASS.
cl_singleton: Lazy Variant
CLASS cl_singleton DEFINITION FINAL
CREATE PRIVATE.
PUBLIC SECTION.
CLASS-METHODS get_singleton RETURNING VALUE(singleton)
TYPE REF TO cl_singleton.
PRIVATE SECTION.
CLASS-DATA singleton TYPE REF TO cl_singleton.
ENDCLASS.
CLASS cl_singleton IMPLEMENTATION.
METHOD get_singleton.
IF cl_singleton=>singleton IS INITIAL.
CREATE OBJECT cl_singleton=>singleton.
ENDIF.
singleton = cl_singleton=>singleton.
ENDMETHOD.
ENDCLASS.</b> -
ABAP Object X Design Patterns X Extreme Program
Hi Evebody,
Im postgraduate in Object Oriented Analysis and Programming.
Ive been working with ABAP procedural development for two years and Ive started to work with ABAP Objects has few months.
Id like to get deeply knowledge in my developments skills, could someone tell me if <b>ABAP Object X Designer Patterns X Extreme Program</b> is a good path to follow?
Id like to share material and guides about this topic.
Ive already bought these books to help me.
<b>ABAP Objects</b> - H. Keller; Hardcover <i>(Pre-Order)</i>
<b>Design Patterns Explained</b> - Alan Shalloway
Ill be very grateful with any help.> And do you think these themes are a great combination
> for ABAP development?
Design pattern are very abstract and can be used with any OO programming language. The implementations will differ but the core concepts are always the same.
XP is an agile development process and can also be used with any programming language.
Learning what design pattern are and how to use them is very important in my opinion. Most companies expect that you are familiar and have experience with them.
Extreme Programming (XP) on the other side is different. When I began to explore XP it got me started on how software should be developed in general. Since the concepts behind XP are quite different, it should at least stimulate you to start thinking about how you develop software at the moment and if there might be better ways of doing it.
If you have only time to study one subject go for the design pattern. You might also consider reading the following books if you want to improve your OO coding skills:
<a href="http://www.amazon.com/Refactoring-Improving-Design-Existing-Code/dp/0201485672/ref=pd_bbs_sr_1/102-4989641-7820932?ie=UTF8&s=books&qid=1173448197&sr=8-1">Refactoring: Improving the Design of Existing Code (a true classic)</a>
<a href="http://www.amazon.com/Refactoring-Patterns-Addison-Wesley-Signature-Kerievsky/dp/0321213351/ref=pd_bbs_sr_2/102-4989641-7820932?ie=UTF8&s=books&qid=1173448197&sr=8-2">Refactoring to Patterns (Shows how to improve code by introducing design pattern)</a>
cheers
Thomas -
Observer Design Pattern: Looking for redesign ABAP OO code example
Hello folks,
I am looking for an example for ABAP OO code that has been redesigned by applying the Observer Design Pattern. I would be very interested in both the code before as well as the code after the pattern is being applied.
Thanks in advance and kind regards, AlexObserver can be implemented using the EVENTS.
I had recently implemented the observer at one of my client's place. I had screen with so many ALVs. One ALV was kind of editable and other were just showing the information of the current row as well as some total information. So, initially I started with the Main ALV and SUB(1 and 2) for other ALVs. Now, when I need to refresh my ALVs based on the main ALV data, I had to explicitly update the data of the each Sub ALV. The code was kind of static and requirement was not yet fixed.
Later on we need to add one more ALV on the same screen. It was easy to change the existing method where I was doing the explicit refresh of each ALV. But I thought of using the Events.
I created an event REFRESH_DETAILS for main ALV. so, when data gets changed (which I was catching by DATA_CHANGED event of ALV), I raise the event.
RAISE EVENT REFRESH_DETAILS
exporting new_data = it_Data.
In Sub ALVs, I created the event handler method to handle the event REFRESH_DETAILS of the main ALV.
methods: handle_refresh_details
for event REFRESH_DETAILS of ZCL_MAIN_ALV.
I also had to register the Handler.
SET HANDLER me->handle_refresh_details FOR ALL INSTANCES.
I'll soon write a post on my [ABAP Help blog|http://help-abap.zevolving.com/] with all the details.
Regards,
Naimesh Patel -
Hi Everyone ,
What are design pattern in Object Oriented ABAP.
How will we know that which pattern suits the particular scenario.
Thanks
SandeepHi,
yes its not free, but its really worth the money.
Other abap specific sources:
http://wiki.sdn.sap.com/wiki/display/ABAP/ABAPObjectsDesignPatterns-ModelViewController%28MVC%29
http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=%28J2EE3417200%29ID0796789650DB21029243082976783901End?blog=/pub/wlg/606
/people/marcelo.ramos/blog/2008/04/30/sapmvc-a-new-mvc-for-classical-abap-dynpro
Greetings,
DSP -
Implementing DAO Pattern in ABAP
This discussion implement DAO pattern asked the question of how to develop a DAO pattern in ABAP but i'd like to go a little deeper.
The only answer given suggested the following design pattern:
I don't have an coded example here, but isn't it sufficient for this pattern to build an interface with some get- and set-methods? This interface can be implemented by several classes with different data retrieval logic. Then a static factory-method could do the job to decide during runtime which actual class is instantiated, returning the interface.
Can anyone give an abstract description of this implementation relative to an SAP module (How would one approach this implementation in MM, PM, FICO, HR)
Can anyone see any issues in this design?
Can anyone provide an alternate design?
Are we missing any steps?
Together we can build a solid abap DAO everyone can use.I started to read about DAO pattern some days ago and found this great blog post:
ABAP Unit Tests without database dependency - DAO concept
I am starting to implement unit test in my developments and DAO pattern seems to be a clever choice.
Regards,
Felipe -
Hello,
does exist a collection of design patterns for developing webdynpro for abap?
Best regards
Oliver Prodingerhi
good
go through this links hope these would help you to solve your problem
http://www.sap-press.de/download/dateien/1079/sappress_web_dynpro_for_abap.pdf
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6081997d-b33d-2a10-2ea5-f945b3467927
thanks
mrutyun^ -
What is a design pattern?
Howdy,
I hear a lot of talk of deasign patterns in ABAP...
My question is what on earth is a design pattern and why/how would it be useful?
Any ideas anyoneHi Steve.
The good point to start with design patterns is to read book "Design Patterns - Elements of Reusable Object-Oriented Software" by Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides. It gives strong, consistent understanding of patterns basis with real life examples.
Short introduction extract:
"Christopher Alexander says, "Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice". Even though Alexander was talking about patterns in buildings and towns, what he says is true about object-oriented design patterns. Our solutions are expressed in terms of objects and interfaces instead of walls and doors, but at the core of both kinds of patterns is a solution to a problem in a context.
In general, a pattern has four essential elements:
The pattern name is a handle we can use to describe a design problem, its solutions, and consequences in a word or two. Naming a pattern immediately increases our design vocabulary. It lets us design at a higher level of abstraction. Having a vocabulary for patterns lets us talk about them with our colleagues, in our documentation, and even to ourselves. It makes it easier to think about designs and to communicate them and their trade-offs to others. Finding good names has been one of the hardest parts of developing our catalog.
The problem describes when to apply the pattern. It explains the problem and its context. It might describe specific design problems such as how to represent algorithms as objects. It might describe class or object structures that are symptomatic of an inflexible design. Sometimes the problem will include a list of conditions that must be met before it makes sense to apply the pattern.
The solution describes the elements that make up the design, their relationships, responsibilities, and collaborations. The solution doesn't describe a particular concrete design or implementation, because a pattern is like a template that can be applied in many different situations. Instead, the pattern provides an abstract description of a design problem and how a general arrangement of elements (classes and objects in our case) solves it.
The consequences are the results and trade-offs of applying the pattern. Though consequences are often unvoiced when we describe design decisions, they are critical for evaluating design alternatives and for understanding the costs and benefits of applying the pattern. The consequences for software often concern space and time trade-offs. They may address language and implementation issues as well. Since reuse is often a factor in object-oriented design, the consequences of a pattern include its impact on a system's flexibility, extensibility, or portability. Listing these consequences explicitly helps you understand and evaluate them."
Regards,
Maxim. -
How can I develop a web application using EJB design pattern?
I have searched over the web and found quite a lot of tutorials on how to use the EJB design pattern.
I know that there will be a home interface, EJB object interface and a SessionBean.
But the tutorials often only cover a single class, this made me unable to get a complete picture of how EJB design pattern can be implemented into a whole system.
I am now required to devleop an online shopping web application using EJB and JSP page.
I think I will need to create a lot of classes: Member, ShoppingCart, Product...etc.
What I want to ask is that, do I need to create a home interface, EJB object interface and a SessionBean for each of these classes?
I really need some ideas on how to develop this system using EJB + JSP pages.
Many thanks to you all.For every EJB that you want to create, you will need to code a home and remote interface and a bean class.
You could start getting your ideas here
http://www.theserverside.com/books/wiley/masteringEJB/
http://www.coreservlets.com -
SERVICE LOCATOR ?? Is it really an interesting Design pattern??
Hi everybody,
i've a problem with the J2EE Design Pattern "Services locator" (it's a singleton).
It is said that by making use of a Service Locator we can :
- hide to the client the complexities of initial context creation, EJB home object lookup,and EJB objectre-creation.
- multiple clients can reuse the Service Locator object to reduce code complexity, provide a single point of control, and improve performance by providing a caching facility.
But i would like to understand at which side should that service locator object reside??!!??
If it is at server side then the clients need well an initial context in order to make a lookup on that object.
Conclusion :
the service locator doesn't hide the complexities of initial context!!
Furthermore the client has to perform a look-up on that service locator object!! The only advantage left is caching facility.
If it is at client side, each client needs his own services locator object
Conclusion :
multiple client don't reuse the same service locator. What's the advantage to be a singleton ???
There is certainly something that i don't understand so help me please!! Thanks.Hi Yves,
But i would like to understand at which side should
that service locator object reside??!!??
If it is at client side, each client needs his own
services locator object
Conclusion :
multiple client don't reuse the same service locator.
What's the advantage to be a singleton ???The service locator resides on the client side and is implemented as
a singleton. Since it is possible that there could be multiple
class loaders/JVMs on the client side, and therefore, multiple
instances of the "singleton" service locator. This is typical
in a distributed environment (e.g. servlets/JSPs in a web-tier
cluster using service locator). Thus service locator is not
a truly "distributed singleton" object. But, the empahsis
is to design the service locator such that it does not hold
any state that needs to be replicated across multiple
instances across different JVMs as mentioned. Thus, there
is no need for multiple clients to use the "same" service locator,
but still the benefits of implementing this pattern is realized.
By making it a singleton, and keeping it from holding state
that needs to be replicated, we realize the benefits of this pattern.
You may also want to visit the J2EE Pattern interest list
and see these relevant discussions :
Topic: Service Locator and passivation
http://archives.java.sun.com/cgi-bin/wa?A2=ind0106&L=j2eepatterns-interest&F=&S=&P=1026
Topic: Caching EJBHome interfaces
http://archives.java.sun.com/cgi-bin/wa?A2=ind0106&L=j2eepatterns-interest&F=&S=&P=9226
Topic: Using Service Locator for Data Source caching
http://archives.java.sun.com/cgi-bin/wa?A1=ind0106&L=j2eepatterns-interest#31
hope this helps,
thanks,
-deepak
Maybe you are looking for
-
Photoshop Elements 8. "Could not use Clone Stamp Tool because of a program error." Please help.
-
[AS] getting valure of color
Hi how would I go about getting the value of a color? I have tried the below but it errrors "Adobe InDesign CS3 got an error: Invalid parameter." tell application "Adobe InDesign CS3" activate set _myDoc to active document tell _myDoc
-
BT telephone and broadband package
Hello, I am currently paying telephone line rental to BT (Line Rental Saver) and have a Carrier Pre Select (CPS) service (Sky Talk Unlimited) on my line. My current broadband provider is O2 ADSL Standard (legacy). I was thinking of switching all my
-
Can't connect to livebox to use wifi
Hi, my mum has just got a curve 8520 so I've been trying to set up the wifi on it to use with our orange livebox, my dad and I have the same phone and I've connected those to the livebox with no problems but I just can't get her one to connect. I've
-
Jre 1.4.1 with IE5 and Mozilla MAC OS X
Hi, I just installed the JRE 1.4.1 on Mac OS X. It's working fine with the apple's browser SAFARI. But my other browsers,IE5 an Mozilla, still launch the applets in the JRE 1.3.1. Is there a way to force IE5 and Mozilla to use the 1.4.1 jre ? Thank y