Code flag to indicate a need to revisit the code / locate unfinished code?

Thomas Sødring Thomas.Sodring at hioa.no
Tue May 30 09:18:41 CEST 2017


Hi,


First off, what you are seeing there is from very early on in implementation, you'll notice that it's searching by id, not systemID, so this is from the time it was unclear in the standard if we should use id or systemIDs to retrieve objects. It was also unclear if we should also be allowed to search by id. This method can safely be deleted.

The code has matured over time and you'll see I'm now putting in @NotNull on inner methods. I'm also now throwing and catching exceptions that are creating sensible return payloads to the client. My aim is to catch problems as close to the endpoint as possible so that I can avoid the endless list if (null != object).  So you will see in the service layer many e.g. getentityOrThrow(). This is a helper class that throws an exception very quickly if there is a problem.

I think there's a nice expression in Norwegian that explains how the project is being developed "Veien ble til mens vi gikk". I had more questions than answers when we started, I knew little of JavaEE and spring, but I knew that they had what we needed. This project is an exploration in JavaEE / spring, and all the other things we have discussed ...

If you search for TODO: you will probably find what I didn' t get around to doing.  There are many, but they are shrinking . This is partly because I am now committing myself to completing the full stack for an entity in one go rather than doing bits and bobs and adding TODO tags. So correpsondencepart is a good example where I spent something like 70 hours, but it all came in one go.

I did consider using the following.
  https://github.com/Stuie/papercut
I do like the approach here.

Perhaps we should try and include papercut, but I am trying to introduce finished blocks of code, rather then half blocks.


 - Tom

________________________________
From: nikita-noark-bounces at nuug.no <nikita-noark-bounces at nuug.no> on behalf of Petter Reinholdtsen <pere at hungry.com>
Sent: Monday, May 29, 2017 23:34
To: nikita-noark at nuug.no
Subject: Code flag to indicate a need to revisit the code / locate unfinished code?


Thanks to the Coverity findings, I came across this code (CID 1437461):

    public Series updateSeriesSetFinalized(Long id){
        Series series = seriesRepository.findById(id);

        if (series == null) {
            // throw Object not find
        }

        String username = SecurityContextHolder.getContext().getAuthentication().getName();

        series.setSeriesStatus(STATUS_CLOSED);
        series.setFinalisedDate(new Date());
        series.setFinalisedBy(username);

        return seriesRepository.save(series);
    }

This made me wonder if perhaps we should standardize on a flag/marker to
place on code like the block for series == null above, to make it easy
to find code that need to be revisited / fixed.

A fairly common way to do it is by adding 'FIXME' or a similar easy to
search for expression in front of comments like this:

        if (series == null) {
            // FIXME throw Object not find
        }

Another is to add output statements reporting that the unfinished code
was reached.  The exact method can differ, but something like this would
probably work:

  import static java.lang.System.out;
  [...]
        if (series == null) {
            out.println("FIXME missing throw Object when not found");
        }

Note, it must be possible to find all such code blocks, so some unique
indicator should be used also here..  I used FIXME in the string, but a
special function call name could be used too.

Thomas, what do you think?  Do you have a better way to keep track of
the unfinished code?

--
Happy hacking
Petter Reinholdtsen
_______________________________________________
nikita-noark mailing list
nikita-noark at nuug.no
https://lists.nuug.no/mailman/listinfo/nikita-noark
nikita-noark Info Page - NUUG<https://lists.nuug.no/mailman/listinfo/nikita-noark>
lists.nuug.no
To see the collection of prior postings to the list, visit the nikita-noark Archives. Using nikita-noark: To post a message to all the list members ...



-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.nuug.no/pipermail/nikita-noark/attachments/20170530/09dd8ad7/attachment.htm 


More information about the nikita-noark mailing list