Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

DEPENDENCY INJECTION

Name: Anonymous 2014-05-24 0:11

What's your opinion on DI? is it just enterprise overengineering shit or it actually makes your code better and testable?

Name: Anonymous 2014-05-24 0:25

Disgusting ENTERPRISE shit.

Name: Anonymous 2014-05-24 2:28

The wikipedia article is too long for me. Can someone summarize it in 5 words for me?

Name: Anonymous 2014-05-24 2:34

>>3
niggers, jews; always bad news

Name: Anonymous 2014-05-24 4:08

>>3
Here is a butthurt PHP programmer talking about dependency injection:
http://www.tonymarston.net/php-mysql/dependency-injection-is-evil.html

The OO Nazis may think that they have silenced my heretical viewpoint, but [...]

Name: Anonymous 2014-05-24 4:14

>>1

It is Java pattern, introduced due to language's deficiencies, like static typing. People writing Lisp usually have all code under dependency injection, because you can easily wrap it inside a macro, which will mock the environment.

Name: Anonymous 2014-05-24 5:03

>>1
It forces retards who write >50 line methods all over the place and use classes as namespaces to write nicer programs. So yes it's a good thing.

Name: Anonymous 2014-05-24 5:20

unit testing is a waste of human and machine time.

Name: Anonymous 2014-05-24 6:29

>>3
basically you use parameters in constructors/methods such that your class/object/methods do not create their own objects if they need to call methods from those objects; let the client code pass them as dependencies.

>>6
wrap it inside a macro, which will mock the environment.
this is why i actually prefer dynamic binding to lexical binding.

Name: Anonymous 2014-05-24 6:41

>>6
Sometimes I'm surprised there are names for something so simple.

Name: Anonymous 2014-05-24 7:00

In functional programming, dependency injection is known as ``passing an argument''

Name: Anonymous 2014-05-24 8:21

>>11
*>le gasp*!

Name: Anonymous 2014-05-24 11:23

>>9
this is why i actually prefer dynamic binding to lexical binding.
Who needs dynamic binding when you have monads? You do have monads, don't you?

Name: Anonymous 2014-05-24 12:19

monads a poo!

Name: Anonymous 2014-05-24 13:34

WARNING: This thread has changed topic
New subject: STRONG/WEAK TYPING

As >>6-san said, dynamic typing can be good in some specific situation. However, you will find many people on /prog/ who will swear for static typing.

Sure, looks like there are both advantages for dynamic and static typing. But what about weak typing? I don't see any real advantages for it, other than having Javashit and PHP clones. C might have weak typing but it is kind of necessary when you're dealing with low-level stuff. The static typing is also, in some way, a compensation for its loose type system.

Is there any point on discussing strong/weak typing, or can we all agree that weak typing is shit for epic Javascript appers?

____
You may not make any reply regarding the old topic.

Name: Anonymous 2014-05-24 14:59

The Scalafags came up with some cake pattern that supposedly helps with dependency injection but shit was so boring that I never actually got to the end of it.
http://www.cakesolutions.net/teamblogs/2011/12/19/cake-pattern-in-depth

Name: Anonymous 2014-05-24 16:05

>>15
Why don't you try defining strong and weak typing first, you retard? What the fuck are you talking about?

Name: Anonymous 2014-05-24 16:14

Name: Anonymous 2014-05-24 16:22

>>18
Are you retarded? That wiki lists 7 different definitions of weak typing. Can you tell what the fuck weak typing is?

Name: Anonymous 2014-05-24 17:39

>>19
Pick the definition of ``predictability'' then.

Name: Anonymous 2014-05-24 17:42

PENIS PUNISHMENT

What's your opinion on PP? is it just a forced meme or does it actually makes people stay in line?

Name: Anonymous 2014-05-24 17:46

>>20
What does that have to do with the question at hand? Predictability is the ability to be predicted. Now what in the fuck is "weak typing"? What is "strong typing"?

Goddamn Ruby idiots and their hipster non-concepts.

Name: Anonymous 2014-05-24 18:48

>>15
I like C, but

C might have weak typing but it is kind of necessary when you're dealing with low-level stuff.
It's not necessary. C's weak type system more likely has something to do with compiler complexity and the computing power available.

On the other hand look at Ada or just about any systems language that isn't too closely related to C and you have a good chance of seeing strong typing.

The static typing is also, in some way, a compensation for its loose type system.
It helps, but C will coerce at the drop of a hat. I find I can't rely on it. One thing that works fairly well is creating a new type alias simply to tag it in a newtype sort of fashion. It's not foolproof, and super clunky looking in C, but you can use it to make your code clearer. (See: boolean trap.)

Name: Anonymous 2014-05-24 18:50

>>22
Okay, have this:
* Weak typing: Types are not enforced at all. Type casts are done at the programming language's will. Bad examples, Javashit and PHP. C is not as weak as JS.
* Strong typing: Types are enforced. Operating two things of incompatible types immediately halts execution of the program. Casts need to be explicit. Examples: pretty much everything else.

Name: Anonymous 2014-05-24 18:58

>>19

weak typing follows postmodernism - you can't define it.

Name: Anonymous 2014-05-24 19:01

>>24
This definition applies not to languages, but to their implementations. If the implementation ignores declared or inferred types, that doesn't mean another implementation might not honor them.

Oh and type errors halt execution in any language, even in Javashit. You must've meant "halts the typecheck".

Name: Anonymous 2014-05-24 19:13

>>26

type errors halt execution in any language, even in Javashit.
You have to be very inventive to produce a type error in Perl, because almost any combination of symbols makes sense with Perl

Name: Anonymous 2014-05-24 19:28

>>27 this is what python programmers actually believes XD

Name: Anonymous 2014-05-24 23:37

Typing is good. Languages where types aren't conceptually sets of objects, and that you can't express common set relations as constraints between types are shit e.g. Haskell. Haskell types are disjoint, and I cannot express that one type is a subset of an other. Furthermore, there is no universal type. So, Haskell a shit.

Name: Anonymous 2014-05-25 2:40

>>29
I keep hearing this about Haskell but I don't believe it. Do you maybe have a link to a foaming-at-the-mouth blog I could read?

Name: Anonymous 2014-05-25 4:34

>>29
Haskell types are disjoint, and I cannot express that one type is a subset of an other.
huh?

Name: Anonymous 2014-05-25 4:40

In a nutshell, types™ are simple functions, so if function A calls function B, then A is is by definition a subtype of B. When function calls several other functions, we have multi-inheritance.

So if you want to change the way function behaves, just wrap it inside of another function.

Name: Anonymous 2014-05-25 5:40

>>32
I just realized that given monads you can avoid the diamond problem.

Name: Anonymous 2014-05-25 5:57

>>31
He's only half-right, actually. He means that if you say

data Foo = A Int | B Double
data Bar = C Int | D Double | E Text


then there is no way to express that the types Foo and Bar share a subset of values (in fact, values of Foo form a subset of values of Bar). And it's also not possible to say

data Foo = A Int | B Double
data Bar = A Int | B Double | E Text


What he's wrong about is:

1) Haskell types are actually not disjoint, as they all share the "bottom" value.
2) With parametric polymorphism, typeclasses and existential types you don't really ever need subtyping
3) Instead of subtyping, Haskell has subclassing which achieves many of the same objectives
3) Subtyping is for OBJECTIVE-ORIENTED SCALABLE CLOUD-READY ENTERPRISE faggots anyway, as it hinders type inference.

>>32
Give me some of that crack you've been smoking, mate.

Name: Anonymous 2014-05-25 6:59

>>34
No crack dog, read the Wadler paper again.

Don't change these.
Name: Email:
Entire Thread Thread List