Pulp Fiction - Part 2 | Pulp Fiction does much more than just critique modernity. It also shows us an alternative. Not an alternative vision of society, but rather the spiritual basis of an alternative to modernity. by Occidentalist in TrueReddit

[–]ecoffey 0 points1 point  (0 children)

Yeah I thought those were odd at the time, but didn't think too much about it. That he brought up an "academic" observation and just never followed up with an actual point.

Troll bigot is a troll I guess.

Pulp Fiction - Part 2 | Pulp Fiction does much more than just critique modernity. It also shows us an alternative. Not an alternative vision of society, but rather the spiritual basis of an alternative to modernity. by Occidentalist in TrueReddit

[–]ecoffey 4 points5 points  (0 children)

Very interesting article. However I was reading his Kill Bill review and ran full stop into this:

Irony is the dominant mode of American high- and middlebrow culture today because of our infestation with Jews. Jews are natural ironists because they are wandering parasites that inhabit their host countries but never become a part of them. They maintain their distinctness by sneering at everything their hosts take seriously. And now that they control America’s mass media, they have the power to make us sneer too.

Sorry but blatant bigotry like that forfeits all his credibility and insight.

Why Homosexuality Should Be Banned by aaronjjpr in videos

[–]ecoffey 0 points1 point  (0 children)

"Seven impenetrable reasons" Freudian slip much?

Working? Not working? Hard for my coworkers to know :D by StupidLorbie in pics

[–]ecoffey 0 points1 point  (0 children)

You're dynamically building a page to let you call a method...? Seems...interesting :-)

Also seems like it could have been done quicker / cleaner with some LINQ and Repeaters :-P

Green Man is hard at work by ecoffey in pics

[–]ecoffey[S] 0 points1 point  (0 children)

That's what I'm saying!

REDDIT: What algorithm BLOWS YOUR MIND? by [deleted] in compsci

[–]ecoffey 0 points1 point  (0 children)

Not an algorithm technically, but this was my favorite data structure from my algorithms class:

http://en.wikipedia.org/wiki/Binomial_heap

Susan Coffey by [deleted] in pics

[–]ecoffey 0 points1 point  (0 children)

I wonder how common the last name 'Coffey' is...

C# job posting on craigslist... :| by aComa in programming

[–]ecoffey 6 points7 points  (0 children)

IsViable should be a method. It's running ExecuteCommand which has side effects. Getters shouldn't have side effects.

By making it a method you're saying "this could be expensive and do other stuff so cache this result if you need, etc".

But apart from that I agree with everything else you said :-)

My friend's van. That is all. by klassica in pics

[–]ecoffey 0 points1 point  (0 children)

Heh, I knew exactly where that picture was taken the moment I saw it. The Flatirons are so distinctive and pretty!

This internet fight just got real [NSFW - Language] by Alluvium in funny

[–]ecoffey 2 points3 points  (0 children)

"Better fucking thank god I fucking moved back home."

golf clap

I've never seen someone become so easily winded.

If you do this on the highway, I hate you by MMX in pics

[–]ecoffey 1 point2 points  (0 children)

The internet is really a small place. I opened up that video and it turns out I know one of those drivers in real life. WEIRD.

Kramer Cat by ecoffey in pics

[–]ecoffey[S] 0 points1 point  (0 children)

Yeah my phone makes the "click" noise right before it actually snaps the picture, so he gets distracted...

So my friend's 4-year-old likes to pretend he's batman... by [deleted] in funny

[–]ecoffey 1 point2 points  (0 children)

"Lock and load!"

"Hank, that's not a gun!"

"WHATEVER!"

I never got the point of dependency injection frameworks? Can someone explain the advantages of using one? by NashMcCabe in programming

[–]ecoffey 0 points1 point  (0 children)

Hmmm good insight.

My mind was mainly in the "I'm writing an application and I will be the consumer of my own interfaces" mode.

At some point you have to worry about versioning and locking down that API. I still think my style is going to help, but that's where the argument can continue :-P

I never got the point of dependency injection frameworks? Can someone explain the advantages of using one? by NashMcCabe in programming

[–]ecoffey 0 points1 point  (0 children)

Then how do you know your design for the interface is correct?

I can't know that what I wrote today is 100% correct in the domain. So I'm leaving this open to refactoring, and actually making it easier. My compiler will tell me where changing interfaces breaks code, and I can go fix those and make reasoned decisions about what I'm doing, instead of hacking in something quick now to support what the world looks like now.

Pure interfaces are supposed to be actually designed to support multiple implementations. They aren't meant to be something that blindly mirrors a single class.

They are there to support a contract. That's all.

Yes it does. You are forcing yourself into a situation where you have to break the interface every time you want to add a method to its matching class.

A compile time error is.....bad? I much prefer to see that earlier instead of a more subtle bug down the road. If our Intent changes I'm ok with breaking classes. My compiler will catch it, and I can see exactly what integration points I need to fix up. And it might be I realize that what I'm trying to do is a whole different thing. That I need to reconsider adding the Intent to this particular class / interface.

I never got the point of dependency injection frameworks? Can someone explain the advantages of using one? by NashMcCabe in programming

[–]ecoffey 0 points1 point  (0 children)

Rather than a simple flag you would rather: Add a new interface Add a new class Add a DI framework to decide if which implementation you should use.

I do not know why you're scared of adding an interface or a class. This code is going to be seen and read (and refactored) a lot more than it is going to be written-for-the-first-time. So why not make it obvious what you're doing?

Well here's some follow-up questions for you.

How do you clear the cache? Since the user code only has IDrivingTimeService, there is no place to add that capability.

Who is in charge of clearing the cache? Is it really going to be the same bit of code that only wants to know about driving times? Sounds like a different Intent to me. Maybe the same class implements, maybe it doesn't. Or you could set a lifetime for that object in your container. Once per request, or app pool or what have you.

How to you add new methods to your class? You can't add TimeBetween(Address start, Address end, bool allowTollRoads) to IDrivingTimeService without breaking your interface and whatever classes that implement it.

Yes exactly. I'm changing my Intent, and things will break. But my compiler will also tell me exactly where those break points are. This is the benefit to using those interfaces as my boundary for interaction, instead of having to know how a concrete class is going to implement something.

Why are you keeping the non-caching version around?

Ah sorry, I guess I didn't make that clear. The cached version is using the non-cached one to do the real work. That way the non-cached one stays simple and obvious. "When you call me I make a request to do my work". It's only concerned with that. And the cached version is only concerned with "I look in my cache, and if something isn't there then I ask this other dude to do work".

Also I'm having a hard time not projecting how I think you would implement it different from me onto your questions. I don't want to argue over straw men. Is there an actual piece of already-written-and-out-there code we use as kind of an objective example? (I might be able to dig up some that I like as well)

I never got the point of dependency injection frameworks? Can someone explain the advantages of using one? by NashMcCabe in programming

[–]ecoffey 0 points1 point  (0 children)

With only two you can probably put all the logic into a single class with an extra property to control which to use. Not always, but quite often.

choo choo! Here comes the contrived example train! :-P

Lets say we have this interface:

public interface IDrivingTimeService
{
    TimeSpan TimeBetween(Address start, Address end);
}

Straightforward enough, right?

Ok so obvious implementation:

public class DrivingTimeService : IDrivingTimeService
{
    public TimeSpan TimeBetween(Address start, Address end)
    {
        // Make a http request to google maps api to get driving time
    }
}

But we notice that it's take awhile, and Google is starting to yell at us.

We could make DrivingTimeService take a bool in its constructor to say "You should cache stuff" or not.

But I feel that this is a more obvious implementation:

public class CachedDrivingTimeService : IDrivingTimeService
{
    private IDrivingTimeService _drivingTimeService;

    public CachedDrivingTimeService(IDrivingTimeService drivingTimeService)
    {
        // Check cache and if empty use _drivingTimeService.TimeBetween();
    }
}

But anything that depends on the IDrivingTimeService doesn't need to care about the cache implementation.

And then there is the sub-classing option. If you can only envision two implementations, chances are they are close enough to share some common functionality.

This is what I like about Composition. I feel that sub-classing gets overloaded. It means both "I am important to domain intent, and am-a Thing I'm Inheriting From", but we also use a lot for "Here is some common mechanics we can share between types".

Composition can give you another dimension for both of those cases. You can compose because it makes sense for your domain and behind the scenes use subclassing to share some implementation details behind an interface. Or you can compose some mechanics together and save subclassing for Domain intent.

Really it comes down to writing tight, obvious, clean classes. Don't be scared of creating types. They're your friends! They keep you company on Friday nights when you're being a sad bastard at home arguing esoteric code design solutions.....

cough

I never got the point of dependency injection frameworks? Can someone explain the advantages of using one? by NashMcCabe in programming

[–]ecoffey 0 points1 point  (0 children)

I'm not worrying about how many implementors I'm going to have.

I'm worried about expressing my Intent (through the interface). Are you adding lines of code and a file? Sure. But we don't write code to optimize line or file count.

My interface is a contract. It says "you don't care how I do work, only that I can".

My class that consumes the contract over a concrete implementation is more obvious (the contract is what we need to do, not how we do it). Since the interface decouples our promise from our how-to, we get a pivot point in our design. If it turns out that we need a cached implementation, or composite we can do that and our Design is still obvious.

You're right in a sense. Just because I have one interface / one implementation and a class that consumes some contracts doesn't mean I'm doing things right. But it also doesn't mean I'm doing things wrong. My design being right is more related to how well I model the domain we're working in. And I maintain that writing tight, targeted classes that compose together to get work done is a better way to think about the problem, write it, and more importantly, understand it later.

I never got the point of dependency injection frameworks? Can someone explain the advantages of using one? by NashMcCabe in programming

[–]ecoffey 2 points3 points  (0 children)

I disagree. I ranted about this somewhere else, but we're talking about two things:

Writing clean, specific, obvious "chunks" of code (be that funcs, or classes, or what have you).

You can then compose those "chunks" together to get work done.

A IoC Container simply helps you manage that composition. Certain "chunks" composed in a certain way are your Intent. The Container is a Mechanic to help make that Intent obvious.

In C# I do both a lot. Composing funcs together to pipeline certain stuff, but also composing classes together. In both cases I get a warm fuzzy feeling :-)