« first day (1943 days earlier)      last day (3061 days later) » 

6:00 PM
life's too short for "is foo really overriding Base::foo?" puzzles
 
in Python 3, it's super().foo, which would probably only be called inside of cls.foo
 
I'm afraid to ask if super() is just a getter or something more sinister
 
@Ixrec yes well luckily you live in JS where you can get away with that... actually in .NET I currently get to do entirely my own code so inheritance isn't an issue for me either. Hooray for composition over inheritance.
 
super is considered super. If you read that it's considered harmful, the guy doesn't know what he's talking about.
 
@AaronHall remember these rules you understand are very Python specific.
 
6:03 PM
@JimmyHoffa yeah, even in C++ the only times I inherit are when the framework/libraries order me to
 
Sure, prepend Python everywhere you see me say anything
 
@AaronHall the fact that it's a function call looks strange to me, which makes me worry it's doing something non-trivial, that's all
114
A: How to use 'super' in Python?

John MillikinThe benefits of super() in single-inheritance are minimal -- mostly, you don't have to hard-code the name of the base class into every method that uses its parent methods. However, it's almost impossible to use multiple-inheritance without super(). This includes common idioms like mixins, interf...

 
It is nontrivial. It uses the original class's Method Resolution Order (linearized by the C3 algorithm) and calls the method from the class next in line.
 
whoa, wait a minute...this is totally different from the super I know
@AaronHall you lost me
 
@Ixrec I think he means it works like how abstract or virtual methods work for us from a base class; a base class calling one will execute the derived classes method (or property or field)
but in Python the base class has to use super() to delineate it should execute a derived classes implementation
I guess?
Oh gods don't explain it
I don't think I want to know
 
6:07 PM
I'm still waiting for my XBone to finish installing Halo 5 so might as well go looking for the explanation
unless Aaron is willing to take another stab at explaining Python to us
 
does watching that require knowing how super works first?
 
no, it's totes easy.
 
@Ixrec maybe he's as confused by the way we're phrasing things as we are by him
 
@JimmyHoffa probably
@AaronHall okay, let's see if Microsoft can install one video game before this talk finishes
 
6:11 PM
@Ixrec XBone fail; Steam Box, Steam Link, or Nvidia Shield are the only acceptable living room machines now.
 
"cooperative multiple inheritance" hmm
 
(mostly because console games are stuuupid expensive)
 
@JimmyHoffa I got it as a Christmas gift
 
fair.
 
I've yet to be personally convinced by the value proposition of any "living room machine"
 
6:12 PM
@Ixrec yep, you'll be a convert before you know it.
 
since my laptop does 90% of what they do on a smaller screen, and I don't mind that the screen is smaller
 
Speaking of steam, I should go check on the latest sale state
@Ixrec you have to want to use a controller and or do local-coop. Without those two things, Roku and done.
 
"inheritance is a tool for code reuse" gotta be honest, I always get skeptical when this argument shows up
 
@JimmyHoffa even the controller doesn't matter since you can buy controllers for PC too
 
6:14 PM
@Ixrec yeah, my controllers all work on my computer. I have an Nvidia shield and bought a hand full of cheap bluetooth controllers for it; with bluetooth they work perfectly well on my PC as well
 
Hello everyone, I'm a newbie here.
And I need your valuable help. I looking for project suggestions where I can get to learn about Quality Assurance. Which sort of projects if I get into will most likely help me in understanding and applying QA??? plz help..
:)
 
@JimmyHoffa yup, that's exactly my perspective on it
 
Most coders are consumers. Some coders rarely have a reason to create a class in the first place. Some coders write core dependencies for other coders to use. They occasionally find cases for elegant multiple inheritance.
 
@AaronHall O_O WHAT ON EARTH??
 
once again, inheritance of implementations, or inheritance of interfaces?
 
6:16 PM
you live in a vastly different software world than me if you think of most coders as "consumers" who don't actually design and create software systems
 
if you meant the latter then 100% agree with what you just said
 
Perhaps you're confusing technical business / IT analyst or general IT person with "coder" ? To me, a coder is someone who: Maintains and designs software systems through the use of a software language with which they design solutions in the scope of a broader or not-so-broad software system.
People who write one-off scripts aren't "coders", that's a sys admin or an ETL or reports person
 
I'll have to disagree with Jimmy here, while I do design "systems" as part of my coding, I am most definitely a "consumer" of other people's systems rather than a producer of systems used by other coders
 
A coder is anyone who could instantiate your object in their own code, even if they don't have "programmer" in their job title.
 
@Ixrec I consume other peoples code too, but are you going to tell me you don't design and implement software as a part of your daily job? He just said most coders don't do that
 
6:21 PM
You are a consumer if you instantiate other people's code. I am a consumer, but I try to contribute to core dependencies as well.
I try to write code that is easily reused.
 
technically he didn't, what he said was some coders rarely have a reason to create a class, which is actually completely true for me
well, I have some, but they could just as easily have not been classes
 
@Ixrec just because you create closures instead :P The spirit of what he's saying is they create one-off scripts
> Some coders rarely have a reason to create a class in the first place.
I just cannot agree with this
when you say "class" do you mean a software module for their own use? Or do you mean publically distributed library?
 
if we're talking modules with defined public APIs then yes I'm making those all the time
 
Sometimes I write simple functions that elegantly combine disparate utilities in a very useful way. Sometimes I write objects. My main personal project uses a large inheritance tree to factor out redundancy.
 
lol'd @ "whenever you call super, it's about calling your parents"
 
6:23 PM
he's funny
 
also, flat-out admitting at the start of the talk that "super" was the wrong name will probably go a long way to making this make sense
 
He's good, but he's afraid to tweet back to me because my dumbness might rub off on him.
That or he didn't notice
My personal project has lots of classes that, aside from docstrings, are basically empty, and I don't think I'm using any multiple inheritance either.
 
@AaronHall stupid question time: would it be fair to say that the MRO C3 whatever its called solves the diamond of death by essentially saying "depth-first search the left side first, but backtrack every time you hit a common ancestor"?
 
Well it's also a locally consistent.... something or other. I haven't totallly mastered it, to be honest.
 
lol
 
6:29 PM
@AaronHall just go learn Haskell and everything about Python will become clear.
Nov 13 at 23:07, by Jimmy Hoffa
@Ixrec Have you accepted Haskell into your home and into your heart yet? Can I interest you in a monoid?
 
user55340
Perl 5's MI resolution is reasonable... though it comes with a cautionary tale too. perldoc.perl.org/perlobj.html#Inheritance
 
user55340
> Multiple inheritance often indicates a design problem, but Perl always gives you enough rope to hang yourself with if you ask for it.
 
as does C++
sometimes I get the impression Perl is the C++ of scripting languages
/hides
 
@Ixrec I thought C++ was the Perl of assemblers..
 
I wrote the Python part of this wikipedia article:
In computing, the C3 superclass linearization is an algorithm used primarily to obtain the order in which methods should be inherited (the "linearization") in the presence of multiple inheritance, and is often termed "MRO" for Method Resolution Order. The name C3 refers to the three important properties of the resulting linearization: a consistent extended precedence graph, preservation of local precedence order, and fitting the monotonicity criterion. (The name "C3" is not an initialism.) It was first published at the 1996 OOPSLA conference, in a paper entitled "A Monotonic Superclass Linearization...
 
user55340
6:34 PM
 
Yeah, also in Dylan and Parrot, there's a paper...
Anyways, I think you can use depth-first, left to right as a crutch until you can totally get it. I've tried working it out on paper with that complicated multiple inheritance, but it's not easy when it's that complicated.
 
@AaronHall if you define a class as class Foo(Bar):, and in a method of Foo you write Bar.doStuff(), are those two instances of Bar in any way connected to each other, or could I just as easily have written StuffDoer.doStuff()?
 
EMH?
 
because at first glance that syntax makes it look like we're defining a class in terms of "type parameters" to be supplied later when instantiating actual objects
@AaronHall cool, my main point was that it defines an unambiguous way to traverse the diamond, so that works for now
 
6:39 PM
If you write Bar.doStuff you are hard-wiring the call to the method. Instead you should do self or cls.doStuff
 
ah, and that version will go to the X in class Foo(X)?
 
or use super if you're already in a call to self or cls.doStuff
 
@AaronHall Yes
 
Efficient Market Hypothesis?
 
Emergency Medical Help?
 
6:44 PM
Did a celebrity with those initials die or something?
 
"are any of you even slightly unsettled by this?" lol, yes, I most certainly am unsettled by the ability to change X's dependencies simply by creating a new subclass of X
I am intrigued though
 
I found a copy of the paper: citeseerx.ist.psu.edu/viewdoc/…
It's cool, right? Dependency injection, due to C3.
 
for the record, the stability of the algorithm does not worry me, I get that OrganicPizza would continue to call the get_dough() method of OrganicDoughFactory until the maintainer of OrganicPizza himself decided to change that
it's the whole becoming dependent on other people's base classes thing that unnerves me; the maintainer of Pizza and DoughFactory may decide that get_dough should return a Dough object instead of a string, and then I'm hosed
 
open closed principle?
but they could return a Dough object that's a subclass of str, and you'd be fine - Liskov Substitution
 
6:51 PM
but how do I know they've committed to keep get_dough returning subclasses of str?
 
You don't even need to check type - Dependency Inversion
How do you know? Do you work with code monkeys or real programmers?
 
I suppose the real question is how do I know I won't accidentally override a method on a base class I didn't even know existed because it's internal to the other package
if DoughFactory was a public documented thing then sure I'd do the organic dough trick
 
user55340
 
Now I once broke a guy's code. My code was in dev, and he started importing a function from my package. I knew it was a useful function, his code broke when I moved it into a util module.
But it wasn't even in production.
And I had no idea my code was already becoming a dependency.
 
perhaps this is just some kind of bias on my part, but this currently feels like a way to break into a class' implementation and alter the other guy's code
but I'll keep it in mind
 
6:56 PM
@AaronHall please don't instruct anybody else on any of these principles until you understand them better yourself; these types of propagations of misunderstandings are how we end up with so much of the industry doing completely nonsense things but convinced it's some "best practice". It's like a bad game of telephone
 
@Ixrec Easy, inspect the object, i.e. dir(obj) and avoid messing with nominally private names. :)
 
user55340
Well... that question is kind of answered. Was moving drives from huge tower to external enclosures (the coffee pot doesn't have any bays). One of the drives when it went in the enclosure went 'snap' and won't come out... but the connections are there and apparently good (finally turned it on after trying to get it out without applying too much force).
 
nominally in Python, everything is public. You say hands off by prepending a single underscore
 
user55340
So, I'm not going to move stuff off of that drive and copy it to another volume - its in there to stay.
 
@AaronHall same convention as Javascript, that I can do
 
6:58 PM
prepending a double-underscore (without an ending one) invokes name-mangling, avoid that.
 
I was under the impression __foo__ was code for PYTHON MAGIC HAPPENS TO FOO
 
@Ixrec nonsense, JavaScript has privates by way of locals
 
@JimmyHoffa it is an actual convention used by people who don't know (or care) that closures are a thing
 
__foo__ means python magic invokes __foo__
 
close enough
 
7:00 PM
a in b invokes b.__contains__(a)
 
@Ixrec to be fair, I'm all for conventional naming to indicate scoping when it's variable like that (I'm more for local-only scoping, but whatever)
 
a + b invokes a.__add__(b) (leaving out some details)
a += b invokes a.__iadd__(b)
 
well, if you're doing local-only scoping than "private" and "public" cease to be meaningful concepts, it's just arguments and return values
 
honestly I thought Python was probably a decent language from the bits you hear here and there before today; the more I hear the more it sounds like some weird in-group nonsense
 
By the way, I'd love to read a SOLID exposition in the context of Python, but I don't think I'll find one.
 
7:02 PM
@Ixrec yep. But like I said, when there is variable scoping; things being used in multiple different scopes- I do like conventional naming
 
@JimmyHoffa I'll probably continue using it for the miscellaneous scripting purposes we're currently using it for where classes are largely not a thing
 
@AaronHall If you study SOLID closely, you'll learn it has nothing to do with a language...
 
Because I think SOLID is incredibly well internalized in Python already.
 
@AaronHall I'm fairly sure S, L and I should apply to practically any language; O and D I'm less sure about but that's only because I'm still not confident I fully understand those two in any language
 
If people learn to program Python using documented best practices and common sense, they'll be using SOLID anyways.
len(a) invokes a.__len__()
 
7:05 PM
@AaronHall that's really not true at all... you can't just proclaim SOLID is this thing you decided it is when there's already a cohesive group-understanding of it by the industry at large. It's been well defined by others, you don't get to just redefine it to mean what you imagine it to be..
 
Well, I've read all I could find on the subject.
 
I mean, I guess you do get to do that if you want. Tons and tons of people do that with engineering concepts constantly
@AaronHall did you read the explanation for LSP I gave earlier?
 
You're welcome to point me at another resource.
 
Do you understand the meaning of "don't strengthen pre-conditions, don't weaken post-conditions" ?
 
No, please tell me more.
 
user55340
7:08 PM
@Ixrec The 'D' isn't too brain wracking. Though that implies that people using the language are coding to the interface.
 
is this still going
 
user55340
@LightnessRacesinOrbit of course. No one else has distracted us with whiskey cupcakes yet.
 
@MichaelT ooo!
 
I'm googling the phrase, seems common enough
 
I would quite like some scotch..
 
user55340
7:09 PM
Jun 19 '14 at 21:26, by MichaelT
@AshleyNunn I'm still waiting for my beer and whiskey cupcake...
 
user55340
@JimmyHoffa There was a cupcake fundraiser at Employer. One of the people came by the table I was sitting at and tried to get us to buy a scotcharoo. I asked if it had scotch in it and when told 'no' mentioned I was very disappointed at the false advertising.
 

LSP

2 hours ago, 4 minutes total – 23 messages, 4 users, 0 stars

Bookmarked 10 secs ago by Jimmy Hoffa

 
can someone explain to me what static methods are in Python
 
@MichaelT the problem with D is the descriptions of it vary between utterly trivial thing with fancy name and architectural astronomy I can't begin to parse, and I'm never sure if it's safe to assume the D really is that trivial thing I like to think it is (i.e., prefer constructor arguments with interface types to #including your dependencies directly) or if many people feel there is additional magic to it
 
I'm still sorting out what is meant by precondition and postcondition
 
7:11 PM
@LightnessRacesinOrbit me me! They're when you rub a method on the carpet and it's hair starts to raise
 
@JimmyHoffa ok thanks
 
@AaronHall read what I described above - the part about "needing to open() before read()ing is a pre condition"
 
user55340
5
Q: How does strengthening of pre conditions and weakening of post conditions violate Liskov Substitution principle?

GeekI read that Liskov substitution principle is violated if : Pre conditions are strengthened . Post conditions are eased out. But I don't get fully yet how these two points would violate Liskov Substitution principle . Can some one please explain with an example. Specifically how would any one...

 
if a contract for the close() method declares that after it's been run, the state of the object must disallow read()ing or write()ing, then those are post conditions of the close() contract
somebody can absolutely violate LSP while still following normal Python practices. Python doesn't save people from implementing interfaces with unexpected behaviours
 
class Square(Rectangle):
 
7:16 PM
ok, I did mention "common sense" too :P
 
user55340
32
Q: Using Design by Contract in Python

ipartolaI am looking to start using DBC on a large number of Python-based projects at work and am wondering what experiences others have had with it. So far my research turned up the following: http://www.python.org/dev/peps/pep-0316/ - PEP 316 that is supposed to standardize design by contract for Pyt...

 
@AaronHall you think people with "common sense" don't violate LSP? or SRP? Or interface segregation?
 
user55340
  >>> def in_ge20(inval):
  ...    assert inval >= 20, 'Input value < 20'
  ...
  >>> def out_lt30(retval, inval):
  ...    assert retval < 30, 'Return value >= 30'
  ...
  >>> @precondition(in_ge20)
  ... @postcondition(out_lt30)
  ... def inc(value):
  ...   return value + 1
  ...
  >>> inc(5)
  Traceback (most recent call last):
    ...
  AssertionError: Input value < 20
 
there's no such thing as common sense
 
@whatsisname thankyou.
 
user55340
7:17 PM
@whatsisname There is, its just that its uncommon.
 
"Common sense" is an insult
 
user55340
   use common::sense;

   # Supposed to be mostly the same, with much lower memory usage, as:

   # use utf8;
   # use strict qw(vars subs);
   # use feature qw(say state switch);
   # use feature qw(unicode_strings unicode_eval current_sub fc evalbytes);
   # no feature qw(array_base);
   # no warnings;
   # use warnings qw(FATAL closed threads internal debugging pack
   #                 portable prototype inplace io pipe unpack malloc
   #                 glob digit printf layer reserved taint closure
 
@MichaelT the only common sense I'm familiar with is sight, sound, taste, touch, smell, hunger, vestibular, and memory. And it's also common to lack any one or more of them.
 
seems legit
 
user55340
> WHAT OTHER PEOPLE HAD TO SAY ABOUT THIS MODULE

apeiron

"... wow"
"I hope common::sense is a joke."
 
code answers again
@MichaelT thanks
 
@whatsisname also true.. some day I should go memorize all of those logical falacy's and argument types like straw man - Common sense is definitely used almost entirely as one of those, like no true scotsman or something
 
I think you could do it easily with ABC's
 
user55340
@AaronHall When you get to DBC, precondition and postcondition are things you think about and have to deal with. They're just implied in other places and likely a good idea.
 
7:20 PM
golden mean fallacy is one of my favorites, partially because I know I've done it at least once
 
I don't know if common sense is a fallacy though, it's just a straight up insult
 
preconditions are conditions on inputs, postconditions are conditions on outputs
am I right?
 
design by contract seems like a waste of time to me
 
@AaronHall for pure stateless functions, I believe that is correct
 
user55340
If you were to override the inc function, it would be a mistake to strengthen the precondition so that it wants a value greater than 21. That would violate the expectation of how that function works.
 
7:22 PM
though usually one uses those terms in the context of stateful stuff, like Jimmy's earlier example about reads and writes
 
user55340
Likewise, if you were to weaken the postcondition so that the output didn't have to be less than 30, it could lead to the downstream code having unexpected data sent to it - because the original version guaranteed that the output was always less than 30.
 
So don't expand the possible inputs is what is meant by don't weak the preconditions?
 
@Ixrec ok that is really cool. They've evidenced the idea that it is attainable
 
don't constrict the possible inputs is what it means
don't exclude an input that existing code might correctly be providing already
@JimmyHoffa yup, this is why I read philosophy all day
 
user55340
If the method is defined so that it takes a List, strengthening the precondition so that it requires it to be an ArrayList would be 'bad'.
 
7:24 PM
Won't let me edit for some reason.
 
it's the outputs you don't want to expand
 
user55340
And likewise, if the return value is expecting a Set (guaranteeing no duplicates), having it return a Collection (which might be a Set, it might be a List) would be a weakening of its contract.
 
eg, if foo() normally returns a string, I might call string methods on foo()'s return value, so if you changed foo() in your subclass to sometimes return a number, that'd be bad (in the same way as what Michael said)
 
@AaronHall like I said earlier; if you have a Repository contract that allows you to GetPerson(id), and the contract has no concept of Open(), don't create an Oracle version separate from the File version where the Oracle version requires you to Open() it before you can GetPerson(id) where GetPerson(id) throws an exception if you haven't first Open()ed the repo. That would be strengthening the precondition: The precondition for the contract doesn't require Open()ing
 
user55340
Now, weakening the precondition isn't a violation - if inc could now take a String or an Int rather than just an Int, all the code that was sending it Ints would still work as expected.
 
user55340
7:26 PM
Likewise, strengthening the postcondition isn't a violation. If you were sending a Set before and now send a SortedSet, thats fine - it has the same guarantees.
 
^ and all of this applies to pre/post conditions about the state of the class, not just pre/post conditions about the types of the arguments and return values
 
Sounds like the Robustness principle: en.wikipedia.org/wiki/Robustness_principle
 
What LSP comes down to is you don't have safe substitutability if you have different implementations of the contract demanding different techniques for use and causing different effects on the overall. You try to substitute one implementation for another and suddenly your code no longer works when this is the case - errors bubble out, states don't get into that which you expect. You can't make Write() asynchronous in one implementation and synchronous in another for instance
 
So to me that kind of gets to common sense, after closed, you can't write.
 
I suppose the Robustness principle is vaugely related, but the LSP is meant to be a strict, rigorously correct statement about what a subclass may or may not change without breaking stuff
 
user55340
7:28 PM
If you have a LRU cache, and allow it to have 100 items, you could weaken the state of the cache and allow 110 items in a subclass. Strengthening the precondition that it evicts an item if it has 10 items would be a bad thing.
 
@Ixrec the robustness principle in no way relates to substitution though
 
I assume what Aaron has in mind is "you are allowed to be more liberal in what you accept and more conservative in what you do than your base class, but not vice versa"
stop with the multi-pinging
 
I think it seems to be related. Your subclass can grow its methods, or have more strict behavior, right?
 
7:31 PM
@AaronHall no. the opposite.
 
So a subclass of a set could be an ordered set
 
@AaronHall I can interpret your statement in a way that agrees with LSP, but also in the way Jimmy interpreted it where it completely disagrees with LSP
 
and could be used interchangably
 
@AaronHall definitely can't be used interchangably because a set wouldn't have order guarantees - which is why you have to be thoughtful about contract design if you wish to allow substitution.
 
this is why LSP is a very meaningful statement that "common sense" alone won't necessarily produce for you
 
user55340
7:32 PM
> Several of the key Internet RFCs, especially 1122 and 791 contain a piece of advice due to Jon Postel, which is most often stated as:

“Be liberal in what you accept, and conservative in what you send.”

That is, a well-engineered implementation of any of the Internet protocols should be willing to deal with marginal and imperfectly-formed inputs, but should not assume that the program on the other end (that is, the program dealing with the well-engineered implementation's output) will be anything other than rigid and inflexible, and perhaps even incomplete or downright buggy.
 
You can use an orderedset any place you can use a set
you can use an ordered dict any place you can use a dict
 
@AaronHall but not vice versa. Which is why it's important to recognize the conditions of the contract: Do they demand orderliness? If your consumers expect orderliness and you give them a plain set, the code will shit the bed. Substitution requires thoughtful contract condition design
 
@AaronHall not quite, if you change a function's argument from set to orderedset, you break people
 
Well naturally not vice versa
 
7:34 PM
again, this is why a rigorous statement is useful
 
user55340
@Ixrec and if you change a return value from orderedset to set, you break people.
 
yes, if you require an ordered set to be supplied, after only requiring a set, you'd break people
 
@MichaelT MY ORDERED SET WILL BREAK YOU!!
 
my unordered set will also break you
 
user55340
@JimmyHoffa I order you to break the set.
 
7:35 PM
[1,1,2]
 
But returning a set, and then later returning an orderedset would not break people
 
correct
 
@AaronHall depends on what they expected
is the set return a random order every time? A consistent un-sorted order each iteration?
 
@JimmyHoffa if they expected something more specific than Set, then they were already broken
 
If they are using Python and isinstance(obj, set) they'd be fine. They'd break if they 're using type(obj) == set. Which is why they shouldn't do that.
 
7:36 PM
oh, well now we're talking about the importance of documenting your pre/postconditions
 
user55340
Installing 'brew' always makes me go 'eek' when I type it on the command line.
 
@Ixrec yes and no. Contracts are rarely documented but it's important that they're well understood by the people interacting with them.
 
user55340
 
user55340
> Paste that at a Terminal prompt.
 
7:37 PM
@MichaelT yes, things like that are a bit scary "Let's just go execute some arbitrary bit of the internet"
 
@JimmyHoffa clearly you haven't worked at my company...they're always documented (if other teams use them)
 
@Ixrec it's a good thing to document them. Definitely.
 
(whether their documentation is comprehensive and comprehensible from our point of view is another matter though)
 
@AaronHall now that you have a firmer idea of LSP - would you say you understood it previously?
 
Yeah, but I've obviously had a difficult time communicating it.
I'm still apparently not 100% there, but I'm closer.
 
7:42 PM
@AaronHall well perhaps you'll take my suggestion and not instruct others on SOLID until you have a better grasp on it and how to communicate it now that you recognize you have some shortcomings there?
misinforming people is not really aid to our already poorly informed industry..
ohh you're a consultant, it all makes sense now. Nevermind, carry on ;P
speaking of consultants, where the hell is @Ampt lately?
 
since it sounds like we're done with L now...
37 mins ago, by Ixrec
@MichaelT the problem with D is the descriptions of it vary between utterly trivial thing with fancy name and architectural astronomy I can't begin to parse, and I'm never sure if it's safe to assume the D really is that trivial thing I like to think it is (i.e., prefer constructor arguments with interface types to #including your dependencies directly) or if many people feel there is additional magic to it
is the D actually that simple or am I missing something?
 
@Ixrec The D is never explained well... also it's explained constantly and oft by people who don't understand it.. That is a part of the implementation technique for it definitely. The astronomy stuff is usually people who don't grasp it very well building big crap or attributing it to some framework
@Ixrec here is a perfect example of the D though:
3
A: Does my design break modularity and loose coupling?

Jimmy HoffaI would not encourage your specific approach; it is modular and does appear totally functional, but I would suggest a slight change. I would encourage you to invert the relationship between the HexGrid and HexGridLayout such that instead of the HexGridLayout directly accessing and changing the c...

 
Dependency Inversion
 
the inversion of the dependency is what I suggest there
> I would encourage you to invert the relationship between the HexGrid and HexGridLayout such that instead of the HexGridLayout directly accessing and changing the coords and center properties, instead it takes them as parameters and returns a new set of values.
largely it is as simple as construction injection, but the crux of it comes down to this: Code should not be responsible for choosing it's dependencies at any point below main (or whatever passes for main in your code, i.e. dom's page load et al)
if a class shouldn't be responsible for something (SRP), then it should use something else to do it; and it's not that classes responsibility to choose the implementor of that something else; ergo it must demand it's parent make said choice. It's parent can make the same demand on up the chain until you get to some top level wherein you're deciding the specifics of the given application (does it write to a DB or a file or an MQ?)
 
i'm hungry again
 
7:58 PM
There's surgery that can address that.
 
@LightnessRacesinOrbit you should order takeout, I hear that's really the way to go for you
or at least, that's how it's generally handled. I still think the idea that some other class handles dependency interactions is an even better way to view it. Pure functions, pure classes, all composed by some master puppeteer, none knowing their dependencies, only taking and returning data which the composer pipes together at it's behest.
like my solution #2 in that answer
 
Depend on abstractions sounds like duck-typing in Python. e.g. a function uses a dict, so it just treats the argument like it's a dict, and doesn't bother with type-checking.
 
maybe the reason I don't intuitively get it as much is that in practice I've seen that do little more than invert my "I constructed a banana and got a whole jungle" problem into "I have to construct a jungle before I can construct a single banana"
which is an improvement, at least I know the jungle's there, but it sometimes feels like I'm wasting a lot of time learning how to construct X from scratch because the documentation seems to assume the only place you'd ever use X is somewhere you already have instances of A/B/C floating around for no particular reason
 
@Ixrec it's true, but it puts the jungle construction for your entire application in one easy to manage spot. Want your entire application to begin using Oracle instead of Postgres? Change the repo in that one spot and every banana in the jungle suddenly becomes an apple. The chimps don't care because it implements IEatable
 
indeed, I agree it's probably an improvement, it just happens to be the only one of the letters that annoys me
 
8:03 PM
@JimmyHoffa mmmm
 
S, L and I never annoy me
I suspect this would be different if I were working directly with a language's standard library rather than relying on frameworks built by other teams
 
@Ixrec I don't disagree. More than anything I just take it as a "be mindful of the relationships between dependencies" - and usually err on writing pure code so I don't even have to think about it
 
the O is probably the biggest problem for me since I'm fairly sure I don't understand that one (specifically, I'm not convinced there is an objective distinction between "extension" and "modification")
 
dotnetfiddle.net/RW35EJ <-- stupidly simple DI lib just using a dictionary of functions - with simple example showing how to make all the dependency composition in one spot.
 
what do you think about renaming the site
 
8:09 PM
my opinion has not changed
 
@LightnessRacesinOrbit TakeOut.SE? Nah, not hungry enough.
 
D still reads like duck typing
 
Not at all
@AaronHall D is heavily dependent on contracts which perhaps Python doesn't have
 
are we talking about dependency injection or the D programming language?
 
D means: Your repo shouldn't create it's dataprovider, and your service shouldn't create it's repo, because in both cases you'd be making those classes coupled to the specific implementations rather than abstractions
 
8:13 PM
Define contract
 
code interfaces plus documented pre/postconditions I'd imagine
if it helps, when I think "design by contract", this is what I have in mind: youtube.com/watch?v=1QhtXRMp3Hg
(full disclosure, this Lakos guy did a lot of work at my company)
 
8:34 PM
@Ixrec I try to avoid the technical implementation details when thinking about design by contract as things get a bit mired then. I just like to imagine contract as this vague abstract concept of a set of expectations. Often times they're implicit, sometimes they're explicit, there's lots of techniques around verifying them, but at the end of the day they're just a set of behavioural expectations that we have to be able to rely on one way or another if we want any sutbtitutitatbtitltity
(can't figure out that word; it's mostly ts...)
 
I feel dubious about the possibility of an "implicit contract"
unless you're referring to things like "no our destructors don't throw"
 
@Ixrec it's not a possibility, it's something you touch constantly
@Ixrec yes; that. It doesn't have to be documented, and it rarely is, but you have to be able to rely on it.
 
oh that kind of implicit
lol, I just saw this on the HNQ list:
5
Q: What are "class methods" and "instance methods", in Python?

Lightness Races in OrbitThere has been a discussion in chat relating to a question (the question itself being irrelevant to this one), that has revealed I may not know Python whatsoever. In my mind, although terminology differs across languages, we may generally categorise functions as: [free] functions static method...

 
we've had much worse
 
8:40 PM
@Ixrec just funny to get that stupid little thing into HNQ
 
yeah
 
this looks relatively typical. — Jimmy Hoffa 7 secs ago
...I had to.
2
A: Implementing an interface when you don't need one of the properties

Lightness Races in OrbitLooks fine to me, if this is your situation. However, it seems to me that your interface (or use thereof) is broken if a deriving class doesn't actually implement all of it. Consider splitting that interface up. Disclaimer: This requires multiple inheritance to do properly, and I have no idea w...

argh! That is the classic example of an LSP violation and you're telling him to go right ahead :P
Crazy person
Guess you didn't use your "common sense" :P
 
user55340
9:01 PM
Now that Disney owns Lucas... does that mean Princess Leia is a Disney Princess?
 
according to an SFF answer I read earlier today, she's currently on the unofficial list of princesses that are not official Disney Princesses
 
-12
Q: hi..I want a simple program c++

fahimI want a simple program in c++ that can count some specefic words in a text file. For example It have to read the names of colors from a text file and search and count that names in another file and write the reasuls in a file. plz help me. tnx

 
0
A: Implementing an interface when you don't need one of the properties

Jimmy HoffaThis is a classical example of how people decide to violate the Liskov Subtitution Principle. I strongly discourage it but would encourage possibly a different solution: Perhaps the class you're writing doesn't provide the functionality the interface prescribes if it doesn't have use of all the...

 
I dont know what u mean. I just want to somebody help me. is there any body to write the code of this program?? — fahim 1 min ago
 
so what do u do? — fahim 57 secs ago
hah! That's hilarious, he really did think we were a code writing service!
 
9:04 PM
hah, picked up a downvote.
 
user55340
@LightnessRacesinOrbit I'm sure there's an interesting review in the triage history for that one.
 
@JimmyHoffa You are totally obsessed with LSP today
 
@LightnessRacesinOrbit don't blame me for the fact that somebody asked if they could/should violate LSP right on the front page today..
 
@JimmyHoffa I didn't blame you
 
user55340
Liquor, Scotch, Patron.
 
9:09 PM
@LightnessRacesinOrbit to be sure it's been a pet peeve of mine for years because it's rarely understood and violations of it are both common and rather painful to deal with... "Oh, now I have to do an if(typeof(foo) == typeof(blar)) throughout my code with special behaviours just for that type because it decided to throw exceptions in this one case..."
causes wicked code bloat, and we all deal with it rather often because people rarely know/understand it
which is why I have multiple answers about it on P.SE
 
@AaronHall your assistance is required: should I approve programmers.stackexchange.com/review/suggested-edits/127508 ? (it seems right from what little I do know)
 
looks right to me
 
If it weren't so open-ended and broad this might have been a good Programmers.SE question. — Lightness Races in Orbit 51 secs ago
 
9:27 PM
I have 196 in ... how much does it take to badge in the tag? I could go drop that tag on some other questions I've answered...
I wonder if I'd lose the badge if I tagged some questions and then untagged them..
 
flagging admission of fraud for mod assistance
enjoy ur suspension u crim
 
user55340
@JimmyHoffa Silver is 400 score with 80 answers. Bronze is 100 score with 20 answers (you've already got that one programmers.stackexchange.com/help/badges/114/design - July 1st)
 
darn
 
user55340
@JimmyHoffa go to your profile, and the next privilege level tracker, click that gear thingy and change it to a tag badge... then pick one.
 
Migrate to Programmers.SE? — Lightness Races in Orbit 59 secs ago
 
9:37 PM
nah right now it's showing me protect questions (which somehow I'm near even though I totally don't want it)
 
user55340
I think that if you configure that you can get the tag badges instead.
 
@MichaelT I'm really far away from all the tag badges, I like the idea that it shows me almost reaching but never getting something, like protect questions. I'll drop a 5k bounty on someone before I accept that junk
 
user55340
See the bug fix for it:
 
user55340
7
Q: Can no longer toggle between tracking tag badges and tracking privileges?

Eric WofseyI just noticed that the gear icon on my profile that I used to be able to click to toggle between tracking my next privilege and my next tag badge has disappeared: (If I remember correctly, the gear used to be to the right of the progress bar in this picture.) I've observed this on all the site...

 
9:53 PM
i'm hungry
 
pfft
chinese?
wish they'd bugger off with these minimum cost restrictions
the meal I want is like £5 and I really don't want to waste another £5 on expensive coke bottles just to get the order in -.-
 
10:29 PM
I added a citation needed flag in the first section on this article on LSP in wikipedia: en.wikipedia.org/wiki/Liskov_substitution_principle#Principle
@Ixrec type(self) is preferable to self.__class__
Otherwise, it demonstrates the answerer posts code that doesn't work. Pfft.
I think too many voters use the answerers' rep as a proxy for "is this a good answer or not"
Ah well, it builds character
Interesting?
The type system of many programming languages support subtyping. For instance, if Cat is subtype of Animal, then an expression of type Cat can be used whenever an expression of type Animal could. Variance refers to how subtyping between more complex types (list of Cats versus list of Animals, function returning Cat versus function returning Animal, ...) relates to subtyping between their components. Depending on the variance of the type constructor, the subtyping relation may be either preserved, reversed, or ignored. For example, in C#: IEnumerable<Cat> is a subtype of IEnumerable<Animal>. The...
 
psr
@JimmyHoffa Aren't classes instances of the metaclass class, which an instance of itself?
 
nevermind
I think he meant in the context of C++.
And so I'd imagine he's probably right.
Seems to me that classes are just namespaces in C++, what hasn't been clarified is if you can edit them or not.
 
10:47 PM
you definitely can't edit C++ classes at runtime
unless changing the values of static members counts
 
can you add a static member?
 
nope
 
so you can modify, but not create? So I suppose also not delete, perhaps just set to some Null value
 
any conception of objects as arbitrary key-value pairs does not apply to C++; you'd have to do that yourself with a std::map<std::string, [insert value type]>
yeah, no deletion either, but also note that null is not a primitive value in C++, except as a pointer type
i.e. an object cannot be null
so if you want nullable stuff you usually need to do boost::optional<[insert type here]> or something similar
(note that this is exactly the kind of stuff one might use to implement Python or Javascript or what have you =) )
 
Does pretty much everything get moved from boost to the Standard Library?
 
10:51 PM
nowhere near all of it, though in principle a lot of what's in boost is intended as an experiment for potential inclusion in the standard
 
So some of it is probably considered more likely to be included than other parts?
 
yep
 
interesting
 
it's best to look up actual proposals for additions to the standard
the upcoming ones I'm most interested in are for a filesystem library, a new modules system (instead of that silly #include stuff) and a networking library
the filesystem and networking proposals are both little more than ports from boost:: to std:: iirc
 
psr
@AaronHall - Smalltalk. I thought I'd add to the confusion. My point being that the nomenclature is really annoyingly inconsistent. Of course, the semantics vary a lot too. So knowledgeable intelligent people can talk past each other pretty easily.
 
10:59 PM
as a random example of something boost does that almost certainly will not get into the standard...did you know that C++ lets you overload the comma operator?
 

« first day (1943 days earlier)      last day (3061 days later) »