Software Development and Programming Careers (Official Discussion Thread)

Taharqa

Superstar
Joined
Jun 7, 2015
Messages
3,778
Reputation
2,830
Daps
26,847
Can anyone point me to some beginning c++ type videos. Most of the ones I've found are outdated as fukkk
 

Ayo

SOHH 2001
Supporter
Joined
May 8, 2012
Messages
7,038
Reputation
689
Daps
19,019
Reppin
Back in MIA
Can anyone point me to some beginning c++ type videos. Most of the ones I've found are outdated as fukkk

C++ hasn't changed much (if at all). Start with the stuff you can find. Looking for newer videos is just another form of procrastination.

START NOW!
 

Obreh Winfrey

Truly Brehthtaking
Supporter
Joined
Nov 18, 2016
Messages
20,706
Reputation
25,201
Daps
131,209
Today I learned that TypeScript doesn't have a clean way to overload methods and constructors nor can you have static interface methods. That really threw off my plan for copy constructors. I had to change to a .with() implementation, which I might end up altering again, and making a separate class to handle copying objects. But then I realized using a dedicated class for object copying isn't smart since it spreads implementation details too much.
Does anyone know if there's a way to easily create an object from JSON? That could fix my copy constructors problem albeit in a not so efficient manner.
 

kevm3

follower of Jesus
Supporter
Joined
May 2, 2012
Messages
16,292
Reputation
5,551
Daps
83,491
Today I learned that TypeScript doesn't have a clean way to overload methods and constructors nor can you have static interface methods. That really threw off my plan for copy constructors. I had to change to a .with() implementation, which I might end up altering again, and making a separate class to handle copying objects. But then I realized using a dedicated class for object copying isn't smart since it spreads implementation details too much.
Does anyone know if there's a way to easily create an object from JSON? That could fix my copy constructors problem albeit in a not so efficient manner.
If you have a JSON string, JSON.parse turns it into a javascript object
 

kevm3

follower of Jesus
Supporter
Joined
May 2, 2012
Messages
16,292
Reputation
5,551
Daps
83,491
Does this play well with complex objects? I have quite a few objects composed of other objects.

What are you trying to do exactly? It turns the JSON string into a Javascript object like any other. Javascript/TS is a lot different than Java and C# in that you don't need to create a class to create an instance of an object. You can simply use the 'object notation', which essentially looks like what JSON looks like (Javascript Object Notation). JSON is simply a javascript object turned into a string to be sent down the wire and when it arrives at it's location, JSON.parse turns it back into the standard javascript object it always was.
 

Obreh Winfrey

Truly Brehthtaking
Supporter
Joined
Nov 18, 2016
Messages
20,706
Reputation
25,201
Daps
131,209
What are you trying to do exactly? It turns the JSON string into a Javascript object like any other. Javascript/TS is a lot different than Java and C# in that you don't need to create a class to create an instance of an object. You can simply use the 'object notation', which essentially looks like what JSON looks like (Javascript Object Notation). JSON is simply a javascript object turned into a string to be sent down the wire and when it arrives at it's location, JSON.parse turns it back into the standard javascript object it always was.
The initial question comes from needing to do a deep copy of objects. So essentially I have it like this
Class1 {}
Class2 {}
Class3 {
class1: Class1
class2: Class2[]
}
I guess my main question is if I take the JSON from class3 and use JSON.parse will it give me an intact classes back? Would I need to use JSON.parse() as Class3? I understand JSON and I have a handle on how classes work within JavaScript.
 

kevm3

follower of Jesus
Supporter
Joined
May 2, 2012
Messages
16,292
Reputation
5,551
Daps
83,491
The initial question comes from needing to do a deep copy of objects. So essentially I have it like this
Class1 {}
Class2 {}
Class3 {
class1: Class1
class2: Class2[]
}
I guess my main question is if I take the JSON from class3 and use JSON.parse will it give me an intact classes back? Would I need to use JSON.parse() as Class3? I understand JSON and I have a handle on how classes work within JavaScript.

class Dog {
name: string = "Fido";
}

class Cat {
name: string = "Sam";
}

class Combination {
dog: Dog = new Dog();
cat: Cat = new Cat();
}

let combo = new Combination();

Now, with combo, your object is represented as:
combo = {
dog: {
name: "fido"
},
cat: {
name: "sam"
}
}


if you json.stringify that, you will get a string representation of it that looks like this:
{
"dog": {
"name":"Fido"
},
"cat": {
"name":"Sam"
}
}

once you send this json object down the wire and get it back, you use json.parse to turn it from that string back into a javascript object. it's form is maintained. with json, you don't use it on classes, but only instances of classes, and it will give you back your instanced object intact, except you can't use functions, but only properties as values. For instance, if you added a method to that combo class, it would be omitted in the json representation and you would still get that json string i posted above.
 
Top