code logs -> 2018 -> Fri, 23 Feb 2018< code.20180222.log - code.20180224.log >
--- Log opened Fri Feb 23 00:00:16 2018
--- Day changed Fri Feb 23 2018
00:00
<&ToxicFrog>
ErikMesoy: holy shit
00:42 Jessikat` [Jessikat@Nightstar-elirs0.dab.02.net] has joined #code
00:43 Kindamoody is now known as Kindamoody[zZz]
00:45 Jessikat [Jessikat@Nightstar-98n.159.132.82.IP] has quit [Ping timeout: 121 seconds]
00:51 celticminstrel [celticminst@Nightstar-gil1m1.dsl.bell.ca] has joined #code
00:51 mode/#code [+o celticminstrel] by ChanServ
01:02 Pink` [user1@Nightstar-g7hdo5.dyn.optonline.net] has joined #code
01:05 Pinkhair [user1@Nightstar-g7hdo5.dyn.optonline.net] has quit [Ping timeout: 121 seconds]
01:54
<&[R]>
Looking for examples of Coposition here
01:54
<&[R]>
Wikipedia's description makes it sound almost like Dependency Injection
02:09
<&McMartin>
A is composed with B if one has a field of the type of the other.
02:10
<&McMartin>
It is what 'mere' records buy you, instead of ~~~~===~~OBJECTS~~===~~~~
02:11
<&[R]>
Right, so how does it look compared to DI?
02:12
<&McMartin>
Well, composing Foo and Bar looks like this
02:12
<&McMartin>
type struct foo { struct aleph a; struct bar b; } foo_t;
02:12
<&McMartin>
*typedef
02:12
<&McMartin>
DI looks like a giant build system where you're reading your ultimate class structure out of config files, IIRC.
02:13
<&McMartin>
Composition is the most primitive mechanism available for data structure creation.
02:15 mac [macdjord@Nightstar-a1fj2k.mc.videotron.ca] has quit [[NS] Quit: Live Long and Prosper.]
02:15
<&[R]>
Ah
02:16
<&McMartin>
So, uh, to answer your question possibly unhelpfully literally, but possibly helpfully so, depending on what exactly the confusion is here:
02:16
<&McMartin>
Composition looks like idiomatic, non-object-oriented C code
02:16
<&McMartin>
DI looks like a web application built on the Spring or Struts framework.
02:16
<&McMartin>
Apparently UML narrows Composition to a relationship I know of as "ownership"
02:17
<&[R]>
So a DoA game objection would be composition: class Snake { PhysicsMobile pm, EntityModel em, CombatData cd; }
02:17
<&[R]>
(Except using pointers)
02:17
<&McMartin>
Right, that is collecting them together
02:17
<&McMartin>
As opposed to getting your PhysicsMobile by extending MobileObject which extends PhysicsObject
02:18
<&McMartin>
That said, Wiki also provides this example which I would like to summarize as "holy shit go fuck yourself": https://en.wikipedia.org/wiki/Composition_over_inheritance#/media/File:UML_diagram_of_composition_over_inheritance.svg
02:19
<&[R]>
That entire article is a confusing clusterfuck
02:20
<&McMartin>
It also includes no actual symbols the "Composition" article provides as meaning composition in UML
02:20 * McMartin relinks https://bumbershootsoft.wordpress.com/2016/06/20/object-oriented-programming-at-the-bare-metal/ for his general discussion of it, and of the narrow applicability of inheritance.
02:22
<&[R]>
Thanks
02:23
<&[R]>
I'm increasingly finding Wikipedia's articles on obscure/newer design patterns to be excessively poor.
02:23
<&McMartin>
Composition is a GOF pattern and should not be considered obscure.
02:24
<&ToxicFrog>
The most concise explanation I have is "composition is has_a, inheritance is is_a"
02:24
<&ToxicFrog>
And yeah, neither is at all new or obscure.
02:24
<&McMartin>
Yes, but a Composite can face is_a with Views or Adapters.
02:24
<&McMartin>
*fake
02:24
<&McMartin>
So it's a little more slippery than that.
02:26
<&McMartin>
It is also describing a design technique that is useful in its own right, unlike about half the GOF design patterns, which may be summarized as 'here is how to fake a language feature your language of choice doesn't have'
02:26
<&[R]>
Views or Adapters in this context would look like what?
02:26
<&[R]>
And it's obscure enough that finding examples was difficult
02:26
<&McMartin>
"No, objects with multiple fields are not obscure"
02:26
<&[R]>
There's a bunch of places that had explained it, none of them did it with code :/
02:27
<&McMartin>
View is when you need to be able to pose as some other class but aren't one
02:27
<&McMartin>
So you have a method named, like, as_foo that returns what looks like a foo but is secretly you.
02:27
<&McMartin>
Adapters are when the interface came later and you can't extend the first class, and are a standalone object that are built with the first class and either are a Foo or have an as_foo themselves.
02:28 macdjord [macdjord@Nightstar-a1fj2k.mc.videotron.ca] has joined #code
02:28 mode/#code [+o macdjord] by ChanServ
02:28
<&McMartin>
They exist mainly to work around a lack of partial classes or duck typing.
02:28
<&[R]>
How would a View work in something like C++ where types are checked?
02:29
<&McMartin>
That's exactly what it exists to work around.
02:29
<&McMartin>
as_foo() returns a Foo *.
02:29
<&McMartin>
It is probably actually a subclass of Foo * backed by this.
02:30
<&McMartin>
In Java, it's probably an interface type with an inline implementation.
02:30
<&[R]>
Ah
02:30
<&[R]>
Alright, that makes sense
02:30
<&McMartin>
Iterators can actually be thought of as views into the collection they iterate over
02:30
<&McMartin>
The problem with this is that you have to have designed as_foo() into your class to begin with
02:30
<&McMartin>
This is a bummer if you didn't write that class
02:31
<&McMartin>
It's less of a bummer in C#, where you can extend classes after the fact and add methods.
02:31
<&McMartin>
But otherwise you just add a new function
02:31
<&McMartin>
Or, if you're using a non-OO language, "View" is something more like a converter function.
02:32
<&McMartin>
This is part of that "patterns are covering up language deficiencies" attitude, though like I said above, it's only obviously that for about half of them.
02:32
<&[R]>
Would std::String's c_str() function be considered a View?
02:32
<&McMartin>
I don't know if they would call it that, but I think that would be fair.
02:33
<&McMartin>
More obviously would be NSData's bytes method.
02:33
<&[R]>
No clue what that is :p
02:33
<&McMartin>
Or, I guess, std::vector's data() one.
02:33
<&McMartin>
To stick to C++
02:33
<&McMartin>
IIRC c_str() may be a much more expensive operation, because std::strings need not be contiguous, while std::vectors and C strings do.
02:33
<&[R]>
Cool, thanks I've learned quite a bit today
02:34
<&McMartin>
The GOF design patterns book is a solid read
02:34
<&[R]>
Yeah, sounds like I should get it
02:34
<&McMartin>
But I think a somewhat cynical attitude towards it is justified overall
02:34
<&McMartin>
That isn't as necessary for the core book itself.
02:34
<&McMartin>
Because patterns are treated as lists of spells to cast, or as a list of verbs and nouns to connect, adventure-game style, into a description of a piece of software
02:35
<&McMartin>
The original intent was as a descriptive tool, not as a set of raw building blocks.
02:35
<&McMartin>
But, e.g., functional programmers tend to hold these in disdain because so many of them are utterly unnecessary or intrinsic to how expressions are formed in their preferred languages.
02:36
<&McMartin>
(And indeed, the fact that pre-OO imperative languages use composition as their fundamental data structure primitive is part of why you're having trouble finding code examples; it's omnipresent to the point of invisibility.)
02:36
<&McMartin>
The lesson of Composite is really "hmm, should I be using fields here instead of superclasses? Probably."
02:36
<&McMartin>
And the lesson of FactoryFactoryFactory is "Man, it sure sucks that constructors have to return exactly the type you invoked them with."
02:38 Reiv [NSkiwiirc@Nightstar-ih0uis.global-gateway.net.nz] has joined #code
02:38 mode/#code [+o Reiv] by ChanServ
04:32
<&McMartin>
Man
04:32
<&McMartin>
I'm not sure I actually agree with the "Lawnmower with a Lamborghini Engine" characterization of the Genesis
04:32
<&McMartin>
There's a lot of really nice stuff in that VDP
05:14 Derakon is now known as Derakon[AFK]
05:33 celticminstrel [celticminst@Nightstar-gil1m1.dsl.bell.ca] has quit [[NS] Quit: And lo! The computer falls into a deep sleep, to awake again some other day!]
05:41 Vornicus [Vorn@Nightstar-1l3nul.res.rr.com] has joined #code
05:41 mode/#code [+qo Vornicus Vornicus] by ChanServ
06:17 * McMartin gets his hello world program down to 1754 bytes
06:17
<&McMartin>
The Genesis kind of has a lot more going on
06:36 Kindamoody[zZz] is now known as Kindamoody
06:43 Vornlicious [Vorn@Nightstar-hhn8bt.sub-174-211-0.myvzw.com] has joined #code
06:45 Vorntastic [Vorn@Nightstar-1l3nul.res.rr.com] has quit [Ping timeout: 121 seconds]
06:49 Jessikat` is now known as Jessikat
07:12 Jessikat` [Jessikat@Nightstar-833jnk.dab.02.net] has joined #code
07:14 Jessikat [Jessikat@Nightstar-elirs0.dab.02.net] has quit [Ping timeout: 121 seconds]
07:21 Jessikat` is now known as Jessikat
09:48 macdjord is now known as macdjord|slep
10:16 Pink` is now known as Pink
11:24 Degi [Degi@Nightstar-a3omhh.dyn.telefonica.de] has joined #code
12:14 Degi_ [Degi@Nightstar-orn9ji.dyn.telefonica.de] has joined #code
12:17 Degi [Degi@Nightstar-a3omhh.dyn.telefonica.de] has quit [Ping timeout: 121 seconds]
13:43 Jessikat` [Jessikat@Nightstar-gvok69.dab.02.net] has joined #code
13:46 Jessikat [Jessikat@Nightstar-833jnk.dab.02.net] has quit [Ping timeout: 121 seconds]
15:05 Degi_ [Degi@Nightstar-orn9ji.dyn.telefonica.de] has quit [Connection closed]
16:01
<&[R]>
Wow, npm hit the news again
16:01
<&[R]>
Good job idiots
16:21
< Jessikat`>
what did they do now?
16:28
<&[R]>
Damage system critical directories and files by deletion, permission changing or dumping junk data into them.
16:29
<&[R]>
Namely stuff in /var /etc and such
16:29
<&[R]>
https://www.bleepingcomputer.com/news/linux/botched-npm-update-crashes-linux-systems-forces-users-to-reinstall/
16:31
< Jessikat`>
Ugh
16:32
< Jessikat`>
Good work, team
16:32
<&[R]>
I mean, this is the team that had people submit packages by giving them direct access to the DB
16:45 Jessikat` is now known as Jessikat
16:45
< Jessikat>
The s in npm...
16:47
<&[R]>
Pretty much yeah
17:38 Vornicus [Vorn@Nightstar-1l3nul.res.rr.com] has quit [Ping timeout: 121 seconds]
19:21
<@abudhabi>
When connecting to a remote shell from multiple devices to the same screen (the utility), how do you force it to use the terminal size of the device you are currently on?
19:23
<&ToxicFrog>
abudhabi: I think you need to detach all the smaller ones, but it's been a while since I used screen rather than tmux
19:29 macdjord|slep is now known as macdjord
19:47
<&jerith>
I think there's a command line param for that, but I could be wrong.
19:48
<&jerith>
Yeah, -A.
19:48
<&[R]>
abudhabi: ^a F
19:48
<&jerith>
"Adapt the sizes of all windows to the size of the current terminal."
19:49
<@abudhabi>
Sweet. It worked!
20:03
<&McMartin>
I forgot to mention this last night, but: Man. This Sega Genesis startup code is really clever
20:04
<&McMartin>
I'm not actually good enough at 68k, Z80, or the hardware on the Genesis/MegaDrive to fully grasp everything it does yet.
20:05
<&McMartin>
Though I'm very close for the Z80; the parts I'm missing there is that it's using All The Parts Of The Chip, because there's no BIOS or BASIC reserving entire addressing and operation modes for its exclusive use
20:05
<&McMartin>
So that's one instruction and two registers I've literally never seen before, and two registers I've never been actually permitted to use.
20:05
<&McMartin>
Both of which have addressing modes exclusive to them.
20:12 Jessikat` [Jessikat@Nightstar-vlecin.dab.02.net] has joined #code
20:16 Jessikat [Jessikat@Nightstar-gvok69.dab.02.net] has quit [Ping timeout: 121 seconds]
21:58 Jessikat` [Jessikat@Nightstar-vlecin.dab.02.net] has quit [Ping timeout: 121 seconds]
22:42 Kindamoody is now known as Kindamoody[zZz]
23:01 Degi [Degi@Nightstar-orn9ji.dyn.telefonica.de] has joined #code
23:47 Degi [Degi@Nightstar-orn9ji.dyn.telefonica.de] has quit [Connection closed]
--- Log closed Sat Feb 24 00:00:19 2018
code logs -> 2018 -> Fri, 23 Feb 2018< code.20180222.log - code.20180224.log >

[ Latest log file ]