#Video Tutorial: Learn From Others

14 messages · Page 1 of 1 (latest)

sharp hamlet
#

I know that as someone who is new to modding, specially when we get stock on a problem and can't solve it, and specially when we ask qauestion in forum and we don't get answers fast, many of us had tried to look for answers the "easy" way. How about looking into other mod repositories? They had solved the puzzle, they have the code ready for us, then why not look into their code and copy/paste the whole solution into our own mod and get done with the problem?

This is something that many of us experienced and learned the hard way how hurmful it can be! In this video, I will talk about the bottlenecks regarding this approach and why it may not be such a good idea for newbie programmers to use this approach. I will use some well developed mods written by professional as examples to show how it can become a problem to look for solutions this way. Remember, almost all of the repositories that I choose in this video is written by well-known members and I don't mean any offense and if I sound like I'm feeling terrible, I'm trying to mimic a newbie programmer's feelings when they look into these repositories.

I hope this video can help many newbie programmers out there and show them why it's not such a good idea to look for solutions this way and why they should avoid diving into other people's code unless they really know what they are looking for and only do it when they became a decent mod developer, and they know what they are doing!

https://www.youtube.com/watch?v=iHhRBW2CXNQ

remote pulsar
#

Uh @sharp hamlet how exactly is generics something "questionable"?

#

The Registry registration is implemented in a generic form to allow you to get your registered instance back not as the super class of the registry, but as T, which is what you registered.

sharp hamlet
# remote pulsar The Registry registration is implemented in a generic form to allow you to get y...

I have explained it in the code refactor video (maybe will be published later I forgot the order of videos). The only reason is that it's overkill. You really don't need to use generics for item / block registeration. It's questionable not because of being generics, but because of the place it's being used and because we have easier, not complex way of doing it.

If someone knows what he / she is doing and for sure he / she knows that there should be "generics" usage for registering item / block in his / her mod for whatever reason, that's ok. But if a newbie is trying to learn from repositories and blindly copy/paste the generic approach without knowing what he / she is doing, that is when I would say that behavior is questionable and honestly, as I explain later in code refactoring video, as zero and hisui mentioned in chat (I show the screen shot in the code refactor video) the usage of generics for item / block registeration is not necessary.

By questionable, i meant the above thought process :/

sharp hamlet
remote pulsar
sharp hamlet
#

why wouldn't I type cast in those cases then?

remote pulsar
#

What if you change your class in a month?

#

Suddenly you will have a crash, because of a bad cast. Or a silent error because you check instanceOf that is now failing

sharp hamlet
#

oO, well, i see what you mean. Although personally I would prefer to get the crash and become aware of the potential problem. But the silent error because of instance of would be a nasty one to track.

#

well, this means I should have another video and talk deeper about this and let people choose this or that approach. hmmm

#

thanks for heads up

remote pulsar
#

tiny_potato even better then a crash