ABAP - Type-pool or Class of constants
What is the difference between Type-pool and creating a class for constants?
What is better?
My question is for a large group of constants and to be accessible to other groups.
Thank you
EDIT - Thank you for the answers and I will improve my question. I need something to store constants and I will use them on programs or other classes. Basically, I wanted to know if it is better to use a type-pool or a class with constants (only). I can have more than one class or type-pool.
sap abap
add a comment |
What is the difference between Type-pool and creating a class for constants?
What is better?
My question is for a large group of constants and to be accessible to other groups.
Thank you
EDIT - Thank you for the answers and I will improve my question. I need something to store constants and I will use them on programs or other classes. Basically, I wanted to know if it is better to use a type-pool or a class with constants (only). I can have more than one class or type-pool.
sap abap
3
Did you read the documentation? "type groups are obsolete and should no longer be created"
– petul
Nov 20 at 18:44
@petul more than a comment, it's a good answer
– Sandra Rossi
Nov 20 at 18:46
@petul yes I did that first, but my question was beyond from what is in the documentation. This was presented to me at work because a senior told that type-pools can do somethings that classes with constants don't and those things were useful. So they told me to search for it, I tried before coming here. Sorry if I didn't made the question very well.
– Rafiki
Nov 21 at 21:19
add a comment |
What is the difference between Type-pool and creating a class for constants?
What is better?
My question is for a large group of constants and to be accessible to other groups.
Thank you
EDIT - Thank you for the answers and I will improve my question. I need something to store constants and I will use them on programs or other classes. Basically, I wanted to know if it is better to use a type-pool or a class with constants (only). I can have more than one class or type-pool.
sap abap
What is the difference between Type-pool and creating a class for constants?
What is better?
My question is for a large group of constants and to be accessible to other groups.
Thank you
EDIT - Thank you for the answers and I will improve my question. I need something to store constants and I will use them on programs or other classes. Basically, I wanted to know if it is better to use a type-pool or a class with constants (only). I can have more than one class or type-pool.
sap abap
sap abap
edited Nov 22 at 12:55
asked Nov 20 at 18:27
Rafiki
114
114
3
Did you read the documentation? "type groups are obsolete and should no longer be created"
– petul
Nov 20 at 18:44
@petul more than a comment, it's a good answer
– Sandra Rossi
Nov 20 at 18:46
@petul yes I did that first, but my question was beyond from what is in the documentation. This was presented to me at work because a senior told that type-pools can do somethings that classes with constants don't and those things were useful. So they told me to search for it, I tried before coming here. Sorry if I didn't made the question very well.
– Rafiki
Nov 21 at 21:19
add a comment |
3
Did you read the documentation? "type groups are obsolete and should no longer be created"
– petul
Nov 20 at 18:44
@petul more than a comment, it's a good answer
– Sandra Rossi
Nov 20 at 18:46
@petul yes I did that first, but my question was beyond from what is in the documentation. This was presented to me at work because a senior told that type-pools can do somethings that classes with constants don't and those things were useful. So they told me to search for it, I tried before coming here. Sorry if I didn't made the question very well.
– Rafiki
Nov 21 at 21:19
3
3
Did you read the documentation? "type groups are obsolete and should no longer be created"
– petul
Nov 20 at 18:44
Did you read the documentation? "type groups are obsolete and should no longer be created"
– petul
Nov 20 at 18:44
@petul more than a comment, it's a good answer
– Sandra Rossi
Nov 20 at 18:46
@petul more than a comment, it's a good answer
– Sandra Rossi
Nov 20 at 18:46
@petul yes I did that first, but my question was beyond from what is in the documentation. This was presented to me at work because a senior told that type-pools can do somethings that classes with constants don't and those things were useful. So they told me to search for it, I tried before coming here. Sorry if I didn't made the question very well.
– Rafiki
Nov 21 at 21:19
@petul yes I did that first, but my question was beyond from what is in the documentation. This was presented to me at work because a senior told that type-pools can do somethings that classes with constants don't and those things were useful. So they told me to search for it, I tried before coming here. Sorry if I didn't made the question very well.
– Rafiki
Nov 21 at 21:19
add a comment |
2 Answers
2
active
oldest
votes
The documentation mentions this:
Since it is possible to also define data types and constants in the public visibility section of global classes, type groups are obsolete and should no longer be created. Existing type groups can still be used.
A sensibly named interface with the constants you desire is the way to go. An additional benefit is that ABAP OO enforces some more rules.
Is there any case that type-pools would be better than classes for constants? Thank you for your answer :)
– Rafiki
Nov 21 at 21:21
add a comment |
Agree with @petul's answer, except for one detail: I'd recommend creating one enumeration-like class per logical group of constants, instead of collecting constants in interfaces.
Consider using the new enum language feature for specifying the constant values.
Interfaces can be accidentally "implemented", which doesn't make sense here. Classes can prevent this with final.
Making one class per logical group simplifies finding the constants with IDE features such as Ctrl+Shift+A search in the ABAP Development Tools. Constants that are randomly thrown together into interfaces are hard to find later on.
Classes allow adding enumeration-like helper methods like converters, existence checks, numbering all values.
Classes also allow adding unit tests, such as ensuring that the constant collection is still in sync with the fixed values of an underlying domain.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53399283%2fabap-type-pool-or-class-of-constants%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The documentation mentions this:
Since it is possible to also define data types and constants in the public visibility section of global classes, type groups are obsolete and should no longer be created. Existing type groups can still be used.
A sensibly named interface with the constants you desire is the way to go. An additional benefit is that ABAP OO enforces some more rules.
Is there any case that type-pools would be better than classes for constants? Thank you for your answer :)
– Rafiki
Nov 21 at 21:21
add a comment |
The documentation mentions this:
Since it is possible to also define data types and constants in the public visibility section of global classes, type groups are obsolete and should no longer be created. Existing type groups can still be used.
A sensibly named interface with the constants you desire is the way to go. An additional benefit is that ABAP OO enforces some more rules.
Is there any case that type-pools would be better than classes for constants? Thank you for your answer :)
– Rafiki
Nov 21 at 21:21
add a comment |
The documentation mentions this:
Since it is possible to also define data types and constants in the public visibility section of global classes, type groups are obsolete and should no longer be created. Existing type groups can still be used.
A sensibly named interface with the constants you desire is the way to go. An additional benefit is that ABAP OO enforces some more rules.
The documentation mentions this:
Since it is possible to also define data types and constants in the public visibility section of global classes, type groups are obsolete and should no longer be created. Existing type groups can still be used.
A sensibly named interface with the constants you desire is the way to go. An additional benefit is that ABAP OO enforces some more rules.
answered Nov 20 at 18:53
petul
623512
623512
Is there any case that type-pools would be better than classes for constants? Thank you for your answer :)
– Rafiki
Nov 21 at 21:21
add a comment |
Is there any case that type-pools would be better than classes for constants? Thank you for your answer :)
– Rafiki
Nov 21 at 21:21
Is there any case that type-pools would be better than classes for constants? Thank you for your answer :)
– Rafiki
Nov 21 at 21:21
Is there any case that type-pools would be better than classes for constants? Thank you for your answer :)
– Rafiki
Nov 21 at 21:21
add a comment |
Agree with @petul's answer, except for one detail: I'd recommend creating one enumeration-like class per logical group of constants, instead of collecting constants in interfaces.
Consider using the new enum language feature for specifying the constant values.
Interfaces can be accidentally "implemented", which doesn't make sense here. Classes can prevent this with final.
Making one class per logical group simplifies finding the constants with IDE features such as Ctrl+Shift+A search in the ABAP Development Tools. Constants that are randomly thrown together into interfaces are hard to find later on.
Classes allow adding enumeration-like helper methods like converters, existence checks, numbering all values.
Classes also allow adding unit tests, such as ensuring that the constant collection is still in sync with the fixed values of an underlying domain.
add a comment |
Agree with @petul's answer, except for one detail: I'd recommend creating one enumeration-like class per logical group of constants, instead of collecting constants in interfaces.
Consider using the new enum language feature for specifying the constant values.
Interfaces can be accidentally "implemented", which doesn't make sense here. Classes can prevent this with final.
Making one class per logical group simplifies finding the constants with IDE features such as Ctrl+Shift+A search in the ABAP Development Tools. Constants that are randomly thrown together into interfaces are hard to find later on.
Classes allow adding enumeration-like helper methods like converters, existence checks, numbering all values.
Classes also allow adding unit tests, such as ensuring that the constant collection is still in sync with the fixed values of an underlying domain.
add a comment |
Agree with @petul's answer, except for one detail: I'd recommend creating one enumeration-like class per logical group of constants, instead of collecting constants in interfaces.
Consider using the new enum language feature for specifying the constant values.
Interfaces can be accidentally "implemented", which doesn't make sense here. Classes can prevent this with final.
Making one class per logical group simplifies finding the constants with IDE features such as Ctrl+Shift+A search in the ABAP Development Tools. Constants that are randomly thrown together into interfaces are hard to find later on.
Classes allow adding enumeration-like helper methods like converters, existence checks, numbering all values.
Classes also allow adding unit tests, such as ensuring that the constant collection is still in sync with the fixed values of an underlying domain.
Agree with @petul's answer, except for one detail: I'd recommend creating one enumeration-like class per logical group of constants, instead of collecting constants in interfaces.
Consider using the new enum language feature for specifying the constant values.
Interfaces can be accidentally "implemented", which doesn't make sense here. Classes can prevent this with final.
Making one class per logical group simplifies finding the constants with IDE features such as Ctrl+Shift+A search in the ABAP Development Tools. Constants that are randomly thrown together into interfaces are hard to find later on.
Classes allow adding enumeration-like helper methods like converters, existence checks, numbering all values.
Classes also allow adding unit tests, such as ensuring that the constant collection is still in sync with the fixed values of an underlying domain.
answered Nov 22 at 12:25
Florian
1,125518
1,125518
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53399283%2fabap-type-pool-or-class-of-constants%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
Did you read the documentation? "type groups are obsolete and should no longer be created"
– petul
Nov 20 at 18:44
@petul more than a comment, it's a good answer
– Sandra Rossi
Nov 20 at 18:46
@petul yes I did that first, but my question was beyond from what is in the documentation. This was presented to me at work because a senior told that type-pools can do somethings that classes with constants don't and those things were useful. So they told me to search for it, I tried before coming here. Sorry if I didn't made the question very well.
– Rafiki
Nov 21 at 21:19