Forum search & shortcuts

Writing good softwa...
 

[Closed] Writing good software

Posts: 7127
Full Member
Topic starter
 
[#9558026]

My guide to writing good software:

1. KISS. Being stupid is actually an advantage to a computer programmer. Up to a point.
2. Two mutexes good, four mutexes bad.
3. C++. Just say no.
4. std::shared_ptr<>. See item 3. No, it does *not* prevent memory errors or leaks, it just makes them harder to figure out.
5. If it hasn't been tested, it doesn't work.


 
Posted : 19/09/2017 9:49 am
Posts: 28593
Free Member
 

std::shared

This doesn't sound like the way to win friends.


 
Posted : 19/09/2017 9:57 am
 IHN
Posts: 20152
Full Member
 

6. Testing means verifying that the things that shouldn't happen don't, not just that the things that should happen do.


 
Posted : 19/09/2017 9:57 am
Posts: 6259
Full Member
 

3a. Java. Just say no.

7. There must be a better way (not my words, I stole them from one of the Python Devs that does a lot of software training)


 
Posted : 19/09/2017 9:59 am
Posts: 0
Free Member
 

Understand the user needs
Understand the user needs
Understand the user needs
Build the smallest thing possible


 
Posted : 19/09/2017 10:03 am
Posts: 7127
Full Member
Topic starter
 

8. Profile first, [b]then[/b] optimize. Don't just do the cool thing you've fancied doing for ages.


 
Posted : 19/09/2017 10:06 am
Posts: 0
Free Member
 

9. Contribute back. Whether is is code in an open source project or documentation or other things doesn’t matter. But contribute. It makes you a better dev

Rachel


 
Posted : 19/09/2017 10:09 am
Posts: 108
Full Member
 

I refer to the Klingon Programmers Manual which is very short.

Documentation is for the weak and timid.


 
Posted : 19/09/2017 10:14 am
Posts: 31206
Full Member
 

10. Stack Overflow + Google 😉


 
Posted : 19/09/2017 10:14 am
Posts: 10337
Full Member
 

Until someone else has used it, it doesn't work


 
Posted : 19/09/2017 10:15 am
 IHN
Posts: 20152
Full Member
 

Understand the user needs

+1

As an example of 'Clever Design vs User Experience':

[img] [/img]


 
Posted : 19/09/2017 10:18 am
Posts: 7513
Free Member
 

1. Best not done on Friday afternoon after the lunchtime beers. Makes the coding sail along, but the debugging on Monday is another matter entirely.

2. Googling about R is difficult, until you learn to add "project" to the search terms.

3. A sufficiently talented coder can write fortran in any language.


 
Posted : 19/09/2017 10:20 am
Posts: 0
Free Member
 

11. Write decent comments! Tell me why a line of code exists, not what it does - I can see that by looking at it!

12. Don't code when your brain is toffee, surf STW instead, it'll save you uncoding everything later.


 
Posted : 19/09/2017 10:22 am
 IHN
Posts: 20152
Full Member
 

13. Imagine reading the code you've written at 03:00, after being dragged out of your bed for a call out. Can you still understand what it's doing?


 
Posted : 19/09/2017 10:24 am
Posts: 31206
Full Member
 

Disagree with 3 by the way. Nowt wrong with well written C++.

FWIW, I'm currently working on legacy safety-critical medical software controlling delivery of radiation and it uses a mixed bag of C, C++, C# and... Visual Basic! 😯


 
Posted : 19/09/2017 10:25 am
Posts: 10337
Full Member
 

FWIW, I'm currently working on legacy safety-critical medical software controlling delivery of radiation and it uses a mixed bag of C, C++, C# and... Visual Basic!
sounds like something that I designed 🙂


 
Posted : 19/09/2017 10:27 am
Posts: 0
Free Member
 

FWIW, I'm currently working on legacy safety-critical medical software controlling delivery of radiation and it uses a mixed bag of C, C++, C# and... Visual Basic!
That's quite disturbing. C# and VB require windows, and i'd never trust anything safety critical to run on windows - it has far too much of a mind of its own.


 
Posted : 19/09/2017 10:28 am
Posts: 31206
Full Member
 

9. Contribute back.

Work don't let me and these days I have very little inkling to do even more coding in my spare time.


 
Posted : 19/09/2017 10:28 am
Posts: 7127
Full Member
Topic starter
 

9. Contribute back.

Work don't let me and these days I have very little inkling to do even more coding in my spare time.

You learn an awful lot if you do though. You'll find a few tiny contributions from me inside git, it's well worth it.

EDIT: which reminds me: code is read far more times than it is written.


 
Posted : 19/09/2017 10:30 am
Posts: 31206
Full Member
 

That's quite disturbing. C# and VB require windows

Can't say too much for obvious reasons, but yes it does involve Windows Embedded Standard (i.e. restricted version of XP) but the real-time stuff is handled on LynxOS.


 
Posted : 19/09/2017 10:30 am
Posts: 7127
Full Member
Topic starter
 

Disagree with 3 by the way. Nowt wrong with well written C++.

Is there an existence proof for this?

A friend went to a lecture by Bjarne Stroustrup, where BJ talked at length about the kinds of problems people were having with the terrible code people were writing, and what was being done in the language to make this better.

At the end, he asked for questions. My friend said, "you've given us lots of examples of C++ projects with badly written code, can you give us an example of a well written one?".

There was a long pause. And then the great man replied, "No".

There are no well written C++ programs in existence.


 
Posted : 19/09/2017 10:35 am
Posts: 13594
Free Member
 

I'm pretty sure no one intentionally writes bad code, it just happens as a product of circumstances...


 
Posted : 19/09/2017 10:37 am
Posts: 31206
Full Member
 

Is there an existence proof for this?

Well I do a lot of work in embedded software. The options there are basically assembly, C or C++.

And even then it is often a restricted subset of C++ (e.g. no heap allocation allowed!)

But you are surrounded by embedded software that generally works very well.


 
Posted : 19/09/2017 10:41 am
Posts: 0
Free Member
 

Don't work for Equifax do you. GrahamS? 😉

Rachel


 
Posted : 19/09/2017 10:46 am
 Nico
Posts: 4
Free Member
 

1. Best not done on Friday afternoon after the lunchtime beers.

Does this still happen? I remember the guy who effectively ran the network for a government department being useless after lunch, and I also remember the look of bewilderment when the US company that got the outsourcing contract heard there was a bar on site.


 
Posted : 19/09/2017 10:49 am
Posts: 31206
Full Member
 

Don't work for Equifax do you. GrahamS?

Hey, it worked on my machine.

I also remember the look of bewilderment when the US company that got the outsourcing contract heard there was a bar on site

Once, when working on the (surprisingly complex) embedded software for a car door, we went over to the plant in northern Spain to work with the engineers there.

All kinds of machines assembling car parts, as well as other machines testing them (robots opening and closing doors, sitting on seats etc, just like the adverts only much dirtier).

Their "software department" was literally 3 guys in a corner of the plant, writing code and backing it up to zip files in "My Documents". No source control. No build servers. DevOps didn't really exist in those heady days.

Anyways, on the factory floor they had vending machines full of beer, and the two hour lunch break involved a three course meal and a carafe of wine!

Happy days.


 
Posted : 19/09/2017 11:01 am
Posts: 0
Free Member
 

Having had all my R&D move to India and China, I'm wondering if this page can be translated into Hindi and Mandarin 🙄


 
Posted : 19/09/2017 11:09 am
Posts: 0
Free Member
 

1: "Build things people want"

The rest is quite frankly trivial details if you've got this bit right.


 
Posted : 19/09/2017 11:33 am
Posts: 31206
Full Member
 

In my experience mrblobby, you'll get five folk on an Indian team. One will speak good enough English to be the "project lead" and will say yes to absolutely everything even if they have no idea what you mean. One will actually know what they are doing and do all the real work. And the other three will be getting some on-the-job training from the one that knows what they are doing.

As with all outsourcing, managing it with your own tests, quality reviews, milestones etc is the key. Sadly most companies seem to think they can just push it out the door and forget about it.


 
Posted : 19/09/2017 11:36 am
Posts: 31206
Full Member
 

1: "Build things people want"

[img] [/img]

The hard part is to give them what they need, [i]not[/i] what they say they want.

[img] [/img]


 
Posted : 19/09/2017 11:39 am
Posts: 6259
Full Member
 

Documentation is for the weak and timid.

14. (or whatever number we're up to now) The code, by definition, documents exactly what it does and how it works, more accurately than any other written documentation.


 
Posted : 19/09/2017 11:40 am
Posts: 31206
Full Member
 

The code, by definition, documents exactly what it does and how it works, more accurately than any other written documentation.

But it doesn't tell you WHY


 
Posted : 19/09/2017 11:42 am
Posts: 0
Free Member
 

Good documentation is [I]hard[/I]

Rachel


 
Posted : 19/09/2017 11:52 am
Posts: 0
Free Member
 

The hard part is to give them what they need, not what they say they want.

Absolutely, which is exactly what I've made a career out of. (UX Designer)


 
Posted : 19/09/2017 11:55 am
Posts: 0
Free Member
 

Never let Sales decide the features based on what they think the customer wants or what they personally want to be able to get that sale commission.

End user documentation - no-one RTFMs, don't bother. UI should be self explanatory. If not, invest in support. Even with comprehensive documentation, they'll still ring support first.

mrblobby - Member 
Having had all my R&D move to India and China, I'm wondering if this page can be translated into Hindi and Mandarin

Copy all this and paste it onto Stack Overflow. It's where they'll be looking anyway 😉


 
Posted : 19/09/2017 11:56 am
Posts: 7205
Full Member
 

As a lead developer looking after a team of contractors, I generally didn't put rules onto my staff - just once principle -

Your goal should be to write readable, maintainable and efficient code.

If you don't do that and I spot it in a code review, you're doing it again.

Also, it's twice as hard to debug code as it is to write it, so don't be as clever as you can be when you write code as you'll need a genius to debug it...


 
Posted : 19/09/2017 12:04 pm
Posts: 2559
Free Member
 

9. Contribute back.

Work don't let me and these days I have very little inkling to do even more coding in my spare time.

If you use open source software in any meaningful way, and scratch an itch by fixing spelling in the manual, or fixing a small bug, or implementing a new feature, then there are generally ways to convince work to let you.

One option is to not mention the company at all (loads of contributions in projects I work on come from China in Chinese working hours via @gmail.com), or the worst case of Legal+CTO vetting each project you submit to. Either way, aside from not having patches locally which can be a pain on upgrades, contributing back to an open project means you build up a relationship with the developers, so when you *need* help they're more willing to help.


 
Posted : 19/09/2017 12:05 pm
Posts: 0
Free Member
 

We have made it so that when helping patch Drupal code, you can declare any employer and client you want as “supporting” the time needed to do the work. Then, that gets added up and used to push that employers profile higher on the Drupal marketplace section of the website.

It’s a very neat system.

Rachel


 
Posted : 19/09/2017 12:16 pm
Posts: 31206
Full Member
 

there are generally ways to convince work to let you.

I am a full-time employee to a company that essentially contracts us out to other companies. Any work off the clock or that could be construed as threatening privacy of a client would be very frowned upon.

Even stuff like StackOverflow questions have to be [i]very[/i] careful.

If a client tells me to contribute to open-source I gladly will, but otherwise, not a chance.


 
Posted : 19/09/2017 12:31 pm
Posts: 0
Free Member
 

Ugh documentation... don't even get me started on technical documentation being written and interpreted by Indians and Chinese in second/third language English 🙁


 
Posted : 19/09/2017 12:42 pm
Posts: 2626
Full Member
 

oldnpastit - Member
1. KISS. Being stupid is actually an advantage to a computer programmer. Up to a point.

This is important. Don't be clever if you can be simple. Clever is a complete pain to debug and/or maintain. If you have to be clever please document your cleverness in a way that seems like you're explaining it to a moron. Because if you have to fix it in 6 months or a year or even later you'll be feeling like a moron as you scratch your head over the convoluted code your younger, stupider self thought was clever.


 
Posted : 19/09/2017 12:57 pm
Posts: 7127
Full Member
Topic starter
 

This is important. Don't be clever if you can be simple. Clever is a complete pain to debug and/or maintain. If you have to be clever please document your cleverness in a way that seems like you're explaining it to a moron. Because if you have to fix it in 6 months or a year or even later you'll be feeling like a moron as you scratch your head over the convoluted code your younger, stupider self thought was clever.

In addition, it turns out you can't add developers to your project, because your new developers just won't be able to figure out what the blazes you are/were trying to do. Especially if it's anything involving complicated lifetimes and std::shared_ptr<>.

Or so I've heard anyway.


 
Posted : 19/09/2017 1:00 pm
Posts: 31206
Full Member
 

What have you got against std::shared_ptr<> oldnpastit?

Work pretty well in my experience. Certainly a lot less error prone than managing raw pointers . The only real issue I've had is with programmers who are still trying to write in C and just don't understand them.


 
Posted : 19/09/2017 1:09 pm
Posts: 0
Free Member
 

Bit like in C# world, rewriting everything as LINQ expressions, because it's cool. Actually I fell for that a bit, but ReSharper didn't help as it kept advising this or that could be rewritten in one cool LINQ statement. Looking back at the code and especially if it's someone who doesn't know LINQ and got no idea what's going on there.

Has its place though. A nice bit of LINQ vs some hideous big loop and conditional checks.

There's the opposite end where a team lead or project manager decides to ban the cool stuff because basically they don't understand it, so you're stuck on legacy stuff and have frustrated developers.


 
Posted : 19/09/2017 1:13 pm
Posts: 2559
Free Member
 

I am a full-time employee to a company that essentially contracts us out to other companies. Any work off the clock or that could be construed as threatening privacy of a client would be very frowned upon.

My old job was with a small consultancy. We preached the open source way and the contracts said that where possible code would be freely licensed and public, if the client wanted proprietary code the rates were higher...

Worked surprisingly well!


 
Posted : 19/09/2017 1:19 pm
Page 1 / 3