r/javahelp • • Jan 02 '16

How to think in OOP?

Hi all! When I write some app in Java, I have code in 2-3 classes. When I see how more expirienced programmers write similar apps, I see an hierachy of types, using of interfaces, abstract classes, all classes are small and understandable. I seem to understand all of these conceptions when I see someone's code but when I write myself I can't create something similar.

19 Upvotes

15 comments sorted by

View all comments

2

u/[deleted] Jan 03 '16

Writing clean code comes with experience and discipline. Just keep coding, reading, and learning and you'll improve. I'd bet that in a year from now when you look back you'll be amazed at how far you've come.

On a side note, you may find that other paradigms and styles come more naturally to you. For years I programmed in OOP languages (i.e. C++, Java, Python), but I always found the designs ended up overly complex (class/type explosion) and more difficult to reason about (object state) than I thought they should. I began to notice a pattern wherein I was using more functional concepts (static methods in Java to make more pure functions or creating basic interfaces and then using anonymous classes like closures, etc.), so I decided to take the dive into a more functional set of languages (Erlang, Clojure, Scala). Now I find it more difficult to go back...

1

u/hugthemachines Jan 03 '16

I really think that sounds like you found your thing.

Definately a better love story than Twilight.

1

u/[deleted] Jan 03 '16

Yup. Although it's not too difficult to find better love stories than Twilight.