dingoblog / dingo

Blog engine written in Go
MIT License
284 stars 37 forks source link

Initial implementation of DI on handler package #76

Open fernandez14 opened 8 years ago

fernandez14 commented 8 years ago
bentranter commented 8 years ago

Hey @fernandez14, this is a really interesting PR, but I'm not sure if it'd fit within this project for a couple of reasons. Of course it's up to @dinever to make the final call, but I just wanted to share my thoughts:

I know I'm coming off as really negative here, but I think Dingo is as close to the perfect project for new Gophers to use, hack on, and contribute to as you can get. I'd hate for us to do anything that makes that less true, and I'm worried adding another ORM and dependency injection might do that. On the other hand, I'd never even considered the dependency injection approach, so this has taught me a lot about what other Go projects are doing, so for that alone, thank you @fernandez14, and thanks for the contribution 😄

samdfonseca commented 8 years ago

@fernandez14 im on the same boat as @bentranter regarding this pr. i dont see a particularly strong reason to introduce gorm or facebookgo/inject. that said, im a big fan of dependency injection, but i'd rather see it done with mocking.

fernandez14 commented 8 years ago

@bentranter @samdfonseca I completely understand your point of view here but I believe you are not seeing the long term advantages of both DI and gorm and here's why:

Also keep in mind that its a tool made by the good guys! Facebook does pretty good contributions to Golang.

At the end its completely opt to you guys, I liked the project and I tried to make my contribution just let me know to update my PR.

samdfonseca commented 8 years ago

@fernandez14 if the plan is to replace meddler with gorm, im all for that. my concern was ending up using gorm in some places and meddler in others. i'll also throw qb out there as a third option. i haven't used it yet but it looks like it provides better abstraction than meddler and isn't as invasive as gorm.

i agree that we need to move away from globals and can make better use of things like interfaces and embedding to help manage complexity as the apis evolve. that said, i dont think we're at the point were we need to resort to a reflection-heavy DI approach. there's nothing wrong with the approach taken here, its just a bit over-engineered. we should have no problem keeping things under control if we make better use of go's support for object composition.