Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Dates and Times in Python (2014) Let's Build a Timed Quiz App The Question Classes & the Plan

Chul Kim
Chul Kim
2,341 Points

Question on object oriented programming

I have recently finished the track on object oriented programming for python and understand the basic concepts now. But..that’s it..

I was wondering if anyone can take me through the thought process Kenneth took in order to break up the projects into actual classes. How do you go from lets make a math quiz to deciding what classes I actually need. Is there a certain process or general guide that you follow to decide which classes to create?

2 Answers

Hi Chul,

I love the question! This is my paraphrasing of what I hear you asking:

I'd like to journey through the thought process of breaking up projects into actual classes. How does one decide what classes are actually needed? Is there a certain process or general guide that you follow to decide which classes to create?

Believe me, the answers are a mystery to me too. What I've found helpful are practice, ongoing mentorship, collaborative learning (together with peers), online tutorials -- but not too many!

I believe you'll find the answer to this question just as I have by spending more hours going through both the Basic Python and Intermediate Python tracks.

There are Four OOP Principles that weren't all addressed in the OOPython course. For example, I looked up resources on Encapsulation in Python and found these two: from pythonprogramminglanguage and pythonspot

Believe me, I understand roughly what you're asking, and the larger question behind it. I know what my larger questions are. The reason I can't provide a complete answer to it is because, that process will require hundreds of hours. Feel free to respond specifically to keep this conversation going, but Treehouse is a great resource for learning more Python -- it's taught me most of everything I know!

-Mark

A fellow lifelong learner

Chris Jones
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Chris Jones
Java Web Development Techdegree Graduate 23,933 Points

Hi Chul,

I remember feeling like that too. My experience is that dividing related chunks of logic into classes comes with experience, continuous learning, and experimentation.

For work projects, I certainly try to have a conceptual "blueprint" of what I'm going to code, but it's rarely more detailed than a workflow on a whiteboard and a design pattern such as MVC (model-view-controller) or MVP (model-view-presentation) - assuming I'm writing an app. Outside of that, I don't really have any classes in mind. For my own side projects, the whiteboard workflow is usually in my head :P (not necessarily the best idea lol).

Based on my experience, I start to use classes when I see the same code being used in more than one place (I might put this code in something called a Util class). Or when when some logic is related so that it can be isolated into its own class.

All that to say, OOP (and coding in general) is an art/craft. There aren't very many definite right/wrong ways to do things, although some ways have pros/cons depending on what your goal is. Some of the above may seem hard to understand where you are right now - and that's completely understandable and to be expected. I was there too. The best answer to your question is to keep learning through googling, reading other people's code, watching Treehouse videos, and asking for code reviews. But, most importantly, in my opinion, you need to take those learnings and keep experimenting by writing more code :). In other words, be an active learner and put that learning into practice.

I hope that helps! Let me know if you have any more questions!

Keep it up :)!