Follow treslines by email clicking Here!

Monday, August 1, 2011

Why do you need source code conventions ?

Why do you need source code conventions ?
(Clean Code Quality Seal : Orange)
Table of contents
Why do you need source code conventions in your company?
Why shall i establish code convention ? My IDE helps me search alredy if i need ?
OK, but what have code convention to do with data storage management and principles ?
Ok, but how can i make my repository visible and reusable to my developers ?
Ok convinced, but how can i establish good conventions  and what are good conventions?
Database and source code conventions
Some of the potential benefits that can be obtained by adopting a naming convention include the following:
Source code convention tools
Literature, good books and references
How can i subscribe/feed this blog ?
How can i rate this blog ?
Where do i find more clean code knowledge and gadgets?

Why do you need source code conventions in your company?

Hi there ! in this blog i wanna show you why i strong recommend to establish a good source code conventions in your company and why you’ll be developing faster and reusing classes with that. Code convention has been substimated and it is essencial in a company which want to stay competitive in the market. Good code conventions gives you a great vocabulary to communicate with other developers making it easy to understand and explain the code. It makes your code cleaner and reusable. Yes i sad reusable ! Are you curious now, how it is possible to make code reusable only by establishing code convention ? Read and share this blos to other developers. In the next section i’ll give you some ideias how to develop faster and increase your company revenue !

Why shall i establish code convention ? My IDE helps me search alredy if i need ?

I almost allways earn this answer, when i try to explain to developers why code covention is good for them. In fact that’s a good question, because it shows to me, that the developers are interessted on it and still don’t know or substimate the power of a good convention thinking that the IDE alredy solves this problem to him. The clue to find something quickly is the way your store it. The reason why we need code convention are justified in the theoretical bases of data storage. The secret of reusability i not only the fact that a class or interface was coded well, but also how to find it to reuse. To know that there is something good saving you a lot of time. This rule is gulty for evering thing you can imagine even in the market.
Example : Imagine you design a very good product. Let’s call it iPhone. To sell it successfully, two things has to come together. Customers must know, that your IPhone exists and most important: your customers should get from a store, if they want to buy it.
Imagine now that there is a unique store (your IDE) and there are a huge Stock. The stock is so big, (your IDE with thousends of classes and interfaces) that no customer is able to find the IPhone. Let’s make it a little more difficult: The store manager (you and me) does not have a catalog in which we have catalogazed the IPhones (classes in your IDE) we want to find, because we thouth that the store (our IDE) would solve this problem to us already. Your IPhone would flop! Without a system you’ll be just losing time searching a little bit and giving up by writing your own code again. How big is the probability that you find the class you may are looking for in a jungle of thousend trees ? Thats the way we work without code convention. Without class/interface catalog and no orientation the probability to find the right class or interface to reuse is very small. Thing about yourself ! How often do you search for a specific class/interface and really find it and also reuse it ? Ask yourself why ? This rate could be much more higher.

OK, but what have code convention to do with data storage management and principles ?

Well the clue to find something is the way you store something. Databases do that automatically and very efficient for you every time your store something in it. The reason why databases do that so good is that you can’t change the language it uses. (SQL) Database only says to you: use SQL, do something, but let me decide how i’ll do best for you. In Java or other object oriented languages we don’t have this barriere automatically and nothing is under control, because there are to many developers with diffent skill levels programming every day.
Example : (i have done this experiment also with my daughter): Imagine a very big old tree with thousends of leaves on it. You close your eyes and a mark one leave. (like we would store a new class in our IDE or repository) Now i say to you : Find this leave as fast as you can. Consider : There are thousend of green leaves(like in the search bar of our IDE) and they all look the same and very similar(like our classes in our IDE) My daughter sad to me: Papi you are crazy! How shall i do that ?
There is no chance and i bet with you that you also wouldn’t find it ! My daughter is ten year old. The same argument developers will give to you, if you aks them to reuse something they can’t find.
Remember that in your company the situation is more dramatically because of the factor time! And this is a good and acceptable reason. You would not be able to disagree with that, because it is the truth and reality. So now all the effort to code well is done! Nobody is reusing anything. Instead of that they are programing, programing and reprograming!!! That’s effective right? (no for sure not!!!)

Ok, but how can i make my repository visible and reusable to my developers ?

I sad to my daugther : Princeza, papi would find it in max. 5-7 tryes and in milliseconds! She sad: impossible! Well that’s very simple. What you need is not only the product (IDE or repository with classes) but also the catalog (code conventions) and the advertisement (cookbooks - very important) !
Databases have a schema how to store something in a way that you can refind it very fast again. One of those principles is the binary tree. The database saves something in a way that with each search iteration, you are able to cut the result into two reducing the fields binary. Thats a very powerfull way to search and find items, but you need that system to do so. You need a convention how to store it. What i’m telling you is nothing new. It is just something that to many companies and young developers substimates because they thing that in the 20ty centure things can be done faster and in an other way. That’t true, but only gulty to methods. Never for principles and physical rules! Notice that ! principles are static final variables. They are gulty over the universum. If you try to change that or work against that, you certainly early or later will get into troubles.

Ok convinced, but how can i establish good conventions  and what are good conventions?

Well, thats not so easy but it is possible and strongly recommended. Important : Always write down why you need the convention and what benefits it brings. Reason : If you leave the company or if one day a new developer asks you why you are doing those things in this way in the days of today, you will be able to share your expirience and explain to him, why there are things that never changes in life. (principles and constant rules) Also very important : Those conventions should not be in your PC, but futhermore as a small list glued on the front of your pc-screen visible to you. (developers are very lazy people) and every step we have to take, makes it harder to us to reuse.

Database and source code conventions

Minimal database conventions you should establish in your company :
·         Do not use (-)  to connect words. Reason : Some databases like MySQL don’t like this.
Bad : abc-def good : ABC_DEF
·         Allways write column names in big capital even if this doesn’t matter. Reason : be constant
Bad : abcDef good : ABC_DEF
·         Write column names always in the singular. Reason : Weltweiter standart
Bad : CAR_NAMES good : CAR_NAME
·         Avoid abbreviations or general names. Reason : avoid misunderstandings
Bad : NME or FIELD1 good : NAME or PREIS
·         Do not start field or table names with special characters. Reason : portability
Bad : 12_NAME, $NAME, *NAME good : NAME
·         Do not write white spaces. Reason : compatibility, portability
Bad : MY RING good : MY_RING
·         Primary keys has the same name as its table with the postfix ID. Reason : great developer still
Bad : Tablename: Preis, primary key Id good : PREIS, PREIS_ID
·         Foreign key is allways the name from the primary key. Reason : great developer still
Bad : Table: client has foreign key: foreign_Id_1 good : CLIENT, PREIS_ID
Minimal source code conventions best practices you should establish in your company :
·         Speak the same language. Why : See potential benefits.
Bad : to re-invent the wheel again good : see
Abode coding conventions and best practices

Some of the potential benefits that can be obtained by adopting a naming convention include the following:

·         to provide additional information (i.e., metadata) about the use to which an identifier is put;
·         to help formalize expectations and promote consistency within a development team;
·         to enable the use of automated refactoring or search and replace tools with minimal potential for error;
·         to enhance clarity in cases of potential ambiguity;
·         to enhance the aesthetic and professional appearance of work product (for example, by disallowing overly long names, comical or "cute" names, or abbreviations);
·         to help avoid "naming collisions" that might occur when the work product of different organizations is combined (see also: namespaces);
·         to provide meaningful data to be used in project handovers which require submission of program source code and all relevant documentation and
·         to provide better understanding in case of code reuse after a long interval of time.


How could we improve the quality of this article ?

If the content of this article does not help you, so please tell us how to improve the quality of it by giving your contructive feedbacks at the end of this blog. If it was useful to you giving and resuming to you the most important aspects of the subject treated, saving you a lot of time, then help us to maintain this blog with a little appreciation. With a small amount of your choice you help us to cover the prime costs like:


Hosting, autors’s research work, editorial work, blog quality, motivation to make things better than others resulting in a very useful information pool for you and a lot of other developers.

Important : If you do not have the possibility to donate a little amount, than recommend this page to your friends. Thanks !





Source code convention tools

Literature, good books and references

How can i subscribe/feed this blog ?

Subscribe to: Post Comments (Atom) !

How can i rate this blog ?

Press google+1 once !

Where do i find more clean code knowledge and gadgets?

No comments:

Post a Comment