« first day (3404 days earlier)      last day (1536 days later) » 

5:06 PM
I just tried to go home before remembering that I'm meant to be in for another half hour...
 
@HéctorÁlvarez thanks for your advice, Somebody else said this, can you shine any light on it as I'm not sure what he means: "The logger should be a service in your application, not something that every class is doing. You can use your logger service in every class, but not every class should be logging things by itself"
 
@Squirrelkiller I am "the whole team". I figured it out anyway.
 
V.7
5:45 PM
Does anyone know if it's possible to create a button using HTML for Excel document?
 
probably not but you could write it in HTML then convert it to whatever excel uses?
 
it means that none of your other classes must have functions like writing logs to the console and file
 
but implementations of ILogger should?
I mean I wouldn't of thought any different, his message was just unclear, to me anyway
 
that responsibility is your logger, which should be defined by the root of your application and given to every class that wants to write a log
 
"given" I'm guessing you mean by some sort of LoggerFactory if I'm using class-based
 
5:47 PM
if another class wants to log, it should have a logger service object in its properties or parameters
 
I see - so each class has its own Logger (SRP) yeah
 
not necessarily, they could all share the same instance
they are just given an instance and cant know if anyone else uses it too
 
can we speak about that? I use class-based at the moment but I don't care about the reporter, is this a good case to use one-per-app?
I see, that's the set up I have I just inject it into the constructor and that constructor only.
 
one per app?
 
so all sharing the same instance essentially.
 
5:50 PM
if your logger is pure, sure
 
What makes a logger pure?
 
our loggers arent, they have scoped information, so reusing it everywhere would result in using the wrong scoped information
 
I mean they store nothing about the object or objects using it if that's what you mean.
 
a pure class or function has no side effects or other sources of information
although, i dont feel so good with the side effect thingy and often ignore it
 
I don't hold any kind of state in my logger, even logging to a file is written straight away
I do want to implement a flush mechanism though so it caches say 5 logs and then writes them all at once.
 
5:53 PM
so if you have for example a "lastLog" property, the logger would be impure because its side effect is to tell you the most recent log
 
I see
 
flushing technically isnt pure but can be assumed pure
since nothing should be able to mess with the cache
 
I mean if its private I guess it couldn't?
 
well... it always can... but you should stay away from reflection
 
What does reflection have to do with it
 
6:04 PM
all your privates are belong to us
^ feel free to take that out of context
 
I assume a Logging method will always be impure.
Writing to something is definitely a side effect.
They're usually going to have timestamps as well, so they rely on external state.
 
6:19 PM
ye, that is why i think pure purity is silly
 
I mean, not everything needs to be pure, but it can be a useful property to have in some situations.
 
6:31 PM
why is impure bad?
is it the same as the whole php argument and global state (or shared state in this instance) and its hard to test?
 
watup peeps
do you happen to know a tutorial on how to add html5 video tag streaming into a razor web app?
I figured out how to ReadAllBytes of the entire video file but if it's big, that's no bueno
I was thinking there's gotta be a simple way but I've only found some complicated controller classes with buffers
or is that just how everyone does it even today?
 
@AshKetchum Impure isn't necessarily bad. All that it means for a method to be pure is that the output for a given input is always the same regardless of external state, and that there are not side effects. Pure methods can be easy to reason about.
 
thanks!
 
my first thought for streaming video would be "can you host the video somewhere it can be statically served, then just have the video tag point to that"
 
well, I can probably do a local network file:/// urls but that's not cool
 
6:44 PM
Can I post codereview links here?
By codereview I mean stackexchange's code review site
 
like, you have a website, yes
can you store the videos somewhere on the website people are using
then it'd be easy
if you want to do things the hard way, there's the MediaSource API
because it seems like you have a video file all ready to go, you can serve it with a single <video src="video.webm" controls></video>, no messing with javascript and buffering required
 
well, the hard way is already here since I'm not just hosting static .html files but running a razor core 2.2 webapp :p
for now I did a crude var bytes = await System.IO.File.ReadAllBytesAsync(path); return File(bytes, "video/mp4");
it works but for big files it's not great
 
well, yes
but you can run a webapp and also serve static files
 
phone and tablet are not happy about it
both get pretty hot and it takes a while to load
 
like, there's an easy way to do this, which is "statically serve your video files so that the browser can intelligently request chunks"
 
6:54 PM
by static what do you mean?
a file:///192.168.0.3:12345/video.mp4 kinda url or what?
 
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-3.1#serve-static-files

as in "tell your web server to serve files out of this folder so that the user can request them"
No, like
you can tell your web server "when someone asks for mysite.com/videos/something.mp4", let them download that file
 
oh cool I've been doing weird crap instead :D thanks for the link
 
and then if you want to embed that in a page, you can just do

<video src="/videos/something.mp4" controls></video>
 
wonderful, thank you! I'm gonna try this after work
 
7:20 PM
I have a question about EF.Core, how to specify the DateTime Kind to always return UTC?
 
8:19 PM
@JonathonChase what exactly is the nice property of pure functions?
 
No side-effects and the same range for a given domain are easy to reckon.
 
@Node.JS we have the policy that all input of our back ends is already in utc...
perhaps you can change the timezones before reaching the entity models as well
makes the business logic also a lot easier to work with
we were forced to do so because of other reasons, but I am glad we did it
@JonathonChase ye, so function plus(a, b) { a + b } would be pure, right?
 
Yeah.
 
output is entirely based on input
input isnt modified
nothing weird
function plus(a, b) {
    console.log(a, b)
    return(a + b)
}
 
Now impure.
 
8:26 PM
> oh no, this is outrageous!
it is also easy to reckon tho
 
Unless you're coming from the direction of trying to figure out why a, b are being written to the log
 
ye, perhaps I should log a bit more information of them actually being used in a sum formula
but from the caller's point of view, would it make any difference?
same with a lazy value
 
idk, i wouldn't expect my add function to be logging.
you can always wrap a pure function with an impure one later as well
 
if I have some computation and the formula handler would say 'ye, I have seen this before, let me get it from my cache', it would still have the same effect from the caller's point of view
except for being a bit faster probably
@JonathonChase but I cant add a log to my super complex formula tree except if I mark every function as impure (assuming you have to mark them as such)
similar to how you cant just make any function async in C# when it is called by a sync function
you have to mark them as async
I dont have much experience with real functional languages, but I assume there are quite a few that you have to explicitly mark stuff as impure
or... IO (in this case)
 
8:41 PM
Yeah, the async/sync thing is covered really well in this article
haskell handles the need to mark things as having side-effects by having monads that exist to represent side-effects. The IO monad is used for file-system things.
This gets a bit out of my depth though, i'm not really great with haskell or pure functional programming in general.
 
 

« first day (3404 days earlier)      last day (1536 days later) »