Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Class size to make the most of OOP  (Read 809 times)
0 Members and 1 Guest are viewing this topic.
Offline Rakso

Junior Member


Medals: 1



« Posted 2013-05-02 18:59:01 »

This might seem like a stupid question, Im trying to dicsuss now with you how you see on the subject and im not after a real answear. What i want is to build my own view on the following subject.

EDIT: For you who didn't know already OOP stands for Object Oriented Programming

When is a java class becoming too big?
How many lines / methods do you try to make per class?
How do you think the above question effecrts your programming?
Do you prefer smaller or bigger classes?
Do you consider OOP be few big classes or many small classes?
Does having many small classes affect you negative?
Does having many big classes affect you negative?

Hoping to start a discussion with spread oppinions Smiley
Online Jimmt
« League of Dukes »

JGO Kernel


Medals: 128
Projects: 4
Exp: 3 years



« Reply #1 - Posted 2013-05-02 19:16:07 »

You are thinking about this entirely wrong. It's not about the size of classes, it's about making the correct sized classes to have working, efficient and managable code.
Offline Rakso

Junior Member


Medals: 1



« Reply #2 - Posted 2013-05-02 19:19:32 »

Quote
Im trying to dicsuss now with you how you see on the subject and im not after a real answear.

Thats what i said. I want your oppinions on the topic. Im not thinking of that classes have to be this or that size...
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline quew8

JGO Coder


Medals: 29



« Reply #3 - Posted 2013-05-02 19:59:45 »

For me, it depends completely on the purpose of the class, generally I will have a couple "big" classes (this is all relative btw) then the bulk of the code in several "medium" classes and then a scattering of small classes serving as data structures. But all of this is just how the code manifests itself. I do not plan anything at all on a large scale (at least in so far as what classes is concerned, often I have quite a problem coming up with a good name for a class). A class should serve a purpose or represent a single thing. You should make it as long as is required to serve the purpose and no longer.
Einstein:
Quote
We should make things as simple as possible but no simpler.
Offline actual

JGO Coder


Medals: 23



« Reply #4 - Posted 2013-05-02 20:20:13 »


I have found myself moving towards classes with fewer but longer methods. The main reason for this is thinking about objects in terms of domain behavior rather than data + functions.

* I no longer reflexively create getters and setters for all of my fields. I only create one if it is absolutely necessary.
* I no longer write methods "just in case". I don't write a method until there is behavior that I actually need that doesn't currently exist.
* I no longer preemptively break methods into small pieces. I only pull code out of a method if that code is going to be called from multiple places, or if it's something that needs to vary between subclasses.
* I take "Tell don't ask" more seriously.


I found that doing this has made my code easier to understand and the interactions between objects are simplified.
Offline 65K
« Reply #5 - Posted 2013-05-02 22:07:23 »

  • do not create God classes
  • methods should be comprehendible at sight
  • but do not split up algorithms for no reason
  • clearly assign tasks and responsibilities to classes and methods, one for each class or method preferably
  • look up separation of concerns
  • as few dependencies as possible

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

ctomni231 (33 views)
2014-07-18 06:55:21

Zero Volt (29 views)
2014-07-17 23:47:54

danieldean (24 views)
2014-07-17 23:41:23

MustardPeter (26 views)
2014-07-16 23:30:00

Cero (41 views)
2014-07-16 00:42:17

Riven (43 views)
2014-07-14 18:02:53

OpenGLShaders (31 views)
2014-07-14 16:23:47

Riven (30 views)
2014-07-14 11:51:35

quew8 (29 views)
2014-07-13 13:57:52

SHC (64 views)
2014-07-12 17:50:04
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!