Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
10/15/08 14:00
Read: times


 
#159088 - maintability and engineering
Responding to: ???'s previous message
Not a question about a different OS. It is a question about your code. You change one single little variable assign somewhere, and then your assumption suddenly fails. Software Engineering it not just about getting something that works, but something that can continue to work and that can be maintained and extended with limited costs and risks.

Why do the society have to loose millions of dollars every hour? Because more developers than you have thougt the same thing - that they knew the input parameters and that they made informed decisions.

printf() is not intended for producing fixed-size data for binary storage in flash sectors. If you need fixed-size output, you roll your own packing code. Then you can control what happens if a value is <= -1000 or >= 10000.

Maybe you would even decide to store the information in a binary format - with binary storage, a 16-bit integer can always be stored in 16 bits. If building a data logger, you would be able to store two or three times as much data into the flash if using a binary format.

Another thing to think about - pad your output with a suitable number of space characters and truncate the output. The disadvantage is that you will not get any line ending, making a normal text editor unable to open the log.

But are you sure that you can't build a temporary buffer before sending it out? If the RTL has it, the traditional "safe" way of producing a text buffer for further processing is to use snprintf().

List of 17 messages in thread
TopicAuthorDate
How many bytes will be written ??            01/01/70 00:00      
   return value?            01/01/70 00:00      
      OT: That's why you should never use TABs!            01/01/70 00:00      
         go ahead and use tabs            01/01/70 00:00      
            No, don't!            01/01/70 00:00      
            Any programmers editor            01/01/70 00:00      
               insert spaces for TABs            01/01/70 00:00      
      Oh Yes ... the sprintf()...            01/01/70 00:00      
         So here we go            01/01/70 00:00      
            Wrong!            01/01/70 00:00      
               Valid warnings. But...            01/01/70 00:00      
                  No buts!            01/01/70 00:00      
                     maintability and engineering            01/01/70 00:00      
               Not entirely true?            01/01/70 00:00      
                  You are correct            01/01/70 00:00      
                     Good example of counting dangers            01/01/70 00:00      
                        Good interaction.            01/01/70 00:00      

Back to Subject List