Live data from Hacker News

Confessions of an Intermediate Programmer

michaelbromley.co.uk

91–100 of 118 posts

Re: Confessions of an Intermediate Programmer

#91
post #29
post #10

Earlier quoted context omitted.

&structure ... ?

> &structure AFAIK, that's only a legal function signature in C++. To the point of the question : when I wrote that, I was specifically thinking of 2-dimensional arrays, not structs per se.

I meant passing a pointer rather than a by-ref call (which is indeed C++ only).

i.e. void myfunc(thing* stuff) { return; }

int main() { thing stuff; myfunc(&stuff); }

Re: Confessions of an Intermediate Programmer

#92
post #64
post #63

Earlier quoted context omitted.

The big thing I learned (at a company where all changes are code reviewed) is to rewrite the code until it seems obviously correct to someone who doesn't know what I know. I rename variables, methods and extract code into small methods until someone can read the code out loud and it sounds like a comment. for example: if (!thereIsEnoughSpace(user.getDataRequestSize()) { if (canAllocateAdditionalStorage()) { reserveSt…

Both good comments :) Another couple of ways to improve your coding... Start with comments outlining what you're going to do. If you are pair programming, this shows the other person what your overall plan is. It also acts as a mini todo list. They should be "What comments". That is, what does this piece of code do, not how it should be done. Comments are better than just coding because you can do that quickly as a s…

Personally I only recommend the code with comments thing to novice programmers doing play projects.

Generally I think comments are bad and it's too easy to leave nonsense in the code with that technique.

Re: Confessions of an Intermediate Programmer

#93

I've found the following really sets apart my programming now vs. earlier in my career: 1. I write and rewrite more now. I view the first time the code works as just the first draft (like I would with a paper). Earlier in my career I thought that making it work meant I was done. 2. I spend a lot more time thinking about what's happening in the code and why. I have found some of my best work to happen after days of th…

I hate to sound like an old fogie here (I am almost 40) but one thing that occurs to me is that as we age our thinking changes and all the things you mention often develop over time. When you are 20 you are pretty much at the height of your mathematical abilities. This is fine for certain kinds of programming, but it is not really ideal for others. It ensures that algorithms primary and the domains in a real sense be…

I feel like a big force that changes programming style is the gradual transition from guess-and-check to gradual bricolage, exploration, creation. I feel in my perspective like that explains at least a bit of the difference between "young" and "old" programmers here.

Guess and check programming tends to optimize around fast reset cycles so that many, many solutions can each be tried with little investment. This is the programmer who loves to refresh their window every second to see how their changes impacted the product. It's high energy and exciting. It also lends itself to prepackaged solutions—be they existing frameworks of specific transliterations of known algorithms. I also find that it tends to generate spaghetti code more quickly (all styles do, but GnC does so more quickly) and to fall flat on tasks which have either slow reset cycles, long dependency chains, or are difficult to visualize.

"Slow" programming, for the lack of a better word, orients itself around a deep understanding of both the domain and the natural "seams" in the problem space. It involves a lot of quick drafts that are perhaps never even observed—the mere act of trying and failing to express the problem elegantly is highly informative. It tends to find less "obviously optimal" solutions because it's in search of novel optimal solutions. It also tends to be more easily guided by high-level goals such as business value or elegance. Finally, programming slowly requires great reasoning skills and thus is more amenable to tools and processes which enhance reasoning. It can take stabs at deep, difficult domains because it happily uses great domain modeling or mathematical skills to break those challenging domains into clever, interlocking, and simple pieces. For all this though it suffers from having a design aesthetic and becomes less willing to "just dive in there and try all 500 solutions" in case one of them works.

I think this cuts broadly across several stylistic differences in coders. I think that age and experience pushes one toward the latter style. I also think that they both have strengths and weaknesses—so I strongly agree that mixed style teams are valuable.

Re: Confessions of an Intermediate Programmer

#95
post #77

Earlier quoted context omitted.

> I'm increasingly tolerant of other technologies. I would like to think I am, but recently I have noticed that everyone seems to want to jump on the NoSQL bandwagon. A lot of the jobs I see I would be a good fit want experience using MongoDB (or something similar). I have been looking to learn them, but having read up on the technologies, I can't find a reasonable use case for any of them in my own work. One that wo…

NoSQL DBs have real advantages - e.g. you have a huge production relational DB, you want to make schema changes - you have to take your app offline for hours.

No. You can migrate big production relational DBs with much less than hours of downtime; sometimes there's no downtime at all. Please, either qualify your statement, or stop speaking in such an absolute sense.

Re: Confessions of an Intermediate Programmer

#96

Nice article but i was wondering why didn't you go to university/IT School to learn computer science? -- "To me, the object-oriented approach was just a bunch of unnecessary overhead and boilerplate" If you had made real C++, you would'nt have think of object oriented programming as an overhead. I suggest you to buy a few O'Reilly books (Probably the best code book )

Not the author, but personally, I chose Maths as I felt it gave me a broader basis to approach my career. I am now happily employed as a Software Engineer. I do find I've missed out on some things (TDD indoctrination, for example), but I've gained in others.

There are only very few universities that will actually give you a proper indoctrination in most modern software engineering practices. Usually you get a bit of horrible object orientation, a few stern words about coding standards, and the lovely advice to "always test your code". If you take a Compilers course chances are the words "static analysis" will be used a lot.

I'm sure there are exceptions to this, but they are hard to find and universities aren't entirely to blame for it. Some parts of software engineering move fast and there is a justified fear to teach students things that will be useless by the time they graduate. So the focus is more on laying a solid ground-work.

Re: Confessions of an Intermediate Programmer

#97

For me the thing I had to learn was commenting more than anything else; working alone I never saw as much use for it. Then I worked with a guy that commented his code very well and suddenly I saw massive value in it. I'm definitely still an intermediate programmer, but I think I was always fine admitting that to myself. It was getting over the fear of others reading and modifying my code that took me a while.

Yeah well...

Great code needs no comments.

Bad code needs lots of comments.

I've seen examples of both recently.

I randomly met a guy who told me of his idea to implement a UX framework with windows, buttons, views, etc in python.

A week later he sends me the finished framework. And it's perfect. It's easy to understand, all the names of things make sense, it's orthogonal. Not a single comment anywhere, but perfectly clear. Great code basically.

And there's a project I am maintaining where some parts of the code are pretty much impossible to understand, full of duplicated code - somebody loved copy&paste - duplicated method and class names, and threads going off in all directions. There is a comment for every line of code but despite the fact that I consider myself pretty good at reading other people's code, I am not touching that thing with a 10 foot pole.

My goal is to write code that doesn't require a lot of comments.

Re: Confessions of an Intermediate Programmer

#98
post #63

For me the thing I had to learn was commenting more than anything else; working alone I never saw as much use for it. Then I worked with a guy that commented his code very well and suddenly I saw massive value in it. I'm definitely still an intermediate programmer, but I think I was always fine admitting that to myself. It was getting over the fear of others reading and modifying my code that took me a while.

The big thing I learned (at a company where all changes are code reviewed) is to rewrite the code until it seems obviously correct to someone who doesn't know what I know. I rename variables, methods and extract code into small methods until someone can read the code out loud and it sounds like a comment. for example: if (!thereIsEnoughSpace(user.getDataRequestSize()) { if (canAllocateAdditionalStorage()) { reserveSt…

The naming thing is huge. Give things good names. One can also factor out some specialized code into its own method / class - but because you want to re-use it necessarily but because you want to describe what it is doing. Divide et impera.

Having to explain to another what you're doing - I found that to be great as well. It removes bugs and produces cleaner code. You don't even need another - at check-in time, for every change, you can ask yourself "what is this doing" and "why". And if the answer isn't convincing, change what you're doing.

The value of peer-review was rarely on the peer's side - the other person doesn't really know what you're doing and is unlikely to catch a bug. But the peer would ask some question so you would start thinking about it and discover a problem.

The best thing about asking somebody for advice is often to come up with a good question. If you ask the right question, it contains the answer.

Re: Confessions of an Intermediate Programmer

#99
post #36

From both my own experience and witnessing others, one major factor that sets apart from beginner and expert is working with legacy code. And by legacy I mean legacy from previous developer, previous team, whatever, not necessarily a decade old code base. Beginners are keen to get rid of all the legacy code. It's tightly coupled, it's hard to read, hard to maintain, yada yada yada. And then they tend to make a way to…

Experienced programmers refuse to take the job.

We once tried to contract this really fancy team to take over some code. They asked if we had unit tests. "No". "Then we can't do it, sorry, bye."

And I agree with them.

Re: Confessions of an Intermediate Programmer

#100
post #97

For me the thing I had to learn was commenting more than anything else; working alone I never saw as much use for it. Then I worked with a guy that commented his code very well and suddenly I saw massive value in it. I'm definitely still an intermediate programmer, but I think I was always fine admitting that to myself. It was getting over the fear of others reading and modifying my code that took me a while.

Yeah well... Great code needs no comments. Bad code needs lots of comments. I've seen examples of both recently. I randomly met a guy who told me of his idea to implement a UX framework with windows, buttons, views, etc in python. A week later he sends me the finished framework. And it's perfect. It's easy to understand, all the names of things make sense, it's orthogonal. Not a single comment anywhere, but perfectly…

Great code needs no comments.

Sure it does.

« The simple and obvious way to do this misses important edge cases X, Y and Z. »

« This is to work around a bug in the framework we're using; see http://... . »

« This is deliberately wrong, for compatibility with ABC system. »

Post reply on HN