Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Tweeted twitter.com/StackSoftEng/status/1614230873410265088
Bumped by Community user
Bumped by Community user
Bumped by Community user
deleted 4 characters in body
Source Link
Christophe
  • 82.2k
  • 11
  • 136
  • 202

I'm developing an application (Java) in a modular architecture. I have two approaches in mind and I'm not sure which one will be "better code" in case of maintenance and conventions.

I have two main modules that I want to wire them up:

  1. CORECORE - backend stuff
  2. UIUI - frontend stuff

and now I want to wire them up.

APPROACH #1

CORE module will expose Engine class, UI will expose UserInterface class. UserInterface will need an Engine in its constructor. Creationcan think of both objects will take place in the third module called LAUNCHER.

APPROACH #2

CORE module will expose Engine class, UI will expose UserInterface class. The difference is both modules with expose those classes ONLY to PRELAUNCHER module that will create objects and pass them to the LAUNCHER module as interfaces.two approaches:

MY THOUGHTS:

  • APPROACH 1: CORE module will expose Engine class, UI will expose UserInterface class. UserInterface will need an Engine in its constructor. Creation of both objects will take place in the third module called LAUNCHER.

  • APPROACH 2: CORE module will expose Engine class, UI will expose UserInterface class. The difference is both modules with expose those classes ONLY to PRELAUNCHER module that will create objects and pass them to the LAUNCHER module as interfaces.

The second approach looks promising, because it won't allow any module create the instantion of UI/CORE module classes (as Java offers sealed interface - that means I can choose which class can implement it). That's kind of dependency injection - the needed items will be created in one place and passed as interfaces.

On the other hand - the approach introduces more code - one more module and at least two new interfaces.

Any ideas which one is better in terms of maintenance and conventions?

I'm developing an application (Java) in a modular architecture. I have two approaches in mind and I'm not sure which one will be "better code" in case of maintenance and conventions.

I have two main modules:

  1. CORE - backend stuff
  2. UI - frontend stuff

and now I want to wire them up.

APPROACH #1

CORE module will expose Engine class, UI will expose UserInterface class. UserInterface will need an Engine in its constructor. Creation of both objects will take place in the third module called LAUNCHER.

APPROACH #2

CORE module will expose Engine class, UI will expose UserInterface class. The difference is both modules with expose those classes ONLY to PRELAUNCHER module that will create objects and pass them to the LAUNCHER module as interfaces.

MY THOUGHTS:

The second approach looks promising, because it won't allow any module create the instantion of UI/CORE module classes (as Java offers sealed interface - that means I can choose which class can implement it). That's kind of dependency injection - the needed items will be created in one place and passed as interfaces.

On the other hand - the approach introduces more code - one more module and at least two new interfaces.

Any ideas which one is better in terms of maintenance and conventions?

I'm developing an application (Java) in a modular architecture. I have two approaches in mind and I'm not sure which one will be "better code" in case of maintenance and conventions.

I have two main modules that I want to wire them up:

  1. CORE - backend stuff
  2. UI - frontend stuff

I can think of two approaches:

  • APPROACH 1: CORE module will expose Engine class, UI will expose UserInterface class. UserInterface will need an Engine in its constructor. Creation of both objects will take place in the third module called LAUNCHER.

  • APPROACH 2: CORE module will expose Engine class, UI will expose UserInterface class. The difference is both modules with expose those classes ONLY to PRELAUNCHER module that will create objects and pass them to the LAUNCHER module as interfaces.

The second approach looks promising, because it won't allow any module create the instantion of UI/CORE module classes (as Java offers sealed interface - that means I can choose which class can implement it). That's kind of dependency injection - the needed items will be created in one place and passed as interfaces.

On the other hand - the approach introduces more code - one more module and at least two new interfaces.

Any ideas which one is better in terms of maintenance and conventions?

deleted 17 characters in body
Source Link

I'm developing an application (Java) in a modular architecture. I have two approaches in mind and I'm not sure which one will be "better code" in case of maintenance and conventions.

I have two main modules:

  1. CORE - backend stuff
  2. UI - frontend stuff

and now I want to wire them up.

APPROACH #1

CORE module will expose Engine class, UI will expose UserInterface class. UserInterface will need an Engine instance in order to instantiate itits constructor. Creation of both objects will take place in the third module called LAUNCHER.

APPROACH #2

CORE module will expose Engine class, UI will expose UserInterface class. The difference is both modules with expose those classes ONLY to PRELAUNCHER module that will create objects and pass them to the LAUNCHER module as interfaces.

MY THOUGHTS:

The second approach looks promising, because it won't allow any module create the instantion of UI/CORE module classes (as Java offers sealed interface - that means I can choose which class can implement it). That's kind of dependency injection - the needed items will be created in one place and passed as interfaces.

On the other hand - the approach introduces more code - one more module and at least two new interfaces.

Any ideas which one is better in terms of maintenance and conventions?

I'm developing an application (Java) in a modular architecture. I have two approaches in mind and I'm not sure which one will be "better code" in case of maintenance and conventions.

I have two main modules:

  1. CORE - backend stuff
  2. UI - frontend stuff

and now I want to wire them up.

APPROACH #1

CORE module will expose Engine class, UI will expose UserInterface class. UserInterface will need an Engine instance in order to instantiate it. Creation of both objects will take place in the third module called LAUNCHER.

APPROACH #2

CORE module will expose Engine class, UI will expose UserInterface class. The difference is both modules with expose those classes ONLY to PRELAUNCHER module that will create objects and pass them to the LAUNCHER module as interfaces.

MY THOUGHTS:

The second approach looks promising, because it won't allow any module create the instantion of UI/CORE module classes (as Java offers sealed interface - that means I can choose which class can implement it). That's kind of dependency injection - the needed items will be created in one place and passed as interfaces.

On the other hand - the approach introduces more code - one more module and at least two new interfaces.

Any ideas which one is better in terms of maintenance and conventions?

I'm developing an application (Java) in a modular architecture. I have two approaches in mind and I'm not sure which one will be "better code" in case of maintenance and conventions.

I have two main modules:

  1. CORE - backend stuff
  2. UI - frontend stuff

and now I want to wire them up.

APPROACH #1

CORE module will expose Engine class, UI will expose UserInterface class. UserInterface will need an Engine in its constructor. Creation of both objects will take place in the third module called LAUNCHER.

APPROACH #2

CORE module will expose Engine class, UI will expose UserInterface class. The difference is both modules with expose those classes ONLY to PRELAUNCHER module that will create objects and pass them to the LAUNCHER module as interfaces.

MY THOUGHTS:

The second approach looks promising, because it won't allow any module create the instantion of UI/CORE module classes (as Java offers sealed interface - that means I can choose which class can implement it). That's kind of dependency injection - the needed items will be created in one place and passed as interfaces.

On the other hand - the approach introduces more code - one more module and at least two new interfaces.

Any ideas which one is better in terms of maintenance and conventions?

Source Link

Design of a modular application

I'm developing an application (Java) in a modular architecture. I have two approaches in mind and I'm not sure which one will be "better code" in case of maintenance and conventions.

I have two main modules:

  1. CORE - backend stuff
  2. UI - frontend stuff

and now I want to wire them up.

APPROACH #1

CORE module will expose Engine class, UI will expose UserInterface class. UserInterface will need an Engine instance in order to instantiate it. Creation of both objects will take place in the third module called LAUNCHER.

APPROACH #2

CORE module will expose Engine class, UI will expose UserInterface class. The difference is both modules with expose those classes ONLY to PRELAUNCHER module that will create objects and pass them to the LAUNCHER module as interfaces.

MY THOUGHTS:

The second approach looks promising, because it won't allow any module create the instantion of UI/CORE module classes (as Java offers sealed interface - that means I can choose which class can implement it). That's kind of dependency injection - the needed items will be created in one place and passed as interfaces.

On the other hand - the approach introduces more code - one more module and at least two new interfaces.

Any ideas which one is better in terms of maintenance and conventions?