-1

I saw an answer on SO which said that just having a class with methods doesn't make it OOP and that it represents Class Oriented Design.

I'd like to hear the differences between Class Oriented Design and Object-Oriented Design also want to know how can I sense Class Oriented Design in a codebase?

6
  • 3
    This can mean a few different things depending on context. In what context did you hear it?
    – JacquesB
    Apr 27, 2021 at 8:24
  • @JacquesB The context is where the code don't care about Object responsibility..
    – jeffbRTC
    Apr 27, 2021 at 9:38
  • I found where I heard it, it's from softwareengineering.stackexchange.com/questions/187764/…
    – jeffbRTC
    Apr 27, 2021 at 11:15
  • 3
    Note that the author of that post put "class-oriented" in "air-quotes." This is a clear indication that they didn't mean it as an "official" term. Apr 27, 2021 at 13:17
  • A static class with only methods is just an excuse to have a function library and call "Hey, we're fully object oriented." see: java.lang.Math
    – Pieter B
    Apr 29, 2021 at 6:41

3 Answers 3

7

I think you're misreading an opinionated statement as being a literal statement of fact.

I saw an answer on SO which said that just having a class with methods doesn't make it OOP and that it represents Class Oriented Design.

If I really like cars, and I have a distaste for cheap foreign vehicles, I could tell my friend who drives a cheap foreign car "just because it has four wheels and an engine doesn't make it a car, you know", and then my friend then takes this as truth and goes around looking for an answer to what the definition of a car is.

This is the position you find yourself in. You took what you heard as the literal truth and are now on a search for the answer that confirms what you heard.

What you heard wasn't literal truth. It is known as the "No True Scotsman" fallacy, whereby the speaker argues that a commonly understood definition, i.e. Scotsman, should be applied more restrictively. Instead of "person from Scotland", the speaker argues it should be "person from Scotland who doesn't put sugar on his porridge".

The problem here is that the speaker willfully redefines a commonly understood concept just to argue their point. While their underlying point may or may not be valid, silently changing definitions is a sign of poor communication skills as it does nothing but add confusion, just to not have to acknowledge something you don't like (such as sugar on your porridge, I guess).

The same is happening here. (Non-static) classes lie at the base of OOP design. However, the speaker is arguing that one can still use classes badly, and therefore such bad usage is "not true OOP". I don't quite disagree with their underlying argument, but I disagree with their conclusion and how they try to label it.

I'm not saying he's wrong per se, there is merit to his argument, but he's trying to argue about a purer form of OOP and is wrongly calling everything else "not OOP", instead of admitting it's "just not very pure OOP". It's at the very least an overstatement, which sadly detracts from the value of the underlying opinion which may actually contain value.


That being said, I'm not going to claim that I've never pulled a "no true ..." claim, but I'd like to think that I only do so when it is clear that I'm expressing a personal opinion rather than an objective truth, so it is clear that I'm talking about a personal definition rather than a common one.


Feel free to correct me if I'm wrong, but based on your question/comments I surmise you are a beginner who is learning about OOP. It's good that you're trying to think critically about what others say, but beware taking things too literally.
The internet is filled with people who tout personal opinion as if it were objective fact, and especially in abstract fields such as software development, it's easy to be misled by someone's assertions.

6
  • 4
    This is the danger of basing your body of knowledge on word definitions. I hear "is there a term for this concept" asked all the time, when the proper questions should be "how does this work" and "what can I use it for." Apr 27, 2021 at 13:17
  • @RobertHarvey 100% agree. Anecdotally, I once almost failed an interview (as a junior) because I didn't know what "string immutability" was. But one of the panel asked why string+string is a bad idea and I could answer in long detail about strings not changing after initialization, needing new memory per new string, using string builders, ... I just didn't know what the word "immutable" meant (note: neither me nor the interviewers were from a native English speaking background)
    – Flater
    Apr 27, 2021 at 13:20
  • 1
    "(Non-static) classes are the basic foundation of OOP design" – No, they aren't. Objects are the basic foundation of OOP design. Hence why it is called "object-oriented", not "class-oriented". Apr 27, 2021 at 17:59
  • What actually is a Scotsman, though? There is no generally accepted definition of what "object-oriented" really means, beyond that it has something to do objects (whatever those are). I've seen people use the term to mean any and all of: "classes", "inheritance", "polymorphism", "dynamic dispatch", "encapsulation", "message-passing", "SOLID", "code reuse", "modular", "abstract", "complicated", and even just "nice". I would not accuse the author of the other post of NTS just because they used a narrower definition than whatever one you're using.
    – trent
    Apr 27, 2021 at 19:02
  • 1
    @JörgWMittag: That's a semantical splitting of hairs. Objects have a type, and that type is generally speaking a class. While it's not theoretically impossible to have object-oriented code without specific typing, in reality the concept of objects and classes go and in hand. However, I'll rephrase my statement to say that classes lie at the base of OOP, which is what I wanted to say (instead of implying they alone are the foundation of OOP, which indeed they are not)
    – Flater
    Apr 28, 2021 at 8:25
0

This can mean a few different things depending on context. I don't think Class-Oriented Design is standard term.

Class-Oriented design can refer to object-oriented design using classes. Many OOP languages uses classes (e.g Java, C++) but not all. For example earlier versions of JavaScript did not have classes but used prototypes for inheritance. So class-oriented design is a subset of object oriented design.

But in Java it is also possible to have classes without objects. E.g. if you have only static methods on classes, then you don't have an object oriented design, for better or worse. This could also be what was referred to.

It might also refer to the antipattern where code tries to model real-world entities and taxonomy as classes, e.g. the infamous "a Dog is a subclass of Animal"-examples.

1
  • I'm not sure I agree that modelling real-world entities and taxonomy as classes is an antipattern in such a blanket way. Sure, there are bad ways implementing a taxonomy using classes, but there are several times where modeling things like that can make a lot of sense. It isn't because one can use a pattern in a bad way that it is automatically an antipattern.
    – T. Sar
    Apr 27, 2021 at 14:21
0

I think two things have been mixed.

  1. having a class with methods doesn't make it OOP

This is true. You create a class, dump a lot of members and methods in it but don't care about behavior boundaries and class responsibilities.

  1. it represents Class Oriented Design.

This statement is false. Class Oriented design is the way a language provides inheritance opposed to Prototype Oriented Design. The first one is used in C++ or Java where classes extend other classes, the later is used in ECMAScript (javascript, typescript).

2
  • @JazyZ C with classes refers to writing C-style C++ eg raw pointers, char without Modern C++ features..
    – jeffbRTC
    Apr 27, 2021 at 9:40
  • Indeed C with class is more than missusing classes
    – JayZ
    Apr 27, 2021 at 11:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.