|
Nothing wrong with COBOL
We can’t stop here, this is bat country - Hunter S Thompson RIP
|
|
|
|
|
The third option is correct.
Jeremy Falcon wrote: And who's really right or wrong?
I am.
|
|
|
|
|
your first example is not the same as the others:-
?: is NOT if-then-else...
var x = (y == 0) ? 0 : z / y;
var x;
if (y == 0) x = 0; else x = z / y;
If it were easy then anybody could do it.
Wait, .... what!
|
|
|
|
|
I'm not sure if this is sarcasm or not.
Jeremy Falcon
|
|
|
|
|
To me, studying what good code looks like and the best practices thereof has more value than looking at somebody else's code. I consider the reference article here[^] to be of more value than a bunch of code.
If you want to lose your mind, read the source for the stl libraries.
I'm retired. There's a nap for that...
- Harvey
|
|
|
|
|
As a recommendation I'd always suggest having a look at the GitHub repo for Doom & Doom3 (from John Carmack at id Software). Doom written in C and Doom3 in predominantly C++.
GitHub - id-Software/DOOM: DOOM Open Source Release[^]
GitHub - id-Software/DOOM-3-BFG: Doom 3 BFG Edition[^]
Although a lot of the work is in game development and graphics (and in C), I found it useful to look at how it highlights good project and code layout.
Like people have said already in this thread, I wouldn't look at the code to "learn how to write code" but rather to learn what good "coding practices" result in. Keep in mind some of this code has been cleaned up before publishing on GitHub.
K
|
|
|
|
|
Thank you!
Yeah, it seems writing good code stems from both design and good coding practices...
Currently, I am reading the books Code Complete and Clean Code by Uncle Bob. Code Complete seems to focus more on the design aspect stuff, and Clean Code seems to focus more on the actual code-writing practices.
However, Simply looking at projects gives me at least some insight into the coders' styles out there and what type of code I will run into out there.
|
|
|
|
|
|
First, reading lots of code is the RIGHT approach. Kudos. To put it into reading/writing books, I would say that someone who actually writes a (decent) book has read THOUSANDS of books first. It just makes sense.
Second, you can learn from ANY code. Even if you learn "Ouch. That's terrible". B-Movies exist. They remind us what works in good movies, and what doesn't work.
Third, consider reading the (source code for) well understood concepts. Compilers (GCC?). Compiler theory is pretty stable. the concepts of cross compilers, linkers, etc. are all well understood. Optimizers, for example, re-teach indirection (converting code to pseudo assembler, optimizing that, then generating the assembler already optimized). Allowing the optimizer to be shared!
Finally, a discussion about engineering... Most people think that engineering is about perfection. It is actually about making things Good Enough. Optimizing the 3 corners of the triangle of (Fast, Right and Cheap). You can only optimize 2 of the 3, and you agree to sacrifice the third. You can optimize only 1, and sacrifice the other 2.
I learned about this from an engineer neighbor who was designing a factory floor with equipment mounting technology. His junior engineer was calculating the EXACT bolt sizes required based on the machine and the other variables. He made him go back and find the Most Common Denominator to reduce installation issues and mistakes.
In words developers can understand. I have a compiler to sell you. It's NEW warnings are guaranteed to reduce the number of bugs by 10% in your code. It costs $1 Million per seat. Interested?
I hope not!
So, keep reading code.
Then find useful code, like Notpad++, and work on compiling it and testing it.
Then find a list of bugs for that Product and start fixing them and testing your solutions.
You should quickly learn a couple of things. Like having a set of automated tests makes you feel safer to make changes and know if you actually broke something.
I would finish it off with. BREAK the software. Find what tests fail, and how. It's insightful!
|
|
|
|
|
You are asking a FANTASTIC question, and you should be HIGHLY commended for your EXEMPLARY judgement and acumen for seeking such recommendations. (Of course, I can say that because I asked the same question myself about six months ago! )
Among the many helpful replies that I got in that thread, the one from BillWoodruff[^] was the most extensive and helpful.
|
|
|
|
|
Starting in 1975, when I had an epiphany, I have been writing code that I find I could easily maintain. The code was written for clients, both in-house and external. It ranged from real-time to interactive financial systems; from assembly language to high level languages (yes, even COBOL and FORTRAN).
The key to my success was, I believe, the strict use of coding standards. These coding standards were applied to all my code, not just deliverables to clients but also to code developed during research and experimentation. When a chief programmer (team leader, these days), I required the entire team to use an unambiguous set of coding standards.
I have published some of these standards on CP under the guise of "guidelines." But more importantly, I offer as examples the code in any of the articles I have published on CP. As I said, I use the standards whenever I develop code. It is now so automatic that I seldom need to think about it (so much for the argument that standards slow you down).
There is an unfortunate perception that applying standards makes software cost more. Agreed, as an organization starts using standards, code reviews are needed to assist programmers in achieving standards compliance. But once it's happened, you'll be amazed at the result. Not only is the software maintainable (reducing the long-term cost) but it is reusable (as a colleague once said "good software that you do not need to write is very cheap").
Gus Gustafson
|
|
|
|
|
Last week, MS wanted to update my laptop. It was late, so I hibernated it instead, figuring it would save the state and I could complete it the next evening. The next evening, when I went to do that, I found that MS had turned my laptop on so they could do their update, and then left it on once they were done. Good thing I make a habit of leaving it plugged in when its not in use. Clearly MS has decided that when they want to do an update, the only thing that will stop them is if the laptop battery dies in the middle of it.
A week later, last night, they updated again, this time whacking the mouse settings into unusability and forcing me to uninstall the mouse driver before they would allow the mouse settings dialog to run.
After two botched updates in two weeks, I've given up on Windows 10 and have reverted my laptop back to 8.1. Anyone else giving up on Win10?
We can program with only 1's, but if all you've got are zeros, you've got nothing.
|
|
|
|
|
patbob wrote: Anyone else giving up on Win10? I haven't even moved to Win 8.
/ravi
|
|
|
|
|
I'm on the glacial ring (Windows 7), it's the best ring I think when you want to stay as far as possible away from the fast ring.
|
|
|
|
|
Nope. Moved from win8 to win 10 and haven't had any problems. Probably helps having HP kit which is pretty stock standard.b
|
|
|
|
|
I thought Lenovo was pretty standard, or at least well supported, too. Apparently, I was wrong.
We can program with only 1's, but if all you've got are zeros, you've got nothing.
|
|
|
|
|
Nope, but I'm always hesitant to upgrade any laptop to any OS. On the other hand, my oldest upgraded her Windows 7 laptop to Windows 10 without asking me and it runs just fine (okay, it still has a spinning drive which is horribly slow. I thought about swapping it out for an SSD, but this is a Dell which requires you take apart the entire laptop to get to the HDD.)
|
|
|
|
|
W7 still working as fine as usual.
NEVER10 did a good job too.
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
patbob wrote: Clearly MS has decided that when they want to do an update, the only thing that will stop them is if the laptop battery dies in the middle of it. Actually, I believe they check for a power supply, because wupdate has a couple of times told me to plug a lappie in for updates to continue.
[edit] Unless, of course, that's yet another of the genuinely useful features they decided to break or exclude from winio [/edit]
I only have winio on one device, which came with it installed. I blocked the update on all others, so I'm mostly weven + 1 w8 device.
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
Mark_Wallace wrote: Actually, I believe they check for a power supply,
And how exactly do they do that when the system is off? Obviously, they have to turn it on. Now that they've done that, what do you think they're going to do? Certainly not re-hibernate it for you. I even doubt they'll shut the system down for you.
We can program with only 1's, but if all you've got are zeros, you've got nothing.
|
|
|
|
|
I have avoided the update and will hold onto Win7 as long as it works. After that, I'm sure that my next 'Windows' will be called Ubuntu or Fedora.
If, let's say the manufacturer of my car, came along and hijacked my car every week, I would certainly get a little angry.
No, we are not going to your appointment. We will go to the Mickeysoft garage and do some updates on your car. Just a few hours and then you (hopefully) can go where you want. Please make sure we have enough gas for the little trip.
Many years ago I saw a bumper sticker which read 'Honking is useless. Driver is remote controlled from Moscow.' Forget Moscow and don't let Mickeysoft near any car software.
The language is JavaScript. that of Mordor, which I will not utter here
This is Javascript. If you put big wheels and a racing stripe on a golf cart, it's still a f***ing golf cart.
"I don't know, extraterrestrial?"
"You mean like from space?"
"No, from Canada."
If software development were a circus, we would all be the clowns.
|
|
|
|
|
CDP1802 wrote: No, we are not going to your appointment. We will go to the Mickeysoft garage and do some updates on your car. Just a few hours and then you (hopefully) can go where you want. Please make sure we have enough gas for the little trip.
Your comment collided in my head with all this hubbub about self-driving cars. Wonder how long it'll take before they make them do that
We can program with only 1's, but if all you've got are zeros, you've got nothing.
|
|
|
|
|
At least you can then take 'blue screen of death' literally.
The language is JavaScript. that of Mordor, which I will not utter here
This is Javascript. If you put big wheels and a racing stripe on a golf cart, it's still a f***ing golf cart.
"I don't know, extraterrestrial?"
"You mean like from space?"
"No, from Canada."
If software development were a circus, we would all be the clowns.
|
|
|
|
|
With a devilish grin he began wandering around town exclaiming "Tan! Tan! Tan!" and, since, has been known as "SayTan".
modified 23-Sep-16 16:48pm.
|
|
|
|
|
So, I need to upgrade some old code to VS2008. Yes, I know VS2008 old as well, but I'm OS constrained. It's an embedded system (CE 5.0), so you do what you have to do.
Silly me, I took a project and opened it in VS2008. It said, "We need to convert that project. Would you like to proceed?" Thinking this would save me some time, I hit the yes button where upon my project was mangled into some unrecognizable form it was simply stunning.
Does not compile. Won't link (I fixed the compiler errors). Bat crap crazy build errors that are all due to the wizard not even bothering to look at the old project settings. I mean, wth Microsoft, if you are going to release a black wizard on us.... As near as I can tell, the ONLY thing the wizard did was to add files to a project list.
This is worse than half-baked. If I had spare time, I'd go to 2013 or 2015 and see how their wizards work.
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|