[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]


what's your favorite design pattern, /g/?

mine is facade or strategy
>>
>>108781226
Most of these things a talented programmer will just implement naturally. I hate “Design Pattern” niggers so much, weird cult who attached themselves to Java in the early 2000s.
>>
>>108781226
Sorry I only use anti-patterns
>>
don't be a parrot op. create your own patterns. think for yourself. don't live someone else life ffs
>>
>>108781239
FPBP
it's genuinely hard to know which "Pattern" is best to implement into the software without making it into spaghetti code. Same thing with these dogshits known as "Micro-Services" and "Reactive Programming".
Combine all of the above with vibe coding and you got yourself an unmaintainable clusterfuck of a program
>>
>>108781295
These are newer nuisances. I’m haunted by “Reusable Enterprise Java beans”. Reuse? Never once!
>>
>>108781310
and how about reusable classes for said software?
you wouldn't reuse someone's mystery undocumented code, unless you're forking said project, would you?
>>
>>108781239
>>108781289

The point of design patterns is communication. Instead of saying "I encapsulated these two classes inside a new class which shares the same interface" you say "I wrote a facade".

Most of these patterns are idiotic, though.
>>
>>108781239
True.
>>
>>108781289
>don't be a parrot op. create your own non-round wheels. think for yourself. don't live someone else life ffs
>>
>>108781226
my favorite design pattern was the memento
although we implemented it in a totally different way i recognized it
>>
>>108781617
yes. create your own wheels. allocate manually your memory. embrace state mutation. embrace null terminated signs. make your own naming convention. format code in your own way. see how far can you go before it starts to get unwieldy and brittle. your own experience is the best teacher. introduce bus. eperience segfaults. embrace FAFO. grow some balls. live free or die.
>>
I like indenting my code, it makes it readable
>>
>>108781226
I only recently realized that dependency injection means function argument are the rest of the design patterns similar bullshit?
>>
File: 1611107465981.jpg (51 KB, 720x540)
51 KB JPG
>>108781723
>dependency injection means function argument are the rest of the design patterns similar bullshit?
wut?
>>
>>108781226
I'm a big fan of the visitor
>>
>>108781226
"Design Patterns" are not actually good. They exist largely to help wagies refactor old code bases into forms other wagies can recognize and read. Outside that use-case, they don't really have a purpose.

If you find yourself reaching for any of the patterns in this specific book, what has actually happened is that your program has scaled to a level of complexity/size that OOP is not well suited to and you should consider using a different language. The only reason to care about this book is if you are a wagie tasked with refactoring some legacy code base for other wagies. You're just kind of torturing your code into silly shapes to cope with the fact that OOP is not the correct tool for your project.
>>
>>108781391
ok except one of these is only understandable to someone who hasn't wasted time memorizing names of design patterns
>>
>>108781226
Some times I look at my code and think "hmmm, this could use the prototype pattern"
>>
>>108781226
Adapter pattern master race.
>>
>>108781391
>Instead of saying "I encapsulated these two classes inside a new class which shares the same interface" you say "I wrote a facade".
but then they will ask you
>wtf you mean by I wrote a facade
at which point you will reply
>I encapsulated these two classes inside a new class which shares the same interface

after all these years the only useful "design pattern" I've encountered and go out of my way to teach newfags is dependency injection. everything else is just overly anal retroactive taxonomy
>>
>>108782163
>Adapter pattern
>look inside
>it's literally just a wrapper
>>
>>108781723
>dependency injection means function argument
what if your dependency is a string? or a file pointer? or an abstract observer base interface factory?
>>
File: 'toss liberal.png (43 KB, 500x497)
43 KB PNG
>>108781226
Are your factories carbon-neutral?
>>
>>108781723
>I only recently realized that dependency injection means function argument
Low IQ take that's been making the rounds recently. DI as a pattern shows its true benefits when it comes to object composition.
>>
>>108781239
>a talented programmer
*any programmer with enough time and frustration

there's usually only so many ways to skin the cat and sufficient bashing of the head against the nearest wall will usually recover most of them eventually
>>
>>108782227
it's just a generally useful trick to solve chicken and egg problems of many varieties
>>
>>108781990
The book is descriptive, not prescriptive. The authors write about and categorize the recurring patterns that arose spontaneously across various codebases, as solutions to specific problems that various developers faced.
Treating the book as prescriptive (ie "this is what you should be doing") just leads to clusterfucked codebases a la Enterprise grade FizzBuzz
>>
I once had an interview where my interview ask me about design patterns and which ones I knew, than proceeded to claim Rails's ActiveRecord is a design pattern too. This is what we're dealing with.
>>
>>108781226
Yes.
>>
All design patterns are pointless if your intent isn't to write good code but code to just meet functional requirements.
>>
>>108781226
The thing that gets me is there are probably a large number of similarly simple patterns that nobody has named yet (or will ever name). And probably many would be very useful to think in terms of. My feeling is some organization or community should deliberately try to map the space of all used patterns, and perhaps the space of all possible patterns -- at least try to glean something from that space. Probably something about assigning integers to sequences of integers, and developing a maximally expressive vocabulary to shorten the length of sequences the most for common expressions, or something



[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.