IT/Software career thread: Invert binary trees for dollars.

Neranja

<Bronze Donator>
2,605
4,143
Use some structs then!

I'm not really arguing that #defines can be useful, I just don't like the overall concept.

Those types of #define statements can almost always be replaced by enum statements, which would be statically resolved just like #define statements by the compiler.

By now it is more convention than necessity, but it stems from the time when the C preprocessor was a different program than the compiler itself, and you would cram all those static definitions as #defines into it to not fill up the compiler tables - as memory was a concern back in the day.

It's looked up disfavorably because people got really creative, like implementing whole functions. Which, in turn, was made redundant by both inline functions and automatic loop unrolling in modern compilers. But people learn programming by looking and understanding code of other programmers, which is naturally older and uses those old conventions. And so they pick up some bad habits here and there.
 
  • 1Like
Reactions: 1 user

Warrian

╰⋃╯ლ(´ڡ`ლ)
141
29
Can you guys give any recommendations on learning material for program design? We’re starting to become python heavy where I work because automation is a big focus. I’m a network engineer so programming has never really big a focus of mine up until a year or so ago. I’m not bad at using python but I’m still struggling with program design and how my programs should be laid out, or how I should attack a problem. Should I be using more classes or more functions? Should variable declarations be made at the top of the program or under __main__? It’s little things like these that don’t make sense yet. Sometimes I read other scripts out there and realize people are on another level.
 
  • 1Like
Reactions: 1 user

Deathwing

<Bronze Donator>
16,356
7,363
Can you guys give any recommendations on learning material for program design? We’re starting to become python heavy where I work because automation is a big focus. I’m a network engineer so programming has never really big a focus of mine up until a year or so ago. I’m not bad at using python but I’m still struggling with program design and how my programs should be laid out, or how I should attack a problem. Should I be using more classes or more functions? Should variable declarations be made at the top of the program or under __main__? It’s little things like these that don’t make sense yet. Sometimes I read other scripts out there and realize people are on another level.
Code reviews. Do you work at a company with a software department? I would *LOVE* to review our IT department's code, perhaps not for benign reasons...

Other than that, learn by doing. I started my current job without even an idea that Python existed. Made mistakes, had our product architect tell me my code was dumb, and just gotten better over the last 5 years.
 

Deathwing

<Bronze Donator>
16,356
7,363
Not really code learning, more like problem grinding.
Where exactly do you see the value in this? I was bored yesterday so I gave some of these a try. A lot of the questions seem geared towards languages like C. Why would I want to implement square root in Python?

I get that it's an exercise in Newtonian search. I'm not sure whether I should be mad at myself for thinking it was dumb, or mad that these type of questions are commonplace in interviewing.
 

Lendarios

Trump's Staff
<Gold Donor>
19,360
-17,424
Where exactly do you see the value in this? I was bored yesterday so I gave some of these a try. A lot of the questions seem geared towards languages like C. Why would I want to implement square root in Python?

I get that it's an exercise in Newtonian search. I'm not sure whether I should be mad at myself for thinking it was dumb, or mad that these type of questions are commonplace in interviewing.

a) it is fun to do this kind of exercises
b) they help to keep your skills fresh.
c) they are fun to do

You should be able to implement a square root function, or at least an approximation one in any language by doing a series consecutive divisions.
 

Asshat wormie

2023 Asshat Award Winner
<Gold Donor>
16,820
30,963
Where exactly do you see the value in this? I was bored yesterday so I gave some of these a try. A lot of the questions seem geared towards languages like C. Why would I want to implement square root in Python?

I get that it's an exercise in Newtonian search. I'm not sure whether I should be mad at myself for thinking it was dumb, or mad that these type of questions are commonplace in interviewing.
Well first I just thought a leet code plug in for VS code was cute so that's what I was linking. As for leet code itself I imagine the value depends on the personal needs. Some people do it for fun, some do it to practice for interviews. Did you try the harder problems? Maybe those would be more interesting.
 

Deathwing

<Bronze Donator>
16,356
7,363
a) it is fun to do this kind of exercises
b) they help to keep your skills fresh.
c) they are fun to do

You should be able to implement a square root function, or at least an approximation one in any language by doing a series consecutive divisions.
Yes, that's what a Newtonian search is...

wormie wormie not yet, I plan on that today. And they can be interesting. One of questions we ask candidates has to do with path elision, I had a lot of fun practicing that one. Wish I had more time for this, I don't get a lot of time to practice my coding skills as a QA manager.
 

Deathwing

<Bronze Donator>
16,356
7,363
I code all day long, can't even imagine coding outside of work for pleasure/practice
That's my point. Get up at 6 AM, put kid to sleep at 8:30 PM, practicing coding skills is the last thing on my mind. I'm only giving these a try because I'm on vacation and bored.
 

Neranja

<Bronze Donator>
2,605
4,143
Can you guys give any recommendations on learning material for program design? We’re starting to become python heavy where I work because automation is a big focus.
If you are going to do automation (which smells like code for DevOps and "Software-Defined Computing") it would be best to learn about the software/framework you are going to use. With Python it may be something like SaltStack or Ansible?

If you want something more general the term you are looking for may be "software architecture". Something I found while googling that may be helpful: