Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Parzi88335y@12bitfloat @C0D4 if you can't structure code in a good way without multiple files and classes you need to take a step back and wonder where the fuck you went wrong
-
Root825575yIf you would do it for someone else, why the hell wouldn't you do it for yourself?
Others get the good treatment.
I get the best treatment. 😉 -
C0D4681455y@Parzi sorry, I do like to compartmentalise my code so every class is on its own instead of massive files that go for miles.
-
I came to Python from Java, so it took a while to learn when classes are actually necessary and when they aren't. Most of the time they aren't. I can count on one hand the number of classes I've created in Python in the past couple years.
-
Some applications get large pretty fast man, in that case it is best to compartmentalize decent code structures across multiple files. Say for example you are writing an api with Flask or Django, let us think of flask first, you could very well add your entire application in one file, but that can get messy quite fast, normally people would define each endpoint in its own set of files and call them out as needed, modify them as needed, or add more to them as needed, in this case simple methods with decorators would become quite cumbersome and classes would represent an easier way to maintain and pass stuff around.
You don't have to per-se, but for larger applications it is best if you do. -
@Parzi So you like writing spaghetti code without any real structure? Well, good luck I guess
-
@AleCx04 It's not even about the size of the code base. Just like writing a novel, programming is art and you want to have some form of quality even if it's just a 4 page short story
-
@12bitfloat you are saying that as if I don't do it on my own codebase. While I don't share the "art" perspective of it, I can appreciate good structure and the need for proper engineered solutions. But if our boy here ain't seeing the benefits on it then I will provide the more logical reasoning behind it, if not for the sake of art(in the event of him not sharing said views) then for the sake of completeness and properly engineered platforms.
-
Voxera115855y@Parzi well, the moment you leave basic web pages and dive into web applications you can easily get thousands of lines of server side code for a single page.
-
Parzi88335y@C0D4 That's fair, as Tkinter's not the greatest.
@yellow-dog why would you make a game in Python? Just... don't. It's not a good lang for that.
@don-rager i'm serious, actually.
@EmberQuill I've never made one for actual use, even for my own use. Never had to.
@AleCx04 if you properly format and document your code, it's not hard to just use one file. In a team with dickheads, this may not hold true, but...
@12bitfloat Proper documentation and formatting makes it not terrible, and i've never needed them as functions do everything I'd need to be disjointed from the main code. Hopefully real-world pros don't make every line their own function, like my CIS class implies. You don't need to make a separate function to print an arbitrary string to the screen, just use print() inline ffs
@Voxera I don't do web design or webapps, i'd honestly rather die. -
Parzi88335y@yellow-dog I mean, if anyone who doesn't do it for a living is a beginner, then yes. Otherwise, not really, no.
-
Nothing wrong with that, just your lack of real world experience shows.
And to answer your claim, every language is good for anything, some are just more geared towards certain tasks -
@Parzi Making every single line of code a seperate function is obviously wrong. Making every logical unit of code a seperate function or class on the other hand is not
-
Parzi88335y@sweetnothings i'm used to linear code structure, or at least semi-linear, as it's actually intuitive, but if you say so...
-
Reminds me of the way I used to rationalize not to use git back when I was starting out which prevented me from learning it properly for quite a while.
-
Parzi88335y@don-rager Just because i don't use them doesn't mean i don't know how they work or can't use them, I just have yet to find a use for them that's not overkill. I've toyed with them some, which is why I know I don't have a use for them at present. I know very well that i will need to use them at some point, I just haven't found a situation where functions don't do the same job better yet.
How the fuck do classes work in Python? Why, exactly, do people make them for themselves? I get doing it for like making modules other people will use, but just for your own shit...?
rant