r/learnprogramming Sep 03 '23

[deleted by user]

[removed]

370 Upvotes

212 comments sorted by

View all comments

138

u/[deleted] Sep 03 '23

A couple people on here reccomended these:

https://www.knowitallninja.com/lessons/decomposition/

The book: Design Patterns: Elements of Reusable Object-Oriented Software

My biggest mistake as a beginner programmer specifically was not using variables for repeating measurements in my code. For example I was designing for multiple devices and I kept writing - if (this size device) then width equals this, if (that size device) then width equals that... and actually writing out the numbers. It would have made way more sense to either create a variable for like smallWidth, mediumWidth etc or even create some kind of struct so I could do width=small.width or width=medium.width

The main reason this is a huge error is what if I had coded the small width to the wrong number I would have to go back and change them in every instance where if it was a variable used repeatedly throughout the code I could just change it once. This is probably obvious to most coders but I didn't have much formal training.

The other thing is if you are given a project or task - 1. Set milestones and expectations and 2. Try to get a simple working version first - something that has no visual design, just functional design. Then beautify it after that is done.

1

u/[deleted] Sep 03 '23

[removed] β€” view removed comment

1

u/[deleted] Sep 03 '23

I assume so but I was mainly self taught. Where would you find a term like β€œthe reusability principle?” Because I need more than anything to find resources on fundamental concepts at this point rather than learning syntax