Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Splitting objects into their most fundamental parts

Not sure if the title captures what I'm trying to say here.

When designing in OO should I be splitting my objects up into their most specific areas - so if I have a factory object that deals with creating objects but later on i come across a way of creating objects for another purpose even though they may be the same objects is it worth creating a seperate fcatory or just add to the exsiting.

My biggest worry is bulking up classes with tons of stuff, or splitting objects and diluting my projects into a sea of classes.

Any help?

EDIT:

I guess on a side note/sub topic part of me wants to find out the level of granularity you should use in a program. Kind of, how low should you go?

like image 572
Julio Avatar asked Oct 29 '10 15:10

Julio


People also ask

What is splitting of something into two parts is known as?

bisect. verb. to divide something into two equal halves, especially in mathematics.

What is object splitting?

Central to object relations theory is the notion of splitting, which can be described as the mental separation of objects into "good" and "bad" parts and the subsequent repression of the "bad," or anxiety-provoking, aspects (Klein, 1932; 1935).

What is splitting according to Freud?

To characterize these cases Freud defined splitting of consciousness as a process of oscillation between two different psychical complexes, which become conscious and unconscious in alteration (Freud, 1912, p. 2850).

What is an example of splitting in psychology?

Examples of splitting behavior may include: Opportunities can either have "no risk" or be a "complete con" People can either be "evil" and "crooked" or "angels" and "perfect" Science, history, or news is either a "complete fact" or a "complete lie" Things are either "always" or "never"


1 Answers

My biggest worry is bulking up classes with tons of stuff, or splitting objects and diluting my projects into a sea of classes

This is a very valid point and in any even reasonably sized project, extremely difficult to get right up front especially because realistically, requirements themselves evolve over time in most cases. This is where "Refactoring" come in. You design based on what you know at any given point and try not too make too many leaps of faith as to what you think the system MAY evolve to.

Given that you know what you are building right now, you design your classes trying to make the best possible use of OO concepts - eg encapsulation / polymorphism. This is itself, like others have noted as well, can be notoriously difficult to achieve and thats where experience, both in designing OO systems as well as knowledge of the domain can really come in handy.

Design based on what you know --> Build It --> Review it --> Refactor it --> Re-design --> and it goes on and on..

like image 78
Jagmag Avatar answered Sep 22 '22 17:09

Jagmag