rtsketo
08/01/2021, 7:01 PModay
08/01/2021, 7:13 PModay
08/01/2021, 7:13 PMBenoît Liessens
08/01/2021, 7:48 PModay
08/01/2021, 8:09 PModay
08/01/2021, 8:09 PMCLOVIS
08/01/2021, 9:56 PMStackImpl
. That's not a name that helps anyone understand what it does. You should probably call it ArrayListStack or similar, and add a `stackOf()`/`.toStack()` functions that use that as a default if you want to explicitly use it as a default.oday
08/02/2021, 8:12 AMBenoît Liessens
08/02/2021, 8:18 AMsize
and isEmpty
as properties of `Stack`: both reflect state of the Stack rather than behaviour such as pop()
and push()
. I was expecting that to be the driving factor to choose between "property"-based vs "method"-based implementation. Does that make sense at all?CLOVIS
08/02/2021, 9:05 AMstack.size
Implies that the size is easy to calculate (low complexity)
stack.size()
Implies that the size is hard to calculate (high complexity, if you use it multiple times in a function you might want to create an intermediary variable)
There's also the question of Java/JS interop (it might make sense to make it a function, because it's one in Java).
The problem with the complexity thing above is that it doesn't work well for interfaces (you can't know in advance whether it will be expensive to calculate or not). If it were up to me, I'd make them properties, but I see why some people don't like that.oday
08/02/2021, 10:26 AMBenoît Liessens
08/02/2021, 11:42 AMstorage
can be val
rather than var
oday
08/02/2021, 11:45 AMCLOVIS
08/02/2021, 12:15 PMCLOVIS
08/02/2021, 12:26 PMCLOVIS
08/02/2021, 12:27 PMlazy
, then it's ok to have a property that does a complicated calculation, because it's only once)