« first day (4423 days earlier)      last day (507 days later) » 

7:49 AM
so I was axe throwing yesterday as a team event with colleagues... it was more fun then I have expected
 
8:16 AM
what is axe throwing called in German?
BAUMZERSTÖRERWURFEN ?
 
Tim
8:31 AM
ideal time to 'accidentally' axe someone
 
9:13 AM
@MwBakker close enough. Holzspaltenwerkzeugswerfen
Short: Axtwerfen
 
9:35 AM
hello
 
10:09 AM
hello
 
how are you?
 
im alright besides an unanswered case in Flutter
 
yea mate saw that
maybe i ll have a look but 99% idk how to help
 
Tim
10:39 AM
let me know tomorrow or something I can put a bounty on it to attract attention
all the rep whores will come like flies to shit
4
 
haha
timmy g that s why i like you
but @MwBakker
Cabrio cabrio = Car.fromJson(dyn[0], 'cabrio');
if you know it's a cabrio
why don t u call Cabrio.fromJson
like do it the other way
something like this
idk if it compiles lol
 
@ballBreaker You should! And you could either buy it (Not sure if it sells in your country) or read it online. There are many fan translations. You can check that on reddit under r/nagatoro
@ballBreaker You must! Let's hang out
@MwBakker Gesundheit
 
10:59 AM
like if you have Car and Cabrio extends Car
shouldn't Cabrio call Car's method?
is this how inheritance should work?
mauker help me
:D
 
What do you need?
 
help
so you have abstract class Car
and class Cabrio that extends Car
 
Wait, I'm sending air support
user image
3
 
xD
how long have you been waiting for this moment?
19 hours ago, by MwBakker
1
Q: Derived classes' properties not getting value

MwBakkerSay one has an abstract Car class with a derived Cabrio class. From a REST api he recieves a JSON with data abstract class Car { int id; String name; String description; Car({ this.id, this.name, this.description, }); factory Car.fromJson(Map<String, dynamic> json, Strin...

this is the question
mwb calls Cabrio cabrio = Car.fromJson(dyn[0], 'cabrio');
and i think he should call Cabrio.fromJson
and inside this one Cabrio.formJson have Car.fromJson
@MwBakker u here?
 
@grrigore quite some time tbh
I will take a look soon, in a call now
 
11:07 AM
sure
 
11:20 AM
@Tim thats nice I think its aligble for bounty now
@grrigore that is whats happening though
Cabrio has its own fromJson
 
u call cabrio.fromjson in car.fromjson
i say u call car.fromjson in cabrio.fromjson
 
ah but I dont want to
in my real-life situation there are further derivants
 
from my point of view that s how inheritance should work but idk if it s ok
 
and I dont want redundant fromJson lines
@grrigore if I call cabrio.fromJson it would mean I need to have all the json['someProp'] set there, even the parent ones
which is redundant, if I do not want redundancy I should be able to just do it the way I have set it in my example
yet it returns an object without having set the derived class' properties, eventhough in the debugger at cabrio.fromJson it clearly sets the cabrio properties correctly
 
Tim
car class doesn't know that cabrio is a subclass of it, it cannot do the json parsing. Also json parsing should not be done inside a model class
 
11:24 AM
it does know it since I'm handing over a type parameter
@Tim "Also json parsing should not be done inside a model class" I agree but this is a factory method thus acts like a second constructor
 
@MwBakker i don t really understant
i m not that good with dart
 
Tim
you should decouple that
 
@MwBakker this feels like a hack to me tbh
 
@Tim if the majority of Flutter projects have the json deserialization inside the model class I will have peace with it
 
i think car should not have "dependencies" on cabrio or the rest
if you have to delete cabrio you'd have to change car too
 
Tim
11:29 AM
then the majority have serious architectural flaws
 
@grrigore setting json values to the properties can happen in the parent class. Car can set a bunch of it's parent's properties already so why would I do that in the derived classes as well. Seems redundant
 
i think you can call Cabrio cabrio = car.fromjson and then set the rest properties of cabrio
 
yes I can do that
doesnt solve the "why" on my question however
 
i don t understand it :D
there would be no code duplication just a call to car.fromjson
 
there will in fact be duplication
imagine there is a parent class with 8 properties and two child classes with 2 properties by itself. Do I want both of the derived classes have a fromJson with 10 lines of code? No
so I let the parent class perform setting it's parent values and the derived classes theirs, as shown in the question
 
Tim
11:35 AM
@MwBakker 2 days after posting question
 
i ll write an example later
 
an example on what? I dont want alternatives I want to know why the derived properties are not set
there are plenty of alternatives Im aware of
 
of the duplication that there isn t
 
I think I know what example you mean
instead of cabrio.fromJson you set the cabrio properties inside the car factory method itself
which in fact wont be redundant but Im still bothered by why the fromJson on the derived class bring back the object without having these derived properties set. Despite all descussion on alternative ways that part alone remains a mystery to me
debugger shows the values are set, the cabrio.fromJson returns the object and 'poof' the derived properties are null again
 
i have no idea mate
 
12:05 PM
thats ok I appreciate the help anyway
@Tim I'll let you know when its eligible for bounty
didnt mean to double ping
 
Tim
ok
 
but what are noticeable downsides of not decoupling the .fromJson method?
 
Tim
angry tim
2
 
@grrigore should use JsonSerializable package or this one - pub.dev/packages/data_class_plugin
 
understood
 
12:12 PM
Parsing json should always be done in model class in Dart
 
Tim
dart does not care about solid principles?
 
It does but you're constructing an instance of the class from a json map being passed into a constructor
If you're doing a GET request that's duty of another class
 
@MarkO'Sullivan im aware of alternatives and packages but I would please like to focus on the "why" issue in my question. Im already using alternative ways so I can move on but the mystery remains
 
What dart sdk version are you using? This looks old
 
Tim
your model class is just representing some data, it should not have knowledge of what format the data from the backend is
 
12:23 PM
@MarkO'Sullivan 2.8.2, what do you want me to do with a comment stating 'this seems old' I can't really do anything with this related to my question
 
@Tim does gson not do the same with kotlin?
You add annotations to your model class to make sure it is serialized / deserialized correctly - doesn't break SOLID principles
 
Tim
wait maybe I am misunderstanding the purpose of your class
 
@Tim same as Klaxon from what I can see, add some annotations to handle how your json will be parsed
@MwBakker brb trying to help you by putting this code into dartpad
 
@MarkO'Sullivan I see but I didnt put a working example just a visual representation (simplified of my real-life situation) along with the problem. I was thinking of a workable one later but since I figured its an inheritance related issue I assumed the visual aspect was enough
 
Tim
typically we have at least 2 classes to represent one model. One class that is used to to parse the data from the backend, and then it is mapped to a domain class that is used in the rest of the app. Mapping one to the other is done in a separate mapper class. This way you can have the gson annotations for convenient parsing, and still have the 'clean' class to actually work with in the app. Maybe it is the same in flutter
 
12:33 PM
@MwBakker I've had to deal with json with abstract classes before so thought I'd look into this for you
 
thats nice, in fact I believe I still have to share the project with you
however when I started working on this project nullable was a rare thing, so thats not implemented since it requires a refactor and Im now focussed on getting everything working first
this problem im facing is on the sidelines, I continued with working around it: it's just an odd situation
 
@MwBakker there's a migration tool to help with that if you need help migrating to later version
Also some nice things you can add to the analyser to offer suggestions when you can use cool new features
like the super parameter
 
@MarkO'Sullivan its big project by now might still be some work. What migration tool are you suggestion? or can I just grab one from google
 
@MwBakker can you send me the json you used for this?
 
@MarkO'Sullivan I'll have to make it, since I simplified both the code and JSON for the question
 
12:43 PM
@MwBakker earliest edition I can use on Dartpad is Flutter 3.0.5
final json = {"id": 1, "name": "ford", "description": "fast car",
"roof_material": "glass", "some_other_prop": "hello"};
 
@MarkO'Sullivan yep
I made one too but you're faster
guess I might as well migrate the version today too
 
I've migrated it to code which will compile to that version of Dart
Just need to add the part which will do the json bit
 
yes, and I put the parent props setting outside the if (type == 'cabrio') since in my real life situation there are more elseif statements to it
so that whatever type I was dealing with, the fromJson on that specific object would set it's derived properties and the parent's class the rest
 
Why are you using Car.fromJson(...) and not Cabrio.fromJson(...)?
If you already know the type then you can do if / else check and then use the class which extends the abstract class fromJson?
 
because then Cabrio.fromJson would also need to have code to set the parent's properties like id : json['id'] and I thought with this way I'd save myself some redundant code
 
12:57 PM
@MwBakker yeah it still does need that code to set the parent's property
also jsonDecode - this returns a map, you shouldn't use dyn[0] as an argument into the fromJson, you want to use dyn itself here
 
I know but dyn[0] happened in a case where I only fetched one object and it was a quick way
@MarkO'Sullivan but how does it 'pop' the set properties coming from the cabrio object
 
I don't understand what you mean
Yeah this won't work, within your fromJson, you're essentially saying return back an instance of Car, not of Cabrio so you never have access to the fields for Cabrio
 
so this is true?
 
@MwBakker this is what you're wanting
You need to put as Cabrio when using Car's fromJson because otherwise the instance will be the Car and not Cabrio
I've tested that out and it's working as expected, the two fields are no longer null
 
1:13 PM
I see
thank you Mark I think that solved my issue, knew I overlooked something
if you want some points you can answer my question
 
I'm glad it helped!
Hate to see someone stuck with a Dart issue
 
it was really bugging me
what is now bugging me is being some version behind the latest Flutter so I'm going to resolve that
 
I haven't updated to the latest version but yeah when you upgrade and have access to super parameters, it's a nice improvement to the syntax
Also felt obliged to help out with this issue because I'm nearly certain I've ran into the same issue one time and then was like "oooohhhh" 😄
 
thanks Mark, really appreciated :D and I now share the same "oooh" moment
 
Tim
mvp mark
 
1:26 PM
@Tim ❤️
 
@MarkO'Sullivan Ill do the version migration and share the project if you still want to
 
Sure I can take a quick skim over, probably wont get a chance to until at least Sunday
 
no worries, im working on it almost every day so sometimes an instable version comes in due to workstation switch or just as backup purpose
 
1:51 PM
I upgraded the version but Im not getting warning signs that for example model properties should have @required annotation
 
2:07 PM
@MwBakker yeah no annotation required now just required without the @
 
that gives an error, because Im not migrated to null-safety yet and required comes with that I just read
 
2:20 PM
new tips
js sucks
 
2:47 PM
js is the worst. change my mind
 
can't help you there, I kinda agree
JS frameworks like Vue however, are a blessing
 
nope if it's js it sucks
ty
 
... and now the weather
 
haha
 
@MarkO'Sullivan I took the point of 'parent class should not be aware of type' and now I just call the derivedClass.fromJson instead. But this does mean I have for example json['id'] stated in all derived classes.. I can't help but feeling thats a little redundant
but after this emerging discussions I might as well learn to have peace with it
 
2:57 PM
@MwBakker that's inheritance no?
Use a package / plugin and never think about it again: less typing = more happy
 
it is but I don't like seeing for example id: json['id'] in all derived classes
 
Yeah so just hide it all in generated classes
😄
 
heh yeah I can do that
 
If you don't like that you should see what I've seen in a graphql query generator package recently 🤣
urgh
so many fields being exposed upon my eyes for no good reason (I think)
btw @MwBakker you can accept my answer ;)
@grrigore ts is better
 
@MarkO'Sullivan stack didnt notice me being a new answer, but yes ofc Ill do that
 
3:01 PM
@MwBakker ❤️
Oh I forgot to show some of the encouraging stats of my side project recently
Nearly 2k impressions let's gooooo
Actually just realized this is far from my best month
 
nice!
thats some motivating stuff right there, good job too
 
Yeah my best month was 7k impressions so need to keep steadily moving in that direction
I expect January will be a lot more busy
 
most surely, yes
btw after all discussions I also updated my question to explain why I went for that approach. It makes things more clear
@MarkO'Sullivan 228% increase is impressive nevertheless
 
@MarkO'Sullivan ts is better
@MarkO'Sullivan nice man
 
wow look at all this coding talk
 
3:09 PM
more to come!
 
It's weird to see followers increase of my account without me doing much to increase the spotlight on it
 
yeah typescript is dope
 
@MarkO'Sullivan seems like we just have to deal with that kind of stuff from time to time
 
oh that's awesome mark! what's the app/side project for? Fitness tracking of a sort?
 
@MarkO'Sullivan people talk/share
 
3:13 PM
@ballBreaker fantasy football tool to help players do better
 
ohh nicee
 
my gf needs to find a thesis subject
she is doing her masters 'Media and communication'
so, I suggested to do a research about the (future) rules of AI. Where will the 'line' be drawn etc
but I can't confince her
and I have no idea about other subjects related to that studie
I have another one: research how closely related dopamine release is to a brain when recieving a 'like' or a 'stack-point' compared to nicotine or heroin or smth
if any of you have an idea of a subject: shoot
 
3:53 PM
what common traits do a bunch of nerds have that makes them return to the same room to talk with eachother year-after-year
 
Tim
mwb: I have no idea
also mwb: I have another idea
5
 
@ballBreaker nice
 
Tim
does she not have an idea of her own?
 
but... MwB is the MAN in this relationship and he MUST dictate everything she does
dont you know?
 
Tim
aha
 
4:07 PM
LOL
im dead
the truth hurts
 
4:29 PM
@Tim yes but the first were very boring she even admitted
@ballBreaker she asked me for help
 
LOL yea check tims history there
i guess that wont help too much
 
@ballBreaker ??
 
lmao
i dont want to spoil tims fun
 
i dont get it
 
I said "lmao jk" and he trashed my message
then changed the 'message moved to trash' with 'aha'
 
4:37 PM
@ballBreaker only if he wants pegged
 
lmao
 
@MwBakker you should feel proud! Your question got me to end my SO silence, 1 year 4 months since my last answer
 
4:53 PM
@MarkO'Sullivan nice to help eachother!
@ballBreaker aaah
 
yaaa lolll I didnt wanna spoil the fun by explaining but here we are
 
5:11 PM
@MwBakker 🤝
 
@ballBreaker fun ruined
*plop * fridaynight: time for a beer
HARRRR to you guys
 
A very old former airforce electrician who no one argues with expect me, while watching tv commented on a news which I knew was not true so I said its false, he said how can media lie, social media is full of lies
I said few days ago channel you are watching aired news about "mutual fight between workers of two political parties" but what actually happened was that party A workers were having tea when party B workers attacked them but all the public joined party A and started beating the attackers
 
@MwBakker arrrrr!
 
he denied them as lies, i showed him actual footage of fight, he stopped watching news and now believes everything on social media
 
he sounds like an idiot
 
5:18 PM
no, he is a known genius, the effort they put on manipulating news here in super ai level, only young gen minds are capable of deciphering the truth out of it
some media channel journos are masters of deception, unmatched in the world
 
I mean it sounds like he lacks critical thinking skills so idk about the genius part
i dont think geniuses believe everything they hear at face value but what do i know
 
you have been told your whole life that hitler was a bad person, have you ever conducted your own research on accepted whats commonly known about him?
 
@asim this is going a wild direction
he bombed Rotterdam so that alone is a huge no-no for me and my elder family
 
@asim yes
 
our media dept of armed forces, dg ispr, on record in a press conference said that our young gen is ill-informed because of social media, what should an old guy with very little interaction with social media would have made out of it?
it was just an example mwb don't panic I was trying to illustrate how intense it is here
 
5:29 PM
I think its pretty common for older folk to get most of their information from news and for younger folk to get most of their information from online - its mostly just a byproduct of what's been available in their life
but I think at this point that's like extremely common knowledge
but maybe i dont give people enough credit idk
 
they recently killed a journalist for going against what they wanted to feed to public
he is at 0:30
young gen wants revolution, basically its young vs old gen in our country at this point
 
I feel like thats the case everywhere in the world but probably more exaggerated in pakistan
sucks for your country tho im sorry to hear
maybe this is one of those cases where hitler would have been a benefit to the world if he took over the whole world
but who is to say for sure
 
5:56 PM
sup jibs
 
 
2 hours later…
7:42 PM
but Jibs, being tied up again in his basement, was unable to respond
 
8:38 PM
Nerds
 
8:59 PM
@MwBakker muffled screams
 
9:12 PM
lol
sometimes I get emails from recruiters asking me to apply to be a "lead software engineer" and im like
do you even know how bad of an idea that is?
 

« first day (4423 days earlier)      last day (507 days later) »