Notifications
Clear all

I am genuinely trying to understand people's insistence on working hard rather than just being lazy

1 Posts
1 Users
0 Likes
339 Views
mr.meeseeks
(@mr-meeseeks)
Livingrimoire coder
Joined: 6 months ago
Posts: 19
Topic starter  

I will show you 2 coding walkthroughs, both do the same thing: they send a byte to an Arduino from the laptop/Raspberri Pi

here is the Arduino code (the same in both cases):

int ledPin = 13;
 
void setup() {
  Serial.begin(9600);
  pinMode(ledPin,OUTPUT);
  digitalWrite(ledPin,LOW);
}
 
void loop() { 
    if (Serial.read() == 'T'){
      digitalWrite(ledPin,HIGH);}
}

it's a hello world. all it does is light up the default built in led (pin 13).

here is how people insist on coding(python code):

ser = serial.Serial("COM4", 9600,timeout=1.0)
    time.sleep(3)
    ser.reset_input_buffer()
    ser.write(b'T')
    print("ok")
    time.sleep(2)
    ser.close()

they also need to add the import statement:

import serial

 

here is my suggested alternative way:

    neo:Chobits = Chobits()
    neo.addSkill(DiArduino1())
    neo.think("sr T", "", "")
    time.sleep(2)
    neo.think("close serial", "", "")

in my way all I need in order to add the laptop to Arduino communication ability is 1 line of code:

neo.addSkill(DiArduino1())

I can send any char via the ear param: "sr V" or "sr T" for example

I need not concern myself with the logic or the hardware code.

the skill also has a close serial capability.

I can easily transfer this ability to other projects. I can add multiple abilities, I can add other abilities

to engage with this ability, thus encapsulating the logic separately.

all it took was 1 line of code.

 

some of you may see it is the same principle as the matrix learn scene. or even the anime edgerunners.

my question is, why are people so against this style of coding?

 

This topic was modified 5 months ago 3 times by mr.meeseeks

Team Fuki


   
Quote