Computer programs consist of code and data

…but what is the difference between those two things? I am reading about OOP and the author is making this distinction. He’s saying, “… a program can be conceptually organize around its code or its data.” So around code its process-oriented model and its data its OOP.

It’s hard to say without knowing what the author wrote.

So the data found inside an object.

That’s not enough information. I would need to actually see what was written to understand what the author means. Can you provide the full paragraph?

Yeah, thanks. It seems I cannot copy and past straight from the PDF, but I have a screenshot.

I was able to write some code that made this clear

function employees(name, timeInComp) { = name;
    this.timeInComp = timeInComp;
    this.introduce = function() {return this.timeInComp <= 2} 
let arrr = [];
let employee221 = new employees('Memet', 3);
let employee109 = new employees('Jilles', 1); 
arrr.push(employee109, employee221);

function a1(val) {
    if(val.timeInComp < 5) {
        console.log(`${} has been in the company for less than 5 years`);
    } else if(val.timeInComp > 5) {
        console.log(`${} has been in the company for more than 5 years`);
    if(val.introduce()) {
        console.log(`${} has to introducte himself, because he has been in the company for ${val.timeInComp} year(s)`);

for(let i = 0; i < arrr.length; i++) {

This is cool, because the condition has only to be changed in the class.

By the way, the book I’m referring to is called: Java The Complete Reference. Schildt, Herbert.

I don’t exactly love the wording the author used, but I see what they mean.

In this context, data is the information, like strings and arrays, and ‘code’ is more the logical steps you want to use to manipulate that data.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.