Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 months ago.
Improve this questionI'm a beginner, actually this semester I have to research about Cobol language. On the internet, there are few example, eve开发者_Go百科n no example about OOP cobol. There are only st like example for theory, they doesn't show me how to add st more ( like a main in Java ) to see the program work. I have some codes like this:
class-id. A data is protected
inherits from Base.
object section.
method-id. "newWithData"
linkage section.
01 lnkObject object reference.
01 lnkName pic x(80).
procedure division using lnkName
returning lnkObject.
*----Create a new instance of A using the "new" method from Base
invoke super "new" returning lnkObject
*----Send it an initialize message.
invoke lnkObject "initialize" using lnkName
exit method.
end method "newWithData".
object.
object-storage section.
01 theName pic x(80).
...
method-id. "initialize"
linkage section.
01 lnkName pic x(80).
procedure division using lnkName.
*----Store the initialization parameter in the object's
* instance data
move lnkName to theName
exit method.
end method "initialize".
end object.
end class "A".
but I don't know how to run (both theory and practice). Can any one show me how? It will be best helping me with another example and explanation.
This really doesn't count as an answer to your question. A comment added to your original question indicated that your assignment is to study and report on the COBOL language and paradigm. If that is your goal, I would not recommend getting into OO COBOL except as a side-bar issue.
Object oriented extensions to COBOL are, in my opinion, a marketing tool. OO extensions boil down to window dressing and are not a good fit with respect to the origins and traditional strengths of the language. The nicest thing I can say about OO extensions to COBOL are that they may ease some interfacing issues encountered when trying to build Java or other OO based front ends for COBOL transaction processing back ends. And I am not completely convinced of this either.
COBOL is an excellent language for doing certain tasks in certain environments. See: What makes COBOL such a hated language
The COBOL paradigm is that of a third generation imperative language. It is naturally suited to structured programming where the design emphasis is around "processes" as opposed to "objects". Take COBOL for what it is, and learn to love it.
There is no such thing like "COBOL paradigm". Don't forget that COBOL is born as a procedural language (with verbose syntax) and therefore "traditional" COBOL followes the paradigm of procedural/structured programming. It's very old but it's still used today, especially in legacy financiary applications. OO COBOL is an extension to this, which means that some additional syntax is added to allow things like object creation, inheritance, etc...By the time it was created, a lot of (better) OO languages were available, so it's largely ignored either in the industry or in the research. However, a few resources are available: this website, this tutorial, I even found a number of books about OO COBOL in this bibliography..
精彩评论