Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Seaside Loafer
Feb 7, 2012

Waiting for a train, I needed a shit. You won't bee-lieve what happened next

jesus fuckling christ rename this source control management megathread and stick it in the comics forum or branch it off hurr hurr

Seaside Loafer fucked around with this message at 06:35 on Jan 18, 2015

Adbot
ADBOT LOVES YOU

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome

Seaside Loafer posted:

jesus fuckling christ rename this source control management megathread and stick it in the comics forum or branch it off hurr hurr

sorry, is the talking about source control in the programming thread bothering you? we have cat threads and current job status threads, perhaps you'd be more interested in those.

Notorious b.s.d.
Jan 25, 2003

by Reene
svn is fine

it will at least not lose your source code or corrupt its own database

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome
I remember someone in yospos irc coming in and was like "I accidentally deleted my local git repo, I haven't pushed for a week"

the other cool thing about git is that it assumed all dev boxes are backed up, because people tend to sit on changes before they push, because they have to craft their commits to tell a software story or some poo poo

compuserved
Mar 20, 2006

Nap Ghost

rotor posted:

the other cool thing about git is that it assumed all dev boxes are backed up, because people tend to sit on changes before they push, because they have to craft their commits to tell a software story or some poo poo

a coworker got burned by this last week when his dev vm poo poo the bed lol

Seaside Loafer
Feb 7, 2012

Waiting for a train, I needed a shit. You won't bee-lieve what happened next

rotor posted:

sorry, is the talking about source control in the programming thread bothering you?
yes its very very boring and isnt about about programming and has been going on for endless pages

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome

Seaside Loafer posted:

yes its very very boring and isnt about about programming and has been going on for endless pages

it is about programming though

Seaside Loafer
Feb 7, 2012

Waiting for a train, I needed a shit. You won't bee-lieve what happened next

rotor posted:

it is about programming though
well it isnt is it, its about source control managment which are not the same things

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome

Seaside Loafer posted:

well it isnt is it, its about source control managment which are not the same things

they're related topics and as such are Just Fine for discussion

hobbesmaster
Jan 28, 2008

rotor posted:

I remember someone in yospos irc coming in and was like "I accidentally deleted my local git repo, I haven't pushed for a week"

the other cool thing about git is that it assumed all dev boxes are backed up, because people tend to sit on changes before they push, because they have to craft their commits to tell a software story or some poo poo

it's almost as if workflow is more important than the tool

Seaside Loafer
Feb 7, 2012

Waiting for a train, I needed a shit. You won't bee-lieve what happened next

whatever floats your boat man but I would suggest some actual programming natter would be much more interesting than endless repitition of source control method a is better than source control method b

triple sulk
Sep 17, 2014



Seaside Loafer posted:

whatever floats your boat man but I would suggest some actual programming natter would be much more interesting than endless repitition of source control method a is better than source control method b

Okay, spaces or tabs?

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome

Seaside Loafer posted:

whatever floats your boat man but I would suggest some actual programming natter would be much more interesting than endless repitition of source control method a is better than source control method b

don't let me stop you, go ahead and talk about programming.

Seaside Loafer
Feb 7, 2012

Waiting for a train, I needed a shit. You won't bee-lieve what happened next

rotor posted:

don't let me stop you, go ahead and talk about programming.
I suggested a topic a few pages back in an attempt to divert, whats your response to it? Id be interested.

Base Emitter
Apr 1, 2012

?

Seaside Loafer posted:

I suggested a topic a few pages back in an attempt to divert, whats your response to it? Id be interested.

lol

FamDav
Mar 29, 2008

Seaside Loafer posted:

I suggested a topic a few pages back in an attempt to divert, whats your response to it? Id be interested.

a miserable little pile of secrets lol

Flat Daddy
Dec 3, 2014

by Nyc_Tattoo

Seaside Loafer posted:

I suggested a topic a few pages back in an attempt to divert, whats your response to it? Id be interested.

imho animal-to-computer UI is coming up

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome

Seaside Loafer posted:

I suggested a topic a few pages back in an attempt to divert, whats your response to it? Id be interested.

my response is "shut the gently caress up and stop bothering me"

Stringent
Dec 22, 2004


image text goes here
we've covered source control so I guess the next thing terrible programmers usually talk about is booze.

I generally like wine but I'll do beer or nihonshu occasionally.

cinci zoo sniper
Mar 15, 2013




vodka or dry gin

Notorious b.s.d.
Jan 25, 2003

by Reene

Stringent posted:

we've covered source control so I guess the next thing terrible programmers usually talk about is booze.

I generally like wine but I'll do beer or nihonshu occasionally.

git ui makes more sense if you are loving plastered

I like dvcs but I do not understand how git came out the winner

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome

Notorious b.s.d. posted:

git ui makes more sense if you are loving plastered

I like dvcs but I do not understand how git came out the winner

everyone tells me hg is good.

I dont really have a thing against dvcs, but i sure do have a thing against git

b0lt
Apr 29, 2005

Notorious b.s.d. posted:

git ui makes more sense if you are loving plastered

I like dvcs but I do not understand how git came out the winner

git's ui is bad but everything else is slow as gently caress

JewKiller 3000
Nov 28, 2006

by Lowtax
i don't care about your source control but i do care about your vodka and gin, please post more about those

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

Notorious b.s.d. posted:

I like dvcs but I do not understand how git came out the winner

linus worship

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

Stringent posted:

we've covered source control so I guess the next thing terrible programmers usually talk about is booze.

I generally like wine but I'll do beer or nihonshu occasionally.

what the heck is nihonshu? i bet its not as good as scotch or beer though

Stringent
Dec 22, 2004


image text goes here

Notorious b.s.d. posted:

git ui makes more sense if you are loving plastered

it's true

suffix
Jul 27, 2013

Wheeee!
i have a terrible programmer question: how do you do dependency injection right?

i get the concept and how it makes unit testing easier, but on the projects i've worked on it always ends up with at least one of two problems:
- all your code ends up unnecessarily tied to a specific injection container
- your outermost layer ends up being a gigantic mess of instantiating and connecting every object in the program, maybe in xml for good measure

like 90% of the time we don't have any alternative implementations and only want to switch it out for our unit tests,
so it doesn't feel right to just pass it up until your main code has to care about a helper class to a helper class to a helper class,
but that's the logical conclusion from the introductory texts i've read

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

suffix posted:

i have a terrible programmer question: how do you do dependency injection right?

i get the concept and how it makes unit testing easier, but on the projects i've worked on it always ends up with at least one of two problems:
- all your code ends up unnecessarily tied to a specific injection container
- your outermost layer ends up being a gigantic mess of instantiating and connecting every object in the program, maybe in xml for good measure

like 90% of the time we don't have any alternative implementations and only want to switch it out for our unit tests,
so it doesn't feel right to just pass it up until your main code has to care about a helper class to a helper class to a helper class,
but that's the logical conclusion from the introductory texts i've read

hmm, i dont know. sorry.

gonadic io
Feb 16, 2011

>>=

suffix posted:

i have a terrible programmer question: how do you do dependency injection right?

i get the concept and how it makes unit testing easier, but on the projects i've worked on it always ends up with at least one of two problems:
- all your code ends up unnecessarily tied to a specific injection container
- your outermost layer ends up being a gigantic mess of instantiating and connecting every object in the program, maybe in xml for good measure

like 90% of the time we don't have any alternative implementations and only want to switch it out for our unit tests,
so it doesn't feel right to just pass it up until your main code has to care about a helper class to a helper class to a helper class,
but that's the logical conclusion from the introductory texts i've read

Lol OO

suffix
Jul 27, 2013

Wheeee!
i don't even know how you'd test an io thing in haskell

gonadic io
Feb 16, 2011

>>=

suffix posted:

i don't even know how you'd test an io thing in haskell

Same as how you test anything else: the quickcheck library. I'm on my phone but if somebody could be bothered to paste some examples in this thread I'd be grateful.

gonadic io fucked around with this message at 12:13 on Jan 18, 2015

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

suffix posted:

i have a terrible programmer question: how do you do dependency injection right?

i get the concept and how it makes unit testing easier, but on the projects i've worked on it always ends up with at least one of two problems:
- all your code ends up unnecessarily tied to a specific injection container
- your outermost layer ends up being a gigantic mess of instantiating and connecting every object in the program, maybe in xml for good measure

like 90% of the time we don't have any alternative implementations and only want to switch it out for our unit tests,
so it doesn't feel right to just pass it up until your main code has to care about a helper class to a helper class to a helper class,
but that's the logical conclusion from the introductory texts i've read

Guice (and presumably other "magical" DI frameworks, though Guice is the only one I'm familiar with) are really cool when you have the discipline to avoid shooting yourself in the foot with them. They make it really easy to shoot yourself in the foot, but if you can avoid that they're all good.

Basic rules are to avoid everything "clever" that the framework lets you do, only inject concrete classes, avoid scopes except for maybe singletons, don't use annotated injections to get multiple different things of the same type. Then it's basically just a way to instantiate objects without needing to know what their dependencies are (which is the whole point of a DI container rather than doing manual DI), while still being able to bind everything to mock instances etc. in your tests. Once you've wrapped your head around it enough to avoid making write-only spaghetti code, you can identify situations where a "clever" feature makes something less painful and won't make you regret it when you have to debug things later.

If you're doing it right then the only code that's actually tied to a specific injection container is the top-level stuff that configures bindings (which you won't have many of if you follow the basic rule and only inject concrete classes) and requests an instance of whatever object is the root of your object graph. Everything else just has an annotation that says it should be DIed and wouldn't need any changes if you switched to a different container for whatever reason.

zokie
Feb 13, 2006

Out of many, Sweden

suffix posted:

i have a terrible programmer question: how do you do dependency injection right?

i get the concept and how it makes unit testing easier, but on the projects i've worked on it always ends up with at least one of two problems:
- all your code ends up unnecessarily tied to a specific injection container
- your outermost layer ends up being a gigantic mess of instantiating and connecting every object in the program, maybe in xml for good measure

like 90% of the time we don't have any alternative implementations and only want to switch it out for our unit tests,
so it doesn't feel right to just pass it up until your main code has to care about a helper class to a helper class to a helper class,
but that's the logical conclusion from the introductory texts i've read

Get The Art of Unit Testing, and use the most "I can't believe I didn't think of this"-thing which is use inheritance and make TestableFoo which overrides a stuff like GetDate().
Or you could use a DI-framework that maps stuff according to conventions

Brain Candy
May 18, 2006

Jabor posted:

Guice (and presumably other "magical" DI frameworks, though Guice is the only one I'm familiar with) are really cool when you have the discipline to avoid shooting yourself in the foot with them. They make it really easy to shoot yourself in the foot, but if you can avoid that they're all good.

to me this kinda sounds like 'don't do DI'. mainly because you can make any unwieldy thing work with discipline

see also

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

MononcQc
May 29, 2007

gonadic io posted:

Same as how you test anything else: the quickcheck library. I'm on my phone but if somebody could be bothered to paste some examples in this thread I'd be grateful.

The quickcheck library wouldn't be much help unless you can figure out a property of your IO system you want to see, or find an alternative function (a model) to compare your implementation to.

Otherwise you'll be generating random-but-guided data and test cases, but you have no guarantee that your tests are relevant in any way.

tef
May 30, 2004

-> some l-system crap ->

rotor posted:

they're related topics and as such are Just Fine for discussion

yes.

Seaside Loafer posted:

well it isnt is it, its about source control managment which are not the same things

why can't you all talk about something more interesting to me?

tef
May 30, 2004

-> some l-system crap ->

quote:

i get the concept and how it makes unit testing easier, but on the projects i've worked on it always ends up with at least one of two problems:
- all your code ends up unnecessarily tied to a specific injection container
- your outermost layer ends up being a gigantic mess of instantiating and connecting every object in the program, maybe in xml for good measure

what you should be aiming for is not good di, but explicit state and loose coupling. these do not come from using di, but a di framework makes them easier to do. you can skip the xml/injectors, and just make the plumbing explicit sometimes. it doesn't hurt to pass in the dependencies by hand some times. you may find that you do not need that much di to get a benefit from it, but the interfaces between components matter much more than how you assemble them.

suffix posted:

i have a terrible programmer question: how do you do dependency injection right?

how to do di right is not a good question, as the answer is: *it depends*. large projects obviously benefit, small ones don't. much of the advice depends on the famework, language, and platform. when to do di, and where to do di are better questions, although the answers are still kinda handwavey. when and where is easier if your codebase is layered. i tend to go for something vaguely like this

libraries -- modules -- components -- frameworks

libraries at the bottom are just utilities, often wrappers around third party or platform apis. very little internal state and very little dependencies. modules atop add policy and workflow, like how requests is built atop urllib3. this is sorta where you put logic around the simpler parts, and glue bits together to make a useable api for common tasks. these two are generally where the reusable parts of a project live.

a component is where the business logic in an application or service lives, and the framework is the thin layer of glue that holds these components together. business logic, although finely interwoven, is not necessarily a gordian knot for you to cut into components. if you can’t replace a component easily, it might not be worth splitting out in the first place — it isn’t hiding enough from the rest of the system.

instead of asking how do i do good DI, we're asking: how do i decompose an application into components, how should they depend on each other, and what the interfaces between them should be. now you have three problems, etc.

on decomposition, to rephrase D. Parnas’ excellent advice: A component exists to hide a hard decision from other components in the system, or to hide a decision likely to change. similarly, part of the layering above is to hide things: components hide business logic from each other, modules should hide implementation, libraries should hide workflow, and the framework should hide all the wires holding it all together. on dependencies: libraries shouldn't have many, and explicitly passed each time. modules can depend on libraries, and so on. as for designing the interfaces: well that's just hard, good luck bub.

once you've split your code up like this it's easier to see where di should go, and when it should happen: in the framework and components. the libraries and modules can probably make do with plain old explicit dependencies. this also answers the question: how much di should I do—enough to glue the larger components in your system together.

quote:

it doesn't feel right to just pass it up until your main code has to care about a helper class to a helper class to a helper class, but that's the logical conclusion from the introductory texts i've read

you have come to a world called car extends vehicle *whipcrack*. the introductory texts are usually a toy example wired to show off the library or technique. the problem with our introductory texts is that they are full of examples no-one should follow.

Adbot
ADBOT LOVES YOU

tef
May 30, 2004

-> some l-system crap ->
on the other hand if you're just using it for unit testing there is probably some classloader hack that will fix this for you.

  • Locked thread