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?
When to split up code in OOP
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: When to split up code in OOP
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
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
The indelible lord of tl;dr
Re: When to split up code in OOP
OOP comes from the technical specification. It's a theory which helps translate use-cases to machine code.
Fighting for peace is declaring war on war. If you want peace be peaceful.