Coding Horror posted by: Vuyiswamb
| Posted on: 9/22/2011 | Category: Pattern and Practices
| Views: 7620 | Level: NotApplicable
| Status: [Member] [MVP] [Administrator]
| Points: 75
| Alert Moderator
I had an honour to work with an amazing groups of programmers in different companies. Some of the companies did not have any rules regarding coding
standards. In some companies there were rules that were enforced to a point where
a developer can be dismissed or given a warning if these rules are broken. One
of the companies I worked for stands out from others. This company (AvantEdge) invested of a lot of money in
development of their products. When their product is out in the market, one
will admire the quality of the product.
If you have been part of this type of company for a long
time, you will get used to the way they do things. They don't only do things
without a valid reason. They develop enterprise applications that generate terabytes
of data a day, so whatever they do must have a valid reason. They have coding
standards, they have architecture standards, and they have Technology
Today I would like to teach you what I know, not deceive you
if you have already being deceived. Today I will try to force some information
into your skull. I don't claim to know
everything, which is why I give anyone a chance to challenge my writing and
criticize with facts. Let me go off the topic a bit. I wrote an article a long
time ago and I am proud in the way I defended the article,
the reason I defended this article, it is because I believe that if good
programming practices were followed then this would not be a problem.
Years of experience can still prove lack of knowledge to
certain areas of development. I have a friend that works for a major bank in my
country. He said something interesting.
"if you previously worked for one or two companies that are
not big for many years, e.g. a period of 20 or 10 years, there is a huge risk
that your knowledge is a bit limited. A person that builds enterprise
application in a huge organisation can learn a lot of things in a short space
of time than a person working for a small organisation. My point is that I did work for those kind
organisations and my knowledge is different for a person who worked on a system
that generates 800 gigs or less of data a day. If you look at my age, I am
supposed to be learning some of the basics, but because of the exposure, that
is different. So I know the meaning of writing a "select *" and a meaning of writing "select col1, col2" on a 5 terabyte Database. Now for small organisations that build
applications and tag them as enterprise applications it is not an issue to
write the code anyhow. I was taught to save the CPU from executing unnecessary
commands. This means I need a plan before I jump into code. I need to follow
certain standards when I write the code.
If you have written an application for a government military you will
know that there are military coding standards that needs to be followed and you
know that you will need to explain each and every of code you wrote and what
were the alternatives and what standards did you use to write the code and were
the coding standards followed properly and why did you choose that approach to
write the code.
From what I wrote, you can see where I come from and I don't
need to disclose everything and make things like this part of my resume when I happen
to apply for a jobJ,
in this post, I want to share something's with you.
Every company that write or attempt to write software must
have coding standard. A programmer who starts writing code without following
standards or believing that, there is no need for coding standards is a
deceived and an evil coder who should not be allowed to code. Coding standards are a mixture of personal
preference and industry tested ways of doing things. If your company says all the variables must
be named with fruit names like "Apple", "Pear". Then these are their standards
and I respect them because they know that they must have control on how code is
written because programmers come and go. But these standards can be proven not
efficient by the industry. One of the rules of naming a variable is that it
should be meaning and reflect what it is going to store and nothing else.
As you can see a company's coding standards can conflict
with the industry standards. But the industry cannot enforce those standards to
the company and when maintenance cost go up or when the application needs to be rewritten by
someone who never wrote the system before it becomes a problem and it leads to
many resignation of developers because they cannot do damage control on the
bugs planted by the previous developer.
When I join a new Company or Office, I usually carry my good
coding standards I used at my previous company. I check if there is anything in
place. If there is none, I will continue doing a good job at writing clean code
and maintainable applications. Coding
standards can save lot money for development houses or companies that develop
their software. Companies get sued for
programming mistakes and it can be a dismissal for that programmer that wrote
that code. If there were coding standards in place during that time, then it is
worse. Let me share with you real life stories of what I am talking about.
Mariner Bugs Out (1962)
Cost: $18.5 million
Disaster: The Mariner 1 rocket with a space probe headed for Venus
diverted from its intended flight path shortly after launch. Mission
Control destroyed the rocket 293 seconds after lift-off.
Cause: A programmer incorrectly transcribed a handwritten formula
into computer code, missing a single superscript bar. Without the
smoothing function indicated by the bar, the software treated normal variations
of velocity as if they were serious, causing faulty corrections that sent the
rocket off course. (more)
Hartford Coliseum Collapse (1978)
Cost: $70 million, plus another $20 million damage to the local
Disaster: Just hours after thousands of fans had left the Hartford
Coliseum, the steel-latticed roof collapsed under the weight of wet snow.
Cause: The programmer of the CAD software used to design the
coliseum incorrectly assumed the steel roof supports would only face pure
compression. But when one of the supports unexpectedly buckled from the
snow, it set off a chain reaction that brought down the other roof sections
like dominoes. (more)
CIA Gives the Soviets Gas (1982)
of dollars, significant damage to Soviet economy
Disaster: Control software went
haywire and produced intense pressure in the Trans-Siberian gas pipeline,
resulting in the largest man-made non-nuclear explosion in Earth's history.
operatives allegedly planted a bug in a Canadian computer system purchased by
the Soviets to control their gas pipelines. The purchase was part of a
strategic Soviet plan to steal or covertly obtain sensitive U.S.
technology. When the CIA discovered the purchase, they sabotaged the
software so that it would pass Soviet inspection but fail in operation. (more)
World War III. Almost (1983)
Cost: Nearly all of humanity
Disaster: The Soviet early warning system falsely indicated the United
States had launched five ballistic missiles. Fortunately the Soviet duty
officer had a "funny feeling in my gut" and reasoned if the U.S. was really
attacking they would launch more than five missiles, so he reported the
apparent attack as a false alarm.
Cause: A bug in the Soviet software failed to filter out false
missile detections caused by sunlight reflecting off cloud-tops. (more)
Medical Machine Kills (1985)
Cost: Three people dead, three people critically injured
Disaster: Canada's Therac-25 radiation therapy machine malfunctioned
and delivered lethal radiation doses to patients.
Cause: Because of a subtle bug called a race condition, a technician could accidentally
configure Therac-25 so the electron beam would fire in high-power mode without
the proper patient shielding.
In the company that I am using as an example, there are
certain things that take place, which I would like to share with you. Every
Friday there is a meeting for all the developers. These are tech meetings.
Every Developer must learn at least something new each month that he is going
to present to the meetings. So each week, there is a different presentation on
different tech topics. Some of the developer's debate about Database tech stuff,
like why a certain query is fast or slow and using some of the Profiling apps
to find the answer. Sometimes a bug that just popup from a client will be presented
to the meeting and the causes and the solution to the problem will be selected
and this makes sure that other developers are aware of these things. One more
thing I like is that every month you must present the best code you have written
that month, the code you are proud of. There is no prize for that but it counts
in the yearly bonuses. I was never reviewed, I reviewed. So I was heading the
Silverlight Projects and I write a damn good code and even go to the director's
office(Previously a Programmer), calling him to come and see my coolest code.
Puzzles were presented by directors and manager to be solved for prizes.
Every company that write or attempt to write software must
have an architect. Most of the time you will find that a developer is an
architect and there is no problem with this way or approach, because I did play
those roles before. To those who read most of my articles, you know that I am
an N-Tier Architecture evangelist. All the applications I created from scratch
were built in N-Tier architecture and even today they are still working and
when changes are made the other parts of the system will continue to work. You
see if you say you build enterprise applications, you must first know about
Architecture and patterns. A Programmer
that writes a program without an architect is a hacker. I have a friend in USA
whom I learned a lot of things from and he was asked to write a piece of
software that was going to be integrated with SAP. They wanted him to start
writing code without plan and taking time to understand the requirement. He told
them that he needs a week to gather more info about this task. They threatened to fire him, but he still
told them he needs a week to gather all the information he will need to write
the software. The Company decided to
give him a notice of Termination of employment and he accepted and after a week
as promised he started writing the software with a plan that he put in place
and after he wrote the software the client loved it and even today it still
works. Few months after he joined a new
company, the previous company telephoned him and apologised. Do you know
why? Remember he was asked to
immediately start writing code, but he refused, he put a plan in place to
understand the requirements and after a week he wrote Bug free software, but
there was no Documentation for that software. He only needed a Plan
(Architecture) and there was no time to write documentation and now the company
wanted changes to the software and no one knew how it was written and the new
developer couldn't figure it out. The following was his comments when I asked
him why he did that.
"I wanted to let them
know that, if you plan carefully before you write software, you can build Bug
free software that can cut your expense in support queries"
In times of ASP classic , we dealt with spaghetti code, the
Microsoft improved and gave asp.net but still people wrote SQL statements
inside the pages, this shows lack of architecture designs and patterns , there
no pattern that support that can of development, if you think there is , then
point them out quickly. After asp.net came in , it was cool and easy to work , but
Programmers get hired, some resigned and all these brings a different style of
programming , some like to use Linq , some StoredProcedure , some use Wizards
to do database work. The Rules or coding standards or architectures were not
followed and companies still continued to spend a lot of money in support until
Microsoft brought in Silverlight. This made things difficult for developers who
broke most of the industry coding standards rules, because they could not embed
their sql statements in the xaml, they could not use wizards to do database
work, this forced them to isolate the business layer, the Data Layer and the
presentation layer from each other.
Today there are few developers who write Silverlight application. It is
because it's different and it makes sure that those rules are not broken,
though I saw some people writing those Sql statements in their WCF services,
but at least I can breathe again. Architecture is good for an application that
will grow in the future. If you plan the application and use the correct architecture
to build your application the maintenance of the application will not cost a
lot and the unknown will be discovered during architecture design phase.
The Company I
mentioned in the beginning of this post is a Microsoft Gold Partner. They use Microsoft products for everything
and nothing fails them because they spend a lot of time researching about the
advantages and disadvantages of these products.
In the Company there are different sections, there is a Section where
you will find Windows Developers and there is another section where you will
find Web Developers doing asp.net Ajax and other things like JQuery and there
is my Section that was doing "Silverlight and WPF". Now I just mentioned that
there is a Section for Windows
Application development and there is a section for WPF/Silverlight application. What the company was doing was to phase
the old technologies out. So in my Team there was WPF which replaces
traditional Win Forms and we did WCF which replaces the traditional web
services. In that company in two years'
time, there will not be any existing application developed in WinForm or
ASP.NET. The reason is that they make good choices when it comes to technology
and developers don't claim they know a technology, but they use it every day. They
don't want to find themselves with one developer doing VB6 in 2014 and the only
person understanding that system (Furniture in the office). Microsoft creates
technologies and dumps them if they feel it's not the way to go. They create
Linq and dumped it
Created VB6 and stopped supporting it.
Well they replaced Linq with Entity Framework, but I am not
a fan of Wizards, I don't like using wizards to do my database work, I prefer
to do it myself. So this means that at some point we need to stop supporting
certain versions of our software and grow. Technology is made to make things
easy for clients and for developers. In this company I was asked what will need
to make our software better. They give you option, that is where I introduced "Telerik" . If you are building Silverlight,
Asp.net, WinForm, WPF applications with Telerik Controls you know what I mean.
They are perfect. I have used their controls, I have never tried to create my
own control and the support I got from them is wonderful. I don't want to waste time building a datepicker,
if there is someone who did it before. I don't want to spend a lot of time
arranging the CSS just to make my site better if there are controls that can
provide me with whatever functionality I want.
The times of creation your custom control are over because we have
deadlines and the client want their software as in like yesterday.
I think I have said enough; well that was my previous
company. So what I am I going to do in my new company?
My plan is to bring change in the mentality about Software Development
and how software should be developed. Bring in new Technologies and let the
company use cutting edge software to build customer satisfactory applications. I
am not here to start new developments with old technologies. As a writer and a
technologist I don't like the past, the times of Java JDK 1.2, the GridbagConstraints to position my
controls are over. Now I don't have time for that and neither will I have time
to build controls if Telerik, Infragistics, DeveExpress can provide them.
Thank you, I am awaiting for your wise comments.
Thank you for posting at Dotnetfunda