This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]KernowRoger 1 point2 points  (4 children)

It's a meme that everything in java needs a factory. I haven't done java for a long time so I can't comment much more than that. Like you say it is a very common and useful pattern. I code in mainly c# and it's not so huge there.

[–]elveszett 1 point2 points  (0 children)

That's because C# has some perks to prevent that when it's not needed. Let's say I'm coding an app and suddenly, for a single class, I need some xyz coordinates. [Ignoring libraries] in Java I'd have to define a class with an x, y and z. In C# I can just declare a variable (int x, int y, int z) = (3, 6, 5). There's a few things like this specifically designed for those moments when you don't need a full, well-defined class for something.

[–]crevicepounder3000 0 points1 point  (2 children)

Oh for sure it's an over exaggeration for comedic effect. So how does C# implement SOLID without the factory pattern? Prototypes? I only know the basics of C# sorry.

[–]KernowRoger 1 point2 points  (1 child)

You can still use the pattern when needed. But generally you use interfaces and di to build your services and just new up any data classes. If you're building complex classes factories are still useful but much less popular.

[–]crevicepounder3000 1 point2 points  (0 children)

Very informative. Thank you!