January 26, 2014

Coding style matters

Coding Style, AKA Programming Style refers to the way you layout your source code. In many languages, source code layout is simply ignored by the compiler. You can write as you like.

It is very important for code readability and understanding to use the same coding style across all files of an application. It is even important to have the same coding style in all your source code.

Having the same coding style helps reading the code. And if you carefully select your coding style, you can even pinpoint coding errors simply because something look strange in the layout.

Of course, if you share your code among a team, like I do, it is very important that everyone in the team uses the same coding style. it is even important that in a company, all development teams use the same coding style so that code can be easily read and shared across teams and developers.

What coding style to use? I would say that this is mostly a matter of personal preferences as long as the style is constant and emphasizes the code structure.

I wrote my personal preferences in a document titled "ICS Coding Style". The name comes from the fact that I wrote it long time ago when a lot of peoples started to make changes to ICS. I wanted everyone to use the same coding style as me. Not an easy task because every developer think his coding style is the best.

The following image gives an idea of my coding style.


You can download my coding style document from here.

There are many "code formatter" on the market. The IDE is use (Delphi) has a fairly powerful code formatter. But this is not enough. For example, no code formatter will be able to rename the variables, methods and other identifiers according to a naming convention. Nad properly naming identifiers is an essential part of the coding sytle.

Code formatter also doesn't handle all aligments. For example, when the code must be broken into several lines, the code formatter will mostly go to the next line with some indentation. i prefer to aligne arguments and this become problematic for the code formatter when arguments are themself function calls.


Follow me on Twitter
Follow me on LinkedIn
Follow me on Google+
Visit my website: http://www.overbyte.be
This article is available from http://francois-piette.blogspot.be

January 23, 2014

3D animation with FireMonkey

Paul Toth, a well known Delphi Developer rewrote his CubeMan3D with FireMonkey, making it a cross platform application. The application shows an animated man made of 3D cubes. The man walk in place and turn on himself.

Actually, each cube is a standard FireMonkey TRoundCude 3D component. They are all linked together to form the body and members. The animation is made with a TFloatAnimation for each cube.

It is amazing how short the code is. The code is just the implementation for the AnimationFinish event for the leg. The event handler simply reverse the direction and restart.

The code source is available from here.

Paul Toth is a freelance Certified Delphi Developer. If you need some help with Delphi, feels free to contact him.



Follow me on Twitter
Follow me on LinkedIn
Follow me on Google+
Visit my website: http://www.overbyte.be
This article is available from http://francois-piette.blogspot.be

January 21, 2014

New blog about Delphi FireMonkey

There is a new blog talking mostly about Delphi FireMonkey on the mobile platform (iOS and Android). The blog also covers other topics, mostly related to FireMonkey and the various supported platforms.

This new blog is named FMXexpress.

Actually, this blog is collecting blog articles from everywhere, display a short abstract and redirect to the original blog article. This is a place to visit on a regular basis.  Click here to visit the blog. There is also a corresponding FaceBook page.


Follow me on Twitter
Follow me on LinkedIn
Follow me on Google+
Visit my website: http://www.overbyte.be
This article is available from http://francois-piette.blogspot.be