Python Forum
Using classes? Can I just use classes to structure code?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using classes? Can I just use classes to structure code?
#1
Hi,
I'm self-teaching myself Python using examples and the excellent documentation. However, I'm stuck trying to understand classes. Do I need them? Can I structure the code with them? Do they introduce too much complexity? Do they apply to my project?

My project is a program that uses a single random seed to generate a made-up "record label", with multiple "artists", each with multiple "albums", each with multiple "tracks", which are generated CSound music code files. It also names the artists, albums, tracks and members of each band, and it generates artwork and album covers. As a side feature it generates a "Rock Family Tree" of the
(If anyone was interested in learning more about this project, PM me. I'd be glad of collaborators!)

There are functions that generate lists of words, functions that generate lists of note pitches, note lengths etc. A function iterates through the list of artists, another iterates through the list of albums for that artist etc etc.

I'm using PyCharm on Linux, which is a great powerful free IDE, with smart folding features. I'm using functions, and modules to break the functions into a separate file. The main file is still quite big, and I would like to be able to structure it to be able to navigate to bits of it easily.

Can anyone advise me of the best way to structure this project? Does it warrant classes? How would you go about structuring the nested functions of this project? Is there any way to flatten what might be too much nesting?

Any advice greatly appreciated. I can post code later from home if necessary.

Best regards,
Matthew Petty
Dubai
Reply


Messages In This Thread
Using classes? Can I just use classes to structure code? - by muteboy - Oct-23-2017, 08:26 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python Classes rob101 4 527 Feb-05-2024, 06:51 PM
Last Post: rob101
  How do I classify colored images into 3 classes max22 0 672 Dec-04-2023, 10:33 PM
Last Post: max22
Question [solved] Classes, assign an attributes to a class not to instances.. SpongeB0B 4 928 May-20-2023, 04:08 PM
Last Post: SpongeB0B
  Organizing several similar classes with overlapping variables 6hearts 7 1,376 May-07-2023, 02:00 PM
Last Post: 6hearts
  Q on classes ebolisa 4 866 Mar-06-2023, 04:17 PM
Last Post: deanhystad
  which design / pattern when building classes and subclasses Phaze90 2 1,123 Nov-19-2022, 08:42 AM
Last Post: Gribouillis
  Understanding Python classes PythonNewbee 3 1,183 Nov-10-2022, 11:07 PM
Last Post: deanhystad
Sad Python classes PythonNewbee 4 1,046 Nov-09-2022, 01:19 PM
Last Post: deanhystad
  super multiple parallel classes catlessness 2 1,327 Jun-07-2022, 02:35 PM
Last Post: deanhystad
  Adding Decimals to classes with OOP + rounding to significant digits (ATM demo) Drone4four 7 2,292 May-04-2022, 06:15 AM
Last Post: Drone4four

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020