Which is the best way to program

Hi everyone

Some days ago we had a conversation about which is the best way to program in 4D, in the past we programmed methods with a lot of lines in it, as we know, 4d works procedurally and it doesn’t bother us because the system worked fast. Now with all changes in the way that we can develop applications i have tried to make as many possible methods from a long code, to make readable and concise, but i don’t know if this affects performace of my applications.

In your experience, which is the best way to program in 4D?, is it faster than the other way?, is there another ways to control the development and coding?, tell me about your experiences making code in 4D, tips or quirks that you’ve found programming in it

Thanks for your opinions

Hello Jorge,

Good question.
4D is really moving forward quite fast these years.
The best practices from yesterday are definitely not the same as the new ones to efficiently develop with 4D v17 and the v17 R-releases.

http://go.4d.com/4DWT2019-Latam.htmlDuring the 4D World Tour,> the team travelling these days in Latinamerica, is sharing key tips and recommendations, on how to be efficient with the new and modern ways of programming with 4D.

If there is no stop this year in Columbia, in the 2 coming weeks, after Argentina and Chile, the team will be present in http://go.4d.com/4DWT2019-Latam.htmlEcuador, Panama and Mexico>.

Then I’m sure you’ll receive some good input from the 4D community.

Best regards,

Laurent

Well, thanks for your answer, unfortunately i can’t go to the summit, but i guess that in the future i’ll go to one of this

Readable and concise wins always. Unless you do something really extreme, I suspect you would never even be able to measure a user perceptual difference between using big methods or small methods.

It is a question of the relationship between the execution time of the method and the number of calls. The call to a method is not neutral, but is relatively fast. On the other hand, if the number of calls of this method is high, then the impact in terms of performance may be very high.

It is also important to measure the impact of splitting methods regarding the database engine queries in a Client/Server environment. If this split generates a greater number of exchanges between client and server, it may be disadvantageous to do so because it will have a significant impact in terms of latency and will disproportionately slow down the execution of your application.

Naming convention will help to be more in control.

Use the Macro to enhance your productivity.

Before to start implementing any code in your target application, do a simple database first to test your code and your idea. This way you will have a much better control, you will be able to better test and isolate any issues without risk of side effects related to your target application.

Code review with a 4D expert is also a very good way of enhancing your skills.

More generally

Embrace rather than fight

My main recommendation is to follow 4D’s development principles and not to try to apply your technical habits inherited from other environments.

I’ve seen too many projects failing because programmers were trying to apply their practices inherited from C#, JAVA, PHP, etc… to 4D.

It’s like you decide to swim against the waves. You’ll exhaust yourself and eventually drown. On the other hand, if you decide to surf the wave…

: Maurice INZIRILLO

Embrace rather than fight
make love with 4d, not war :lol:

Wow, that was a very good answer, yes, i feel that using 4d is a matter of taste, and also i think that we can perform better ways for coding in it, but there are many requirements for our clients that make very difficult to decide if we code by one way to another.

I love 4D a lot. I’ve been programming with it for 15 years, and I’m also very impressed with all new changes that have been made with it

Thanks again for your answers and 4d forever!!

The course is good but the path is long…

many new features did not see the arrive for the moment…

ORDA, collections, 4D Write PRO, 4D View PRO, all those features are good but far to be mature

ORDA is mature enough for me.

I mean integration of ORDA and 4D widget like listboxes… (there is still bug for refresh, etc…)
And there is still some lack in collection (we can’t delete user selection correctly for example, etc…)

Maurice stated it very well and 4D indeed has it’s own best approach to coding (outside of very general good coding practices applicable to any language). I really enjoy coding in 4D and find it very flexible for many uses…

As a base: I follow the programming recommendations from 4D for the version I am using as much as possible and go from there with a “Function Specific Method” approach (for lack of a better term).

As much as possible I create a 4D method to perform a specific function / task; in general the length of the method is not important as long as it directly helps the method complete the function / task. If that method needs to complete some other related specific function / task, that is put into a different “function specific” method and then called appropriately, etc.

This has worked well for me and helps to reduce the amount of code that needs updated for changes, enhancements, etc. It is also easier to determine what method(s) need updated based upon what function / task is being enhanced in the overall application. It makes changes a smaller impact on the overall application as a smaller amount of code is changed…

We will be upgrading our 4D production servers to v17.1 this summer (currently on v16) - looking forward to those new capabilities (and the adjusted best approach to coding that goes with it)… :mrgreen:

Hello,

: Milan ADAMOV

ORDA is mature enough for me.
Yes ! That’s right.
You can do amazing task with objects, collection and ORDA right now. I’ve switch to this mode without major problem and deploy into production.

Regards,

Hello,

: Manuel PIQUET

I mean integration of ORDA and 4D widget like listboxes… (there is
still bug for refresh, etc…)
And there is still some lack in collection (we can’t delete user
selection correctly for example, etc…)
That’s a typical french approach. Please don’t take care of this and take the opportunity to go ahead and be able to use the full power of 4D … even if all is not perfect.
Trust me, if you follow the 4D best practice (as Maurice made the recommandation) you’ll be happy.

Regards,

Hello,

: John DESOII suspect you

would never even be able to measure a user perceptual difference
between using big methods or small methods

No.
That’s not only a question of perceptual difference as Maurice explain. If you avoid “entry points method” with a big “case of” to perform all the tasks of a module, you will make a big step in the right direction.

Regards,

: John DESOI

difference between using big methods or small methods.
I tried to measure that a while ago (3-4 years ?). In interpreted, repeated calls to a big method took more time than a small one (I suppose it is a load time), while in compiled I could not see any difference.