[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: 1752319341546231.jpg (48 KB, 434x245)
48 KB
48 KB JPG
>he uses abstract classes and abstract methods
>he uses getters and setters for every single fucking variable
>he uses factories
>he refactors every tiny operation into its own function
>>
File: 1lcq6l.jpg (5 KB, 150x150)
5 KB
5 KB JPG
>>106786293
>
>>
>>106786293
Why are white software devs allergic to programming patterns?
Ya'll literally invented them.
>>
what's the point of getters and setters if you don't use them for everything? they have one goal
>>
>>106786346
I think C# got this right that you can later override the getter and setter operation.
Even though having hidden function call in a = operator is niggerlicious
>abstract classes
Good for sharing some common code but forcing user to implement system specific methods.
>>
>>106786329
some are midwits, like OP
>>
>>106786346
>what's the point of getters and setters if you don't use them for everything?
Because you don't want every variable to be set from outside the class?
>>
>>106786293
>he uses getters and setters for every single fucking variable
yes, for me it's
int main()
{
int i;

auto set_i = [&i](int new_i) { i = new_i; };
auto get_i = [&i]() { return i; };

set_i(5);
return get_i();
}
>>
>>106786438
divinely niggerlicious
>>
>>106786438
This is literally what react does btw lmao
>>
>>106786293
I admit I used to be like that. I blame 90s books on OOP, which were pushing this kind of autistic style pretty hard. It's also not all bad. Striking a balance takes experience.
>>
File: 1752253070935388.jpg (47 KB, 752x708)
47 KB
47 KB JPG
>>106786372
>abstract classes
>Good for sharing some common code but forcing user to implement system specific methods.
Also good for spreading your code into 30 files half-full of boilerplate like includes, class definition and so on making it very annoying to read.
>>
you mad bro?
>>
I find OO principles not bad if the code base is small and deals with a pretty limited scope of shit. The moment the scope is larger and requires hyper specific changes to each child object then it gets really fucking messy.
>>
>>106786293
>>he refactors every tiny operation into its own function
for me, it's
result = ArithmeticUtility.add3(var1, var2, var3)
>>
File: 1735393097165142.gif (2.74 MB, 404x364)
2.74 MB
2.74 MB GIF
>>106786293
>bool is called "isTree"
>getter must now be called "getIsTree()" instread of "isTree()"
>>
>>106786293
Is this the hourly "nocoder cant handle the real world" thread?
>>
>>106786293
import Math
math = new Math()
addition = new math.Addition()
addition.add(x, y)
z = addition.getZ()

is better than
z = x + y

chud
>>
>>106786293
>he uses factories
>he refactors every tiny operation into its own function
What if you need to change the underlying data structure of the thing these abstracting?
>>
>>106786293
it's all so tiresome

all because of idiotic niggers like this
>>106787672
>>
>>106787672
what are interfaces
>>
>>106786293
i have no idea what any of these words mean i just get AI to code for me
>>
>>106786293
>he uses abstract classes and abstract methods
Agreed, I don't much care for abstract classes. It's like base classes and interfaces aren't enough so we need some bastard child destined to be a templated base class in the mix.

>he uses getters and setters for every single fucking variable
Ok in all fairness though accessors can be extremely useful sometimes. The same way callback events have add and remove accessors, having that ability to get in there can give you very granular control over things when it's needed. But records and .net10 iirc will have kind of eliminated the need for all the mandatory get and set bullshit which is cool.

>he uses factories
Agreed I don't like factory patterns much. But there are different ways the factory pattern can be used, it's just a lot of them suck. Really basic ones where it's just a simple static class that returns a class based on parameters are useful, but aren't as obscure and abstract enough for pattern nerds to call them factories. I digress.

>he refactors every tiny operation into its own function
Well it can enhance re-usability in larger code bases, but point taken.

My thing is fucking dependency injection. I always stayed away from that shit but have been forced to mingle with it at work and holy fuck do I hate it. There's no fucking reason you can't just use global static classes and introduce enums to define granular behaviors when needed. All the singleton, scoped, transient bullshit is just a retarded abstraction of things everyone was already 100% capable of doing with classes and interfaces to begin with. What's worse is it seems to sometimes produce unexpected behavior when you do actually introduce a globally static class somewhere. It's like the difference between looking under the hood of a car made in the late 90's or early 2000's versus looking under the hood of a car made circa 2020. You can just physically observe the level of retarded abstraction and over complication involved.
>>
>>106786293
abstraction is nigger technology that is needlessly complex and a retarded waste of time that pointlessly designs for all edge cases
>yeah but what if --
you won't.
>>
>>106789441
>you won't
I always do sooner or later.
>>
>>106786757
Why not just z = addition.add(x,y)
I never cared for this setter/getter nonsense
>>
>>106786757
>z = x + y
This is some unholy code from the deepest depths of hell.
>>
>>106786757
new MathFactory.createAddition(new SumFactory.createSum(SumFactory.fromNumber(new Number(1).numberify())), ...
>>
File: 1742377793846027.png (50 KB, 205x208)
50 KB
50 KB PNG
>mfw the software intern we hired uses literals instead of using our number factory pipeline to safely instantiate a 'Number' object.
>>
>>106786293
>he hasn't worked on a project longer than 5k lines before
>>
>>106789801
>my todo app is over 5k lines
>>
>>106786293
>every block of code needs to be an interchangable peice because you are an interchangable human reasource.
>>
>>106789898
>his only projects are trivial
>>
>>106786372
>abstract classes
>Good for sharing some common code but forcing user to implement system specific methods.
And an indicator of bad decomposition and bad separation of concerns.

"Composition over inheritance," applies.
If you have a library with a particular bit of logic in a subsystem that needs to be implemented by the library's users, then that bit of logic should be its own class adhering to an interface, and an instance of it should be supplied into the subsystem when initializing it.
>>
>>106790033
>this is my reading comprehension
>>
What is the point of factories?
I have genuinely never been presented with a use case for one.
>>
>>106786293

i have a single file, main.c with 20k LOC and global varibles only and its fun this way
>>
>>106786293
uhm??? thats how its supposed to be
did you ever have a job?
>>
>>106789409
I think dependency injection is kind of solving the same problem tailwind does. Only times I used it was in angular and java spring, but at least when you can look at a class's annotations and see exactly what the developer was trying to accomplish
>>
>>106789664
>when the intern uses an operator
>>
>>106789409
>There's no fucking reason you can't just use global static classes and introduce enums to define granular behaviors when needed.
Yes, there is a fucking reason. It's called not making a mess of your code.
Dependency injection goes hand-in-hand with the principle of inversion of control and is in fact one of the more hands-off methods of following it, without involving lots and lots of manual boilerplate.

The point of dependency injection and inversion of control, is that your code relinquishes control of what specifically gets injected into it. You don't care what gets injected and used, just that it has to conform to some predefined interface contract. This means you can write units of code that will continue to function as intended without needing to touch them whenever a specific new implementation has to be added to an application.

Contrast with your suggestion where you'd switch-case over different implementations with enums. There you'd have to update all places in your code base that interact with a particular enum type to also handle the newly introduced case, in-situ. Everywhere.


>>106790255
Dependency injection solves actual problems with software at scale.
Tailwind was invented by a fucking hackjob that was very, very proud of the novelty he managed to piece together and wanted so much to gain recognition and hawk it as a solution that he had to start purposely misrepresentating quotations from other people to try and invent a particular class of actually non-existing problem that his little demon would be meant to solve.
>>
>>106790079
>finally realizing the importance of best practices, he can only resort to ad hominem
>>
>>106789409
I'm sorry anon, but it's not the abstraction who is retarded
>>
>>106786400
This literally could have been a keyword instead of this get/set + hidden method bullshit.

Also:
>Needing the language to straightjacket/nag you into writing good code.
I hate this so much. I can stick to my own principles when coding without needing to introduce a shitload of boilerplate and warnings. Just because a field is public, it doesn't mean I am going to change its state from outside of the object.
>>
>>106791334
>This literally could have been a keyword
You mean like public and private? That goes hand in hand with setters and getters. You're supposed to make every variable private to prevent other developers from setting them without a specific setter that enables its mutability from outside.
>Just because a field is public, it doesn't mean I am going to change its state from outside of the object.
That's not going to be an issue if you work alone and have perfect memory. The rest of us will have to make do with safety measures and design patterns.
>>
>>106790475
>You don't care what gets injected and used, just that it has to conform to some predefined interface contract. This means you can write units of code that will continue to function as intended without needing to touch them whenever a specific new implementation has to be added to an application.

That's barely true and not always the case.

>Contrast with your suggestion where you'd switch-case over different implementations with enums. There you'd have to update all places in your code base that interact with a particular enum type to also handle the newly introduced case

You don't know how to get creative with enums and decorators.
>>
some low wage contractor is going to fuck up the code anyway



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.