Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement for the exceptions section #49

Closed
wants to merge 4 commits into from

Conversation

germanysources
Copy link

I write some improvements for:

  • naming exception classes
  • catching exceptions in legacy code dependencies
  • control flow (fail-fast and don't alter behavior)
  • document problem domain terms

* Added Documentation of problem domain terms

Control-Flow

* Added behaviour changes to fail-fast

Exceptions

* Added naming for exception classes

* Added exception in legacy codes
@CLAassistant
Copy link

CLAassistant commented May 28, 2019

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@@ -365,6 +368,13 @@ so choose names that all of these can relate to without a customized dictionary.
> Read more in _Chapter 2: Meaningful Names: Use Solution Domain Names_ and _[...]:
> Use Problem Domain Names_ of [Robert C. Martin's _Clean Code_].

### Document problem domain terms
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I agree with the content of this section, I wonder whether it makes sense in a clean code guide. This is more a question of communication and documentation between the customers, product owners, solution managers, and architects, than the actual code. Do you have specific examples or incidents in mind where this has been neglected and led to misunderstandings? From my experience, we usually find more than enough explanations in the design documentation, architecture concept documents, scope documents, backlog items, and the application help to get along. SAP even has its own tool SAP Term for defining business terminology.

@germanysources
Copy link
Author

Removed this section.

@pokrakam
Copy link
Contributor

Hi,

While some of it makes sense, I am not convinced by this change in the Guide either.

The part about naming exceptions is already explained in the example Use sub-classes to enable callers to distinguish error situations and naming is discussed quite a lot in this guide. Perhaps a small comment in the subclass section could be added, or changing the title to "Use appropriately named subclasses...", but a second example is redundant IMHO.

The legacy code dependencies part is more controversial for me. I think it would make a nice blog on SCN for some discussion. To me the scenario seems very narrow in scope, and whether to catch or to let dump is very context-driven and subjective. Even in the example scenario I would still catch it. Leaving it out as the example suggests looks like someone forgot, therefore it should get a comment, which goes against Clean Code's "Express yourself in code not comments" principle.

I would handle this type of situation in a couple of ways.
Catching others generically makes it clear I don't care what went wrong. I could then raise a slightly informative (possibly dynamic) exception to provide at least some info:

CALL FUNCTION 'BAL_LOG_MSG_ADD'
   EXPORTING
     i_log_handle = log_handle
     i_s_msg = message_to_be_logged
   EXCEPTIONS
     others = 9.
  IF sy-subrc <> 0. 
    RAISE lcx_log_not_initialized.
  ENDIF.

(in real life I would use a RAISE method that also reads the SY message information for more clarity).

Alternatively go by Dump for totally unrecoverable situations, which I believe is the intent of your example, making it also feel a bit redundant for me.

Base automatically changed from master to main March 9, 2021 12:46
xtough pushed a commit to xtough/styleguides that referenced this pull request Mar 29, 2021
* scenario updates

* upd

* upd

* clarify
xtough added a commit that referenced this pull request Apr 1, 2021
* Creative commons license

it's not code, anyway

* Create README.md

initial title

* Scaffolding (#5)

* scaffolding

* remove non existing logo

* update title

* README: additional info for onboarding (#6)

* scaffolding #2 (#7)

* scaffolding #2

* some first intro content

+ added VSCode build task

* first intro content

* Inital diagram

Finally got ditaa to work. Plantuml activity diagrams are apparently not supported. Not really convinced yet of the text-based diagrams
approach.

Co-authored-by: Christoph Pohl <christoph.pohl@sap.com>

* change font to sans-serif (#9)

* introduction, minor changes (#10)

* some more notes (#12)

* some more notes

* some words regarding impact

* mention abapgit restrictions/design

* update scenarios

* add note regarding steampunk

* first attempt at best practices

Co-authored-by: Christoph Pohl <christoph.pohl@sap.com>

* small formatting issues (#16)

* minor changes (#17)

* updates (#23)

* update deps

* updates

* upd

* closes #15

* upd

* small additions and corrections

+ some official text on (g)CTS

Co-authored-by: Christoph Pohl <christoph.pohl@sap.com>

* move the static analysis part into the tooling chapter (#25)

* move the static analysis part into the tooling chapter

* add short abaplint description

* show 3 toc levels

* updates

* upd

* small corrections and enhancements on tooling

Co-authored-by: Christoph Pohl <christoph.pohl@sap.com>

* Update README.md (#31)

* Update README.md

* Update README.md

* fix typos

Co-authored-by: Christoph Pohl <christoph.pohl@sap.com>

* add title page logo (#33)

* add title page logo

* add page numbers

* Build timestamp

* recommend spellchecker
* custom dictionary

* add this document section (#32)

* add this document section

* introduction, sections etc.

* remove heading, move related work to new chapter

* add related work to index

* moved to abstract

Co-authored-by: Christoph Pohl <christoph.pohl@sap.com>

* front page hacks (#34)

* update links (#36)

* update activity diagram (#35)

* update activity diagram

* upper case OK

* polish scenarios (#37)

* should fix #26 , #24 , #14
 * needs some more polishing of example for #21

* publish pdf to latest tag (#38)

* Update build.yml

* Create publish.yml

* Update build.yml

* Update build.yml

* Update publish.yml

* dummy, testing (#39)

* rename release asset (#40)

* mention latest release pdf (#43)

* minor changes (#41)

* link Gerrit

* upd

* add todos

* upd

* minor

* upd

* update abaplint section

* some diagrams

* more diagrams

* I love diagrams

* upd

* remove "to"

* happy -> happen

* Update code_review.adoc (#45)

``todo, wording? remove "qualified" ? 

Done.

`` "gain reputation" -> "developers can actively become more knowledgeable about the codebase" something like that

No need to overdo it.  Meritocracy is all about reputation. I don't see how anyone could take offence in that.

* update url (#46)

* related work: add link (#47)

* workaround page numbering problem (#52)

* adjust headings (#51)

* update README.md with automatic build information (#48)

* update README.md with automatic build information

* Update README.md

Co-authored-by: Christoph Pohl <christoph.pohl@sap.com>

* abapgit examples (#53)

* wip: abapgit examples

* abapgit chapter updates

* split setup steps in two

* scenario updates (#49)

* scenario updates

* upd

* upd

* clarify

* update deps

* minor changes (#54)

* name in italics

* additional abaplint links

* abapGit add note

* add link

* Move gCTS example to separate section (#56)

* fixes from Mike (#58)

* README: add "Thanks To" seciton (#57)

* check links in build (#59)

* check links in build

* test

* move structure

* add link to code review guide in main README.md

* prepare latest release links

release links should point to SAP/styleguides

* use main license

* parent license

* ignore build and node_modules

* Delete LICENSE

redundant to ../LICENSE

* Update .gitignore

moved build and node_modules to top level

* README, add AsciiDoc notes

* code review improvements

* motivation: getting different perspectives
* selection: mention central distribution by team leads

* add missing space

* Automated Review --> Checks

* disambiguation of terms

VCS, git platforms...

Co-authored-by: Lars Hvam <larshp@hotmail.com>
@rdibbern rdibbern added the New Rule The issue or PR proposes an new rule or set of rules label Jun 28, 2022
described properly with the following names.

```ABAP
" The bass-class for all booking faults
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
" The bass-class for all booking faults
" The base-class for all booking faults

Copy link
Member

@sautermi0 sautermi0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just as a small addition to what @pokrakam already wrote:
When implementing code, you can never be sure who will be using it in which context at some point in time. I would argue that a wrapper of legacy functionality can't decide what's managable, unrecoverable, etc.

So to refer to Dump for totally unrecoverable situations and your example: Just because you can't deal with a non-existing log, it doesn't mean none of your consumers can deal with it and try again. And you should at least give them a chance to try, IMHO.

@sautermi0
Copy link
Member

I'll close this pull request because:

  • While the idea of avoiding side effects is noble, just recommending a ROLLBACK WORK in case of exceptions is not a good idea. Whether a ROLLBACK WORK is a good idea or not is depending on the context (used frameworks, different consumers, ...). Additionally, this would distribute the concern of transaction handling to different places which is not a good idea...
  • Regarding meaningful names: We consider this covered in the section names-section and Use sub-classes to enable callers to distinguish error situations of the guide.
  • Regarding not catching legacy exceptions and accepting a short dump: This is not a good idea because a wrapper of legacy functionality can't decide what's managable, unrecoverable, etc. and short dumps make the consumers unable to react.

@sautermi0 sautermi0 closed this Jul 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clean-abap New Rule The issue or PR proposes an new rule or set of rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants