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
VikingofRock
Aug 24, 2008




LeftistMuslimObama posted:

This has been your MUMPS infection for the day.

drat, these are always such good posts. I love reading about the mumps rabbit hole.

Adbot
ADBOT LOVES YOU

MononcQc
May 29, 2007

LeftistMuslimObama posted:

This is incredible. Thank you for this effort post. At the risk of sounding dumb, does erlang execute in some sort of hosting runtime environment that all of this supervision and message passing is possible? I would assume that you couldn't bolt this sort of thing onto a language like C.

Erlang runs in its own virtual machine that does SMP and scheduling, work-sharing, and reimplements processes there.

Notorious b.s.d.
Jan 25, 2003

by Reene
that was some good posting mononcqc

now i think i understand why erlang sees the need to duplicate half the host OS features

bobbilljim
May 29, 2013

this christmas feels like the very first christmas to me
:shittydog::shittydog::shittydog:

I don't know if it's too early in the morning or my brain is just refusing to understand this O_O

e: it just clicked and lol

Hunter2 Thompson
Feb 3, 2005

Ramrod XTreme

pepito sanchez posted:

but being the terrible programmer i am i still recently did this



:doh:

As a terrible programmer, I don't get OO. Why is this terrible? Should you have just folded ReadWritable and ReadWriter into the Game class?

Jerry Bindle
May 16, 2003

meatpotato posted:

As a terrible programmer, I don't get OO. Why is this terrible? Should you have just folded ReadWritable and ReadWriter into the Game class?

when game1,2,3 extend ReadWriter they also implement the ReadWritable interface because what they are extending implements it, so there is no need to explicitly declare that the game classes implement ReadWritable

Jerry Bindle fucked around with this message at 00:17 on Oct 20, 2015

Jerry Bindle
May 16, 2003
it would be like if you had car extends vehicle, and your concrete hotwheels class implements car. you wouldn't also need to declare that hotwheels implements vehicle

Hunter2 Thompson
Feb 3, 2005

Ramrod XTreme

Barnyard Protein posted:

when game1,2,3 extend ReadWriter they also implement the ReadWritable interface because what they are extending implements it, so there is no need to explicitly declare that the game classes implement ReadWritable

Oh, duhhh :downs:

Thanks

Hunter2 Thompson
Feb 3, 2005

Ramrod XTreme
I need to try something besides embedded C one of these days. Erlang sounds cool, maybe I can write embedded erlang...

suffix
Jul 27, 2013

Wheeee!

Funk In Shoe posted:

But I don't understand how this can be the entirety of a job, doing angular.js stuff. I guess if you had to do it every day for 8 hours you'd get pretty bored.

i take it you don't see many "user requirements" in academia

suffix
Jul 27, 2013

Wheeee!


you guys should do a double act

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

Shaggar posted:

inheritance works in same places like controllers in mvc/webapi. The alternative would be duplicating a bunch of plumbing every time you create a new controller.

So most of the reason inheritance ruins things for everyone else is because people think it's "good enough" as code re-use thing. And so proper compositional code re-use often requires pointless boilerplate code to achieve, instead of someone coming up with a good syntax for it.

Bloody
Mar 3, 2013

meatpotato posted:

I need to try something besides embedded C one of these days. Erlang sounds cool, maybe I can write embedded erlang...

lol

pepito sanchez
Apr 3, 2004
I'm not mexican

i'm not into embedded programming at all but i guess the lol means it's not possible or feasible? you can do embedded with other virtual machines...

tef
May 30, 2004

-> some l-system crap ->

pepito sanchez posted:

shaggar is right

if you don't get any benefit from composition what benefit are you getting from inheritance

pepito sanchez
Apr 3, 2004
I'm not mexican

tef posted:

if you don't get any benefit from composition what benefit are you getting from inheritance

not sure! but after your post i'm having fun reading about benefits. i'm happy to be yelled at. it's half the reason i come to yospos.

god drat it's been a full monday :(

MeruFM
Jul 27, 2010

tef posted:

composition

i didn't know this design pattern had a name

pepito sanchez
Apr 3, 2004
I'm not mexican
it's technically called strategy unless i'm mistaken and there is a "composition" pattern?

the way i've been taught, inheritance is all good and well as long as those different "things" inheriting can never be another thing which shares inheritance. for a quick and probably crappy example: manager, waiter, butler extending employee. if there's a chance in your program - in the future - where a butler could move to waiter, or perhaps a waiter could move up to the status of manager, then that's a bad model. changing that state is a massive pain in the rear end if not impossible without breaking everything. if this is your case then employing strategy is the way. person contains type employee implements employable is a? butler()? waiter()? manager()? no problem changing state and keeping inherited behavior from the interface.

happy to be corrected, but this is the case that's been presented to me for and against inheritance and composition.

Bloody
Mar 3, 2013

pepito sanchez posted:

i'm not into embedded programming at all but i guess the lol means it's not possible or feasible? you can do embedded with other virtual machines...

idk im just picturing trying to run erlang on like an msp430

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

i think it would be cool to do embedded functional reactive programming, but lol

Bloody
Mar 3, 2013

it would be

downside is at that level pretty much everything you do is global mutable state and is usually timing sensitive. not really sure how it'd look in an alternative paradigm but it would be interesting

Bloody
Mar 3, 2013

like c in the context of an embedded system is a huge win imo because it is trivial to reason about exactly what the hardware is doing on any line of code (assuming your code base is anything remotely resembling sane)

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

Bloody posted:

like c in the context of an embedded system is a huge win imo because it is trivial to reason about exactly what the hardware is doing on any line of code (assuming your code base is anything remotely resembling sane)

lmao

though maybe this is why embedded c compilers are generally lovely and don't do optimisations

Bloody
Mar 3, 2013

are you compiling with optimizations turned off?

tef
May 30, 2004

-> some l-system crap ->

MeruFM posted:

i didn't know this design pattern had a name

c.f. traits vs classes

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

traits supremacy

my homie dhall
Dec 9, 2010

honey, oh please, it's just a machine
what are the good things about inheritance that composition combined with traits doesn't cover?

zokie
Feb 13, 2006

Out of many, Sweden

Opulent Ceremony posted:

To be more specific, I'm using git from within TFS in Visual Studio, and it tries to automate away a lot of the git processes for you. As an example, their UI for merging does not appear to offer any options with it, you simply select which branch merges into which other branch. Usually it will do an automated merge commit for you, and I think during that process the file in dev was reverted to the older and less-good master one. But just that one.

Sounds like user error. If merging conflicts meant: take mine then git wouldn't need a human to get it right

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

Bloody posted:

are you compiling with optimizations turned off?

are you?

if you're trying to reason about what your code is actually doing after optimisation - well, it's not as easy as you seem to think.

tef
May 30, 2004

-> some l-system crap ->

pepito sanchez posted:

it's technically called strategy unless i'm mistaken and there is a "composition" pattern?

the strategy pattern is, "pass in a function", so for example ["a","bb","ccc"].sort(key=len) in python would be an example of a strategy. in the OO world in which GoF was written, it was just objects and methods, so GoF/The Book is a sorta taxonomy of things you did because the language didn't have those concepts from the outset.

see also: iterators. i mean, we have factories because we don't have functions. we have builders because we don't have named arguments. a lot of this poo poo boils down to things better handled through functional composition. a lot of design patterns are not necessarily good code, but common idioms for approaching a task in languages without support for them natively.

cf. design patterns in dynamic languages: http://norvig.com/design-patterns/ppframe.htm

composition isn't really a pattern. it's just an aesthetic. there are many forms of composition. inheritance in some ways is a form of composition, i just find it very clumsy to use. (although in some ways it's more of a form of delegation, not composition, in that you delegate method calls to other classes)

quote:

happy to be corrected, but this is the case that's been presented to me for and against inheritance and composition.

thing is, i haven't frequently encountered problems that are well modelled by inheritance. interfaces? yes please. loads of them. mixins? yep. traits? please. class inheritrance and superclass dispatch? no thanks. i loving love interfaces, but many of the subclass heirarchies i have encountered are for the latter part clownshoes.

you can't add a new method without carefully inspecting subclasses to make sure you're not accidentally overriding it. you can't extend the type equality without destroying transitivity (liskov substitution principle). it's also too easy to override a superclass's method and breaking things. meanwhile traits are dump all the methods into this class and let the developer resolve conflicts, if any.

pepito sanchez posted:

person contains type employee implements employable is a? butler()? waiter()? manager()? no problem changing state and keeping inherited behavior from the interface.

i guess you want a person type, and a role type. well, you kinda want to capture the history too: really, you have two different state machines here: one for the lifetime of a person in a company, and another for the roles in which they take on. you don't want to add a new method to the class every time a new role appears.

something like person.is_employed() person.current_role().hours, and if you wanted, in java you could use an Enum to represent roles if you wanted to avoid using inheritance unboundedly.

when you structure your software by the patterns it exposes you are not designing software around the interface you want or the state you are modelling inside of it.

and that's all well and good when you need to do tree rewriting, iteration, passing a sort key, but most of these things have been done for you. design patterns are for language features, not for modelling business logic and state, nor a playset for api design.

quote:

in the future - where a butler could move to waiter, or perhaps a waiter could move up to the status of manager, then that's a bad model

WAR IS PEACE
FREEDOM IS SLAVERY
CAR EXTENDS VEHICLE

brap
Aug 23, 2004

Grimey Drawer
so, how is a mixin different from an interface
keep in mind i dont know these things

Jerry Bindle
May 16, 2003

fleshweasel posted:

so, how is a mixin different from an interface
keep in mind i dont know these things

an interface is a set of method signatures

a mixin is a concrete class that implements multiple interfaces or an interface that extends multiple interfaces

an arbitrary example, http://docs.oracle.com/javase/7/docs/api/java/util/Deque.html

deque is a mixin bc it extends the interfaces iterable, collection, and queue

Jerry Bindle
May 16, 2003
bear in mind that everything i say is about java, c or racket, maybe mixin has a different slant in some other languages

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

fleshweasel posted:

so, how is a mixin different from an interface
keep in mind i dont know these things

Mixins are all about implementation inheritance - you extend the mixin class, you get the implementation. Multi-inheritance in general muddies the waters between extending-for-implementation (which is really just composition, without the boilerplate of doing explicit delegation) and extending-for-interface (which is terrible and is way better served with traits and interfaces).

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

tef posted:

WAR IS PEACE
FREEDOM IS SLAVERY
CAR EXTENDS VEHICLE

VikingofRock
Aug 24, 2008




Would you say that war and peace have an IS-A relationship, or an IMPLEMENTED-IN-TERMS-OF relationship?

oh no blimp issue
Feb 23, 2011

tef posted:

WAR IS PEACE
FREEDOM IS SLAVERY
CAR EXTENDS VEHICLE

Kill All Cops
Apr 11, 2007


Pacheco de Chocobo



Hell Gem
i like mixins in sass

code:
@mixin multiLineEllipsis ($line, $lineHeight) {
    display: -webkit-box;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: $lineHeight; // fallback
    max-height: $line*$lineHeight; // fallback
    -webkit-line-clamp: $line; // number of lines to show
    -webkit-box-orient: vertical;
}

.description {
    @include multiLineEllipsis(2, 24px);
    clear: both;
}

#seriesDescription {
    @include multiLineEllipsis(4, 25px);
    font-size: 20px;
}

Kill All Cops fucked around with this message at 07:43 on Oct 20, 2015

Funk In Shoe
Apr 20, 2008

Waiting in line, Mr. Haydon told me it is a wheel not meant for lovers but for infants, lifting people and letting them swing, putting the world on display from up high

suffix posted:

i take it you don't see many "user requirements" in academia

You are, of course, absolutely right and this is yet another point I hadn't even considered. Which I guess serves as further evidence that I should just come to terms with the fact that my plan of "programming/systems design as a backup career if I get tired of this one" is probably not very feasible.

Adbot
ADBOT LOVES YOU

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

Funk In Shoe posted:

You are, of course, absolutely right and this is yet another point I hadn't even considered. Which I guess serves as further evidence that I should just come to terms with the fact that my plan of "programming/systems design as a backup career if I get tired of this one" is probably not very feasible.

stop loving flagellating yourself and remember the title of this thread

  • Locked thread