Support the ongoing development of Laravel.io →
8 years ago
IOC
Last updated 1 month ago.
0

First of all, the performance issue is very much not a concern. As you continue writing code, you definitely need to focus on not worrying about performance for this kind of thing. Instantiating objects is nothing compared to some of the stuff that you deal with. Real memory wasters are loading a TON of Eloquent objects (instead of batch loading) and other stuff.

If you ever wonder if there's a performance issue, just do it and find out. That's just the best way. Write code to be easy to read and easy to modify. Performance is something that's only a problem when it is.

I keep finding that I am somewhat anxious about performance of these sorts of things.. But, I have to push past it. I force myself to keep instantiating a bunch more service level objects to do my work. I'm always amazed at how well it works. There's just something about the old days that messes with my head.

Last updated 1 month ago.
0

Yeah I know that this is not somewhat of a performance issue. But hey! Loading two files just to use one method isn't that awesome... right ?!

Last updated 1 month ago.
0

Well, it depends on what your perspective on object-oriented programming is. If you like OOP, then this is exactly the sort of thing that happens all the time. You instantiate 1-6 objects to call a single public method. It's just the name of the game.

Last updated 1 month ago.
0

Sign in to participate in this thread!

LoadForge

Your banner here too?

breda breda breda Joined 1 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2022 Laravel.io - All rights reserved.