Page 1 of 1

When to split up code in OOP

Posted: Sun Nov 24, 2013 11:52 pm
by Xaos
So. I'm learning Java and I'm working on some practice stuff. I just have one issue. I get the concepts, I know the basic stuff, all of that good stuff. I just don't know when to split stuff up into different classes, methods, objects, etc. When exactly should you split something into a new object, or a new method, or a new class? I get it's something like this:


Class - Cabinet
Object - Big Cup, Little Cup
Method - Cabinet Open, Cabinet Close, Remove Big Cup, Remove Little Cup, Place Big Cup, Place Little Cup

So should all of those things be separated? Or should Add a Cup be one method with the options to do little or big with removing the same way? Are the methods similar to functions in PHP?

OR is all of this dumb and I should just code and find out? ;)

Re: When to split up code in OOP

Posted: Mon Nov 25, 2013 1:19 am
by Jackolantern
That looks about right to me :)

And yes, methods are just functions inside of classes.

But yes, the only way to really get a grip on it is to just work with it. It is all going to take practice :)

Re: When to split up code in OOP

Posted: Tue Nov 26, 2013 8:16 pm
by Chris
OOP comes from the technical specification. It's a theory which helps translate use-cases to machine code.