Using non-created classes in current class

mazunki :

Scenario

This question may be a question about conventions, but Java might have a built-in way to do this. I'm explaining my problem with a scenario:

We are three people working on a project, and we're all doing different parts, and working on different git branches, all of which will be needed in the end project.

My part of the program runs the TUI (let's call the class Startmenu), which requires to run functions from an instance of the Database class. In my switch cases, I know the future code from the other branch will allow me to simply run db.printElements(), as an example.

Problem

Nevertheless, this is the problem: I cannot define Database db; in the class structure, nor can I assign my Startmenu() constructor to take a Database db as an input such as Startmenu(Database db), because it does not yet exist.

In practice, how do I solve this issue? Currently, I'm commenting out the parts that require parts of the other code, and replace it with poisoned code instead, as a placeholder. This doesn't seem like the best idea.

I know a solution is to create the Database class, with empty functions for those functions I will be needing right now, but this will mess with git instead.

tl; dr: How can I prepare my own files to use code that does not yet exist, which will appear "magically" by other people over time?

Adam Barreiro :

All components in your project should have specified an interface to exchange information across layers and other Java components during the design phase.

You can early commit and share these interfaces, so other colleagues can provide their own testing implementations or mock behaviours.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=170880&siteId=1
Recommended