0
Отвечено

Primitive obsesion VS Data class

Nastasia Saby 8 lat temu Ostatnio zmodyfikowane przez anonymous 7 lat temu 1

I have the impression that finally in some way, fighting primitive obsession (for instance transforming an array in a small object) drives to create data classes.

I guess it is a bit subbtle, but I don't get it and to say the truth I prefer creating data classes than having a huge of arrays that make sens together and represent more concepts than arrays.


I really would like to discuss it with you. I would be really pleased to have some other points of view. I'm trying to improve my skills.

Odpowiedź

Odpowiedź
Отвечено

Hey Nastasia,


Great question! I think they both could act as an intermediate step to a cleaner code. Here's example:


1. You have a Primitive obsession situation(say, lots of arrays). It smells bad.

2. You turn arrays into classes.

3. Now you have a lot of Data classes. Smells better, but not that good yet.

4. You add some behaviors to data classes, and merge them together if both have similar purpose.

5. Bam! Now, you've got clean code and nice classes.


Does this make sense?

DOBRZE, JESTEM ZADOWOLONY.

Thanks for you answer

Znak zadowolenia przez Nastasia Saby 8 lat temu
Odpowiedź
Отвечено

Hey Nastasia,


Great question! I think they both could act as an intermediate step to a cleaner code. Here's example:


1. You have a Primitive obsession situation(say, lots of arrays). It smells bad.

2. You turn arrays into classes.

3. Now you have a lot of Data classes. Smells better, but not that good yet.

4. You add some behaviors to data classes, and merge them together if both have similar purpose.

5. Bam! Now, you've got clean code and nice classes.


Does this make sense?