Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
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 1932 times)
0 Members and 1 Guest are viewing this topic.
Offline Rakso

Junior Devvie

Medals: 1

« Posted 2013-05-02 16: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
Offline Jimmt
« League of Dukes »

JGO Kernel

Medals: 167
Projects: 5
Exp: 6 years

« Reply #1 - Posted 2013-05-02 17: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 Devvie

Medals: 1

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

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 Knight

Medals: 53

« Reply #3 - Posted 2013-05-02 17: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.
We should make things as simple as possible but no simpler.
Offline actual

JGO Coder

Medals: 25

« Reply #4 - Posted 2013-05-02 18: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 20: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

Lethal Running - a RPG about a deadly game show held in a futuristic dystopian society.
Pages: [1]
  ignore  |  Print  

EgonOlsen (42 views)
2018-06-10 19:43:48

EgonOlsen (22 views)
2018-06-10 19:43:44

EgonOlsen (43 views)
2018-06-10 19:43:20

DesertCoockie (197 views)
2018-05-13 18:23:11

nelsongames (124 views)
2018-04-24 18:15:36

nelsongames (123 views)
2018-04-24 18:14:32

ivj94 (863 views)
2018-03-24 14:47:39

ivj94 (124 views)
2018-03-24 14:46:31

ivj94 (768 views)
2018-03-24 14:43:53

Solater (140 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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‑
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!