You are here

Parochial Engineering | Cypress Semiconductor

Parochial Engineering

I have been engineering for a long time now and I am still surprised how parochial software engineers can be.  I define it has a focus on immediate concerns at the exclusion of wider contexts.  I find software engineers are the first to propose and insist on a spec but also first to ignore it when they don t agree with the one someone else developed.  In short, it is an attitude that everything would be great if everyone did it my way.  

 When I first got to Cypress the tools team insisted that that all variables in Cypress developed code should use the Hungarian format.  Variables are written CamelCase with a small character in front to designate the type of variable it is.  (iCat is an integer and wCat is an unsigned integer.)  Some people got nuts and had multiple descriptors. So  papsCat was a pointer to an array of pointers to structures.  I thought it was kinda dumb, I mean the words of a modern language have different meanings from their position.  You don t have to have sentences like this.

 

sTom vSlugged oTed.

  (sTom is the subject, vSlugged is the verb , and oTed is the object.)

 

But I am a team player and if they say we use Hungarian style, I use Hungarian style.  Now that we have a different group of tool developers that decided we need a new spec and now Hungarian style is forbidden.  What was mandatory is now forbidden.

 

I suggested that why we didn t just let the programmer use whatever style they liked.  They said then the code would not be consistent which meant we would have inconsistent code which meant code not look consistent.  My response was quote from Emerson.

 

A foolish consistency is the hobgoblin of little minds, adored by little statesmen and philosophers and divines.

 

In 16th century England when they had a Catholic Queen, they filled the prisons with Protestants.  When they had a Protestant Queen they fill the prisons with Catholics.  All in the name of a consistent religious policy.

Comments

Bob Marlowe's picture

There is a book named "Clean Code" by Robert C. Martin. The idea behind this is that code should be "readable". Cypress's code isn't always readable. In the template for the main.c-file of a new project you find "for(;;)". Every C programmer except a newbee understands it. The same construct could be written as "while(forever)" which could be read and understood by everyone (as far as he/she COULD read). CamelCase is more readable than camelcase or CAMELCASE, so if it improves readability, why not use it. Why is readability important? Well, a program is executed continously but red very, very often before it does.
Bob

tommoxon's picture

Hungarian Notation (HN) is a naming convention invented by Charles Simonyi from Microsoft,
and was popular in the '80s for software development. But, as you can imagine,
software development has come a long way since the '80s...

1) Modern IDE's allow you to hover over a variable and see it's type, rendering HN unnecessary.
2) HN can mask errors because you "assume" you know what something is from it's name.

I think that Robert Martin said it best :
"Hungarian notation is, when all is said and done, a commenting technique. And the one great law of comments is that they lie. Comments are not syntax checked, there is nothing forcing them to be accurate. And so, as the code undergoes change during schedule crunches, the comments become less and less accurate.

The same happens with hungarian notation. When the type of a variable changes, it is not likely that you are going to hunt through all the code and change all occurrences of its name. Especially during the schedule crunch. Thus, the variables name will become a lie."

I would prefer that Cypress improve the programming IDE to include "hover-over type reporting"
rather than use or enfore HN for Cypress developed code, this is, after now 2012...
Particularly since Cypress has 8, 16, and 32 bit microcontrollers.

It seems senseless (or false) to define a variable as "BYTE bSomeVariable"
on an ARM Cortex processor , when it's likely to be more efficient as a 32 bit int.
So do I change the variable names in my code when going between PSoC3 and PSoC5?
Or do I just lie about it?

:-) sTom

banti17997_2719411's picture

I am looking here so get the information you join the latest free gethalpwindow10 most web users have to use the site for the doing work forever so getting the setting the access to windows 10 help support and i sure you like this operating system forever thanks for the visit here share this information.

ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.