|
Mmm, self documenting code, sounds good until you have to figure out how and why!
|
|
|
|
|
"military intelligence" is known as perfect example of oxymoron
allow me to add
"self documented code " into the growing list
corollary:
when "open source code " is NOT documented at all - period
is it still
"open source code " ?
|
|
|
|
|
Doxygen homepage[^]
It's something you have to do as you write but when done it's a flexible doc system.
Definition of a burocrate; Delegate, Take Credit, shift blame.
PartsBin an Electronics Part Organizer - Release Version 1.3.1 JaxCoder.com
Latest Article: EventAggregator
|
|
|
|
|
FYI, DoxyPress[^] supports the same features as doxygen but in a far more reliable implementation and fewer limitations.
Software Zen: delete this;
|
|
|
|
|
Thanks for the heads up.
Definition of a burocrate; Delegate, Take Credit, shift blame.
PartsBin an Electronics Part Organizer - Release Version 1.3.1 JaxCoder.com
Latest Article: EventAggregator
|
|
|
|
|
You're welcome.
We have a large code base that's a mix of C++ and C# that build into an application and several Windows services. We found that doxygen only handled single executables (one program or DLL). Its C# support wasn't great.
While DoxyPress isn't perfect, it does the job well enough that we include generating source documentation as part of our automated build process.
Software Zen: delete this;
|
|
|
|
|
I downloaded and ran it against a project that I am working on, with minimal settings.
I'll have to RTFM and find out how to fine tune, but all in all it looks pretty nice.
Definition of a burocrate; Delegate, Take Credit, shift blame.
PartsBin an Electronics Part Organizer - Release Version 1.3.1 JaxCoder.com
Latest Article: EventAggregator
|
|
|
|
|
My experience with Doxygen (my own direct use and how I have seen numerous co-workers use it) is that it is fine for the bottom level documentation. The reader will know all the details about the third argument to a given method, but without a clue about when, where and why that method is called at all. The protocol, both any line protocol and the protocol of interaction between methods in one module and the interaction between modules.
In principle, you can add information about module and object interaction, line protocol specifications etc. My experience is that developers never get around to it Round Tuit[^]. Documenting the third parameter in a Doxygen comment is easy to do when you are editing the code; the higher level documentation is postponed until the next tuit delivery. (But sending the order has been postponed ... ).
As long as the intermediate levels are documented well, from the top level, the main subsystems and their interactions, and then stepwise down to modules and objects, then the reader might as well dive right into the source code. When you understand the use of some component, you have no need for a Doxygen carbon copy of the details that you will find in the source code anyway. Too often, Doxygen 'documentation' is little more than a rephrasing of method header.
Obviously, this very much depends on how developers use Doxygen. I am referring to what I have observed, not what you in theory can do with Doxygen.
Equally important: This is certainly not Doxygen-specific. Give the same developers another documentation system that they can maintain as part of the code editing, and the result will be very much of the same. You see it everywhere, in almost all software and documentation available on internet: Method headers and parameters are documented; how these are intended to be used is often completely omitted. If there are some traces of it, it is often poorly written. (The best way learn the use of some library, server etc. is to search for some other open source code to see how they are using it!)
So, my advice is: Forget about the source code documentation, at the method header and parameter level (with the exception of APIs exported to users outside your organization). Document it top-down, with focus on component interactions. If there are explicit protocols across a line, describe it, but document the protocol, not the API! E.g. MSCs can be very helpful to understand the component interactions. You can even make MSCs for protocols between modules or objects, even if they are not line protocols.
Document data structures thoroughly, but again: Top down. What kind of information is held in each structure, which components have access to it, which component maintains it. I am so old that I still think of ER as a good data modelling tool; today it is about as non-PC as the riverfall model, but you can have an ER-like approach even if you do not use ER notation. Stick to abstract data types - at this level it doesn't matter if a counter is 16, 32 or 64 bits. It does matter that it is a counter, though!
If it suits the software, state diagrams and/or state tables are great documentation tools. Unfortunately, few young developers have a good grasp on state transitions; it is more like a vague, remote concept in the same class as the OSI 7-layer model .
So how far down should the documentation go? My answer is clear (but lots of people will frown): Write your documentation so that it is independent of programming language. If the system is re-implemented in, say, Fortran or Pascal, all of you documentation should still be valid. It should contain the language independent stuff, all the language independent stuff and nothing but the language independent stuff.
When you need code snippets or declarations to make your point, leave it to the source code itself. Your documentation tells what it should do. How does it can be seen from the code.
There is one big pitfall, though: When you start describing your system as a set of well documented(/defined) protocols, MSCs, a bird's eye on the data structures, state transitions etc., chances are that you will utter a few nasty words about how the system should have been written. You'll discover messy transitions, irregular use of interaction protocols, undisciplined access to data structures, ... There will be a lot of new entries in the ToDo-list! Just make sure to get that tuit order in the mail as soon as possible
Religious freedom is the freedom to say that two plus two make five.
|
|
|
|
|
The real problem is that there is not enough money or time in the budget for documenting and the programmer is usually to lazy to do it.
Definition of a burocrate; Delegate, Take Credit, shift blame.
PartsBin an Electronics Part Organizer - Release Version 1.3.1 JaxCoder.com
Latest Article: EventAggregator
|
|
|
|
|
There are people/companies promoting 'Test Driven Development', writing all the tests, from module level and upwards, before any coding is started. I have even talked with people claiming to practice it
For all my private projects, I practice 'Documentation Driven Development': I write both (end) User Guide and system documentation (implementation language independent, as noted earlier) before I start coding. Admittedly, it happens that the 'ideal' view of the system, described in the documentation, cannot be realized 100% in practice. Yet I would say that having the 'ideal' solution in the documentation is a great help to make sure that adaptations are done in a structured and architecturally sound ways, so that they do not appear as random hacks. Both end user and system documentation is of course updated correspondingly.
The one big software suite I was working on that tried to follow a TDD style (admittedly, tests were implemented in parallel with the code, but by a completely independent team) did experience very similar situations: The original spec, underlaying both tests and code, could not reasonably be implemented exactly as given, so both code and tests had to be modified midway. Specs are not carved in stone.
Religious freedom is the freedom to say that two plus two make five.
|
|
|
|
|
You sir are an anomaly.
I know people that write a spec to go by but usually written by a project manager. But I guess if you are a one person shop that would be you.
I start out with a general plan but, as an example my current project, I started with a very generic idea of what I wanted to accomplish and it just grew and grew. The one saving grace is that I programmed it so that it could expand...and it has grown exponentially.
I document code pretty heavily as I go, but writing user manual or any kind of formal docs is VERY difficult for me.
Definition of a burocrate; Delegate, Take Credit, shift blame.
PartsBin an Electronics Part Organizer - Release Version 1.3.1 JaxCoder.com
Latest Article: EventAggregator
|
|
|
|
|
"So, my advice is: Forget about the source code documentation, at the method header and parameter level (with the exception of APIs exported to users outside your organization). Document it top-down, with focus on component interactions."
This right here.
Charlie Gilley
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
Has never been more appropriate.
|
|
|
|
|
Mike - would you email me at cgilley2640@gmail.com? I want to ask you a retirement question(s) offline. Used to be that CP would allow a discrete but direct email...
Charlie Gilley
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
Has never been more appropriate.
|
|
|
|
|
> I have written a bit of Code to talk to bit of hardware.
Does the hardware in question has a datasheet?
If hard to find, provide link or better the actual PDF you used to write the code.
Some example applications are often more useful than documentation in practice.
At least a minimalistic "hello world" app to get started, maybe a performance testing one.
The more complex the hardware the more example apps might be needed.
What is also useful is adding some (minimal) debugging.
E.g. an I2C based class should contain something like bool isConnected().
A SPI based class should have means to set the clock speed.
This allows 1st order testing for users of your code.
my 2 cents
|
|
|
|
|
The bit of Hardware are the guts of scale which then lashed to a mechanical rig (not of my design) so the scale documentation is of limited use. The comms is over USB which is part of the problem my first attack I started to go down the rabbit hole...
|
|
|
|
|
Its not a silly question to ask
I would at least include:
- source code documentation (Doxygen is your friend)
- build instructions (which you tested on a clean machine)
- description of the communication protocol between PC and the hardware
- installation instructions (which you tested on a clean machine)
- use instructions (e.g. command line arguments)
- eventually an high-level flowchart of how the system operates
The first two items are helpful when in the future, you or somebody else needs to do some work.
The other are useful for the actual users and typically will be part of manual. Which I strongly
advise you to make, if somebody else isn't doing. I have found that "have you read the manual ?"
substantially decreases support effort
A lot of work ? The first time yes, a few days at least, but then it is just minor edits to the documents.
I use Doxygen for generating the documentation of the source code, of the language own tool if better.
And Sphinx[^]
for writing the manual and instructions.
|
|
|
|
|
My meme for the engineering triangle for project documentation has two sides labelled "complete" and "correct".
The third side is un-labelled to represent non-existence.
But it's funny 'cuz it's true.
|
|
|
|
|
And "It can't be too odd" you'd be wrong. I have seen so many developers blow past this area it makes my eyes water. Marc has a good list, but personally I would condense it. The real question is, what are your doc requirements? I had to write MILSPEC docs a long time ago. DD something or other, very specific and completely useless. I went to the USAF Captain handling the project and told him I could give him what he asked for but it would be complete crap and useless. Alternatively, I could give him something useful and we just wrap it in the boilerplate of the doc spec. He was happy.
- if you are documenting code stuff, it must be automated. Else, the doc will become a project of it's own, no one will maintain that part and worse, it will become obsolete and not reflect the code. Frankly, this is mostly useless documentation.
- what you need to build the project - good stuff. Software to install, build procedures, etc.
- my biggest career beef - I rarely come across doc that explains why the code is the way the code is, the abrasions, broken limbs and late nights of things that have bit you, and on and on.
- DO NOT INCLUDE WEB REFERENCES TO INFORMATION. Especially Microsoft. Print the info in PDF form and archive it with the doc. Microsoft routinely prunes useful info for the misguided reason that nobody could possibly care about this any more.
Charlie Gilley
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
Has never been more appropriate.
|
|
|
|
|
[tl;dr]: Is RAID5 really causing such a huge performance hit?
I have a system (a Hyper-V VM host) with both eSATA and USB3.0 connectors.
I have a retired set of 8TB drives. I got myself a Mediasonic HFR2-SU3S2 PRORAID 4-drive enclosure, which can use either connector.
I love how trivial this enclosure's RAID setup is. I chose RAID5, so I have a total of 24TB worth of storage. Performance however makes it downright unusable. I could leave my VMs powered down overnight to back them up, but what I'm currently seeing could take days. Backing up a VM while it's running is just not a good idea (I use robocopy) so the VMs have to remain down while backing them up. That's not gonna fly during my workweek.
I made sure that, whether I'm using USB3 or eSATA, the "Better Performance" radio button is selected in Device Manager / Disk drives / [the RAID enclosure] / Properties / Policies.
Write operations hold steady at ~2.6MB/s. Active time is flat at 100%.
Same setup, but using eSATA instead, holds steady at ~5MB/s. Better, but still way below expectations. I'm questioning what my expectations should be.
The OS sees the RAID, not individual drives. On top of that, I use VeraCrypt to encrypt the entire RAID. I understand RAID involves some overhead, especially for Write operations--parity calculations would be done by the enclosure hardware, not my VM host's CPU. OTOH, VeraCrypt also introduces its own overhead, and that would be done by the host's CPU (which holds steady at ~3-4% when copying, so that's hardly the killer).
Before I got the RAID enclosure, I backed up the VMs onto a single external disk over USB3, and there was always plenty of time to do the whole thing overnight. I forget what I got in terms of transfer rate, but I'll be sure to pay attention the next time I do it - surely at least 10x the current performance. That single disk is also encrypted with VeraCrypt, so--unless I'm missing something--the only thing left that can account for the difference in transfer rate is the fact that the target drives are set up in a RAID, as opposed to transferring to a single drive.
My (somewhat rhetorical) question is: Really?
Does my diagnostic make sense? Is the fact that I'm backing up to a RAID the real performance killer? Everything is otherwise the same - both the RAID and my single external drive are connected via USB3, and using VeraCrypt.
Does it make sense at all that RAID5 kills performance to the extent I'm seeing?
What would you expect with a setup like this? I know I'll never get close to USB3's theoretical maximum throughput, but this is insane.
[The RAID isn't indicating any failure, and the last time I've used the drives individually, they were all working fine]
|
|
|
|
|
(Definitely didn't read the whole thing.)
When selecting a RAID level, you have to consider the ratio of reads to writes. Most situations have many more reads than writes and (if I recall correctly) RAID 5 is designed for that. But if your situation doesn't have so many reads, a different RAID level may provide better performance.
|
|
|
|
|
Well, I really only bought the RAID enclosure to maintain an extra backup set. I'm already backing up on single drives, but I had more than enough retired 8TB drives to make a RAID out of them. While I'll sacrifice capacity for performance, there's a limit to what I'll find acceptable. I thought RAID5 was a good compromise. Of course I'd never settle for a purely striped setup.
In theory, the only time I'll ever read back what I have on that RAID is if I my 'live' drives fail and need to restore from the backup. Otherwise the intend is to just re-sync (once a week?) what's different from my live drive back onto it (essentially incremental updates - robocopy's good at that).
At this point I'm thinking maybe I should just do my backups straight from my live drive, onto a single external drive, and then let the RAID bring itself up to date by syncing from the backup instead. Then it doesn't matter if that takes days, since that won't force me to have my VMs powered down when the extra backup is taking place...
|
|
|
|
|
RAID 0+1 might be a better option for RAID mode in your use case.
Basically, striped, but with an extra drive for parity, so a bit of both worlds.
Something is going on here though... Still thinking what it would be.
|
|
|
|
|
First off, are you sure you've got RAID 5 selected? If you do, and you have 4 8TB drives, the total storage should be far less than 24TB. Depending on how the controller sets the mirrored slices, then you might only see 8 TB.
If the enclosure supports non-raid operation, I'd be tempted to try just one drive with no encryption, and see what transfer speed you get. If it's still poor, then that might suggest that the enclosure itself has poor transfer rates. You might also try it with the other drives, just in case one or more of them has some hardware issue that's slowing the whole thing down. If you get good transfer rates with a single drive, I'd move on to basic mirror (RAID-1), and see how that works out. Maybe try some of the other RAID configurations as available to see if there's a sweet spot that provides good transfer rates and protection from drive failure.
"A little song, a little dance, a little seltzer down your pants"
Chuckles the clown
|
|
|
|
|
I think just about every discussion I've ever seen about RAID capacities said essentially that the capacity for a RAID5 setup (assuming drives of identical sizes) is N-1 (where N is the capacity of one drive). So 24TB sounds right to me.
I suppose I will take the time to try out various combinations, but this is all taking a very long time. I had initially started off with four 4TB drives, and was essentially seeing the same thing under the same conditions.
|
|
|
|
|
You are right about the capacity. I don't know what I was thinking. Something like the stripes were duplicated over the array, something like RAID 5+0 (?).
"A little song, a little dance, a little seltzer down your pants"
Chuckles the clown
|
|
|
|
|