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.
 
  • Post
  • Reply
Finster Dexter
Oct 20, 2014

Beyond is Finster's mad vision of Earth transformed.

DaTroof posted:

the controller class is a good example. ime inheritance works better if it's shallow, even if it's wide; e.g., a handful of classes that directly extend a single superclass. if your inheritance tree is ten levels deep, it's probably fragile

interface implementation seems closer to composition than inheritance

Yes to all this.

Interface implementation is not inheritance.

Aramoro posted:

Composition is superior depending on the design pattern being used, and it being superior in no way makes inheritance bad. They are in fact both good depending what it is you're trying to do. They're also both bad if you implement them badly.

I disagree. Anywhere that you think Inheritance is good, it's probably actually really bad. Inheritance is literally the worst way to extend class behavior and no one should ever do it. There are scenarios outside of class extension where it makes sense, but probably not then either. Like, you can inherit from ControllerBase for .Net core MVC, but that's a very specific use case based on the conventions of MVC.

Adbot
ADBOT LOVES YOU

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

if you have ever written a subclass, you are a piece of poo poo

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



carry on then posted:

if you have ever written a subclass, you are a piece of poo poo

class You(Butt)

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


oh boy does using reflection feel dirty

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Powerful Two-Hander posted:

oh boy does using reflection feel dirty

yeah it owns

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Powerful Two-Hander posted:

oh boy does using reflection feel dirty

yeah

Soricidus
Oct 21, 2010
freedom-hating statist shill

Finster Dexter posted:

Yes to all this.

Interface implementation is not inheritance.


I disagree. Anywhere that you think Inheritance is good, it's probably actually really bad. Inheritance is literally the worst way to extend class behavior and no one should ever do it. There are scenarios outside of class extension where it makes sense, but probably not then either. Like, you can inherit from ControllerBase for .Net core MVC, but that's a very specific use case based on the conventions of MVC.

gently caress you, i'm adding another layer of inheritance to all my class hierarchies to own the .libs

Finster Dexter
Oct 20, 2014

Beyond is Finster's mad vision of Earth transformed.

Soricidus posted:

gently caress you, i'm adding another layer of inheritance to all my class hierarchies to own the .libs

kitten emergency
Jan 13, 2008

get meow this wack-ass crystal prison
inheritance is bad, composition is good, be gay, do crimes, hail satan

Gallatin
Sep 20, 2004

uncurable mlady posted:

inheritance is bad, composition is good, be gay, do crimes, hail satan

can i pick & choose?

Soricidus
Oct 21, 2010
freedom-hating statist shill
today i looked at two classes that implemented the same interface and did the same thing to two different kinds of data, and observed a large amount of code copy-pasted between them making it difficult to see the actual differences and introducing a bunch of fragility if changes weren't performed in both places. so i moved all the shared code into a new abstract superclass and now there's no repetition and each class does exactly as much as it needs to with minimal boilerplate

i'm a monster

FlapYoJacks
Feb 12, 2009

Soricidus posted:

gently caress you, i'm adding another layer of inheritance to all my class hierarchies to own the .libs

Terrible programming: Adding layers of inheritance to own the .libs

Edit*

I have a personal idiom of never EVER going more than 1 layer of inheritance. Usually a base class with several variants stemming from that base class.

IE: OCPP base class, then OCPP1.5, 1.6, and 2.0 classes that inherit the base class.

I think that's perfectly fine and acceptable.

Finster Dexter
Oct 20, 2014

Beyond is Finster's mad vision of Earth transformed.

Soricidus posted:

today i looked at two classes that implemented the same interface and did the same thing to two different kinds of data, and observed a large amount of code copy-pasted between them making it difficult to see the actual differences and introducing a bunch of fragility if changes weren't performed in both places. so i moved all the shared code into a new abstract superclass and now there's no repetition and each class does exactly as much as it needs to with minimal boilerplate

i'm a monster

lmao yeah because now when someone needs to update code in the abstract class that adds a feature or fixes a bug for subtype A, there's a high chance they will gently caress up something in subtype B without even realizing it.

You better have 100% test coverage or else this code will be turbofucked in no time flat

Soricidus
Oct 21, 2010
freedom-hating statist shill

Finster Dexter posted:

lmao yeah because now when someone needs to update code in the abstract class that adds a feature or fixes a bug for subtype A, there's a high chance they will gently caress up something in subtype B without even realizing it.

You better have 100% test coverage or else this code will be turbofucked in no time flat

now it sounds like you're arguing against code reuse period

i mean i'll grant you the world would be a better place if nobody ever reused my code but that's a different story

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


ratbert90 posted:

Terrible programming: Adding layers of inheritance to own the .libs

Edit*

I have a personal idiom of never EVER going more than 1 layer of inheritance. Usually a base class with several variants stemming from that base class.

IE: OCPP base class, then OCPP1.5, 1.6, and 2.0 classes that inherit the base class.

I think that's perfectly fine and acceptable.

you down with OCPP?
yeah you know me
and you know me
and you know me
and you know me
and you ERROR NOT IMPLEMENTED

Aramoro
Jun 1, 2012




Finster Dexter posted:

You better have 100% test coverage or else this code will be turbofucked in no time flat

Why would you not have test coverage for something like that? I mean sure if you're a terrible programmer your usage of inheritance is going to suck, but then so is your composition. Someone breaking subtype B fixing a bug in Subtype A without even testing it is awful and will gently caress up your codebase no matter what you do.

Both pale in comparison to reflection in your ability to gently caress things up horribly but it's still got a place.

Aramoro fucked around with this message at 00:32 on Jan 26, 2019

Phobeste
Apr 9, 2006

never, like, count out Touchdown Tom, man

Aramoro posted:

I mean sure if you're a terrible programmer

buddy have I got news for you

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Aramoro posted:

Why would you not have test coverage for something like that? I mean sure if you're a terrible programmer your usage of inheritance is going to suck, but then so is your composition. Someone breaking subtype B fixing a bug in Subtype A without even testing it is awful and will gently caress up your codebase no matter what you do.

Both pale in comparison to reflection in your ability to gently caress things up horribly but it's still got a place.

i feel like inheritance is ultimately more destructive. i mean, yeah, i've seem reflection used to horrific ends, but most people are aware of this and avoid it. inheritance is bad because most people think it's a good idea when in fact it's a bad idea. although honestly most up-to-date programmers seem to be getting the message these days.

DELETE CASCADE
Oct 25, 2017

i haven't washed my penis since i jerked it to a phtotograph of george w. bush in 2003
inheritance is not the problem, implied subtyping due to inheritance is the problem

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

DELETE CASCADE posted:

inheritance is not the problem, implied subtyping due to inheritance is the problem

that's an interesting idea

but without implied subtyping is inheritance really worth talking about?

DELETE CASCADE
Oct 25, 2017

i haven't washed my penis since i jerked it to a phtotograph of george w. bush in 2003
there are languages which use structural subtyping instead of nominal, it's just pretty rare

Doom Mathematic
Sep 2, 2008

DELETE CASCADE posted:

inheritance is not the problem, implied subtyping due to inheritance is the problem

OK, perhaps I'm a fool, but this a safe space so would you mind explaining the distinction between inheritance and subtyping? I thought they were the same thing.

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

Doom Mathematic posted:

OK, perhaps I'm a fool, but this a safe space so would you mind explaining the distinction between inheritance and subtyping? I thought they were the same thing.

I think what DELETE CASCADE is on here is that subtyping implies liskov substitution but inheritance does not

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Aramoro posted:

Why would you not have test coverage for something like that? I mean sure if you're a terrible programmer your usage of inheritance is going to suck, but then so is your composition. Someone breaking subtype B fixing a bug in Subtype A without even testing it is awful and will gently caress up your codebase no matter what you do.

Both pale in comparison to reflection in your ability to gently caress things up horribly but it's still got a place.

i don't wanna call anyone out because maybe what i inferred is not what they meant, but in a very general sense, some people seem to think type safety precludes testing, and HOLY poo poo are they wrong

Oneiros
Jan 12, 2007



DaTroof posted:

i don't wanna call anyone out because maybe what i inferred is not what they meant, but in a very general sense, some people seem to think type safety precludes testing, and HOLY poo poo are they wrong

"if it compiles it works"
~ literally one of my coworkers

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

at my first job people would tell junior developers that writing unit tests was unnecessary because the only way you can have a bug that the scala typechecker can't handle is if you have side effects, which are bad, so

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord
I always felt like some staticlangers tend to trust the type system way too much but that's just ridiculous

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord
if you don't wanna write tests, that's fine, sometimes it's not worth it.

but jesus don't make up bullshit like that.

kitten emergency
Jan 13, 2008

get meow this wack-ass crystal prison
types dont guard against npe

mod saas
May 4, 2004

Grimey Drawer
as someone who learns by example are there demo pages or whatever that have demo code and tests for it, with explanation of how the tests were chosen and why the test runs the way it does

I understand the purpose of testing and I've done some, but I always draw blanks on what to do when I'm actually in the thick of it.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

mod saas posted:

as someone who learns by example are there demo pages or whatever that have demo code and tests for it, with explanation of how the tests were chosen and why the test runs the way it does

I understand the purpose of testing and I've done some, but I always draw blanks on what to do when I'm actually in the thick of it.

jeez, it took me years before i got used to writing test suites. nowadays it's my sop, but i still feel like i learned it by ear

one thing i can suggest, look for anything written/presented by sandi metz. a lot of her stuff is specific to ruby, but she knows the poo poo out of oop and tdd

Beamed
Nov 26, 2010

Then you have a responsibility that no man has ever faced. You have your fear which could become reality, and you have Godzilla, which is reality.


uncurable mlady posted:

types dont guard against npe

why would you write in a language which allows null pointers

Gallatin
Sep 20, 2004

Oneiros posted:

"if it compiles it works"

said frequently by the owner of the last company i worked at

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Beamed posted:

why would you write in a language which allows null pointers

because languages that don't allow null pointers* don't exist

*or an equivalent they don't call "null"

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde
https://www.nytimes.com/2019/01/24/technology/computer-science-courses-college.html

no you fools its a trap

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



is there a good comparison/overview of the pros/cons of the various nltk tokenizers?

their docs are autogenerated and pretty barebones..
https://www.nltk.org/api/nltk.tokenize.html

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?

aardvaard posted:

javascript, apis, and markup

what a normal person would call a "single page app" or "why is this page so god drat slow"

but that type of development has been deprecated since mid-2008, when the App Store was introduced

the only worthwhile development is native development and backend development supporting native development

Xarn
Jun 26, 2015

uncurable mlady posted:

types dont guard against npe

Here is a penny, buy yourself a real language.

Xarn
Jun 26, 2015

eschaton posted:

but that type of development has been deprecated since mid-2008, when the App Store was introduced

the only worthwhile development is native development and backend development supporting native development

I might give you poo poo sometimes, but I love this gimmick.

Adbot
ADBOT LOVES YOU

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



wtf just wrote this:

code:
    init __self__():
:psyduck:

i guess my mind missed 'def' but my fingers still formatted the line as if i didnt

e: also probably says a lot about how my brain processes language

Carthag Tuek fucked around with this message at 10:23 on Jan 26, 2019

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply