Dimension of a matrix

I keep hoping to see a single example of effective code reuse before I stop working. A wise man once told me "reuse is at the team level" - you reuse teams familiar with the code, not just the code. No point in paying for the learning curve twice...

Yes!

That's up to him/her. When I get a new code base, I tend to create a to-be-deleted branch and put in all sorts of instrumentation to establish what the rules of it are.

IMO, the biggest sin programmers commit is trying to make ever second count as "productive time ", working towards an assigned goal. You gotta spend time with a code base to get to know it.

--
Les Cargill
Reply to
Les Cargill
Loading thread data ...

There are really just two simple rules here.

  1. Make sure it is obvious how large your array is.
  2. Don't access arrays unless you know its size.

The next guy working on your code should not /be/ working on your code, or any code, if these rules are not blindingly obvious to him.

Some "traditional" C mistakes, like overrunning string buffers, I can understand - people are sometimes lazy or make unwarranted assumptions about sizes, beginners have read books with functions like "strcat", "strcpy" and "sprintf", and even more advanced users can easily misunderstand the subtle details of the "n" variants.

But arrays are well-defined structures with specific sizes. You /know/ the size when the array is created, and you need to know the size when you use it. Getting this wrong is not just making unwarranted assumptions - it is misunderstanding the point of the code you are trying to write.

Of course all sorts of mistakes can creep into a program, especially during heavy development and before checks, code reviews, and testing. But array size errors should be a rare event - they are not something that should be common enough to be singled out.

Reply to
David Brown

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.