Skip to Content

                              ‘You have got to be willing to read other people’s code ,

                              Then write your own , then have other people review your code ‘

                              – Bill Gates

 

I have always thought about blogging in SCN, but refrained in doing so mostly for the fact that, I was always doubtful about how appealing it would be/ helpful to other community members. But today I have got some guts to jolt down something because I want to share something which really helped me and feel like upgrading one level up. I ensure you would feel the same after reading this.

Background

I am sort of a person who scratch my head 100 times a day, thinking on how to be a better programmer. Interestingly one of my favorite off work search on Google is with the keyword ‘How to be a good programmer’. It is something which I do very often, even though I stumble upon the same webpages again and again 😊 . But this made feel better, motivated and keep reminded me a few things. Usually you could see the main points authors will emphasize to be a good programmer would be .

  • Learn many programming languages.
  • Read lot of technical books
  • Write lot of code
  • Start building a new product.
  • Learn from others code.

I would like to elaborate on the fifth point, learning from others code.  I recently had the fortune to write a fairly big program and I tried to imbibe the techniques ( Primarily object oriented ) from of one my expert colleagues. It was really hard to start of with the program but later on the concepts became more and more clear . After the successful completion of program, I felt like I have scaled up by one level.  Most of my career, I didn’t have the chance to look into others code because I was the sole developer in the company and you have no idea how others code and probably you end up as a frog in the well. ( it is not the case these days with github with just one click away… I will come to that later ) .

My present organization gifted me the fortune to work with many skillful developers and I am learning a lot from them.

Why learning from others code is important and what all I have learned 

  • How to use object oriented concepts effectively and reap benefits out of it ?

 

 

 

 

Source:https://study.com/academy/lesson/object-oriented-programming-vs-procedural-programming.html

 

I can really vouch on this one. I myself have kicked off and left half way, many a times on the journey with object oriented books with plenty of car class and methods. When many used to say object oriented is a way of thinking, I really struggled to get the gist of it. But now I understand how objects can make your life wonderful. It is an art which you would flow  into 😊 . You would definitely can understand where to use static methods (mostly helpful in object creation in design patterns such as singleton, factory ) , the reusability of methods, polymorphism and the proper way of designing the method signature from a well written object oriented program . Personally, I believe methods(… the whole design also) are the life blood of object oriented programming because methods are those crazy things which make things happen. So declaring the method right is very important in the object oriented context. Start declaring functional methods and you feel like a whole world of reusability open before you.

Ref:..https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abapcall_method_functional.htm

Object orientation is not all about converting the subroutines to methods …alas which is the one big mistake you will be automatically drawn into when starting with object oriented.

And please don’t say that you haven’t learned anything from this wonderful procedural to Objects blog series.

 

https://blogs.sap.com/2018/07/15/getting-comfortable-using-the-object-oriented-design-model-with-abap-part-1/#  and the rest of the series

 

  • New Programming ideas

 

If given a program problem to 10 persons, the ten would come up with 10 solutions. But there is always a solution which is tad better than the other. (may be in terms of performance, memory management, variable usage, design etc) and the general flow of the program which is neater and more readable than others.  SAP is heavily backing the usage of ABAP unit testing these days.  So it won’t be a bad idea to look into the code of people who use test classes and methods logically. It is quite normal to have questions like when, where , how often , how much while designing test classes and methods in the initial stage. If you are still not aware of this, this is where you could start of with

https://open.sap.com/courses/wtc1

 

  • Naming conventions

Source: https://www.crazyegg.com/blog/naming-conventions/

Naming conventions is ever evolving as far I believe.  We used Hungarian notations religiously where we further ‘typify’ a strongly typed variable, then there were preachers of much more simplified versions of naming conventions where MATERIALS is what all we need to indicate that it is an internal table which has many materials and MATERIAL  is a structure which only have a material data  . Hmm.. and waiting for much more simplified versions for lazy coders like me.

 

  • New ABAP Keywords

Source: https://www.pinterest.com/pin/90986854951143666/

The advent of the new ABAP features has thrown a new world of possibilities for ABAP coding. Enthusiast ABAP’ers will always have the urge to use the new ABAP features. The  VALUE, CONV , REDUCE, NEW ,COND , SWITCH, CAST  operators can make your code more precise and understandable. But unfortunately we spend hours on https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/index.htm and still get bamboozled with the fact that,  where to use when the new features in our productive code, where we deal with VRBK , VBRP , BSIS ,BSAS data. Handling Business data is a bit different ball game when we compare to the innocuous but uncanny integer internal tables in the ABAP documentations. …Jokes Apart.. 😊 .   I would like to write one more blog where I have effectively and efficiently used the new ABAP syntaxes.  But a few small, neat and unbelievably awesome ones,

  1. Forget about converting internal to external formats and vice versa, CONVERTION_EXIT_ALPHA_INPUT/OUPUT and helper variable junk when you can do it as simple as this ,
BILLING_DOC_NO =  |{  BILLING_DOC_NO ALPHA = OUT }|

2. This one is even more simple, when you have an importing parameter in the methods signature, you can still use the inline declaration . I have seen many extensively using inline declarations but missing on this part.

 

CALL METHOD me->mr_grid_best_uber->check_changed_data
IMPORTING
e_valid = DATA(i_valid).

3. Calculations with in SQL Query

SELECT carrid, connid , price * seatsmax AS max_revenue FROM sflight INTO

TABLE @DATA(max_rev_frm_flights) .

 

  • Commenting styles, formatting

 

May be not on the high priority list . But while going through code review you could see very neatly commented, formatted, Pretty Printe ‘d’ code. Even a neatly commented  Method signature is a beautiful sight worth spending time on .

You could even see enjoy some creativity like this if you have time.

 

  • Where all you can find others code ?

 

My first suggestion Github( + Plus Point – You can find a whole project  , ABAP to EXCEL , Plant UML, ABAP Git to name a few), second SAP community , third websites run independently by resourceful persons ( leaving it to your ‘Googling Skills’  since I think it is not permissible to publish/promote other website in the community ) where they share their ABAP expertise and fourth if ever it exists that is from your colleagues who write excellent code. Not everyone is fortune in this regard, so you could only keep your fingers crossed.

Footnote: I, myself had the wrong assumption that ‘SAP’ writes the best code and could learn from there, which is not true all the time. I could even see the reluctancy among SAP developers(in new progrms) to use the new ABAP syntaxes where it could be used effectively. Nonetheless if you are in the ‘game’ for quite some time, you could make out from which one you have to learn and which one to ignore.

 

 

You have seen some great code, learn from it .

You have seen some bad code, you know now what not to be done.

In either case, you win. So rejoice!

To report this post you need to login first.

7 Comments

You must be Logged on to comment or reply to a post.

  1. Michelle Crapo

    Yes!!!!   Learn from others code.  Recently I was/am still involved in an “upgrade” move to the on-premise version of SAP.   We have a group of consultants that came in.  A VERY nice consultant gave a presentation on ODATA and Adobe forms.  She not only gave the presentation but put together a great document.   I loved that.

    I also found some CDS ABAP that was written.   I loved writing my own but that gave me a great example.

    I’m totally with you on this one:

    BILLING_DOC_NO = |{ BILLING_DOC_NO ALPHA = OUT }|

    Talk about a time saver and defining tables, variables, etc inline.  I was about dancing with that one.  As I code and decide I need different fields – I no longer go to the top of my code to add the field!

    Naming conventions.  I’ve got to say the longer I code, the less they make sense.  You can always double click.  Basically I think it comes down to if your code is readable.

    For us olderish people I got a great smile out of some code a different developer had written.

    If rabit_season = abap_true.

    endif.

    Love the blog,

    Michelle

    (1) 
    1. Michelle Crapo

      Want to get really excited.  I read your blog post as a suggestion in one of the comments of my blog post.  From where Matthew Billingham commented.

      “Here is a great blog written by someone without decades of experience.”   

      The “here” linked me to this blog!!!  Pretty great.

      Please do continue blogging – I love reading blogs like this one.

      Michelle

      (1) 

Leave a Reply