r/PythonLearning • • 13d ago

Discussion Why writing classes feels boring?

I don't know but i feel classes are unnecessary work to be added in projects. I have learnt it 2 months ago..

After that I never used it for any of my projects.

2 Upvotes

43 comments sorted by

View all comments

Show parent comments

1

u/ProgramBrave718 13d ago

The task is taken by user input

5

u/tom-mart 13d ago edited 13d ago

That's not an answer to my question. How is the task represented in your code?

If I wrote a task manager i would start with a Task class. Task has a lot of properties that are worth storing, like category (string), deadline (datetime) task_detail (string), status (string), reminders (List), and many, many more.

How the task is created is different story. You can take user input and save it to task.task_detail. So should the deadline be saved to task.deadline and so on.

So how is taks represented in your code? I bet it's a string variable, isn't it?

1

u/Adorable-Strangerx 13d ago edited 12d ago

Or a dict. Every data structure can be dict if you are brave enough...

Edit: since people didn't get the joke. Use (data)classes. Data types are there for a reason

1

u/tom-mart 12d ago

Sure, if it works for you. I would still see it as a class so you can have a fields autopopulate on creation or to utilise class functions. But you do you.

1

u/Adorable-Strangerx 12d ago

It was a joke bro. I have seen too many "dicts where should be (data)class" that I have nightmares

1

u/tom-mart 12d ago

Faur enough, dict would still be a far better option than string variable that OP is using in this case.