E11042: application has too many registrations - split into focused applications

Category: E11xxx Code quality and IR analysis · Reported in phase: PRE_IR_CHECKS · Classification: EXCESSIVE_APPLICATION_REGISTRATIONS · All error codes

What went wrong

An application block has too many registrations (more than 12). Large application blocks become difficult to understand and maintain. Consider splitting into focused applications with clear responsibilities.

Worked examples

Compilable examples demonstrating this error and the correct fix:

  • ek9 -q 892 (What is the maximum number of DI registrations in an EK9 ...)

Rationale

Twelve is EK9's design limit, not a research figure: focused, modular composition keeps an application understandable. Large registration blocks often indicate that the application is a monolith.

How to fix it

  1. Split into focused applications (infrastructure, domain, presentation)
  2. Applications do not compose: a program names exactly ONE application ('with application of'), so give each program the focused application that registers only the components it reaches
  3. Group related registrations together

See also

  • E11042: excessive registrations (this error)
  • E11040: excessive injection fields

Examples

Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.

Fails with E11042: application has too many registrations - split into focused applications

#!ek9
defines module error.e11042.bad

  defines component

    Part1 as abstract
      id() as abstract
        <- rtn as Integer?

    Part1Impl is Part1
      override id()
        <- rtn as Integer: 1

    Part2 as abstract
      id() as abstract
        <- rtn as Integer?

    Part2Impl is Part2
      override id()
        <- rtn as Integer: 2

    Part3 as abstract
      id() as abstract
        <- rtn as Integer?

    Part3Impl is Part3
      override id()
        <- rtn as Integer: 3

    Part4 as abstract
      id() as abstract
        <- rtn as Integer?

    Part4Impl is Part4
      override id()
        <- rtn as Integer: 4

    Part5 as abstract
      id() as abstract
        <- rtn as Integer?

    Part5Impl is Part5
      override id()
        <- rtn as Integer: 5

    Part6 as abstract
      id() as abstract
        <- rtn as Integer?

    Part6Impl is Part6
      override id()
        <- rtn as Integer: 6

    Part7 as abstract
      id() as abstract
        <- rtn as Integer?

    Part7Impl is Part7
      override id()
        <- rtn as Integer: 7

    Part8 as abstract
      id() as abstract
        <- rtn as Integer?

    Part8Impl is Part8
      override id()
        <- rtn as Integer: 8

    Part9 as abstract
      id() as abstract
        <- rtn as Integer?

    Part9Impl is Part9
      override id()
        <- rtn as Integer: 9

    Part10 as abstract
      id() as abstract
        <- rtn as Integer?

    Part10Impl is Part10
      override id()
        <- rtn as Integer: 10

    Part11 as abstract
      id() as abstract
        <- rtn as Integer?

    Part11Impl is Part11
      override id()
        <- rtn as Integer: 11

    Part12 as abstract
      id() as abstract
        <- rtn as Integer?

    Part12Impl is Part12
      override id()
        <- rtn as Integer: 12

    Part13 as abstract
      id() as abstract
        <- rtn as Integer?

    Part13Impl is Part13
      override id()
        <- rtn as Integer: 13

  defines application

    everything
      register Part1Impl() as Part1
      register Part2Impl() as Part2
      register Part3Impl() as Part3
      register Part4Impl() as Part4
      register Part5Impl() as Part5
      register Part6Impl() as Part6
      register Part7Impl() as Part7
      register Part8Impl() as Part8
      register Part9Impl() as Part9
      register Part10Impl() as Part10
      register Part11Impl() as Part11
      register Part12Impl() as Part12
      register Part13Impl() as Part13

Fixed: Split it into focused applications

#!ek9
defines module error.e11042.good

  defines component

    Part1 as abstract
      id() as abstract
        <- rtn as Integer?

    Part1Impl is Part1
      override id()
        <- rtn as Integer: 1

    Part2 as abstract
      id() as abstract
        <- rtn as Integer?

    Part2Impl is Part2
      override id()
        <- rtn as Integer: 2

    Part3 as abstract
      id() as abstract
        <- rtn as Integer?

    Part3Impl is Part3
      override id()
        <- rtn as Integer: 3

    Part4 as abstract
      id() as abstract
        <- rtn as Integer?

    Part4Impl is Part4
      override id()
        <- rtn as Integer: 4

    Part5 as abstract
      id() as abstract
        <- rtn as Integer?

    Part5Impl is Part5
      override id()
        <- rtn as Integer: 5

    Part6 as abstract
      id() as abstract
        <- rtn as Integer?

    Part6Impl is Part6
      override id()
        <- rtn as Integer: 6

    Part7 as abstract
      id() as abstract
        <- rtn as Integer?

    Part7Impl is Part7
      override id()
        <- rtn as Integer: 7

    Part8 as abstract
      id() as abstract
        <- rtn as Integer?

    Part8Impl is Part8
      override id()
        <- rtn as Integer: 8

    Part9 as abstract
      id() as abstract
        <- rtn as Integer?

    Part9Impl is Part9
      override id()
        <- rtn as Integer: 9

    Part10 as abstract
      id() as abstract
        <- rtn as Integer?

    Part10Impl is Part10
      override id()
        <- rtn as Integer: 10

    Part11 as abstract
      id() as abstract
        <- rtn as Integer?

    Part11Impl is Part11
      override id()
        <- rtn as Integer: 11

    Part12 as abstract
      id() as abstract
        <- rtn as Integer?

    Part12Impl is Part12
      override id()
        <- rtn as Integer: 12

    Part13 as abstract
      id() as abstract
        <- rtn as Integer?

    Part13Impl is Part13
      override id()
        <- rtn as Integer: 13

  defines application

    partsOneToSeven
      register Part1Impl() as Part1
      register Part2Impl() as Part2
      register Part3Impl() as Part3
      register Part4Impl() as Part4
      register Part5Impl() as Part5
      register Part6Impl() as Part6
      register Part7Impl() as Part7

    partsEightToThirteen
      register Part8Impl() as Part8
      register Part9Impl() as Part9
      register Part10Impl() as Part10
      register Part11Impl() as Part11
      register Part12Impl() as Part12
      register Part13Impl() as Part13

Questions and answers

These Q&A entries show E11042 and its fix: