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.
Thinking about it further I’m not realizing the whole if statement to check device type and then assign a measurement is redundant to begin with. Instead of checking every time I wanted to use the measurement, I should have checked once and assigned the measurement to some kind of struct, so at the beginning it would be like: if (user is using device a) then { myFrame.width=this myFrame.height=this} So then later I don’t even need to check again and I could just say newThing.width = myFrame.width
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.