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
Forums Terrorist
Dec 8, 2011

in the eyes of god every computer made after the fall of the iron curtain is haraam

Adbot
ADBOT LOVES YOU

Baxate
Feb 1, 2011

rrrrrrrrrrrt posted:

not that I disagree with the idea that all webpages should be static, server generated html but yeah it sounds like you don't get JS at all. like, do you think pages should have no scripting at all ever?

I can't think of any good uses of js so no

Space Whale
Nov 6, 2014

Forums Terrorist posted:

in the eyes of god every computer made after the fall of the iron curtain is haraam

I really want to see what would happen if someone was running some babby linux distro on a 386 and tried to run a modern browser.

Hell, a Pentium.

Shaggar
Apr 26, 2006

prefect posted:

you get to offload all the processing work to the clients, and gently caress up their computers instead of your nice servers

its basically this. user experience doesn't really matter

Valeyard
Mar 30, 2012


Grimey Drawer

Ludwig van Halen posted:

I can't think of any good uses of js so no

hello richard matthew stallman

Baxate
Feb 1, 2011

Valeyard posted:

hello richard matthew stallman

I think that web pages should only be used to display information or to allow mild editing of data via forms that correspond to sql columns

if u need more than that maybe you should write a native application

brap
Aug 23, 2004

Grimey Drawer
lol yeah let's go back to synchronous web pages this will be great

my homie dhall
Dec 9, 2010

honey, oh please, it's just a machine

Ludwig van Halen posted:

I think that web pages should only be used to display information or to allow mild editing of data via forms that correspond to sql columns

if u need more than that maybe you should write a native application

yeah whatever grandpa

Forums Terrorist
Dec 8, 2011

They ask you about the internet and scripts of Java. Say: In both of them there is a great sin and means of profit for men, and their sin is greater than their profit. And they ask you as to what they should spend. Say: What you can spare. Thus does Allah make clear to you the communications, that you may ponder

Flat Daddy
Dec 3, 2014

by Nyc_Tattoo
Javascript should only be used to progressively enhance your mouse cursor icon.

The Leck
Feb 27, 2001

am i missing something, or is dependency injection mostly "pass the needed stuff in to the function/object rather than hardcoding it"?

qntm
Jun 17, 2009
it wouldn't be the first stunningly obvious and simple programming concept with a dramatic name which makes it sound intimidating

Space Whale
Nov 6, 2014
What's the thread for "Mommy and Daddy are fighting?"

We have no project manager/dev director/{layer just on top of devs who reports to management title} and there's a power struggle between our BA/scrum master (who has a lot of experience being a scrum master) and one of our Devs, and a big fussing match with our CEO and, uh, everyone.

I'm right next to the office of our CFO, and the CEO's office is another door down. Everyone's in the CFOs office fussing and the CEO is getting pissed. The best part is a lot of this started from some rear end in a top hat coming back who everyone was begging the CEO not to bring back for causing drama.

:q:

Space Whale
Nov 6, 2014
I'm the only dev left at their desk, save for our long timer mousey back end engineer, who seems to have mastered the art of giving no fucks.

gonadic io
Feb 16, 2011

>>=

qntm posted:

code:
def isPerfect(num):
    return num in [6,28,496,8128,33550336]

lmao

cinci zoo sniper
Mar 15, 2013




code:
int GetRandomNumber()
{
return 4; // Chosen by a fair dice roll
// Guaranteed to be a random
}

leftist heap
Feb 28, 2013

Fun Shoe

The Leck posted:

am i missing something, or is dependency injection mostly "pass the needed stuff in to the function/object rather than hardcoding it"?

you're just missing that DI containers provide ways to do the DI that are more sophisticated like via magic, or obtuse layers of config files, or peppering annotations everywhere, etc. so that you barely have to know the DI is happening except when something goes wrong and you have to unravel why some object way down the dependency graph wasn't instantiated correctly and wait why the gently caress does it need to be DI'ed in the first place since there's only ever been one implementation???

theadder
Dec 30, 2011


Ludwig van Halen posted:

I can't think of any good uses of js so no

:agreed:

jesus WEP
Oct 17, 2004


textbooks often have the same problem where they address things like DI and mocking frameworks and unit testing via babby's first c# mvc webapp or w/e, and youre left thinking why the gently caress would you go to the trouble

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

St Evan Echoes posted:

textbooks often have the same problem where they address things like DI and mocking frameworks and unit testing via babby's first c# mvc webapp or w/e, and youre left thinking why the gently caress would you go to the trouble

lmao di is trivial

1. write to an interface not an implementation
2. let the constructor take the implementation for that interface

=> DI frameworks just poo poo that up by having implict filling in of dependencies and poo poo

brap
Aug 23, 2004

Grimey Drawer
dependency injection just sounds more complex than it is.

Valeyard
Mar 30, 2012


Grimey Drawer
im burned out

Space Whale
Nov 6, 2014
Pass an Engine to your Car constructor :)

code:
[Police_Interceptor]
Public Class CrownVic
{
IRevable engine;

CrownVic(Engine _engine)
{
engine = _engine;
}
//code
}

Space Whale fucked around with this message at 05:04 on Jan 21, 2015

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Space Whale posted:

Pass an Engine to your Car constructor :)

code:
[Police_Interceptor]
Public Class CrownVic
{
IRevable engine;

CrownVic(Engine _engine)
{
engine = engine;
}
//code
}


i finally grok di

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
seems like it would be a lot better if the the car came with an engine but you had the option to upgrade it if you wanted. like a rice rocket or something.

i suppose that would come at the cost of unnecessary expense (memory allocation!)!!!!

FamDav
Mar 29, 2008

qntm posted:

it wouldn't be the first stunningly obvious and simple programming concept with a dramatic name which makes it sound intimidating

no no man in order to do dependency injection you {insert spring tutorial here}

the reason you need a DI framework is because you can't do partial application with java constructors :(.

Flat Daddy
Dec 3, 2014

by Nyc_Tattoo

FamDav posted:

no no man in order to do dependency injection you {insert spring tutorial here}

the reason you need a DI framework is because you can't do partial application with java constructors :(.

i thought that's why we have the builder pattern

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

FamDav posted:

the reason you need a DI framework is because you can't do partial application with java constructors :(.

how does partial application get you out of the pass-from-above parameter explosion hellpit?

Shaggar
Apr 26, 2006
heh, all my DI dependencies are runtime :smug:

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Here's how the evolutionary chain leading to DI usually plays out.

code:
function A() {
  B();
}

function B() {
  C();
}

function C() {
  var t = new Thing();
  t.molest();
}

A();
"Oh poo poo, I need to mock Thing, I better pass it in!"

code:
function A(thing) {
  B(thing);
}

function B(thing) {
 C(thing);
}

function C(thing) {
  thing.molest();
}

var t = new MaybeFakeThing();
A(t);
"Oh poo poo, I have to mock a bunch of stuff in C, I better pass it all in."

code:
function A(thing, other, fuckoff) {
   B(thing, other, fuckoff);
}

function B(thing, other, fuckoff) {
  C(thing, other, fuckoff)[
}

function C(thing, other, fuckoff) {
  thing.molest(other.fondle(fuckoff));
}

A(new FakeThing, new OtherOther, new JustFuckoff);
"OK, that sucks, every internal dependency changes all API transitively, I'll just pass in a context object."
code:
function A(ctx) {
  B(ctx);
}

function B(ctx) {
  C(ctx);
}

function C(ctx) {
  ctx.getThing().molest(ctx.getOther().fondle(cx.getFuckoff));
}

var ctx = new Context(new Thing, new Other, new Fuckoff);
A(ctx);
"Well poo poo, that context configuration is all global, I'll just make it static."
code:
function A() {
  B();
}

function B() {
  C();
}

function C() {
  GlobalContext.getThing().molest(GlobalContext.getOther().fondle(GlobalContext.getFuckoff()));
}

GlobalContext.setup(new Thing, new Other, new Fuckoff);
A();
"That's a lot of boilerplate, I wish I could have the compiler rewrite my calls to new to look in the right place."

AOP goes here.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Then: "Why is my application spending 500ms parsing XML at startup before it spins the event loop?"

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

Subjunctive posted:

Here's how the evolutionary chain leading to DI usually plays out.

code:
function A() {
  B();
}

function B() {
  C();
}

function C() {
  var t = new Thing();
  t.molest();
}

A();
"Oh poo poo, I need to mock Thing, I better pass it in!"

code:
function A(thing) {
  B(thing);
}

function B(thing) {
 C(thing);
}

function C(thing) {
  thing.molest();
}

var t = new MaybeFakeThing();
A(t);
"Oh poo poo, I have to mock a bunch of stuff in C, I better pass it all in."

code:
function A(thing, other, fuckoff) {
   B(thing, other, fuckoff);
}

function B(thing, other, fuckoff) {
  C(thing, other, fuckoff)[
}

function C(thing, other, fuckoff) {
  thing.molest(other.fondle(fuckoff));
}

A(new FakeThing, new OtherOther, new JustFuckoff);
"OK, that sucks, every internal dependency changes all API transitively, I'll just pass in a context object."
code:
function A(ctx) {
  B(ctx);
}

function B(ctx) {
  C(ctx);
}

function C(ctx) {
  ctx.getThing().molest(ctx.getOther().fondle(cx.getFuckoff));
}

var ctx = new Context(new Thing, new Other, new Fuckoff);
A(ctx);
"Well poo poo, that context configuration is all global, I'll just make it static."
code:
function A() {
  B();
}

function B() {
  C();
}

function C() {
  GlobalContext.getThing().molest(GlobalContext.getOther().fondle(GlobalContext.getFuckoff()));
}

GlobalContext.setup(new Thing, new Other, new Fuckoff);
A();
"That's a lot of boilerplate, I wish I could have the compiler rewrite my calls to new to look in the right place."

AOP goes here.

gross

Subjunctive
Sep 12, 2006

✨sparkle and shine✨


Extremely. Good DI environments either rewrite invisibly or let you write something compact like

code:
new DI<Thing>(p, q, r);
or interpose at runtime via a classloader equivalent. Wanting to late-bind implementation selection is OK, and wanting to avoid pass-from-above's terrible encapsulation behaviour is just good sense, but some languages really make you suffer for it.

And then you write a processor of some kind that statically binds your production implementations so you don't pay the heap/initialization/etc costs in the configuration that actually matters to your users.

brap
Aug 23, 2004

Grimey Drawer
my experience with DI is basically this

code:
public class Bar : IBar { ... }

public class Foo
{
    private IBar bar;

    public Foo() : this(new Bar()) { }

    public Foo(IBar bar)
    {
        this.bar = bar;
    }
}
so that in your unit test you can make a Foo while providing some mocked IBar implementation that gives hardcoded results.

you should avoid DI outside of constructors.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

fleshweasel posted:

you should avoid DI outside of constructors.

as long as your language can abstract away singletons behind constructors, yes

Space Whale
Nov 6, 2014

MALE SHOEGAZE posted:

seems like it would be a lot better if the the car came with an engine but you had the option to upgrade it if you wanted. like a rice rocket or something.

i suppose that would come at the cost of unnecessary expense (memory allocation!)!!!!

Default/optional params? Null check? Parameterless constructor?

Shaggar
Apr 26, 2006

MALE SHOEGAZE posted:

seems like it would be a lot better if the the car came with an engine but you had the option to upgrade it if you wanted. like a rice rocket or something.

i suppose that would come at the cost of unnecessary expense (memory allocation!)!!!!

the right way to use inheritance is base abstract class functionality that is extended by real classes. ex: A Controller class that implements a pile of methods for generating responses that you would use within a child implementer.

in this case a controller interface doesnt make sense.

You could have a controller class that accepts interfaces of various types to handle requests which would make those implementations reusable in another controller. However, it makes the controller harder to understand which defeats part of the purpose of MVC.

Baxate
Feb 1, 2011

i don't "get" object oriented programming either

the c programming language was handed down to us mortals by god and u make an abomination of it by altering god's vision

b0lt
Apr 29, 2005

Ludwig van Halen posted:

i don't "get" object oriented programming either

the c programming language was handed down to us mortals by god and u make an abomination of it by altering god's vision

http://www.templeos.org/Wb/Doc/HolyC.html

Adbot
ADBOT LOVES YOU

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome

Subjunctive posted:

AOP goes here.

you forgot the picture of the trash can

  • Locked thread