Resolved MVVM - persistent API key between viewmodels

ConsKa

Well-known member
Joined
Dec 11, 2020
Messages
140
Programming Experience
Beginner
I have an application that is hard coded with an API key....it works, perfectly fine.

I created a login screen so other people can use it with their API key.

It will not hold the API key, I have tried assigning it to a public property, I have tried creating a class to hold it in a property and then call to that class to get it, I created a textbox that was hidden and tried to write it to the hidden textbox....

I run the program, the first run through it works - the api key is there, it has been properly passed, but the moment it calls another method (the get method calls a datagrid view which is populated in another method by making selections form the json objects)....the API key is null and the json is null - hard coded - no problem. I don't understand why it goes to null, and I don't understand why the json goes to null - they are both properties which is how the different methods are able to populate the datagrid view without keep calling to the API.

I have seen solutions online, that require like 4 pages of code (exaggeration for effect) - and I just feel like....it can't be that hard can it? to simply pass a passkey to another viewmodel.

I am using Caliburn Micro for the MVVM model, dependency injection stuff - if that helps.

Thanks for any help offered, because this one has me stumped, I mentioned 3 things above - but I have tried like 15 stupid ideas that I am too embarrassed to post....
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
3,560
Location
Chesapeake, VA
Programming Experience
10+
Sorry. Been a little crazy over here lately. I really wanted to reply back to this thread. The only reason why I made the comment regarding Calburn.Micro being like Ruby on Rails is with reference to the question regarding where was the DataContext being set. With most coding by convention frameworks, having to explicitly set or create things manually goes away because often it's boilerplate code, and so by using coding by convention, the boilerplate code doesn't need to be written, thereby freeing up the developer to focus their efforts elsewhere. The downside, is a lot of stuff seems to happen by magic unless the person reading the code is familiar with how the framework works.
 

NoUserHere

Well-known member
Joined
Sep 5, 2018
Messages
2,138
Programming Experience
10+
He put out a video yesterday - says exactly what you were saying above - yes 3-tier applications are the 'standard' in the classroom, but you know what sometimes you just need a 1-tier application - it depends on what you need. Just thought you would find that interesting.
I don't actually. I have a major problem on other forums, not so much on here, but most places where I post, I get challenged quiet a bit on my coding ethics, opinions, but more-so when sharing how things will change later in some of the platforms. Yet, someone somewhere on different forums always manages to find something online to backup my claims. (Similar to the above).

I am very clued in, and keep myself well informed about what goes on in the industries I work in. It seems microsoft are moving away from using the MVVM approach. I've also said that microsoft would soon release a javascript only platform in place of asp.net or solely for use with asp.net. I guess time will tell how right or wrong I will be. They bought up their own js stack fairly recently. Wonder why?

The video I referenced, from Tim Corey, isn't some bloke in his bedroom, he is a professional teacher
:LOL::LOL::LOL:

A) He is only a 'youtuber'. He is also self-professed last time I checked him out. I don't even think he is a MVP. Some on the mod team here on this website are MVP's and I'd be bound to give them a lot more respect than Tim Corey.

B) He is promoted by the people at youtube, like all youtubers. And yes this is something I do know, as I have a lot of "famous" friends on youtube. I was given insider info on how the system works, while receiving private leads for people behind the system. Youtubers don't climb the ladder or manipulate their way to the top from using "keywords" or some of that shite you are led to believe. No, they are all selected by people in Youtube.

C) I also don't like him or his videos.

regarding Calburn.Micro being like Ruby on Rails is with reference to the question regarding where was the DataContext
I understood that from your previous reply, which is why I was talking about libraries and gems, but it seems you didn't read that, or you felt the need to explain it again.
because often it's boilerplate code, and so by using coding by convention, the boilerplate code doesn't need to be written, thereby freeing up the developer to focus their efforts elsewhere. The downside, is a lot of stuff seems to happen by magic unless the person reading the code is familiar with how the framework works.
Again, that is why I mentioned why I don't use libraries. For the same reason why most people haven't stuck with rails. I would be one of them. Rather than bringing my post forward again, go back and read what I said. I actually understood what you meant if I wasn't being clear before.
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
3,560
Location
Chesapeake, VA
Programming Experience
10+
I felt like it went on a tangent when discussing libraries and gems when all I was trying to address was the missing setting of the DataContext. No need to repost, because like you, I prefer to see explicit code rather than have magic happen. If magic does happen, I'd like for there be a way to be to attach a debugger and trace through human readable source code to see how the magic happens. I think my only exception to magic frameworks are IoC containers and mocking frameworks -- as long as they get me the results I want, they can have all the magic they want to do.
 

NoUserHere

Well-known member
Joined
Sep 5, 2018
Messages
2,138
Programming Experience
10+
We think very alike indeed.
I felt you were touching on what you wrote in p2/#21 when you posted this :
Unless specifically overridden, it will use convention to figure out which objects are related to each other and which should be injected where.
I just thought I'd expressly explain why I don't use rails for the same reasons you posted about directly above. If magic can happen in a library, then you are highly unlikely to find it easy to find your problem. Write your own code and save yourself the headache.
all I was trying to address was the missing setting of the DataContext.
Yea, but I'd never have known that, because i don't know anything about the library Conska was using. :)
 

ConsKa

Well-known member
Joined
Dec 11, 2020
Messages
140
Programming Experience
Beginner
I have a major problem on other forums, not so much on here, but most places where I post, I get challenged quiet a bit on my coding ethics

I think it's less that your opinions are controversial but the rather abrasive way in which you express them. I don't care, I have extraordinarily thick skin, I was also a barrister in the UK dealing with some of the worst criminals in the UK - so I am used to people behaving in ways that would be considered rude in the real world.

As to the rest of your post, 80% of it comes across as you patting yourself on the back and denigrating everyone else in the world simply because you know more. Did I claim Tim Corey was the best in the world? No, I just pointed out he wasn't a guy in his bedroom and was a professional teacher, which he is...but that can't be accepted by you, you have denigrate him and show your superiority in doing so.

If you don't want to be confronted so much, then really you should reign your neck in and stop putting everyone else down to feel better about yourself.

See that was harsh, but it was no harsher then everything you post.
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
3,560
Location
Chesapeake, VA
Programming Experience
10+
Okay. That's enough gentlemen. Please both go back to your respective corners.
 
Top Bottom