Jump to content

Inheritance. What? Why? How?


Guest Elfocrash

Recommended Posts

Guest Elfocrash

So as you might notice i deleted all of my shares in the L2j Sections. It is not a rage quit. It is because many stuff changed till the last time i wrote a code for mxc.

This means that any share that's gonna come will be a quality share and not crappy codes like my previous ones.

 

So this time i wanna explain some stuff to the l2j community which might have noticed but i doubt that they know.

 

I will talk about Inheritance.

 

What is Inheritance?

 

[*]Inheritance is a mechanism wherein a new class is derived from an existing class.

[*]Software reusability in which new classes are created from existing classes.

 

 

Advantages:

Saves time in program development.

It encourages the reuse of proven and debuffed high-quality software.

 

Inheritance explained.

A new class can inherit the data members and methods of previously defined class called base class.

The new class is called derived class.

With single inheritance, a class is derived from one base class

With multiple inheritance, a class is derived from multiple base classes. (However multiple inheritance in Java is not really common and it is

provided by protocols and interfaces mostly.)

A derived class can add data members and member methods on it's own so it can be larger than its base class.

A derived class is more specific than its base class and represents a smaller group of objects.

In the derived class we can define additions, replacements or refinements of the features inherited from the base class.

 

"Is a" and "Has a" Relationship explained

Inheritance and composition are the two ways of defining new classes using existing classes.

In an “is a” relationship, an object of the derived class can also be treated as an object of the base-class type.  The new class “is a kind of” existing class.

“Is a” is inheritance.

Example: circle “is a” shape.

In a “has a” relationship, a class has one or more objects of other classes as members.

“Has a” is composition .

Example: employee “has a” birth date, employment date.

 

Base Classes and Derived Classes

Base class: Shape

Derived classes:

  • Circle
  • Triangle
  • Rectangle

 

 

Derive class. How it looks like?

 

class Triangle extends Shape {

    // new fields and methods defining 
    // a triangle goes here

}

 

private members of the base class are not accessible in the derived class.

The public and protected members of the base class are inherited as public and protected members of the derived class.

 

Overriding a Method

 

An instance method in a subclass with the same signature and return type as an instance method in the superclass overrides the superclass's method.

 

The ability of a subclass to override a method allows a class to inherit from a superclass whose behavior is "close enough" and then to modify behavior as needed. The overriding method has the same name, number and type of parameters, and return type as the method it overrides. An overriding method can also return a subtype of the type returned by the overridden method. This is called a covariant return type.

 

When overriding a method, you might want to use the @Override annotation that instructs the compiler that you intend to override a method in the superclass. If, for some reason, the compiler detects that the method does not exist in one of the superclasses, it will generate an error.

 

 

Reference: http://docs.oracle.com/javase/tutorial/java/IandI/override.html

 

That's a short and basic guide to explain what inheritance is. Even if a simple weapon it can be really powerful if you use it properly.

Link to comment
Share on other sites

Guest Elfocrash

That's 0.001% of what I had to study for my exam ( All stuff related to OOP )

You really dont wanna see what i had to study for my exams on C++ and OOP :)

Link to comment
Share on other sites

Guest Elfocrash

It actually was a rage quit, but it happends to everyone, no worries.

I did want to get demoted and people of  my daily company like Finito and Noble did know it. Don't really give a shit for what people think btw.

Just explaining how it is.

 

Also, l2j section is not the best possible choice for a java guide.

Oh and it is because it is meant to be used for L2j purposes.

Link to comment
Share on other sites

Firstly, newboston is retarded.

 

Secondly, you don't need to talk about inheritance, and you will never should use OOP widely in large programs. Like l2j or game engines.

Some senior developers are so anti OOP, that they resort to massive reflection factory just to not deal with the memory consumption of the inherited reference.

 

Thirdly, this is not something to like, show off dude, its kinda..uh really newbish? That's like the first class you get, and if your teachers ever told you that OOP is best for everything, then you should consider telling them to shove it up their ass.

 

In conclusion, yeah its smth for newbies, but this is the problem here, your Guide was short and there are alot of newbie developers like newboston that was coming from other languages or from 0, and blaming the language of being slow and retarded and impossible to work with, just cause they saw a tutorial and they are so closed minded to believe only in urs since theres alot of ass kissing in here. Opinions should always be debated, not accepted from the start in any way, direct or indirect.

 

I saw that retard newboston sorting LinkedLists, what the shit? The action is retarded but the way he referred to it and its usability was simply cretinous, retarded, stupid, the guy should die.

Link to comment
Share on other sites

Guest Elfocrash

Thirdly, this is not something to like, show off dude, its kinda..uh really newbish? That's like the first class you get, and if your teachers ever told you that OOP is best for everything, then you should consider telling them to shove it up their ass.

It is meant to be newbish and yeah it is only the basic idea nothing more. Do you really think that someone can demonstrate something more in mxc and expect from the community to

understand. Look at this. There is not one serious reply apart from yours. Btw thanks for the reply.

Link to comment
Share on other sites

Firstly, newboston is retarded.

 

Secondly, you don't need to talk about inheritance, and you will never should use OOP widely in large programs. Like l2j or game engines.

Some senior developers are so anti OOP, that they resort to massive reflection factory just to not deal with the memory consumption of the inherited reference.

 

Thirdly, this is not something to like, show off dude, its kinda..uh really newbish? That's like the first class you get, and if your teachers ever told you that OOP is best for everything, then you should consider telling them to shove it up their ass.

 

In conclusion, yeah its smth for newbies, but this is the problem here, your Guide was short and there are alot of newbie developers like newboston that was coming from other languages or from 0, and blaming the language of being slow and retarded and impossible to work with, just cause they saw a tutorial and they are so closed minded to believe only in urs since theres alot of ass kissing in here. Opinions should always be debated, not accepted from the start in any way, direct or indirect.

 

I saw that retard newboston sorting LinkedLists, what the shit? The action is retarded but the way he referred to it and its usability was simply cretinous, retarded, stupid, the guy should die.

This dude knows how to create beer and wine, what are you talking about?
Link to comment
Share on other sites

It is meant to be newbish and yeah it is only the basic idea nothing more. Do you really think that someone can demonstrate something more in mxc and expect from the community to

understand. Look at this. There is not one serious reply apart from yours. Btw thanks for the reply.

I think you right, i tend to think i live on a different planet sometimes, with high hopes :P

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Posts

    • Welcome to my store :  https://topestore.mysellix.io/fr/ 2015-2022 Aged Discord Account 2015 Discord Account : 50.99 $ 2016 Discord Account : 10$ 2017 Discord Account :3.99 $ 2018 Discord Account : 3.50$ 2019 Discord Account : 2.70 $ 2020 Discord Account :1.50$ 2021 Discord Account :0.99$ 2022 Discord Account :0.70$ Warranty :Lifetime Payment Methods : Crypto/ PayPal Contact Me On Discord Or Telegram Discord : @ultrasstore11 Telegram : https://t.me/ultrastore1 Welcome to my store :  https://topestore.mysellix.io/fr/ 2015-2022 Aged Discord Account 2015 Discord Account : 50.99 $ 2016 Discord Account : 10$ 2017 Discord Account :3.99 $ 2018 Discord Account : 3.50$ 2019 Discord Account : 2.70 $ 2020 Discord Account :1.50$ 2021 Discord Account :0.99$ 2022 Discord Account :0.70$ Warranty :Lifetime Payment Methods : Crypto/ PayPal Contact Me On Discord Or Telegram Discord : @ultrasstore11
    • L2 ArenaWar: Low Rate PvP Server with Free Buffs & Autofarm [PVP]⚔️ [Free]🆓 Classic Interlude with  3x XP rates! Free starter pack(no grade) to kickstart your adventure! Autofarm for convenient grinding! Free buffs to keep you fighting fit! (2 job buffs) No experience loss on death! (Except with Karma) Clear Karma system to keep things fair! ⚖️ Active community of 800-1k players! Join our Discord to learn more! >> Discord <<     Server website: https://l2arenawar.com/en/    
    • This is dedication! 2 years working on a problem. Congratulations!
    • You indeed have to save player position over Enterworld to properly clean it up later (if you don't, even trying to delete packet content would eventually keep it up), that's what we do with debug packet (which is a reusable Map of ExServerPrimitive packets) on aCis.   It doesn't solve the FPS stuttering - more you draw/delete lines, more your client becomes laggy. It's like if client wasn't deleting drawn points/lines properly, but instead simply hide them and redrawn content above.   If you got a solution, I would happy to integrate it.   You should check aCis#Player _debug packet integration, it allows very big amount of lines/points to be drawn, it is also reusable.   https://gitlab.com/Tryskell/acis_public/-/blob/master/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/Player.java?ref_type=heads https://gitlab.com/Tryskell/acis_public/-/blob/master/aCis_gameserver/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java?ref_type=heads  
    • we sell website templates, make websites to order. Great selection at very good prices. My contacts discord : advert1231 telegram : https://t.me/ggwpins  
  • Topics

×
×
  • Create New...