1334 views|15 replies

109

Posts

0

Resources
The OP
 

How do you get rid of the feeling of copying someone else's code and just patching it up? [Copy link]

 

I haven't been in contact with MCU software for a long time. I used to work on hardware. When a project comes, I often start to read the manual and "secondary processing" according to the source code I get. I even download the source code directly from the Internet and then try to figure out why others write it this way. I almost never type the code one by one. I just copy and paste and modify it. I feel lazy. I think this is a bad experience. I hope to get some suggestions to get rid of this situation. Thank you.

This post is from stm32/stm8

Latest reply

I heard a big guy say: The daily work of embedded software engineers is mainly "porting + debugging" Think about how you learned to speak, I guess programming is the same   Details Published on 2023-6-30 22:38
 

7422

Posts

2

Resources
2
 

Write more and read more. Copying is a difficult task for beginners.

This post is from stm32/stm8
 
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 

6748

Posts

2

Resources
3
 

I basically learned it step by step from the examples, and copying and pasting is very common. When I write project codes, more than half of them are copied and pasted.

This post is from stm32/stm8
 
 

6748

Posts

2

Resources
4
 

As long as you know what the code does after copying, pasting and modifying it, there will be no problem.

This post is from stm32/stm8

Comments

I can understand other people's code, and I know why they do it and what the code does. But when I write it myself, I find that I can't write a framework. I still have to modify it based on others to achieve the functions I want. I feel that without other people's source code, I can't write it myself.  Details Published on 2023-6-21 10:43
 
 
 

351

Posts

3

Resources
5
 

When I was playing with AVR before, I would write code by myself step by step by referring to the manual registers. Since I used PIC's MCC and then ST's CUBE, I never studied the registers in detail again. It is enough for me to just have a general understanding of the functions and usage. Is this a habit spoiled by the manufacturer?

This post is from stm32/stm8

Comments

It is possible. For example, ST has library functions, but other microcontrollers may not have them. You still need to read the manual to get the registers.  Details Published on 2023-6-21 10:44
 
 
 

4764

Posts

12

Resources
6
 
The code is really like this. If someone writes it well, they can only write it that way. The complexity and resource usage are both optimal. Why change it?
This post is from stm32/stm8
 
 
 

4764

Posts

12

Resources
7
 
The author of the post said that being able to solve the problem is the real thing. The bosses don't really care how you solve it. It doesn't matter whose code you borrowed.
This post is from stm32/stm8
 
 
 

1791

Posts

0

Resources
8
 

This is normal. MCU manufacturers and some driver chip manufacturers also provide routines. Nowadays, no one types every letter from beginning to end by themselves. They all transplant modules one by one. I think more important skills and more time are spent on debugging. There are often problems with transplanted programs, which need to be converted into what your own project needs.

This post is from stm32/stm8
 
 
 

1791

Posts

0

Resources
9
 

Of course, there are many ways to write code. At least when making applications, you can’t avoid copy-paste-modify.

This post is from stm32/stm8

Comments

Thanks, I've learned a lot.  Details Published on 2023-6-21 10:44
 
 
 

109

Posts

0

Resources
10
 
wangerxian posted on 2023-6-20 18:27 As long as you know what this code does after copying and pasting it, there will be no problem.

I can understand other people's code, and I know why they do it and what the code does. But when I write it myself, I find that I can't write a framework. I still have to modify it based on others to achieve the functions I want. I feel that without other people's source code, I can't write it myself.

This post is from stm32/stm8

Comments

Just like you said, you can understand what it is used for, but you can't understand why it is written like this, so you have to spend some time to study why it is written like this. After you understand it, try to write a similar framework yourself. If you can write it, it means you know this framework.  Details Published on 2023-6-23 17:34
Just like you said, you can understand what it is used for, but you can't understand why it is written like this, so you have to spend some time to study why it is written like this. After you understand it, try to write a similar framework yourself. If you can write it, it means you know this framework.  Details Published on 2023-6-21 10:50
 
 
 

109

Posts

0

Resources
11
 
hjl2832 posted on 2023-6-20 20:16 When I used to play with AVR, I would go through the manual registers step by step and type the code myself. Since I used PIC's MCC and then ST's CUBE, I never...

It is possible. For example, ST has library functions, but other microcontrollers may not have them. You still need to read the manual to get the registers.

This post is from stm32/stm8
 
 
 

109

Posts

0

Resources
12
 
sint27 posted on 2023-6-21 08:55 Of course, there are many ways to write code. At least when making applications, you can’t avoid copy-paste-modify.

Thanks, I've learned a lot.

This post is from stm32/stm8
 
 
 

6748

Posts

2

Resources
13
 
aq1261101415 posted on 2023-6-21 10:43 I can understand other people's code, and I know why they do this and what this code does, but when I write it myself, I find that I can't write a box...

Just like you said, you can understand what it is used for, but you can't understand why it is written like this, so you have to spend some time to study why it is written like this. After you understand it, try to write a similar framework yourself. If you can write it, it means you know this framework.

This post is from stm32/stm8
 
 
 

4764

Posts

12

Resources
14
 
wangerxian posted on 2023-6-20 18:27 As long as you know what this code does after copying, pasting and modifying it, there will be no problem.
I can understand other people's code, and I know why others do this and what this code does, but when I write it myself, I find that I can't write a framework. I still have to modify it based on others', and I can also achieve the functions I want. I feel that without other people's source code, I can't write it myself
Write less and write more, and you will naturally get it. Just like when we type and post, we will post more if we post more~
This post is from stm32/stm8
 
 
 

410

Posts

0

Resources
15
 

Personally, I think that in addition to the learning and practice mentioned by the previous big guys, you still have to read and understand the code of a certain module, and on this basis, you can independently solve the bugs you encounter. Basically, you can get started, and later you can try to rewrite it yourself. PS: If you have time,

This post is from stm32/stm8
 
 
 

224

Posts

0

Resources
16
 

I heard a big guy say: The daily work of embedded software engineers is mainly "porting + debugging"

Think about how you learned to speak, I guess programming is the same

This post is from stm32/stm8
 
 
 

Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list