It's really annoying how "extends" in programming means exactly the opposite of what it means.
A class is a concept. To extend a concept is to allow more instances to fall under it. Extending a class restricts the instances falling under it.
that's why in C++ it's just ":" and in spoken word it's called inheritance, a more concrete class has ancestor as more abstract class that matches it, Java is just moronic
Exactly, and the stuff is the instances of the class. In mathematics, by the axiom of extensionality, a class is defined by its instances.
4 weeks ago
Anonymous
>the stuff is the instances of the class
Extension does not mean disjointed union, that would be an interface
4 weeks ago
Anonymous
Nobody mentioned a disjointed union. Learn to read.
4 weeks ago
Anonymous
A subclass is defined both by the class it inherits from and the stuff it adds to it, not just the latter
4 weeks ago
Anonymous
In mathematics and philosophy and life, a class A extends a class B if it has all the elements of A.
In java, a class A "extends" a class B if B has all the elements of A.
4 weeks ago
Anonymous
>In java, a class A "extends" a class B if B has all the elements of A.
Wtf are you smoking
4 weeks ago
Anonymous
A extends B in java <=> x in A implies x in B, means B has all the same elements and more, means B actually extends A.
4 weeks ago
Anonymous
You are getting it backwards homie, I don't even know where the frick you got this from
4 weeks ago
Anonymous
Just read what I wrote again. Everything I said is logical and 100% makes sense.
You are just confused or dumb.
4 weeks ago
Anonymous
You are literally getting it backwards you fricking braindead pseud
A extends B in java <=> x in B implies x in A
4 weeks ago
Anonymous
Oh my god you are moronic. It's literally the opposite. Have you never coded in java?
4 weeks ago
Anonymous
class B {
public int x = 10;
}
class A extends B {
public int y = 20;
}
public static void main(){
A a = new A();
System.out.println(a.x);
}
By your moronic logic a.x shouldn't exist
4 weeks ago
Anonymous
a.x exists be cause B extends A, you idiot. That's what it means to be a bigger class: all members of A are also members of B, and all members of B have property x, so all members of A also have property x, because B is a BIGGER class that EXTENDS A.
public B b = new B();
System.out.println(b.y);
According to you, this should work. Fricking moron.
4 weeks ago
Anonymous
>According to you, this should work
No lmao
So let me get this straight: if according to you B is the bigger class then what additional elements does it have? Surely not y
4 weeks ago
Anonymous
B b = new B();
B has the element b but A doesn't have the element b, because A is a smaller class than B. This is elementary. I don't understand how you can be so moronic.
4 weeks ago
Anonymous
>mixing up types, classes and sets of elements to mud the waters
4 weeks ago
Anonymous
It doesn't matter which term you use in this context. The point still stands.
4 weeks ago
Anonymous
Ok Black person this is my last reply
The TYPE modeled by CLASS B contains all the elements of the TYPE modeled by CLASS A and then some, meaning that the TYPE modeled by CLASS B is a bigger set than the TYPE modeled by class A.
An INSTANCE of the CLASS A contains all the elements of an INSTANCE of the CLASS B and then some, meaning that an INSTANCE of the CLASS A is a bigger set than the INSTANCE of the CLASS B
Terms matter and you are a pseud Black person
4 weeks ago
Anonymous
>The TYPE modeled by CLASS B contains all the elements of the TYPE modeled by CLASS A and then some, meaning that the TYPE modeled by CLASS B is a bigger set than the TYPE modeled by class A
This is literally what I said. Also you could remove the "type modeled by", it would mean the exact same thing. > An INSTANCE of the CLASS A contains all the elements
An instance is an element. Wtf did you think an element of a class/type was?
4 weeks ago
Anonymous
An object contains fields, which in turn can be other objects. Thus an object is itself a set of sets.
4 weeks ago
Anonymous
Doesn't address my point.
4 weeks ago
Anonymous
A extends B in java <=> x in A implies x in B, means B has all the same elements and more, means B actually extends A.
In mathematics and philosophy and life, a class A extends a class B if it has all the elements of A.
In java, a class A "extends" a class B if B has all the elements of A.
Is this an elaborate shitpost? If so, congrats on the (you)s.
4 weeks ago
Anonymous
>
4 weeks ago
Anonymous
You are literally getting it backwards you fricking braindead pseud
A extends B in java <=> x in B implies x in A
>doesn't understand polymorphism
many such street shitters, sad!
>he doesn't understand covariance and contravariance
Sorry buddy, that's not how class inheritance works.
public class Vehicle : Idrivable, ICrashable, ICanHaveSexInAble, INewtonianSolid
protected class Car : Vehicle, ISteerable, IBluetoothConnectable, ICar
Car car = VehicleFactory.NewInstanceOfType<ICar, ISteerable>(make = "Fodr", model = "Corolla");
FTFY. Next time don't be so lazy with your domain modeling. A proper object oriented hierarchy is crucial for success in the modern enterprise environment.
class BasicCar implements Car {
@Override
public void drive() {
System.out.println("driving");
}
}
interface CarFactory {
Car createCar();
}
class BasicCarFactory implements CarFactory {
@Override
public Car createCar() {
return new BasicCar();
}
}
public class Main {
public static void main(String[] args) {
CarFactory carFactory = new BasicCarFactory();
Car car = carFactory.createCar();
car.drive();
}
}
Why is enterprise quality code so repulsive? I know it's supposed to make everything an object to increase code reuse but it's just so disgusting for some reason
All the fricking POO examples are like that, Animal Class, Monster Class, Vehicle Class, fricking moronic examples. I never understood POO because of this and having a 34IQ
OOP came up when the israelites realized that the advent of the Internet meant Infinite money, because they could have the glorious shabbos goy white engineer from the North send the UML to the shitskins to code for pennies on the dollar.
It obeys to no real directive other than to prove your compliance. A programmer's mind has never worked that way. A programmer's mind will produce C/Cpp style code. Java style code is, instead, solely intended to prove that you're a well-read, textbook abiding golem of the israelites, that you're down with the clown, that you obey your programming.
can I just not use classes ever? like I understand the utter basics of programming with C++ and a few other languages but just fail to ever see the utility of classes.
genuine question, even if it sounds like moronic bait.
Of course. I have been mostly doing that. You can use structs/dicts/objects.
There is a few situations where they are neat, usually when making a game, but they are completely optional.
>"Amidst the allure of simplicity, don't mistake complexity for incompetence. While it's easy to dismiss intricate systems as flawed, true brilliance lies in discerning when complexity serves a purpose. beware of praising simplicity blindly, for in the realm of intellect, it's the mastery of intricacies that truly distinguishes the brilliant from the mundane."
>my spaghetti code is an elegant silk weave where every knot serves a purpose, yours is an abstract obfuscation made only to complicate the simplest of problems
I just need a simple structure to hold pertinent information for vehicles, an over-engineered encapsulation method for an abstract data type just makes you sound like an ass.
>TypeScript >it's just JavaScript but with extra layers of bloat and pretension
I'm just not going to listen to someone's opinion on languages when they promote that moronic gay shit.
You can also just use the variable declaration keyword if you want in C#.
var car = new car();
The reason you would want to use the type is to define the type of the reference to your object.
class Op : homosexual{}
homosexual op = new Op();
This. all this nocoder seething about classes kek. if you really think you write decent code without classes, post it so we can laugh. its all cnile shit where you have to do this, which is 10x worse than op's example, which isnt even a real example because most langs have a variable declaration that has type inference
This drove me up a wall, but it ultimately makes sense when you understand how C# works.
You're basically creating a variable car, of the object type of Car. Meaning, you have the blueprints called Car, and you have a box that will ultimately hold the car. You now put in an order to the factory with the = that you want a new Object that is the Car object itself.
You can always rewrite this for clarity like:
Car itsABrandNewCar = new Car()
Stand bloody back sirts. authentic cnile code no pooooooop here from mario 64
/**
* Puts Mario into a given action, putting Mario through the appropriate
* specific function if needed.
*/
u32 set_mario_action(struct MarioState *m, u32 action, u32 actionArg) {
switch (action & ACT_GROUP_MASK) {
case ACT_GROUP_MOVING:
action = set_mario_action_moving(m, action, actionArg);
break;
case ACT_GROUP_AIRBORNE:
action = set_mario_action_airborne(m, action, actionArg);
break;
case ACT_GROUP_SUBMERGED:
action = set_mario_action_submerged(m, action, actionArg);
break;
case ACT_GROUP_CUTSCENE:
action = set_mario_action_cutscene(m, action, actionArg);
break;
}
// Resets the sound played flags, meaning Mario can play those sound types again.
m->flags &= ~(MARIO_ACTION_SOUND_PLAYED | MARIO_MARIO_SOUND_PLAYED);
if (!(m->action & ACT_FLAG_AIR)) {
m->flags &= ~MARIO_UNKNOWN_18;
}
class OP extends homosexual{}
It's really annoying how "extends" in programming means exactly the opposite of what it means.
A class is a concept. To extend a concept is to allow more instances to fall under it. Extending a class restricts the instances falling under it.
that's why in C++ it's just ":" and in spoken word it's called inheritance, a more concrete class has ancestor as more abstract class that matches it, Java is just moronic
To extend a concept means to keep the original and add stuff to it homie
Exactly, and the stuff is the instances of the class. In mathematics, by the axiom of extensionality, a class is defined by its instances.
>the stuff is the instances of the class
Extension does not mean disjointed union, that would be an interface
Nobody mentioned a disjointed union. Learn to read.
A subclass is defined both by the class it inherits from and the stuff it adds to it, not just the latter
In mathematics and philosophy and life, a class A extends a class B if it has all the elements of A.
In java, a class A "extends" a class B if B has all the elements of A.
>In java, a class A "extends" a class B if B has all the elements of A.
Wtf are you smoking
A extends B in java <=> x in A implies x in B, means B has all the same elements and more, means B actually extends A.
You are getting it backwards homie, I don't even know where the frick you got this from
Just read what I wrote again. Everything I said is logical and 100% makes sense.
You are just confused or dumb.
You are literally getting it backwards you fricking braindead pseud
A extends B in java <=> x in B implies x in A
Oh my god you are moronic. It's literally the opposite. Have you never coded in java?
class B {
public int x = 10;
}
class A extends B {
public int y = 20;
}
public static void main(){
A a = new A();
System.out.println(a.x);
}
By your moronic logic a.x shouldn't exist
a.x exists be cause B extends A, you idiot. That's what it means to be a bigger class: all members of A are also members of B, and all members of B have property x, so all members of A also have property x, because B is a BIGGER class that EXTENDS A.
public B b = new B();
System.out.println(b.y);
According to you, this should work. Fricking moron.
>According to you, this should work
No lmao
So let me get this straight: if according to you B is the bigger class then what additional elements does it have? Surely not y
B b = new B();
B has the element b but A doesn't have the element b, because A is a smaller class than B. This is elementary. I don't understand how you can be so moronic.
>mixing up types, classes and sets of elements to mud the waters
It doesn't matter which term you use in this context. The point still stands.
Ok Black person this is my last reply
The TYPE modeled by CLASS B contains all the elements of the TYPE modeled by CLASS A and then some, meaning that the TYPE modeled by CLASS B is a bigger set than the TYPE modeled by class A.
An INSTANCE of the CLASS A contains all the elements of an INSTANCE of the CLASS B and then some, meaning that an INSTANCE of the CLASS A is a bigger set than the INSTANCE of the CLASS B
Terms matter and you are a pseud Black person
>The TYPE modeled by CLASS B contains all the elements of the TYPE modeled by CLASS A and then some, meaning that the TYPE modeled by CLASS B is a bigger set than the TYPE modeled by class A
This is literally what I said. Also you could remove the "type modeled by", it would mean the exact same thing.
> An INSTANCE of the CLASS A contains all the elements
An instance is an element. Wtf did you think an element of a class/type was?
An object contains fields, which in turn can be other objects. Thus an object is itself a set of sets.
Doesn't address my point.
Is this an elaborate shitpost? If so, congrats on the (you)s.
>
>he doesn't understand covariance and contravariance
Sorry buddy, that's not how class inheritance works.
>doesn't understand polymorphism
many such street shitters, sad!
Not an argument.
i dont get it
then get off DA
i thought this was the tech consumerism board, not the programming board
i dont want to
public class Vehicle : Idrivable, ICrashable, ICanHaveSexInAble, INewtonianSolid
protected class Car : Vehicle, ISteerable, IBluetoothConnectable, ICar
Car car = VehicleFactory.NewInstanceOfType<ICar, ISteerable>(make = "Fodr", model = "Corolla");
FTFY. Next time don't be so lazy with your domain modeling. A proper object oriented hierarchy is crucial for success in the modern enterprise environment.
I can still understand it so it's not OOP and enterprise enough
should not Vehicle be abstract?
>ICanHaveSexInAble
This should be YouCanHaveSexInAble
Inheritance is identity moran
all of this and it doesn't even prevent you from creating a Ford Corolla lol
var c = new Car();
Use that thinking you're smart then regret it on large codebase.
car = Car()
what's the problem?
how does the compiler know if you are referring to a new or old car tho
`Vehicle car = Car.new(new CarTire[]{new CarTire() .... })`
- Well used Interfaces
- Factory methods
- A thing shouldn't have to create its dependencies, it should be given them (dependency injection)
Vehicle car = Car.new(new CarTire[]{new CarTire() .... })
code tag tongue my anus
rate my car saars
interface Car {
void drive();
}
class BasicCar implements Car {
@Override
public void drive() {
System.out.println("driving");
}
}
interface CarFactory {
Car createCar();
}
class BasicCarFactory implements CarFactory {
@Override
public Car createCar() {
return new BasicCar();
}
}
public class Main {
public static void main(String[] args) {
CarFactory carFactory = new BasicCarFactory();
Car car = carFactory.createCar();
car.drive();
}
}
don't stutter, if you already have CarFactory, you can simply name the method "create()"
Why is enterprise quality code so repulsive? I know it's supposed to make everything an object to increase code reuse but it's just so disgusting for some reason
let car = Car::new();
All the fricking POO examples are like that, Animal Class, Monster Class, Vehicle Class, fricking moronic examples. I never understood POO because of this and having a 34IQ
OOP came up when the israelites realized that the advent of the Internet meant Infinite money, because they could have the glorious shabbos goy white engineer from the North send the UML to the shitskins to code for pennies on the dollar.
It obeys to no real directive other than to prove your compliance. A programmer's mind has never worked that way. A programmer's mind will produce C/Cpp style code. Java style code is, instead, solely intended to prove that you're a well-read, textbook abiding golem of the israelites, that you're down with the clown, that you obey your programming.
Stop larping you fricking Black person
OOP the way it is normally used, is completely gay and moronic, polymorphism should only be used sparingly in really high level constructs
car.car.cardoor.siding.knob.window.up=false;
Frog frog = new Frog();
New old = new Old();
Tesla tesla = new VehicleFactory().getCarFactory().buildTestla().implementation().build();
good morning sirs
VehicleFactory factory = VehicleFactories.carFactory();
Tesla tesla = factory.createDefault(Tesla.class);
tesla.start().join();
data Car = Car
car = Car
Car car{};
gcc/libstdc++
var car = new Car();
Car car = new();
Or, my personal favorite:
var car = new();
can I just not use classes ever? like I understand the utter basics of programming with C++ and a few other languages but just fail to ever see the utility of classes.
genuine question, even if it sounds like moronic bait.
yes you can, cniles reinvent whole OOP from scratch and even when they do it, they still have no classes, and it works
Of course. I have been mostly doing that. You can use structs/dicts/objects.
There is a few situations where they are neat, usually when making a game, but they are completely optional.
yes. I never use classes
Have you never written a large program before?
Do you put everything in one file or something?
JavaScript dev?
Why does Java suck the joy out of programming?
>auto car = new Car();
NOOOO SAR THAT WILL LEAK MEMORY, SAR DO NOT REDEEM AND REMEMBER TO delete, OKAY?!
>auto mobile = new Car();
>car* car = new car{};
>car car = car Car();
>#define cAr =
>#define caR new
>#define CAr {
>#define cAR }
>#define Car ;
>#define CAR *
>car CAR car cAr caR car CAr cAR Car
heheh
Should be
auto car = std::make_unique<Car>();
c++ is a disease
i'd say that too if i got filtered by it
Good day sir
sirs would use ::New() thoughever
manual car = new Car();
Car car = new();
C# gods won
struct Car {
make: String,
model: String,
year: u32,
}
impl Car {
fn new(make: String, model: String, year: u32) -> Car {
Car { make, model, year }
}
fn drive(&self) {
println!("{} {} is driving.", self.make, self.model);
}
}
post hair colour
It's black. I'm black.
>classes
>objects
>methods
>properties
>or are they attributes
>this is not CSS
>extends this dick
>implements this dick
><this dick>
>"Amidst the allure of simplicity, don't mistake complexity for incompetence. While it's easy to dismiss intricate systems as flawed, true brilliance lies in discerning when complexity serves a purpose. beware of praising simplicity blindly, for in the realm of intellect, it's the mastery of intricacies that truly distinguishes the brilliant from the mundane."
>my spaghetti code is an elegant silk weave where every knot serves a purpose, yours is an abstract obfuscation made only to complicate the simplest of problems
I just need a simple structure to hold pertinent information for vehicles, an over-engineered encapsulation method for an abstract data type just makes you sound like an ass.
In languages where type also serves as the variable declaration keyword you can't have type inference, hence this garbolini
Compare with TypeScript:
const car = new Car;
C# cucks how do u tolerate this
C# has Car car = new();
>TypeScript
>it's just JavaScript but with extra layers of bloat and pretension
I'm just not going to listen to someone's opinion on languages when they promote that moronic gay shit.
Yep. It doesn't do anything, it's just extra bloat you have to type so the compiler can protect you from rookie mistakes
yep, ts is just a linter, the types are fake
have to use it at work though because there's lots of morons
or you just use a dummy keyword in place of the type, stupid
You can also just use the variable declaration keyword if you want in C#.
var car = new car();
The reason you would want to use the type is to define the type of the reference to your object.
class Op : homosexual{}
homosexual op = new Op();
import car
car.run()
>oop in a statically typed language
ngmi
in c# it's now just Car car = new();
You don't need to say what it is again after the =
QUICK!
car(Car car) {
car = Car();
}
aCar := Car new
>using dick assignment
car = Car.new()
let car = Car::new()
local car = Car:new()
car1, car2 = [Car(x) for x in ['Chevrolet', 'GMC']]
this is based and most comfy
pythonchads win again!
undoubtedly!!
Pyjeet
or, the mature and fair complexion way
std::unique_ptr<Car> car = std::make_unique<Car>();
Just do
>Car car;
i said
>fair complexion
struct Car *car = malloc(sizeof(struct Car));
This. all this nocoder seething about classes kek. if you really think you write decent code without classes, post it so we can laugh. its all cnile shit where you have to do this, which is 10x worse than op's example, which isnt even a real example because most langs have a variable declaration that has type inference
int buf[128];
vs
int [] buf = new int[128];
declare -a carMake
declare -a careModel
declare -a carYear
createCar ()
{
carMake+=($1)
carModel+=($2)
carYear+=($3)
}
car=$(createCar "Renault" "Twingo" "1997")
This drove me up a wall, but it ultimately makes sense when you understand how C# works.
You're basically creating a variable car, of the object type of Car. Meaning, you have the blueprints called Car, and you have a box that will ultimately hold the car. You now put in an order to the factory with the = that you want a new Object that is the Car object itself.
You can always rewrite this for clarity like:
Car itsABrandNewCar = new Car()
This this type of wordage I want confetti and fanfare to play while I guess the MSRP.
maloc(100)
Funniest post
Stand bloody back sirts. authentic cnile code no pooooooop here from mario 64
/**
* Puts Mario into a given action, putting Mario through the appropriate
* specific function if needed.
*/
u32 set_mario_action(struct MarioState *m, u32 action, u32 actionArg) {
switch (action & ACT_GROUP_MASK) {
case ACT_GROUP_MOVING:
action = set_mario_action_moving(m, action, actionArg);
break;
case ACT_GROUP_AIRBORNE:
action = set_mario_action_airborne(m, action, actionArg);
break;
case ACT_GROUP_SUBMERGED:
action = set_mario_action_submerged(m, action, actionArg);
break;
case ACT_GROUP_CUTSCENE:
action = set_mario_action_cutscene(m, action, actionArg);
break;
}
// Resets the sound played flags, meaning Mario can play those sound types again.
m->flags &= ~(MARIO_ACTION_SOUND_PLAYED | MARIO_MARIO_SOUND_PLAYED);
if (!(m->action & ACT_FLAG_AIR)) {
m->flags &= ~MARIO_UNKNOWN_18;
}
// Initialize the action information.
m->prevAction = m->action;
m->action = action;
m->actionArg = actionArg;
m->actionState = 0;
m->actionTimer = 0;
return TRUE;
}
>has oop anyway
>bitmasking for booleans
the power of cniles whoaaaaa...... time to throw away 50 years of language improvements for this