Earlier quoted context omitted.
I've recently taken a calculus problem (multidimensional real optimization) I guess for the first time since I was an student. While your description has some merit, there's a huge amount of trivia in the format of "I can do X, I just have to do Y first", "X has no known solution, try something else", and "operation X is very useful, try it". That goes away, and everything gets way harder.
I've always felt that if I had done all of my calculus with Mathematica I would have left college with an excellent grasp on how to use higher level functions provided by Mathematica that would have largely abstracted away all of this. Of course, the higher level functions might get covered in cobwebs - but I suspect not the same way; I would have kept these higher level skills up to date because: - I recently went t…
I no longer understand my PhD dissertation
131–140 of 281 posts
Re: I no longer understand my PhD dissertation
#132Earlier quoted context omitted.
> there are absolutely times when comments are necessary . I'll have to take your word for it, because I've yet to run into that situation.
Comments are not for how or what, the code does that just fine. Comments are for why . Sometimes the why is obvious, then you don't need a comment. The rest of the time, add that comment. Even if it's something like "Steve in accounting asked me to put this in."
It's generally true that the code expresses the what, but it's also true that it can take the reader time to discern. A simple comment here and there can be a shortcut to this discernment which, over thousands of lines of code can save serious time.
Re: I no longer understand my PhD dissertation
#133Earlier quoted context omitted.
I started taking readability very seriously once I started going back to extend old code and finding I couldn't immediately understand what it was doing. Now, if I have that problem, it's now two problems. The original problem, and the readability problem. The readability problem is solved first, and the original problem can only be solved afterward. I don't see comments helping me, I could spend the time better by m…
I'm fixing someone else’s code right now and a few single line comments would have saved my client thousands of dollars. Today I put in a log statement to see why the code deletes data from the database if there is no new temperature data for the time period. The cron job has been running all day and so far every time it attempts to delete the data, there is no data to delete. Another line runs a different script if…
Re: I no longer understand my PhD dissertation
#134Earlier quoted context omitted.
I started taking readability very seriously once I started going back to extend old code and finding I couldn't immediately understand what it was doing. Now, if I have that problem, it's now two problems. The original problem, and the readability problem. The readability problem is solved first, and the original problem can only be solved afterward. I don't see comments helping me, I could spend the time better by m…
I'm fixing someone else’s code right now and a few single line comments would have saved my client thousands of dollars. Today I put in a log statement to see why the code deletes data from the database if there is no new temperature data for the time period. The cron job has been running all day and so far every time it attempts to delete the data, there is no data to delete. Another line runs a different script if…
Re: I no longer understand my PhD dissertation
#135Earlier quoted context omitted.
> Why can't we just provide a simple real life example first and then go on explaining the details? This. People learn differently, in my case, if I can't get the 'Why' first, I'm not that excited to learn it. I guess making 'simple' real life examples in many cases is hard. I also tend to learn things much better if they came from a real problem/need I have. There was a good discussion about a 'project based univers…
Yeah, teaching the basics of an abstract concept without first explaining how it fits into the bigger picture is IMO not the best way to motivate some people. I'm also a person who wants to understand why it's important instead of just trusting someone that it'll be useful "later". It'd be cool if, once you start your major, there was basically an overview class explaining why each of your courses is important and wh…
Re: I no longer understand my PhD dissertation
#136In my experience, earning a PhD in [redacted] was excellent training in problem solving. And in developing working expertise in new areas. I suspect that the choice of field is indeed irrelevant.
> Mathematics embeds character in students
I'd say that actually finishing a PhD does that.
> Mathematics is fun
Whatever you pick for your dissertation topic had better be fun ;)
Re: I no longer understand my PhD dissertation
#137Earlier quoted context omitted.
Comments are incredibly useful for that bit of code that you spent hours trying to make it work and you couldn't figure out a way to name things well or to improve it. That's where a comment is priceless.
The downside of course is that comments aren't compiled/run - so they often become out of date. "Often" might actually be an understatement. I can't tell you how many times I've been reading a comment that runs quite contrary to what the code really does. You then end up reading the code to reason about it anyway, paying two taxes. After too many of those experiences, you just end up going straight to the code as the…
Re: I no longer understand my PhD dissertation
#138Earlier quoted context omitted.
Comments are incredibly useful for that bit of code that you spent hours trying to make it work and you couldn't figure out a way to name things well or to improve it. That's where a comment is priceless.
Maybe it's because I write in Ruby, and so never have to do any tricky optimizing, but if solving a particular problem starts to run over a half hour, I look to re-architect the project, either by reaching for a gem or telling my boss that X is too hard and we should do Y instead. My patience for going down rabbit holes has mostly gone over the last year. Also, again perhaps because I use Ruby, it never takes me more…
Example for obvious: Int add(Int x, Int y) in a typed language. Example for not obvious: add(x, y) in an untyped (or "dynamically typed") language (Does it auto-coerce? How? Can it add complex numbers? In my particular representation? ...).
Someone mentioned that sometimes comments are useful e.g. to document a quirk/bug in library function you call, and I have some examples of that in my own code. But most often you should be able to rectify that by wrapping said function in your own one that omits the problem.
If a function seems impossible to give it a sensible name that isn't ridiculously long, split it up. The more clear code of the individual parts and how they are combined should give a hint of what is actually computed here. Maybe it's a new concept in your business logic, in which case providing a clear and exact definition makes sense anyway (put it into the appropriate place in your documentation). This whole procedure can take a significant amount of time, but it will be worth it in maintainance!
Re: I no longer understand my PhD dissertation
#139Earlier quoted context omitted.
> there are absolutely times when comments are necessary . I'll have to take your word for it, because I've yet to run into that situation.
1) Vector3 computeNewtonianGravity(float massA, Vector3 positionA, float massB, Vector3 positionB); Which way does the returned force vector point? Towards mass A, or towards mass B? 2) Vector3 UnitVectorWithDirection(Vector3 originalVector); What does this function do when the magnitude (length) of originalVector is zero? 3) float ArcTan(float x); What is the allowable range of values for x? ...
Certainly calling things like "x_returnsNaNIfNot0to1" works, but I find it a bit ugly and it gets complicated if you have multiple or more complex constraints.
This is where languages with docstrings are nice. In Python all I would do is add a """ comment describing the inputs and the return values.
You then have a) a comment describing the code; and b) documentation that's standard so people can pull it up with pydoc or ? in Ipython. When I'm working in Jupyter, I often hit shift-tab to check what a function is expecting.