The 'shape' of code to come !?
Posted: Thu Feb 23, 2017 5:00 pm
Hi guys,
I have just been adding the last few slides to my second 'Power Point' presentation, for Cologne at the end of April. (xBase.Future)
I would like to share the image of this slide with you here in Pearls. For the good reason that it suddenly hit me that although I am solving a definite business problem (common?), the shape and style of the computer code is looking really quite different to much of what I have coded over the last few decades - where 'few' is starting to be 'many'!
It is not just that putting the answer details on a colourful GUI took about half a line (240) of code, but more of the syntax, and what underlying facilities / technologies that are being used.
[And before you ask - YES, I do this stuff each and every day to solve real problems.]
Study the following :-
Yes, it was easier for me to chain four queries together to get the final results set (answer) and most of the code is LINQ based, and we see four anonymous types being used in the coding, as well as the results being passed back from the static method as a List of 'Dynamic' types.
I believe the 'Dynamic' means more or less that it is a place holder and that the type is provided at run time. Some don't like type 'Dynamic' but it works well with such problems.
Oh! should have said, the querying is being done on Entities (from version 6 EF).
I will leave it up to you to count the number of FOR loops used, 'For' and 'Foreach' both count.
It may be helpful for you to know that the 'OrderLine' entity has a Product property and that the Product entity has a Supplier property. So in some ways query 1 is flattening out the properties. We can then use the new 'flat' properties to calculate 'values'.
Obviously, query 3 groups the products by Supplier.
As Nick Friend often says, this stuff becomes second nature when we use it regularly (even easy), AND, we would not now wish to go back and do it the old ways. He or me.
Don't panic, this is slide 35 (P2) of a two slide show presentation (parts 1 and 2).
If you are not coding like this now, then look at your coding future style !
Hope this is of interest to some.
Best regards,
Phil.
Wales, UK.
I have just been adding the last few slides to my second 'Power Point' presentation, for Cologne at the end of April. (xBase.Future)
I would like to share the image of this slide with you here in Pearls. For the good reason that it suddenly hit me that although I am solving a definite business problem (common?), the shape and style of the computer code is looking really quite different to much of what I have coded over the last few decades - where 'few' is starting to be 'many'!
It is not just that putting the answer details on a colourful GUI took about half a line (240) of code, but more of the syntax, and what underlying facilities / technologies that are being used.
[And before you ask - YES, I do this stuff each and every day to solve real problems.]
Study the following :-
Yes, it was easier for me to chain four queries together to get the final results set (answer) and most of the code is LINQ based, and we see four anonymous types being used in the coding, as well as the results being passed back from the static method as a List of 'Dynamic' types.
I believe the 'Dynamic' means more or less that it is a place holder and that the type is provided at run time. Some don't like type 'Dynamic' but it works well with such problems.
Oh! should have said, the querying is being done on Entities (from version 6 EF).
I will leave it up to you to count the number of FOR loops used, 'For' and 'Foreach' both count.
It may be helpful for you to know that the 'OrderLine' entity has a Product property and that the Product entity has a Supplier property. So in some ways query 1 is flattening out the properties. We can then use the new 'flat' properties to calculate 'values'.
Obviously, query 3 groups the products by Supplier.
As Nick Friend often says, this stuff becomes second nature when we use it regularly (even easy), AND, we would not now wish to go back and do it the old ways. He or me.
Don't panic, this is slide 35 (P2) of a two slide show presentation (parts 1 and 2).
If you are not coding like this now, then look at your coding future style !
Hope this is of interest to some.
Best regards,
Phil.
Wales, UK.