0

I'm new to SO, so if I've done this wrong, please point me in the right direction.

I think this is a bit of an awkward question, because I'm not so great at articulating my thoughts.

At university, we are taught that a java class which is written to be an object, with constructors, getters, setters, etc, are called "Container Classes". They contain data about themselves(a name attribute, for instance).

My question is what are other types of classes? For instance, you have to have a class where you create and manipulate your objects. For a small program this isn't a problem(just put it into the main class/method). For a larger program this would be silly and unmanageable, so obviously you create other classes. I've taken to naming mine "Handler"s. I have a "FileHandler" an "ObjectHandler", etc.

What type of class are these? Are there other class types out there?

Edit: To clarify, I'm wondering about what to call a category of classes, such as classes that are designed to do specific things. Helper classes? Utility classes?

Final Edit: I answered my own question here: https://stackoverflow.com/a/43964279/7985805

Community
  • 1
  • 1
Mav986
  • 1
  • 2
  • 5
    ***At university, we are taught that a java class which is itself an object...*** quit that uni asap!!!! – ΦXocę 웃 Пepeúpa ツ May 09 '17 at 11:17
  • 2
    A class is not an object, it is an object blueprint. Also, this is not a programming question. – DKIT May 09 '17 at 11:17
  • here, you can find ,https://docs.oracle.com/javase/7/docs/api/java/lang/Class.html – parlad May 09 '17 at 11:19
  • 1
    Your question reads as if your looking for a design pattern as [MVC for example](http://stackoverflow.com/questions/129921/what-is-mvc-model-view-controller). At least the second part of it – SomeJavaGuy May 09 '17 at 11:19
  • A `Java class type` is a very broad question, you can categorize them depending on a lot of criteria: `access level`, `inheritance`, purpose, the `design pattern` they implement. For a few of them, check [this link](https://www.quora.com/What-are-the-different-types-of-classes-in-Java). – aUserHimself May 09 '17 at 11:26
  • ΦXocę 웃 Пepeúpa ツ Ah you misread what I said. I meant that a java class that is designed as an object. Not that all classes are objects :) DKIT sorry, not really sure why it's landed in the "programming" subforum or whatever it's called. – Mav986 May 09 '17 at 13:43

3 Answers3

3

At university, we are taught that a java class which is itself an object

I would have to disagree here, classes are templates for objects, you can think of them as containing a description of a particular object i.e. the object states, the behaviours that object can perform etc. An object is an instance of a class thus a class is not an object.

My question is what are other types of classes?

A class can be any type, it just depends on what you're attempting to accomplish e.g. when making a space invaders game, you could have a class of type Alien(enemies), a class of type Defender(the shooter), a class of type Bullet which the Defender can use to shoot the Aliens etc.

Ousmane D.
  • 54,915
  • 8
  • 91
  • 126
  • Sorry, mistranslation. We are not taught that all classes are objects, I was simply saying "a class which is designed to be an object" for use in my example. Also, with regards to 'class types', I am not referring to 'object types'. We are taught that a class "that has been developed to be an object" (ie. a class with constructors, getters/setters, etc) is called a "Container Class". How can I refer to a class which is NOT a Container Class? – Mav986 May 09 '17 at 13:44
0

In my opinion if you call 'classes' 'container classes' you are only adding a redundant word.

In larger programs there could be some kind of classes that have the same purpose, e.g there could be ModelData classes, which only hold data: like employee, contract, ComplicatedCalculationResult; or there could be handler classes: FileHandler, MouseHandler, ... But all this is not set to a fixed wording.

You can name your class as it seems fit. At best name it so that someone else can guess what the class is for.

M. Haverbier
  • 383
  • 2
  • 13
0

So it turns out after a bit of research, the "class types" I was trying to find names for are actually called "Design Patterns". Things like Builders, Factories, Adapters, etc.

I found a handy tutorial explaining them in further depth here: https://www.tutorialspoint.com/design_pattern/design_pattern_overview.htm

Thanks for trying to answer my very badly worded question. As I said, I'm terrible at trying to explain what I want to say.

Mav986
  • 1
  • 2