Stefan Oltmann
06/07/2023, 7:44 PMRob Elliot
06/07/2023, 8:27 PMfitermay
06/07/2023, 9:40 PMandylamax
06/07/2023, 11:36 PMStefan Oltmann
06/08/2023, 5:04 AMStefan Oltmann
06/08/2023, 5:05 AMandylamax
06/08/2023, 5:37 AMStefan Oltmann
06/08/2023, 7:03 AMYoussef Shoaib [MOD]
06/08/2023, 7:35 AMwhen
I'll see if I can find this article I saw a while back about Clean Code's awful recommendations for function length, but basically it recommended that functions be 2-4 lines long, and it resulted in very verbose duplicated code where you had functions that were used only in one place and contained 1-2 lines of code.
So some of those principles are outdated as wellStefan Oltmann
06/08/2023, 1:03 PMfitermay
06/08/2023, 1:08 PMStefan Oltmann
06/08/2023, 1:15 PMfitermay
06/08/2023, 1:18 PMStefan Oltmann
06/08/2023, 1:20 PMStefan Oltmann
06/08/2023, 1:20 PMYoussef Shoaib [MOD]
06/08/2023, 6:01 PMJpegElement
(and specifically JpegBytesElement
, which are the ones that have bytes associated with them) and instead of using a visitor for allowing the "return false to stop iteration" thing, I just have a Sequence<JpegElement>
which you can map
and filter
over as you wish, and stopping execution is as simple as doing a break
. It ended up being that the when
wasn't even needed since you ignored images in readSegments
. A good example for using when
over that hierarchy is this.
I'm not expecting that this PR will get merged or anything btw. It's just a good example of replacing that visitor with a much simpler sealed hierarchy + sequence, thus unlocking the power of when
and all the iterable methods (map
, filter
, forEach
, etc)Stefan Oltmann
06/08/2023, 6:51 PMelizarov
06/09/2023, 11:01 AM